Search in sources :

Example 6 with Difference

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

the class ShouldBeEqualByComparingFieldByFieldRecursively_create_Test method should_use_unambiguous_fields_description_when_standard_description_of_actual_and_expected_collection_fields_values_are_identical.

@Test
public void should_use_unambiguous_fields_description_when_standard_description_of_actual_and_expected_collection_fields_values_are_identical() {
    // GIVEN
    WithCollection<String> withHashSet = new WithCollection<>(new LinkedHashSet<String>());
    WithCollection<String> withSortedSet = new WithCollection<>(new TreeSet<String>());
    withHashSet.collection.add("bar");
    withHashSet.collection.add("foo");
    withSortedSet.collection.addAll(withHashSet.collection);
    List<Difference> differences = determineDifferences(withHashSet, withSortedSet, null, null);
    // WHEN
    // @format:off
    String message = shouldBeEqualByComparingFieldByFieldRecursive(withSortedSet, withHashSet, differences, REPRESENTATION).create(new TextDescription("Test"), REPRESENTATION);
    // @format:on
    // THEN
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <WithCollection [collection=[bar, foo]]>%n" + "to be equal to:%n" + "  <WithCollection [collection=[bar, foo]]>%n" + "when recursively comparing field by field, but found the following difference(s):%n" + "%n" + "Path to difference: <collection>%n" + "- actual  : <[\"bar\", \"foo\"] (LinkedHashSet@%s)>%n" + "- expected: <[\"bar\", \"foo\"] (TreeSet@%s)>", toHexString(withSortedSet.collection.hashCode()), toHexString(withHashSet.collection.hashCode())));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) WithCollection(org.assertj.core.internal.objects.Objects_assertIsEqualToComparingFieldByFieldRecursive_Test.WithCollection) Integer.toHexString(java.lang.Integer.toHexString) Difference(org.assertj.core.internal.DeepDifference.Difference) Test(org.junit.Test)

Aggregations

Difference (org.assertj.core.internal.DeepDifference.Difference)6 Test (org.junit.Test)6 Integer.toHexString (java.lang.Integer.toHexString)3 AssertionInfo (org.assertj.core.api.AssertionInfo)3 TextDescription (org.assertj.core.description.TextDescription)3 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)3 WithCollection (org.assertj.core.internal.objects.Objects_assertIsEqualToComparingFieldByFieldRecursive_Test.WithCollection)1 WithMap (org.assertj.core.internal.objects.Objects_assertIsEqualToComparingFieldByFieldRecursive_Test.WithMap)1