I'm currently struggling with how to make sure 2 maps have the same key/values in a unit-test, while ignoring some of the keys. This should be applied recursively, as a value within the map might be a map again - so that I want to check the whole tree.
Maybe an example is helpful here:
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"));
This 2 maps should be considered equal in regard to the test-result.
I tried to solve this by the following approach - but unfortunately it does not work'
assertThat(mapA)
.usingRecursiveComparison()
.ignoringFieldsMatchingRegexes(".*description")
.ignoringFields("description")
.isEqualTo(mapB);
Does anyone have an idea how to solve that?