Skip to content

Commit

Permalink
jakartaee#59: Add context info for JSON Patch test failure
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <[email protected]>
  • Loading branch information
lukasj committed Oct 24, 2017
1 parent 4688cac commit 8a1673f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions impl/src/main/java/org/glassfish/json/JsonMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ static String PATCH_MOVE_TARGET_NULL(String from) {
return localize("patch.move.target.null", from);
}

static String PATCH_TEST_FAILED() {
return localize("patch.test.failed");
static String PATCH_TEST_FAILED(String path, String value) {
return localize("patch.test.failed", path, value);
}

static String PATCH_ILLEGAL_OPERATION(String operation) {
Expand Down
2 changes: 1 addition & 1 deletion impl/src/main/java/org/glassfish/json/JsonPatchImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private JsonStructure apply(JsonStructure target, JsonObject operation) {
return pointer.add(from.remove(target), from.getValue(target));
case TEST:
if (! getValue(operation).equals(pointer.getValue(target))) {
throw new JsonException(JsonMessages.PATCH_TEST_FAILED());
throw new JsonException(JsonMessages.PATCH_TEST_FAILED(operation.getString("path"), getValue(operation).toString()));
}
return target;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ noderef.array.index.err=An array item index is out of range. Index: {0}, Size: {
patch.must.be.array=A JSON Patch must be an array of JSON Objects
patch.move.proper.prefix=The ''{0}'' path of the patch operation ''move'' is a proper prefix of the ''{1}'' path
patch.move.target.null=The ''{0}'' path of the patch operation ''move'' does not exist in target object
patch.test.failed=The JSON Patch operation ''test'' failed
patch.test.failed=The JSON Patch operation ''test'' failed for path ''{0}'' and value ''{1}''
patch.illegal.operation=Illegal value for the op member of the JSON Patch operation: ''{0}''
patch.member.missing=The JSON Patch operation ''{0}'' must contain a ''{1}'' member

0 comments on commit 8a1673f

Please sign in to comment.