I believe this regex is intended to convent \. -> . to unescape the dot operator. Instead, this regex replaces \ + any char with .. This makes things like Windows paths as keys in objects impossible to use with .node(...) in the AssertJ integration.
Example (that I observed while debugging this issue):
{"C:\\path\\file.ext": {"Status": "OK"}}
java.lang.AssertionError: Different value found in node "C:\path\file\.ext", expected: <node to be present> but was: <missing>.
Expected :<node to be present>
Actual :<missing>.
<Click to see difference>
at net.javacrumbs.jsonunit.assertj.JsonAssert.failWithMessage(JsonAssert.java:119)
at net.javacrumbs.jsonunit.assertj.JsonAssert.failOnDifference(JsonAssert.java:266)
at net.javacrumbs.jsonunit.assertj.JsonAssert.isPresent(JsonAssert.java:261)
at net.javacrumbs.jsonunit.assertj.JsonAssert.isPresent(JsonAssert.java:221)
at com.company.MainTest.testIdentifyPomFile_HasPom_Windows(MainTest.java:143)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
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.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
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.junit.runners.ParentRunner.run(ParentRunner.java:363)
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)
I debugged the failure above and Path.doStep converts C:\path\file\.ext to: C:.ath.ile.ext
Tested in 2.4.0, 2.6.0, master of junit-assertj. Reproduces every time.
https://github.com/lukas-krecan/JsonUnit/blob/8eeffd138405b7e1b05b1a188846e78030eced95/json-unit-core/src/main/java/net/javacrumbs/jsonunit/core/internal/Path.java#L131
I believe this regex is intended to convent
\.
->.
to unescape the dot operator. Instead, this regex replaces\
+ any char with.
. This makes things like Windows paths as keys in objects impossible to use with.node(...)
in the AssertJ integration.Example (that I observed while debugging this issue):
Output of running the test:
I debugged the failure above and
Path.doStep
convertsC:\path\file\.ext
to:C:.ath.ile.ext