use of org.assertj.core.test.AlwaysEqualComparator.ALWAYS_EQUALS_TIMESTAMP in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withTypeComparators_Test method should_handle_null_field_with_type_comparator.
@Test
void should_handle_null_field_with_type_comparator() {
// GIVEN
Patient actual = new Patient(null);
Patient expected = new Patient(new Timestamp(3L));
// THEN
assertThat(actual).usingRecursiveComparison().withComparatorForType(ALWAYS_EQUALS_TIMESTAMP, Timestamp.class).isEqualTo(expected);
assertThat(actual).usingRecursiveComparison().withEqualsForType((o1, o2) -> true, Timestamp.class).isEqualTo(expected);
}
use of org.assertj.core.test.AlwaysEqualComparator.ALWAYS_EQUALS_TIMESTAMP in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test method should_handle_null_field_with_field_comparator.
@Test
void should_handle_null_field_with_field_comparator() {
// GIVEN
Patient actual = new Patient(null);
Patient expected = new Patient(new Timestamp(3L));
// THEN
then(actual).usingRecursiveComparison().withComparatorForFields(ALWAYS_EQUALS_TIMESTAMP, "dateOfBirth").isEqualTo(expected);
then(actual).usingRecursiveComparison().withEqualsForFields((o1, o2) -> true, "dateOfBirth").isEqualTo(expected);
}
use of org.assertj.core.test.AlwaysEqualComparator.ALWAYS_EQUALS_TIMESTAMP in project assertj-core by joel-costigliola.
the class RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test method field_comparator_should_take_precedence_over_type_comparator_whatever_their_order_of_registration.
@Test
void field_comparator_should_take_precedence_over_type_comparator_whatever_their_order_of_registration() {
// GIVEN
Patient actual = new Patient(new Timestamp(1L));
Patient expected = new Patient(new Timestamp(3L));
// THEN
then(actual).usingRecursiveComparison().withComparatorForType(NEVER_EQUALS, Timestamp.class).withComparatorForFields(ALWAYS_EQUALS_TIMESTAMP, "dateOfBirth").isEqualTo(expected);
then(actual).usingRecursiveComparison().withComparatorForFields(ALWAYS_EQUALS_TIMESTAMP, "dateOfBirth").withComparatorForType(NEVER_EQUALS, Timestamp.class).isEqualTo(expected);
then(actual).usingRecursiveComparison().withEqualsForType((o1, o2) -> false, Timestamp.class).withEqualsForFields((o1, o2) -> true, "dateOfBirth").isEqualTo(expected);
then(actual).usingRecursiveComparison().withEqualsForFields((o1, o2) -> true, "dateOfBirth").withEqualsForType((o1, o2) -> false, Timestamp.class).isEqualTo(expected);
}
Aggregations