Search in sources :

Example 11 with AssertionInfo

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

the class Iterables_assertContainsExactly_Test method should_fail_if_actual_contains_all_given_values_but_size_differ.

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

Example 12 with AssertionInfo

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

the class Iterables_assertContainsNull_Test method should_fail_if_actual_does_not_contain_null_whatever_custom_comparison_strategy_is.

@Test
public void should_fail_if_actual_does_not_contain_null_whatever_custom_comparison_strategy_is() {
    AssertionInfo info = someInfo();
    actual = newArrayList("Luke", "Yoda");
    try {
        iterablesWithCaseInsensitiveComparisonStrategy.assertContainsNull(info, actual);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainNull(actual));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 13 with AssertionInfo

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

the class Iterables_assertContainsOnlyNulls_Test method should_fail_if_actual_contains_non_null_elements_only.

@Test
public void should_fail_if_actual_contains_non_null_elements_only() {
    AssertionInfo info = someInfo();
    actual = newArrayList("person", "person2");
    List<String> nonNulls = newArrayList("person", "person2");
    try {
        iterables.assertContainsOnlyNulls(info, actual);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnlyNulls(actual, nonNulls));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 14 with AssertionInfo

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

the class Iterables_assertContainsOnlyNulls_Test method should_fail_if_actual_is_empty.

@Test
public void should_fail_if_actual_is_empty() {
    AssertionInfo info = someInfo();
    try {
        iterables.assertContainsOnlyNulls(info, actual);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnlyNulls(actual));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IterablesBaseTest(org.assertj.core.internal.IterablesBaseTest) Test(org.junit.Test)

Example 15 with AssertionInfo

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

the class Iterables_assertContainsOnlyNulls_Test method should_fail_if_actual_contains_null_and_non_null_elements.

@Test
public void should_fail_if_actual_contains_null_and_non_null_elements() {
    AssertionInfo info = someInfo();
    actual = newArrayList(null, null, "person");
    List<String> nonNulls = newArrayList("person");
    try {
        iterables.assertContainsOnlyNulls(info, actual);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldContainOnlyNulls(actual, nonNulls));
        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