use of org.assertj.core.test.AlwaysEqualComparator in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test method recursivelyEqualObjectsWhenUsingTypeComparators.
private static Stream<Arguments> recursivelyEqualObjectsWhenUsingTypeComparators() {
Person person1 = new Person("John");
person1.home.address.number = 1;
Person person2 = new Person("JoHN");
person2.home.address.number = 2;
Person person3 = new Person("John");
person3.home.address.number = 1;
Person person4 = new Person("John");
person4.home.address.number = 2;
Person person5 = new Person("John");
person5.home.address.number = 1;
person5.dateOfBirth = new Date(123);
person5.neighbour = new Person("Jack");
person5.neighbour.home.address.number = 123;
Person person6 = new Person("John");
person6.home.address.number = 1;
person6.dateOfBirth = new Date(123);
person6.neighbour = new Person("Jim");
person6.neighbour.home.address.number = 456;
MapEntry<Class<?>, Comparator<?>> stringComparator = entry(String.class, CaseInsensitiveStringComparator.instance);
MapEntry<Class<?>, Comparator<?>> intComparator = entry(Integer.class, new AlwaysEqualComparator<Integer>());
MapEntry<Class<?>, Comparator<?>> personComparator = entry(Person.class, new AlwaysEqualComparator<Person>());
return Stream.of(arguments(person1, person2, mapOf(stringComparator, intComparator), "same data except int fields and case for strings"), arguments(person3, person4, mapOf(intComparator), "same data except for int fields"), // any neighbour differences should be ignored as we compare persons with AlwaysEqualComparator
arguments(person5, person6, mapOf(personComparator), "same data except for persons, person's fields should not be compared recursively except at the root level"));
}
Aggregations