From 6ea4d4f5ffef74626efd972d8363c361084b76c2 Mon Sep 17 00:00:00 2001 From: Joel Costigliola <382613+joel-costigliola@users.noreply.github.com> Date: Wed, 1 Jan 2025 17:36:48 +0100 Subject: [PATCH] Recursive comparison: add test with ignored fields in nested map Fix #3226 --- ...onAssert_isEqualTo_ignoringFields_Test.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/assertj-tests/assertj-integration-tests/assertj-core-tests/src/test/java/org/assertj/tests/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_ignoringFields_Test.java b/assertj-tests/assertj-integration-tests/assertj-core-tests/src/test/java/org/assertj/tests/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_ignoringFields_Test.java index 5e6c17bd76..c1f9e80fd1 100644 --- a/assertj-tests/assertj-integration-tests/assertj-core-tests/src/test/java/org/assertj/tests/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_ignoringFields_Test.java +++ b/assertj-tests/assertj-integration-tests/assertj-core-tests/src/test/java/org/assertj/tests/core/api/recursive/comparison/RecursiveComparisonAssert_isEqualTo_ignoringFields_Test.java @@ -786,6 +786,24 @@ void should_honor_ignored_fields_regex() { .isEqualTo(expected); } + @Test + public void should_honor_ignored_fields_in_nested_map() { + // GIVEN + Map mapA = Map.of("foo", "bar", + "description", "foobar", + "submap", Map.of("subFoo", "subBar", "description", "subFooBar")); + Map mapB = Map.of("foo", "bar", + "description", "barfoo", + "submap", Map.of("subFoo", "subBar")); + // WHEN/THEN + then(mapA).usingRecursiveComparison() + .ignoringFields("description", "submap.description") + .isEqualTo(mapB); + then(mapA).usingRecursiveComparison() + .ignoringFieldsMatchingRegexes(".*description") + .isEqualTo(mapB); + } + static class Data { private final InnerData innerData; private final List innerDataList;