Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ else if (value.isObject())
public void test(JsonPointer path, JsonNode value) throws JsonPointerEvaluationException {
JsonNode valueNode = path.evaluate(target);
if (!valueNode.equals(value))
throw new JsonPatchApplicationException(
"Expected " + show(value) + " but found " + show(valueNode), Operation.TEST, path);
throw new JsonPatchTestFailedException(
"Expected " + show(value) + " but found " + show(valueNode), path);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.flipkart.zjsonpatch;

public class JsonPatchTestFailedException extends JsonPatchApplicationException {
public JsonPatchTestFailedException(String message, JsonPointer path) {
super(message, Operation.TEST, path);
}
}
5 changes: 4 additions & 1 deletion src/test/resources/testdata/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
{
"op": [{ "op": "test", "path": "", "value": true }],
"node": [ 1, 2 ],
"type": "com.flipkart.zjsonpatch.JsonPatchTestFailedException",
"message": "Expected value true but found array at root"
},
{
"op": [{ "op": "test", "path": "/x", "value": -30.000 }],
"node": { "x": -29.020 },
"type": "com.flipkart.zjsonpatch.JsonPatchTestFailedException",
"message": "Expected value -30.0 but found value -29.02 at /x"
},
{
"op": [{ "op": "test", "path": "/x", "value": null }],
"node": { "x": 3 },
"type": "com.flipkart.zjsonpatch.JsonPatchTestFailedException",
"message": "Expected null but found value 3 at /x"
}
],
Expand All @@ -43,4 +46,4 @@
"expected": null
}
]
}
}