Summary
The recursive does not set field location properly for maps and thus is not evaluating ignored fields rules properly.
Example
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", "description", "subBarFoo"));
// should work but fails
assertThat(mapA).usingRecursiveComparison()
.ignoringFields("description", "submap.description")
.isEqualTo(mapB);
assertThat(mapA).usingRecursiveComparison()
.ignoringFieldsMatchingRegexes(".*description")
.isEqualTo(mapB);
with the above maps, AssertJ should compare these fields (fieldname: actual value vs expected value)
- foo : bar vs bar
- description : foobar vs barfor
- submap.subfoo: subBar vs subBar
- submap.description: subFooBar vs subBarFoo
instead it compares actual expected values without field location:
- "" : bar vs bar
- "" : foobar vs barfor
- "": subBar vs subBar
- "": subFooBar vs subBarFoo
The fix consists in properly setting the field location to the entry key.
Summary
The recursive does not set field location properly for maps and thus is not evaluating ignored fields rules properly.
Example
with the above maps, AssertJ should compare these fields (fieldname: actual value vs expected value)
instead it compares actual expected values without field location:
The fix consists in properly setting the field location to the entry key.