Search in sources :

Example 51 with AssertionInfo

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

the class Integers_assertIsCloseTo_Test method should_fail_if_actual_is_not_close_enough_to_expected.

@Test
@DataProvider({ "1, 3, 1", "3, 1, 1", "-2, 0, 1", "-1, 1, 1", "0, 2, 1" })
public void should_fail_if_actual_is_not_close_enough_to_expected(int actual, int expected, int offset) {
    AssertionInfo info = someInfo();
    try {
        integers.assertIsCloseTo(info, actual, expected, within(offset));
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldBeEqual(actual, expected, within(offset), abs(actual - expected)));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test) IntegersBaseTest(org.assertj.core.internal.IntegersBaseTest)

Example 52 with AssertionInfo

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

the class Integers_assertIsNotCloseToPercentage_Test method should_fail_if_difference_is_equal_to_given_percentage.

@Test
@DataProvider({ "1, 1, 0", "2, 1, 100", "1, 2, 50", "-1, -1, 0", "-2, -1, 100", "-1, -2, 50" })
public void should_fail_if_difference_is_equal_to_given_percentage(Integer actual, Integer other, Integer percentage) {
    AssertionInfo info = someInfo();
    try {
        integers.assertIsNotCloseToPercentage(someInfo(), actual, other, withPercentage(percentage));
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldNotBeEqualWithinPercentage(actual, other, withPercentage(percentage), abs(actual - other)));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test) IntegersBaseTest(org.assertj.core.internal.IntegersBaseTest)

Example 53 with AssertionInfo

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

the class Integers_assertNotEqual_Test method should_fail_if_integers_are_equal.

@Test
public void should_fail_if_integers_are_equal() {
    AssertionInfo info = someInfo();
    try {
        integers.assertNotEqual(info, 6, 6);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldNotBeEqual(6, 6));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) IntegersBaseTest(org.assertj.core.internal.IntegersBaseTest) Test(org.junit.Test)

Example 54 with AssertionInfo

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

the class Iterables_assertAreExactly_Test method should_fail_if_condition_is_met_much.

@Test
public void should_fail_if_condition_is_met_much() {
    testCondition.shouldMatch(false);
    AssertionInfo info = someInfo();
    try {
        actual = newArrayList("Yoda", "Luke", "Obiwan");
        iterables.assertAreExactly(someInfo(), actual, 2, jedi);
    } catch (AssertionError e) {
        verify(conditions).assertIsNotNull(jedi);
        verify(failures).failure(info, elementsShouldBeExactly(actual, 2, jedi));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Test(org.junit.Test) IterablesWithConditionsBaseTest(org.assertj.core.internal.IterablesWithConditionsBaseTest)

Example 55 with AssertionInfo

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

the class Iterables_assertAreNot_Test method should_fail_if_condition_is_met.

@Test
public void should_fail_if_condition_is_met() {
    testCondition.shouldMatch(false);
    AssertionInfo info = someInfo();
    try {
        actual = newArrayList("Solo", "Leia", "Yoda");
        iterables.assertAreNot(someInfo(), actual, jedi);
    } catch (AssertionError e) {
        verify(conditions).assertIsNotNull(jedi);
        verify(failures).failure(info, elementsShouldNotBe(actual, newArrayList("Yoda"), jedi));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Test(org.junit.Test) IterablesWithConditionsBaseTest(org.assertj.core.internal.IterablesWithConditionsBaseTest)

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