whenIgnoringPaths doesn't ignore missing paths
See original GitHub issueI’m using the AssertJ integration of JsonUnit (net.javacrumbs.json-unit:json-unit-assertj:2.6.1
) and expected JsonAssert#whenIgnoringPaths(String ...)
to ignore missing paths/keys as well.
The documentation at https://github.com/lukas-krecan/JsonUnit/tree/json-unit-parent-2.6.1#ignorepaths says (emphasize by me):
whenIgnoringPaths
configuration option makes JsonUnit ignore the specified paths in the actual value. If the path matches, it’s completely ignored. It may be missing, null or have any value.
The following test is failing, though:
assertThatJson("{\"root\":{\"foo\":1}}")
.whenIgnoringPaths("root.bar", "missing")
.isEqualTo("{\"root\":{\"foo\":1, \"bar\":2}, \"missing\":{\"quux\":\"test\"}}");
net.javacrumbs.jsonunit.core.internal.JsonAssertError: JSON documents are different:
Different keys found in node "", missing: "missing", expected: <{"missing":{"quux":"test"},"root":{"bar":2,"foo":1}}> but was: <{"root":{"foo":1}}>
Different keys found in node "root", missing: "root.bar", expected: <{"bar":2,"foo":1}> but was: <{"foo":1}>
at net.javacrumbs.jsonunit.core.internal.ExceptionUtils.createException(ExceptionUtils.java:50)
at net.javacrumbs.jsonunit.core.internal.Diff.failIfDifferent(Diff.java:612)
at net.javacrumbs.jsonunit.assertj.JsonAssert.isEqualTo(JsonAssert.java:106)
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Ignore specific nodes/attributes while comparing two JSONs
When I try to use this it just uses the built in JSONComparator and ignores the lambda. It tries to call a function...
Read more >net.javacrumbs.jsonunit.JsonAssert.whenIgnoringPaths java ...
Sets paths to be ignored. Popular methods of JsonAssert. assertJsonEquals. Compares to JSON documents. Throws AssertionError if they are different.
Read more >Getting "Json Path ... Doesn't Match" When Running Rest ... - ADocLib
The assertion will not fail if the element is missing in the actual value. Ignoring paths. whenIgnoringPaths configuration option makes JsonUnit ignore the....
Read more >JsonUnit - Bountysource
The behaviour doesn't change when using when(path(...), thenIgnore()) or other means of ignoring paths, values, ... ... I expected this test to pass...
Read more >Ignoring files issues in Apache Spark SQL - Waiting For Code
else { val index = createInMemoryFileIndex(globbedPaths) val ... getOrCreate() "ignore missing files flag" should "not make the processing ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released as 2.6.3
Fixed via #184