Search in sources :

Example 6 with MapEntry

use of org.assertj.core.data.MapEntry in project assertj-core by joel-costigliola.

the class Maps_assertContainsExactly_Test method should_fail_if_actual_and_expected_entries_have_different_size.

@Test
public void should_fail_if_actual_and_expected_entries_have_different_size() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Yoda"));
    thrown.expectAssertionError(shouldHaveSameSizeAs(linkedActual, linkedActual.size(), expected.length).create());
    maps.assertContainsExactly(info, linkedActual, expected);
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) MapEntry(org.assertj.core.data.MapEntry) MapsBaseTest(org.assertj.core.internal.MapsBaseTest) Test(org.junit.Test)

Example 7 with MapEntry

use of org.assertj.core.data.MapEntry in project assertj-core by joel-costigliola.

the class Maps_assertContainsExactly_Test method should_fail_if_actual_contains_entry_key_with_different_value.

@Test
public void should_fail_if_actual_contains_entry_key_with_different_value() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expectedEntries = array(entry("name", "Yoda"), entry("color", "yellow"));
    try {
        maps.assertContainsExactly(info, actual, expectedEntries);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainExactly(actual, asList(expectedEntries), newHashSet(entry("color", "yellow")), newHashSet(entry("color", "green"))));
        return;
    }
    shouldHaveThrown(AssertionError.class);
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) MapEntry(org.assertj.core.data.MapEntry) MapsBaseTest(org.assertj.core.internal.MapsBaseTest) Test(org.junit.Test)

Example 8 with MapEntry

use of org.assertj.core.data.MapEntry in project assertj-core by joel-costigliola.

the class Maps_assertContainsOnly_Test method should_fail_if_actual_does_not_contains_every_expected_entries.

@Test
public void should_fail_if_actual_does_not_contains_every_expected_entries() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Yoda"), entry("color", "green"));
    Map<String, String> underTest = Maps.mapOf(entry("name", "Yoda"));
    try {
        maps.assertContainsOnly(info, underTest, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnly(underTest, expected, newHashSet(entry("color", "green")), emptySet()));
        return;
    }
    shouldHaveThrown(AssertionError.class);
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) MapEntry(org.assertj.core.data.MapEntry) MapsBaseTest(org.assertj.core.internal.MapsBaseTest) Test(org.junit.Test)

Example 9 with MapEntry

use of org.assertj.core.data.MapEntry in project assertj-core by joel-costigliola.

the class Maps_assertContains_Test method should_fail_if_actual_does_not_contain_entries.

@Test
public void should_fail_if_actual_does_not_contain_entries() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Yoda"), entry("job", "Jedi"));
    try {
        maps.assertContains(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContain(actual, expected, newLinkedHashSet(entry("job", "Jedi"))));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) MapEntry(org.assertj.core.data.MapEntry) MapsBaseTest(org.assertj.core.internal.MapsBaseTest) Test(org.junit.Test)

Example 10 with MapEntry

use of org.assertj.core.data.MapEntry in project assertj-core by joel-costigliola.

the class Maps_assertContainsExactly_Test method should_fail_if_actual_does_not_contains_every_expected_entries_and_contains_unexpected_one.

@Test
public void should_fail_if_actual_does_not_contains_every_expected_entries_and_contains_unexpected_one() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Yoda"), entry("color", "green"));
    Map<String, String> underTest = newLinkedHashMap(entry("name", "Yoda"), entry("job", "Jedi"));
    try {
        maps.assertContainsExactly(info, underTest, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainExactly(underTest, asList(expected), newHashSet(entry("color", "green")), newHashSet(entry("job", "Jedi"))));
        return;
    }
    shouldHaveThrown(AssertionError.class);
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) MapEntry(org.assertj.core.data.MapEntry) MapsBaseTest(org.assertj.core.internal.MapsBaseTest) Test(org.junit.Test)

Aggregations

AssertionInfo (org.assertj.core.api.AssertionInfo)10 MapEntry (org.assertj.core.data.MapEntry)10 MapsBaseTest (org.assertj.core.internal.MapsBaseTest)10 Test (org.junit.Test)10