Search in sources :

Example 16 with AssertionInfo

use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.

the class Iterables_assertContainsOnlyOnce_Test method should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy.

@Test
public void should_fail_if_actual_does_not_contain_given_values_only_according_to_custom_comparison_strategy() {
    AssertionInfo info = someInfo();
    Object[] expected = { "Luke", "Yoda", "Han" };
    try {
        iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainsOnlyOnce(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet(), comparisonStrategy));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 17 with AssertionInfo

use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.

the class Iterables_assertContainsOnlyOnce_Test method should_fail_if_actual_contains_given_values_more_than_once_even_if_duplicated_according_to_custom_comparison_strategy.

@Test
public void should_fail_if_actual_contains_given_values_more_than_once_even_if_duplicated_according_to_custom_comparison_strategy() {
    AssertionInfo info = someInfo();
    actual.addAll(newArrayList("LUKE"));
    Object[] expected = array("LUke", "LUke", "lukE", "YOda", "Leia", "Han");
    try {
        iterablesWithCaseInsensitiveComparisonStrategy.assertContainsOnlyOnce(someInfo(), actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainsOnlyOnce(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("LUke", "lukE"), comparisonStrategy));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 18 with AssertionInfo

use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.

the class Iterables_assertContainsOnlyOnce_Test method should_fail_if_actual_contains_given_values_more_than_once.

@Test
public void should_fail_if_actual_contains_given_values_more_than_once() {
    AssertionInfo info = someInfo();
    actual.addAll(newArrayList("Luke", "Luke", null, null));
    Object[] expected = { "Luke", "Luke", "Yoda", "Han", null };
    try {
        iterables.assertContainsOnlyOnce(someInfo(), actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainsOnlyOnce(actual, expected, newLinkedHashSet("Han"), newLinkedHashSet("Luke", null)));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 19 with AssertionInfo

use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.

the class Iterables_assertContainsOnly_Test method should_fail_if_actual_contains_additional_elements.

@Test
public void should_fail_if_actual_contains_additional_elements() {
    AssertionInfo info = someInfo();
    Object[] expected = { "Luke", "Yoda" };
    try {
        iterables.assertContainsOnly(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnly(actual, expected, newArrayList(), newArrayList("Leia")));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 20 with AssertionInfo

use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.

the class Iterables_assertContainsOnly_Test method should_fail_if_actual_does_not_contain_all_given_values.

@Test
public void should_fail_if_actual_does_not_contain_all_given_values() {
    AssertionInfo info = someInfo();
    Object[] expected = { "Luke", "Yoda", "Han" };
    try {
        iterables.assertContainsOnly(info, actual, expected);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnly(actual, expected, newArrayList("Han"), newArrayList("Leia")));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Aggregations

AssertionInfo (org.assertj.core.api.AssertionInfo)1174 Test (org.junit.Test)1172 IterablesBaseTest (org.assertj.core.internal.IterablesBaseTest)94 DatesBaseTest (org.assertj.core.internal.DatesBaseTest)92 ByteArraysBaseTest (org.assertj.core.internal.ByteArraysBaseTest)84 ObjectArraysBaseTest (org.assertj.core.internal.ObjectArraysBaseTest)84 Date (java.util.Date)60 CharArraysBaseTest (org.assertj.core.internal.CharArraysBaseTest)47 FloatArraysBaseTest (org.assertj.core.internal.FloatArraysBaseTest)47 IntArraysBaseTest (org.assertj.core.internal.IntArraysBaseTest)47 LongArraysBaseTest (org.assertj.core.internal.LongArraysBaseTest)47 MapsBaseTest (org.assertj.core.internal.MapsBaseTest)47 ShortArraysBaseTest (org.assertj.core.internal.ShortArraysBaseTest)47 BigIntegersBaseTest (org.assertj.core.internal.BigIntegersBaseTest)44 BigDecimalsBaseTest (org.assertj.core.internal.BigDecimalsBaseTest)42 Index (org.assertj.core.data.Index)40 Index.atIndex (org.assertj.core.data.Index.atIndex)40 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)40 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)34 DoublesBaseTest (org.assertj.core.internal.DoublesBaseTest)33