Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 4474200

Browse files
authored
Merge pull request #67 from lukasj/iss59
fixes #59: Add context info for JSON Patch test failure
2 parents afb2f55 + 8a1673f commit 4474200

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

‎impl/src/main/java/org/glassfish/json/JsonMessages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ static String PATCH_MOVE_TARGET_NULL(String from) {
269269
return localize("patch.move.target.null", from);
270270
}
271271

272-
static String PATCH_TEST_FAILED() {
273-
return localize("patch.test.failed");
272+
static String PATCH_TEST_FAILED(Stringpath, Stringvalue) {
273+
return localize("patch.test.failed", path, value);
274274
}
275275

276276
static String PATCH_ILLEGAL_OPERATION(String operation) {

‎impl/src/main/java/org/glassfish/json/JsonPatchImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private JsonStructure apply(JsonStructure target, JsonObject operation) {
193193
return pointer.add(from.remove(target), from.getValue(target));
194194
case TEST:
195195
if (! getValue(operation).equals(pointer.getValue(target))) {
196-
throw new JsonException(JsonMessages.PATCH_TEST_FAILED());
196+
throw new JsonException(JsonMessages.PATCH_TEST_FAILED(operation.getString("path"), getValue(operation).toString()));
197197
}
198198
return target;
199199
default:

‎impl/src/main/resources/org/glassfish/json/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ noderef.array.index.err=An array item index is out of range. Index: {0}, Size: {
107107
patch.must.be.array=A JSON Patch must be an array of JSON Objects
108108
patch.move.proper.prefix=The ''{0}'' path of the patch operation ''move'' is a proper prefix of the ''{1}'' path
109109
patch.move.target.null=The ''{0}'' path of the patch operation ''move'' does not exist in target object
110-
patch.test.failed=The JSON Patch operation ''test'' failed
110+
patch.test.failed=The JSON Patch operation ''test'' failed for path ''{0}'' and value ''{1}''
111111
patch.illegal.operation=Illegal value for the op member of the JSON Patch operation: ''{0}''
112112
patch.member.missing=The JSON Patch operation ''{0}'' must contain a ''{1}'' member

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /