use of org.assertj.core.internal.ComparisonStrategy in project assertj-core by joel-costigliola.
the class ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test method should_create_AssertionError_with_message_differentiating_expected_and_actual_persons_even_if_a_comparator_based_comparison_strategy_is_used.
@Test
public void should_create_AssertionError_with_message_differentiating_expected_and_actual_persons_even_if_a_comparator_based_comparison_strategy_is_used() {
Person actual = new Person("Jake", 43);
Person expected = new Person("Jake", 47);
ComparisonStrategy ageComparisonStrategy = new ComparatorBasedComparisonStrategy(new PersonComparator());
shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, ageComparisonStrategy, new StandardRepresentation());
shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class);
when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription);
AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation());
assertThat(error).isInstanceOf(AssertionFailedError.class).hasMessage("[my test] %n" + "Expecting:%n" + " <\"Person[name=Jake] (Person@%s)\">%n" + "to be equal to:%n" + " <\"Person[name=Jake] (Person@%s)\">%n" + "when comparing values using PersonComparator%n" + "but was not.", toHexString(actual.hashCode()), toHexString(expected.hashCode()));
}
Aggregations