Skip to content

Commit

Permalink
Recursive comparison: add test with ignored fields in nested map
Browse files Browse the repository at this point in the history
Fix #3226
  • Loading branch information
joel-costigliola committed Jan 1, 2025
1 parent 75954ab commit 6ea4d4f
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,24 @@ void should_honor_ignored_fields_regex() {
.isEqualTo(expected);
}

@Test
public void should_honor_ignored_fields_in_nested_map() {
// GIVEN
Map<String, Object> mapA = Map.of("foo", "bar",
"description", "foobar",
"submap", Map.of("subFoo", "subBar", "description", "subFooBar"));
Map<String, Object> 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<InnerData> innerDataList;
Expand Down

0 comments on commit 6ea4d4f

Please sign in to comment.