use of org.assertj.core.internal.objects.data.Address in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test method should_fail_when_actual_differs_from_expected_when_using_comparators_by_type.
@Test
void should_fail_when_actual_differs_from_expected_when_using_comparators_by_type() {
// GIVEN
Person actual = new Person("John");
actual.home.address.number = 1;
actual.dateOfBirth = new Date(123);
actual.neighbour = new Person("Jack");
actual.neighbour.home.address.number = 123;
// actually a clone of actual
Person expected = new Person("John");
expected.home.address.number = 1;
expected.dateOfBirth = new Date(123);
expected.neighbour = new Person("Jack");
expected.neighbour.home.address.number = 123;
// register comparators for some type that will fail the comparison
recursiveComparisonConfiguration.registerComparatorForType(new AlwaysDifferentComparator<>(), Date.class);
recursiveComparisonConfiguration.registerEqualsForType((Address a1, Address a2) -> false, Address.class);
// WHEN
compareRecursivelyFailsAsExpected(actual, expected);
// THEN
ComparisonDifference dateOfBirthDifference = diff("dateOfBirth", actual.dateOfBirth, expected.dateOfBirth);
ComparisonDifference addressDifference = diff("home.address", actual.home.address, expected.home.address);
ComparisonDifference neighbourAddressDifference = diff("neighbour.home.address", actual.neighbour.home.address, expected.neighbour.home.address);
verifyShouldBeEqualByComparingFieldByFieldRecursivelyCall(actual, expected, dateOfBirthDifference, addressDifference, neighbourAddressDifference);
}
Aggregations