Search in sources :

Example 1 with MapEntry

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

the class Maps_assertDoesNotContain_Test method should_fail_if_actual_contains_given_values.

@Test
public void should_fail_if_actual_contains_given_values() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Yoda"), entry("job", "Jedi"));
    try {
        maps.assertDoesNotContain(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldNotContain(actual, expected, newLinkedHashSet(entry("name", "Yoda"))));
        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 2 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_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 = Maps.mapOf(entry("name", "Yoda"), entry("job", "Jedi"));
    try {
        maps.assertContainsOnly(info, underTest, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnly(underTest, 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)

Example 3 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_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.assertContainsOnly(info, actual, expectedEntries);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnly(actual, 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 4 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_contains_unexpected_entry.

@Test
public void should_fail_if_actual_contains_unexpected_entry() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Yoda"));
    try {
        maps.assertContainsOnly(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnly(actual, expected, emptySet(), 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 5 with MapEntry

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

the class Maps_assertContainsAnyOf_Test method should_fail_if_actual_does_not_contain_any_of_the_given_entries.

@Test
public void should_fail_if_actual_does_not_contain_any_of_the_given_entries() {
    AssertionInfo info = someInfo();
    MapEntry<String, String>[] expected = array(entry("name", "Vador"), entry("job", "Jedi"));
    try {
        maps.assertContainsAnyOf(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainAnyOf(actual, expected));
        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)

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