Search in sources :

Example 1 with TypeComparators

use of org.assertj.core.internal.TypeComparators in project assertj-core by joel-costigliola.

the class Objects_assertIsEqualToComparingFieldByFieldRecursive_Test method should_treat_timestamp_as_equal_to_date_when_registering_a_Date_symmetric_comparator.

@Test
public void should_treat_timestamp_as_equal_to_date_when_registering_a_Date_symmetric_comparator() {
    Person actual = new Person();
    actual.name = "Fred";
    actual.dateOfBirth = new Timestamp(1000L);
    Person other = new Person();
    other.name = "Fred";
    other.dateOfBirth = new Date(1000L);
    TypeComparators typeComparators = new TypeComparators();
    typeComparators.put(Timestamp.class, SYMMETRIC_DATE_COMPARATOR);
    objects.assertIsEqualToComparingFieldByFieldRecursively(someInfo(), actual, other, noFieldComparators(), typeComparators);
    objects.assertIsEqualToComparingFieldByFieldRecursively(someInfo(), other, actual, noFieldComparators(), typeComparators);
}
Also used : TypeComparators(org.assertj.core.internal.TypeComparators) TypeComparators.defaultTypeComparators(org.assertj.core.internal.TypeComparators.defaultTypeComparators) Timestamp(java.sql.Timestamp) Date(java.util.Date) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Aggregations

Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)1 TypeComparators (org.assertj.core.internal.TypeComparators)1 TypeComparators.defaultTypeComparators (org.assertj.core.internal.TypeComparators.defaultTypeComparators)1 Test (org.junit.Test)1