There are 2 json, there multiple paths which is needed to be applied on both json. Then these jsons should be compared via some assert in test. The ide solution whould be:
Stirng actualJson - ....
Stirng expectedJson - ....
Stirng actualJsonFiltered - filter(actualJson, lisofJsonPath);
Stirng expectedJsonFiltered - filter(expectedJson, lisofJsonPath);
JSONAssert.assertEquals(actualJsonFiltered, expectedJsonFiltered);
What is not a solutiom: 1. Any code like that:
for(String p: lisofJsonPath) {
assertEquals(JsonPath.read(actualJson, p), JsonPath.read(expectedJson , p);
}
It is needed to filter jsons and show/fail with all existing path. Show error that several paths are not matches. Not one by one json path matching.
org.assertj.core.api.SoftAssertions
- also is not a solution because it is hard to understand from message what assetons are failed.harcrest
allOf
/anyOf
also is not a solution because it fails on first matched asseretion not combinig them.
P.S. Any suggestions for json diff visualizations are wellcome. The ideal way looks like this. (but this is in javascript)