JOHNZON-173 ensure all patch 'operations' use the same JsonProvider
Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/25a2e980 Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/25a2e980 Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/25a2e980 Branch: refs/heads/master Commit: 25a2e9802abd7b79db1a9e6b106e4fc3999eabfd Parents: 4b33157 Author: Romain Manni-Bucau <[email protected]> Authored: Wed Jun 13 08:58:06 2018 +0200 Committer: Romain Manni-Bucau <[email protected]> Committed: Wed Jun 13 08:58:06 2018 +0200 ---------------------------------------------------------------------- .../johnzon/core/JsonPatchBuilderImpl.java | 34 ++--- .../org/apache/johnzon/core/JsonPatchDiff.java | 7 +- .../org/apache/johnzon/core/JsonPatchImpl.java | 29 +++-- .../apache/johnzon/core/JsonPointerImpl.java | 15 ++- .../apache/johnzon/core/JsonProviderImpl.java | 8 +- .../johnzon/core/JsonPatchBuilderTest.java | 81 ++++++++---- .../org/apache/johnzon/core/JsonPatchTest.java | 101 +++++++------- .../apache/johnzon/core/JsonPointerTest.java | 130 ++++++++++--------- 8 files changed, 225 insertions(+), 180 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchBuilderImpl.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchBuilderImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchBuilderImpl.java index ada2db7..95ca672 100644 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchBuilderImpl.java +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchBuilderImpl.java @@ -21,20 +21,25 @@ import javax.json.JsonObject; import javax.json.JsonPatch; import javax.json.JsonPatchBuilder; import javax.json.JsonValue; +import javax.json.spi.JsonProvider; + import java.util.ArrayList; import java.util.List; class JsonPatchBuilderImpl implements JsonPatchBuilder { + private final JsonProvider provider; private final List<JsonPatchImpl.PatchValue> operations; - JsonPatchBuilderImpl() { - operations = new ArrayList<>(); + JsonPatchBuilderImpl(final JsonProvider provider) { + this.provider = provider; + this.operations = new ArrayList<>(); } - JsonPatchBuilderImpl(JsonArray initialData) { - operations = new ArrayList<>(initialData.size()); + JsonPatchBuilderImpl(final JsonProvider provider, JsonArray initialData) { + this.provider = provider; + this.operations = new ArrayList<>(initialData.size()); for (JsonValue value : initialData) { @@ -45,7 +50,8 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { String from = operation.getString("from", null); JsonValue jsonValue = operation.get("value"); - operations.add(new JsonPatchImpl.PatchValue(op, + this.operations.add(new JsonPatchImpl.PatchValue(provider, + op, path, from, jsonValue)); @@ -55,7 +61,8 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder add(String path, JsonValue value) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + return addOperation(new JsonPatchImpl.PatchValue(provider, + JsonPatch.Operation.ADD, path, null, value)); @@ -79,7 +86,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder remove(String path) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + return addOperation(new JsonPatchImpl.PatchValue(provider, JsonPatch.Operation.REMOVE, path, null, null)); @@ -88,7 +95,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder replace(String path, JsonValue value) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + return addOperation(new JsonPatchImpl.PatchValue(provider, JsonPatch.Operation.REPLACE, path, null, value)); @@ -112,7 +119,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder move(String path, String from) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + return addOperation(new JsonPatchImpl.PatchValue(provider, JsonPatch.Operation.MOVE, path, from, null)); @@ -121,7 +128,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder copy(String path, String from) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + return addOperation(new JsonPatchImpl.PatchValue(provider, JsonPatch.Operation.COPY, path, from, null)); @@ -130,7 +137,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder test(String path, JsonValue value) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + return addOperation(new JsonPatchImpl.PatchValue(provider, JsonPatch.Operation.TEST, path, null, value)); @@ -154,10 +161,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatch build() { - JsonPatchImpl patch = new JsonPatchImpl(new ArrayList<>(operations)); - - return patch; - + return new JsonPatchImpl(provider, new ArrayList<>(operations)); } http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchDiff.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchDiff.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchDiff.java index 301a775..8610184 100644 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchDiff.java +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchDiff.java @@ -24,22 +24,25 @@ import javax.json.JsonPatch; import javax.json.JsonPatchBuilder; import javax.json.JsonStructure; import javax.json.JsonValue; +import javax.json.spi.JsonProvider; /** * Create a diff from a source and target JsonStructure */ class JsonPatchDiff extends DiffBase { + private final JsonProvider provider; private final JsonStructure source; private final JsonStructure target; - JsonPatchDiff(JsonStructure source, JsonStructure target) { + JsonPatchDiff(final JsonProvider provider, final JsonStructure source, final JsonStructure target) { + this.provider = provider; this.source = source; this.target = target; } JsonPatch calculateDiff() { - JsonPatchBuilder patchBuilder = new JsonPatchBuilderImpl(); + JsonPatchBuilder patchBuilder = new JsonPatchBuilderImpl(provider); diff(patchBuilder, "", source, target); http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java index 257ab40..ec3109d 100644 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchImpl.java @@ -23,7 +23,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonArrayBuilder; import javax.json.JsonException; @@ -32,17 +31,20 @@ import javax.json.JsonObjectBuilder; import javax.json.JsonPatch; import javax.json.JsonStructure; import javax.json.JsonValue; +import javax.json.spi.JsonProvider; class JsonPatchImpl implements JsonPatch { + private final JsonProvider provider; private final List<PatchValue> patches; - JsonPatchImpl(PatchValue... patches) { - this.patches = Arrays.asList(patches); + JsonPatchImpl(final JsonProvider provider, final PatchValue... patches) { + this(provider, Arrays.asList(patches)); } - JsonPatchImpl(List<PatchValue> patches) { + JsonPatchImpl(final JsonProvider provider, final List<PatchValue> patches) { + this.provider = provider; if (patches == null) { this.patches = Collections.emptyList(); } else { @@ -117,7 +119,7 @@ class JsonPatchImpl implements JsonPatch { @Override public JsonArray toJsonArray() { - JsonArrayBuilder builder = Json.createArrayBuilder(); + JsonArrayBuilder builder = provider.createArrayBuilder(); for (PatchValue patch : patches) { builder.add(patch.toJson()); } @@ -128,21 +130,24 @@ class JsonPatchImpl implements JsonPatch { static class PatchValue { + private final JsonProvider provider; private final JsonPatch.Operation operation; private final JsonPointerImpl path; private final JsonPointerImpl from; private final JsonValue value; - PatchValue(JsonPatch.Operation operation, - String path, - String from, - JsonValue value) { + PatchValue(final JsonProvider provider, + final JsonPatch.Operation operation, + final String path, + final String from, + final JsonValue value) { + this.provider = provider; this.operation = operation; - this.path = new JsonPointerImpl(path); + this.path = new JsonPointerImpl(provider, path); // ignore from if we do not need it if (operation == JsonPatch.Operation.MOVE || operation == JsonPatch.Operation.COPY) { - this.from = new JsonPointerImpl(from); + this.from = new JsonPointerImpl(provider, from); } else { this.from = null; } @@ -195,7 +200,7 @@ class JsonPatchImpl implements JsonPatch { } JsonObject toJson() { - JsonObjectBuilder builder = Json.createObjectBuilder() + JsonObjectBuilder builder = provider.createObjectBuilder() .add("op", operation.name().toLowerCase()) .add("path", path.getJsonPointer()); http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPointerImpl.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPointerImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPointerImpl.java index 50c19f7..b0ac822 100644 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPointerImpl.java +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPointerImpl.java @@ -18,7 +18,6 @@ */ package org.apache.johnzon.core; -import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonArrayBuilder; import javax.json.JsonException; @@ -27,6 +26,8 @@ import javax.json.JsonObjectBuilder; import javax.json.JsonPointer; import javax.json.JsonStructure; import javax.json.JsonValue; +import javax.json.spi.JsonProvider; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -34,6 +35,7 @@ import java.util.Map; public class JsonPointerImpl implements JsonPointer { + private final JsonProvider provider; private final String jsonPointer; private final List<String> referenceTokens = new ArrayList<>(); private final String lastReferenceToken; @@ -45,7 +47,7 @@ public class JsonPointerImpl implements JsonPointer { * @throws NullPointerException if {@code jsonPointer} is {@code null} * @throws JsonException if {@code jsonPointer} is not a valid JSON Pointer */ - public JsonPointerImpl(String jsonPointer) { + public JsonPointerImpl(final JsonProvider provider, final String jsonPointer) { if (jsonPointer == null) { throw new NullPointerException("jsonPointer must not be null"); } @@ -53,6 +55,7 @@ public class JsonPointerImpl implements JsonPointer { throw new JsonException("A non-empty JsonPointer string must begin with a '/'"); } + this.provider = provider; this.jsonPointer = jsonPointer; String[] encodedReferenceTokens = jsonPointer.split("/", -1); @@ -356,7 +359,7 @@ public class JsonPointerImpl implements JsonPointer { private JsonValue addInternal(JsonValue jsonValue, JsonValue newValue, List<String> currentPath) { if (jsonValue instanceof JsonObject) { JsonObject jsonObject = (JsonObject) jsonValue; - JsonObjectBuilder objectBuilder = Json.createObjectBuilder(); + JsonObjectBuilder objectBuilder = provider.createObjectBuilder(); if (jsonObject.isEmpty() && isPositionToAdd(currentPath)) { objectBuilder.add(lastReferenceToken, newValue); @@ -375,7 +378,7 @@ public class JsonPointerImpl implements JsonPointer { return objectBuilder.build(); } else if (jsonValue instanceof JsonArray) { JsonArray jsonArray = (JsonArray) jsonValue; - JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); + JsonArrayBuilder arrayBuilder = provider.createArrayBuilder(); int arrayIndex = -1; if (isPositionToAdd(currentPath)) { @@ -409,7 +412,7 @@ public class JsonPointerImpl implements JsonPointer { private JsonValue remove(JsonValue jsonValue, int currentPosition, int referencePosition) { if (jsonValue instanceof JsonObject) { JsonObject jsonObject = (JsonObject) jsonValue; - JsonObjectBuilder objectBuilder = Json.createObjectBuilder(); + JsonObjectBuilder objectBuilder = provider.createObjectBuilder(); for (Map.Entry<String, JsonValue> entry : jsonObject.entrySet()) { if (currentPosition == referencePosition @@ -421,7 +424,7 @@ public class JsonPointerImpl implements JsonPointer { return objectBuilder.build(); } else if (jsonValue instanceof JsonArray) { JsonArray jsonArray = (JsonArray) jsonValue; - JsonArrayBuilder arrayBuilder = Json.createArrayBuilder(); + JsonArrayBuilder arrayBuilder = provider.createArrayBuilder(); int arrayIndex = -1; if (currentPosition == referencePosition) { http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/main/java/org/apache/johnzon/core/JsonProviderImpl.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonProviderImpl.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonProviderImpl.java index 909d0ba..37483da 100644 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonProviderImpl.java +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonProviderImpl.java @@ -347,17 +347,17 @@ public class JsonProviderImpl extends JsonProvider implements Serializable { @Override public JsonPatchBuilder createPatchBuilder() { - return new JsonPatchBuilderImpl(); + return new JsonPatchBuilderImpl(this); } @Override public JsonPatchBuilder createPatchBuilder(JsonArray initialData) { - return new JsonPatchBuilderImpl(initialData); + return new JsonPatchBuilderImpl(this, initialData); } @Override public JsonPointer createPointer(String path) { - return new JsonPointerImpl(path); + return new JsonPointerImpl(this, path); } public JsonPatch createPatch(JsonArray array) { @@ -366,7 +366,7 @@ public class JsonProviderImpl extends JsonProvider implements Serializable { @Override public JsonPatch createDiff(JsonStructure source, JsonStructure target) { - return new JsonPatchDiff(source, target).calculateDiff(); + return new JsonPatchDiff(this, source, target).calculateDiff(); } public JsonMergePatch createMergePatch(JsonValue patch) { http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchBuilderTest.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchBuilderTest.java b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchBuilderTest.java index 1f0df01..b86cd23 100644 --- a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchBuilderTest.java +++ b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchBuilderTest.java @@ -27,16 +27,20 @@ import javax.json.JsonArrayBuilder; import javax.json.JsonPatch; import javax.json.JsonPatchBuilder; import javax.json.JsonValue; +import javax.json.spi.JsonProvider; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; public class JsonPatchBuilderTest { + private static final JsonProvider PROVIDER = JsonProvider.provider(); + @Test public void testPatchBuilderAddString() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/foo", null, new JsonStringImpl("bar"))); @@ -50,7 +54,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddStringNull() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/foo", null, JsonValue.NULL)); @@ -65,7 +70,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddJsonObject() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/foo", null, Json.createObjectBuilder() @@ -83,7 +89,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddJsonArray() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/path", null, Json.createArrayBuilder() @@ -101,7 +108,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddJsonValueNull() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/path", null, JsonValue.NULL)); @@ -115,7 +123,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddInt() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/foo", null, new JsonStringImpl("bar"))); @@ -129,11 +138,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddBoolean() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/path/true", null, JsonValue.TRUE), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/path/false", null, JsonValue.FALSE)); @@ -154,7 +164,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderRemove() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.REMOVE, "/path/to/remove", null, null)); @@ -174,7 +185,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceString() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.REPLACE, "/path/to/replace", null, new JsonStringImpl("new value"))); @@ -188,7 +200,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceInt() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.REPLACE, "/replace/me", null, new JsonLongImpl(42))); @@ -202,11 +215,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceBoolean() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.REPLACE, "/true/to/replace", null, JsonValue.FALSE), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/false/to/replace", null, JsonValue.TRUE)); @@ -221,7 +235,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceJsonObject() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.REPLACE, "/replace/the/object", null, Json.createObjectBuilder() @@ -239,7 +254,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceJsonArray() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.REPLACE, "/replace/my/array", null, Json.createArrayBuilder() @@ -263,7 +279,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderMove() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.MOVE, "/move/to", "/move/from", null)); @@ -288,7 +305,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderCopy() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.COPY, "/to", "/from", null)); @@ -313,7 +331,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestString() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.TEST, "/to/test", null, new JsonStringImpl("value"))); @@ -327,11 +346,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestBoolean() { - JsonPatchImpl exptected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl exptected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.TEST, "/true/to/test", null, JsonValue.TRUE), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/false/to/test", null, JsonValue.FALSE)); @@ -346,7 +366,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestInt() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.TEST, "/test/int", null, new JsonLongImpl(16))); @@ -360,7 +381,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestJsonValue() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.TEST, "/test/value", null, JsonValue.NULL)); @@ -374,7 +396,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestJsonObject() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.TEST, "/test/the/object", null, Json.createObjectBuilder() @@ -392,7 +415,8 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestJsonArray() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.TEST, "/test/my/array", null, Json.createArrayBuilder() @@ -416,13 +440,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderWithinitialData() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue( + PROVIDER, JsonPatch.Operation.ADD, "/add/an/object", null, Json.createObjectBuilder() .add("name", "Cassius") .build()), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/replace/me", null, Json.createArrayBuilder() @@ -430,12 +455,12 @@ public class JsonPatchBuilderTest { .add(27) .add("test") .build()), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/remove/it", null, null)); - JsonPatch patch = new JsonPatchBuilderImpl(expected.toJsonArray()).build(); + JsonPatch patch = new JsonPatchBuilderImpl(PROVIDER, expected.toJsonArray()).build(); assertNotNull(patch); assertEquals(expected, patch); } http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchTest.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchTest.java b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchTest.java index 8c7ee61..ade393a 100644 --- a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchTest.java +++ b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPatchTest.java @@ -29,6 +29,8 @@ import javax.json.JsonObject; import javax.json.JsonPatch; import javax.json.JsonStructure; import javax.json.JsonValue; +import javax.json.spi.JsonProvider; + import java.io.StringReader; import java.io.StringWriter; @@ -39,6 +41,7 @@ import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; public class JsonPatchTest { + private static final JsonProvider PROVIDER = JsonProvider.provider(); @Test public void testAddObjectMember() { @@ -46,7 +49,7 @@ public class JsonPatchTest { JsonObject object = Json.createReader(new StringReader("{ \"foo\": \"bar\" }")) .readObject(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/baz", null, // no from new JsonStringImpl("qux"))); @@ -69,7 +72,7 @@ public class JsonPatchTest { .add("test", JsonValue.EMPTY_JSON_OBJECT)) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/name", null, new JsonStringImpl("aName"))); @@ -93,7 +96,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/foo/1", null, // no from new JsonStringImpl("qux"))); @@ -119,7 +122,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/foo/-", null, // no from new JsonStringImpl("qux"))); @@ -143,7 +146,7 @@ public class JsonPatchTest { .add("baz") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/-", null, // no from new JsonStringImpl("qux"))); @@ -165,7 +168,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/baz/bat", null, // no from new JsonStringImpl("qux"))); @@ -180,7 +183,7 @@ public class JsonPatchTest { .add("bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/5", null, new JsonStringImpl("baz"))); @@ -197,7 +200,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/baz", null, null)); @@ -220,7 +223,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/foo/1", null, null)); @@ -246,7 +249,7 @@ public class JsonPatchTest { .add("baz") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/1", null, null)); @@ -268,7 +271,7 @@ public class JsonPatchTest { .add("baz", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/nomatch", null, null)); @@ -283,7 +286,7 @@ public class JsonPatchTest { .add("bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/5", null, null)); @@ -300,7 +303,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/baz", null, new JsonStringImpl("boo"))); @@ -323,7 +326,7 @@ public class JsonPatchTest { .add("qux")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/foo/1", null, new JsonStringImpl("boo"))); @@ -350,7 +353,7 @@ public class JsonPatchTest { .add("qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/0", null, new JsonStringImpl("boo"))); @@ -372,7 +375,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/nomatch", null, new JsonStringImpl("notneeded"))); @@ -387,7 +390,7 @@ public class JsonPatchTest { .add("foo") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REPLACE, "/1", null, new JsonStringImpl("notneeded"))); @@ -407,7 +410,7 @@ public class JsonPatchTest { .add("corge", "grault")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/qux/thud", "/foo/waldo", null)); @@ -440,7 +443,7 @@ public class JsonPatchTest { .add("eat")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/foo/3", "/foo/1", null)); @@ -469,7 +472,7 @@ public class JsonPatchTest { .add("one") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/0", "/3", null)); @@ -493,7 +496,7 @@ public class JsonPatchTest { .add("dog")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/bar", "/foo/2", null)); @@ -519,7 +522,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/baz", "/nomatch", null)); @@ -535,7 +538,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/nomatch/child", "/foo", null)); @@ -551,7 +554,7 @@ public class JsonPatchTest { .add("key", "value")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/object/key", "/object", null)); @@ -567,7 +570,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/baz", "/foo", null)); @@ -590,7 +593,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/foo/-", "/foo/0", null)); @@ -616,7 +619,7 @@ public class JsonPatchTest { .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/0", "/1", null)); @@ -642,7 +645,7 @@ public class JsonPatchTest { .add("partner", JsonValue.EMPTY_JSON_OBJECT)) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/partner/partner/name", "/name", null)); @@ -668,7 +671,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/notneeded", "/nomatch", null)); @@ -683,7 +686,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/path/nomatch", "/foo", null)); @@ -699,7 +702,7 @@ public class JsonPatchTest { .add("bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/-", "/2", null)); @@ -714,7 +717,7 @@ public class JsonPatchTest { .add("foo") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/1", "/-", null)); @@ -730,7 +733,7 @@ public class JsonPatchTest { .add("foo", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/foo", null, new JsonStringImpl("qux"))); @@ -747,7 +750,7 @@ public class JsonPatchTest { .add("foo", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/foo", null, Json.createArrayBuilder().build())); @@ -765,7 +768,7 @@ public class JsonPatchTest { .add("Forjgyn")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/parents", null, Json.createArrayBuilder() // yessss, we really want to create a new JsonArray ;) @@ -788,7 +791,7 @@ public class JsonPatchTest { .add(2)) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/numbers", null, Json.createArrayBuilder() // different ordering @@ -808,7 +811,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/foo/1", null, new JsonStringImpl("baz"))); @@ -827,7 +830,7 @@ public class JsonPatchTest { .add("qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/2", null, new JsonStringImpl("qux"))); @@ -846,7 +849,7 @@ public class JsonPatchTest { .add("qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/0", null, new JsonStringImpl("bar"))); @@ -857,7 +860,7 @@ public class JsonPatchTest { @Test(expected = JsonException.class) public void testTestingObjectMemeberNonexistentTarget() { - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/nomatch", null, JsonValue.EMPTY_JSON_OBJECT)); @@ -868,7 +871,7 @@ public class JsonPatchTest { @Test(expected = JsonException.class) public void testTestingArrayElementIndexOutOfBounds() { - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.TEST, "/3", null, JsonValue.EMPTY_JSON_OBJECT)); @@ -885,7 +888,7 @@ public class JsonPatchTest { .add("baz", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/foo", null, new JsonStringImpl("abcd"))); @@ -902,7 +905,7 @@ public class JsonPatchTest { @Test public void testAddArrayElementToEmptyArray() { - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/-", null, new JsonStringImpl("foo"))); @@ -923,33 +926,33 @@ public class JsonPatchTest { // i know this can be done with PatchBuilder but // currently it's not implemented and its fun ;) - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(PROVIDER, new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/family/father", null, Json.createObjectBuilder() .add("name", "Gaio Modry Effect") .build()), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/family/mother", null, Json.createObjectBuilder() .add("name", "Cassius vom Hause Clarabella") .build()), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.MOVE, "/family/children/0", "/family/mother", null), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.ADD, "/family/mother", null, Json.createObjectBuilder() .add("name", "Aimee vom Hause Clarabella") .build()), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.COPY, "/pedigree", "/family", null), - new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, + new JsonPatchImpl.PatchValue(PROVIDER, JsonPatch.Operation.REMOVE, "/family", null, null));
