Search in sources :

Example 1 with AlwaysEqualAddress

use of org.assertj.core.internal.objects.data.AlwaysEqualAddress in project assertj-core by joel-costigliola.

the class RecursiveComparisonAssert_isEqualTo_ignoringOverriddenEquals_Test method should_fail_when_actual_differs_from_expected_as_some_overridden_equals_methods_are_ignored_by_regexes.

@Test
void should_fail_when_actual_differs_from_expected_as_some_overridden_equals_methods_are_ignored_by_regexes() {
    // GIVEN
    Person actual = new Person();
    actual.neighbour = new AlwaysEqualPerson();
    actual.neighbour.name = "Jack";
    actual.neighbour.home.address = new AlwaysEqualAddress();
    actual.neighbour.home.address.number = 123;
    Person expected = new Person();
    expected.neighbour = new AlwaysEqualPerson();
    expected.neighbour.name = "Jim";
    expected.neighbour.home.address = new AlwaysEqualAddress();
    expected.neighbour.home.address.number = 234;
    recursiveComparisonConfiguration.ignoreOverriddenEqualsForFieldsMatchingRegexes(".*AlwaysEqualPerson", ".*AlwaysEqualAddress");
    // WHEN
    compareRecursivelyFailsAsExpected(actual, expected);
    // THEN
    ComparisonDifference neighbourNameDifference = diff("neighbour.name", actual.neighbour.name, expected.neighbour.name);
    ComparisonDifference numberDifference = diff("neighbour.home.address.number", actual.neighbour.home.address.number, expected.neighbour.home.address.number);
    verifyShouldBeEqualByComparingFieldByFieldRecursivelyCall(actual, expected, numberDifference, neighbourNameDifference);
}
Also used : AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) AlwaysEqualAddress(org.assertj.core.internal.objects.data.AlwaysEqualAddress) Person(org.assertj.core.internal.objects.data.Person) AlwaysDifferentPerson(org.assertj.core.internal.objects.data.AlwaysDifferentPerson) AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecursiveComparisonAssert_isEqualTo_BaseTest(org.assertj.core.api.RecursiveComparisonAssert_isEqualTo_BaseTest)

Example 2 with AlwaysEqualAddress

use of org.assertj.core.internal.objects.data.AlwaysEqualAddress in project assertj-core by joel-costigliola.

the class RecursiveComparisonAssert_isEqualTo_ignoringOverriddenEquals_Test method should_fail_when_actual_differs_from_expected_as_some_overridden_equals_methods_are_ignored_by_types.

@Test
void should_fail_when_actual_differs_from_expected_as_some_overridden_equals_methods_are_ignored_by_types() {
    // GIVEN
    Person actual = new Person();
    actual.neighbour = new AlwaysEqualPerson();
    actual.neighbour.name = "Jack";
    actual.neighbour.home.address = new AlwaysEqualAddress();
    actual.neighbour.home.address.number = 123;
    Person expected = new Person();
    expected.neighbour = new AlwaysEqualPerson();
    expected.neighbour.name = "Jim";
    expected.neighbour.home.address = new AlwaysEqualAddress();
    expected.neighbour.home.address.number = 234;
    recursiveComparisonConfiguration.ignoreOverriddenEqualsForTypes(AlwaysEqualPerson.class, AlwaysEqualAddress.class);
    // WHEN
    compareRecursivelyFailsAsExpected(actual, expected);
    // THEN
    ComparisonDifference neighbourNameDifference = diff("neighbour.name", actual.neighbour.name, expected.neighbour.name);
    ComparisonDifference numberDifference = diff("neighbour.home.address.number", actual.neighbour.home.address.number, expected.neighbour.home.address.number);
    verifyShouldBeEqualByComparingFieldByFieldRecursivelyCall(actual, expected, numberDifference, neighbourNameDifference);
}
Also used : AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) AlwaysEqualAddress(org.assertj.core.internal.objects.data.AlwaysEqualAddress) Person(org.assertj.core.internal.objects.data.Person) AlwaysDifferentPerson(org.assertj.core.internal.objects.data.AlwaysDifferentPerson) AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecursiveComparisonAssert_isEqualTo_BaseTest(org.assertj.core.api.RecursiveComparisonAssert_isEqualTo_BaseTest)

Example 3 with AlwaysEqualAddress

use of org.assertj.core.internal.objects.data.AlwaysEqualAddress in project assertj-core by joel-costigliola.

the class RecursiveComparisonAssert_isEqualTo_ignoringOverriddenEquals_Test method should_fail_when_actual_differs_from_expected_as_some_overridden_equals_methods_are_ignored_by_fields.

@Test
void should_fail_when_actual_differs_from_expected_as_some_overridden_equals_methods_are_ignored_by_fields() {
    // GIVEN
    Person actual = new Person();
    actual.neighbour = new AlwaysEqualPerson();
    actual.neighbour.name = "Jack";
    actual.neighbour.home.address = new AlwaysEqualAddress();
    actual.neighbour.home.address.number = 123;
    Person expected = new Person();
    expected.neighbour = new AlwaysEqualPerson();
    expected.neighbour.name = "Jim";
    expected.neighbour.home.address = new AlwaysEqualAddress();
    expected.neighbour.home.address.number = 234;
    recursiveComparisonConfiguration.ignoreOverriddenEqualsForFields("neighbour", "neighbour.home.address");
    // WHEN
    compareRecursivelyFailsAsExpected(actual, expected);
    // THEN
    ComparisonDifference neighbourNameDifference = diff("neighbour.name", actual.neighbour.name, expected.neighbour.name);
    ComparisonDifference numberDifference = diff("neighbour.home.address.number", actual.neighbour.home.address.number, expected.neighbour.home.address.number);
    verifyShouldBeEqualByComparingFieldByFieldRecursivelyCall(actual, expected, numberDifference, neighbourNameDifference);
}
Also used : AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) AlwaysEqualAddress(org.assertj.core.internal.objects.data.AlwaysEqualAddress) Person(org.assertj.core.internal.objects.data.Person) AlwaysDifferentPerson(org.assertj.core.internal.objects.data.AlwaysDifferentPerson) AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecursiveComparisonAssert_isEqualTo_BaseTest(org.assertj.core.api.RecursiveComparisonAssert_isEqualTo_BaseTest)

Aggregations

RecursiveComparisonAssert_isEqualTo_BaseTest (org.assertj.core.api.RecursiveComparisonAssert_isEqualTo_BaseTest)3 AlwaysDifferentPerson (org.assertj.core.internal.objects.data.AlwaysDifferentPerson)3 AlwaysEqualAddress (org.assertj.core.internal.objects.data.AlwaysEqualAddress)3 AlwaysEqualPerson (org.assertj.core.internal.objects.data.AlwaysEqualPerson)3 Person (org.assertj.core.internal.objects.data.Person)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3