question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

whenIgnoringPaths doesn't ignore missing paths

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lukas-krecancommented, May 25, 2019

Released as 2.6.3

0reactions
joschicommented, May 25, 2019

Fixed via #184

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found