Closed maricn closed 6 years ago
Thanks, it's indeed a bug in an edge case when ignoring array order is used and only one difference is found. Will fix it.
Thank you!
Also, maybe relevant here - I added @JsonIgnore(NON_EMPTY)
to my DTO for serialization, and now I get:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at net.javacrumbs.jsonunit.core.internal.Diff.compareArrayNodes(Diff.java:414)
at net.javacrumbs.jsonunit.core.internal.Diff.compareNodes(Diff.java:271)
at net.javacrumbs.jsonunit.core.internal.Diff.compareObjectNodes(Diff.java:143)
at net.javacrumbs.jsonunit.core.internal.Diff.compareNodes(Diff.java:268)
at net.javacrumbs.jsonunit.core.internal.Diff.compare(Diff.java:103)
at net.javacrumbs.jsonunit.core.internal.Diff.similar(Diff.java:550)
at net.javacrumbs.jsonunit.JsonAssert.assertJsonPartEquals(JsonAssert.java:81)
at net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals(JsonAssert.java:66)
at my.project.api.story.SmpIntegrationTest.upsertExistingStory(SmpIntegrationTest.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
You can try 1.29.1
Amazing, thank you for the swift solution and published bugfix version! ❤️
I'm seeing this exception which indicates a bug or it's a bit misleading:
That is, sometimes my matchers receive the whole field value instead only parameter value in
matches
method call, which seems to be related tonet.javacrumbs.jsonunit.core.internal.Diff#compareArrayNodes
.One of the matchers:
Expected json:
Actual json:
Test code:
Stack trace: