use of org.assertj.core.internal.objects.data.AlwaysEqualPerson in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_usingOverriddenEquals_Test method should_pass_when_using_overridden_equals.
private static Stream<Arguments> should_pass_when_using_overridden_equals() {
Person person1 = new AlwaysEqualPerson();
person1.neighbour = new Person("John");
Person person2 = new AlwaysEqualPerson();
person2.neighbour = new Person("Jack");
Person person3 = new Person();
person3.neighbour = new AlwaysEqualPerson();
person3.neighbour.name = "John";
Person person4 = new Person();
person4.neighbour = new AlwaysEqualPerson();
person4.neighbour.name = "Jack";
return Stream.of(arguments(person1, person2, "root Person is AlwaysEqualPerson"), arguments(person3, person4, "neighbour Person is AlwaysEqualPerson"));
}
use of org.assertj.core.internal.objects.data.AlwaysEqualPerson in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test method ignoringOverriddenEquals_should_not_interfere_with_comparators_by_type.
@Test
void ignoringOverriddenEquals_should_not_interfere_with_comparators_by_type() {
// GIVEN
Person actual = new Person("Fred");
actual.neighbour = new AlwaysEqualPerson();
actual.neighbour.name = "Omar";
Person expected = new Person("Fred");
expected.neighbour = new AlwaysEqualPerson();
expected.neighbour.name = "Omar2";
// THEN
assertThat(actual).usingRecursiveComparison().withComparatorForType(ALWAYS_EQUALS, // fails if commented
AlwaysEqualPerson.class).ignoringOverriddenEqualsForFields("neighbour").isEqualTo(expected);
assertThat(actual).usingRecursiveComparison().withEqualsForType((o1, o2) -> true, // fails if commented
AlwaysEqualPerson.class).ignoringOverriddenEqualsForFields("neighbour").isEqualTo(expected);
}
use of org.assertj.core.internal.objects.data.AlwaysEqualPerson in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test method ignoringOverriddenEquals_should_not_interfere_with_field_comparators.
@Test
void ignoringOverriddenEquals_should_not_interfere_with_field_comparators() {
// GIVEN
Person actual = new Person("Fred");
actual.neighbour = new AlwaysEqualPerson();
actual.neighbour.name = "Omar";
Person expected = new Person("Fred");
expected.neighbour = new AlwaysEqualPerson();
expected.neighbour.name = "Omar2";
// THEN
then(actual).usingRecursiveComparison().withComparatorForFields(ALWAYS_EQUALS, // fails if commented
"neighbour").ignoringOverriddenEqualsForFields("neighbour").isEqualTo(expected);
then(actual).usingRecursiveComparison().withEqualsForFields((o1, o2) -> true, // fails if commented
"neighbour").ignoringOverriddenEqualsForFields("neighbour").isEqualTo(expected);
}
Aggregations