Repository: johnzon Updated Branches: refs/heads/master 24cbca333 -> 3fec5685f
JOHNZON-96 remove own PatchOperation in favour of the spec one. spec-patch from rsandtner got applied, so we can now remove our own JsonPatchOperation and use the one from the spec. Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/3fec5685 Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/3fec5685 Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/3fec5685 Branch: refs/heads/master Commit: 3fec5685f137aaddbee338e484e3be7d30011753 Parents: 24cbca3 Author: Mark Struberg <[email protected]> Authored: Sat Feb 25 10:39:25 2017 +0100 Committer: Mark Struberg <[email protected]> Committed: Sat Feb 25 10:41:39 2017 +0100 ---------------------------------------------------------------------- .../johnzon/core/JsonPatchBuilderImpl.java | 14 +- .../org/apache/johnzon/core/JsonPatchImpl.java | 8 +- .../apache/johnzon/core/JsonPatchOperation.java | 143 ------------------- .../johnzon/core/JsonBuilderFactoryTest.java | 44 ++++++ .../johnzon/core/JsonGeneratorImplTest.java | 14 ++ .../johnzon/core/JsonPatchBuilderTest.java | 116 +++++++-------- .../org/apache/johnzon/core/JsonPatchTest.java | 97 ++++++------- 7 files changed, 176 insertions(+), 260 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/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 0d8fe55..bc5815d 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 @@ -40,7 +40,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { JsonObject operation = (JsonObject) value; - JsonPatchOperation op = JsonPatchOperation.valueOf(operation.getString("op").toUpperCase()); + JsonPatch.Operation op = JsonPatch.Operation.fromOperationName(operation.getString("op")); String path = operation.getString("path"); String from = operation.getString("from", null); JsonValue jsonValue = operation.get("value"); @@ -55,7 +55,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder add(String path, JsonValue value) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, path, null, value)); @@ -79,7 +79,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder remove(String path) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, path, null, null)); @@ -88,7 +88,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder replace(String path, JsonValue value) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, path, null, value)); @@ -112,7 +112,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder move(String path, String from) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, path, from, null)); @@ -121,7 +121,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder copy(String path, String from) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, path, from, null)); @@ -130,7 +130,7 @@ class JsonPatchBuilderImpl implements JsonPatchBuilder { @Override public JsonPatchBuilder test(String path, JsonValue value) { - return addOperation(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + return addOperation(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, path, null, value)); http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/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 ae45792..257ab40 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 @@ -81,7 +81,7 @@ class JsonPatchImpl implements JsonPatch { case TEST: JsonValue toTest = patch.path.getValue(patched); if (!toTest.equals(patch.value)) { - throw new JsonException("JsonPatchOperation.TEST fails! Values are not equal"); + throw new JsonException("JsonPatch.Operation.TEST fails! Values are not equal"); } break; default: @@ -128,12 +128,12 @@ class JsonPatchImpl implements JsonPatch { static class PatchValue { - private final JsonPatchOperation operation; + private final JsonPatch.Operation operation; private final JsonPointerImpl path; private final JsonPointerImpl from; private final JsonValue value; - PatchValue(JsonPatchOperation operation, + PatchValue(JsonPatch.Operation operation, String path, String from, JsonValue value) { @@ -141,7 +141,7 @@ class JsonPatchImpl implements JsonPatch { this.path = new JsonPointerImpl(path); // ignore from if we do not need it - if (operation == JsonPatchOperation.MOVE || operation == JsonPatchOperation.COPY) { + if (operation == JsonPatch.Operation.MOVE || operation == JsonPatch.Operation.COPY) { this.from = new JsonPointerImpl(from); } else { this.from = null; http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchOperation.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchOperation.java b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchOperation.java deleted file mode 100644 index 75e5c49..0000000 --- a/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchOperation.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.johnzon.core; - -/** - * <p> - * available operations for {@link javax.json.JsonPatch}. - * </p> - * <p> - * NOTICE: the behavoir of some operations depends on which {@link javax.json.JsonValue} they are performed. - * for details please check the documentation of the very operation. - * </p> - * - * @since 1.1 - */ -public enum JsonPatchOperation { - - /** - * <p> - * required members are: - * <ul> - * <li>"op": "add"</li> - * <li>"path": "path/to/add"</li> - * <li>"value": "{@link javax.json.JsonValue}ToAdd"</li> - * </ul> - * </p> - * <p> - * if the "path/to" does not exist, this operation will result in an error.<br> - * if the "path/to/add" already exists, the value will be <strong>replaced</strong> - * </p> - * <p> - * for {@link javax.json.JsonArray}s the new value will be inserted at the specified index - * and the element(s) at/after are shifted to the right. the '-' character is used to append the value - * at the and of the {@link javax.json.JsonArray}. - * </p> - */ - ADD, - - /** - * <p> - * required members are: - * <ul> - * <li>"op": "remove"</li> - * <li>"path": "path/to/remove"</li> - * </ul> - * </p> - * <p> - * if the "path/to/remove" does not exist, the operation will fail. - * </p> - * <p> - * for {@link javax.json.JsonArray}s the values after the removed value are shifted to the left - * </p> - */ - REMOVE, - - /** - * <p> - * required members are: - * <ul> - * <li>"op": "replace"</li> - * <li>"path": "path/to/replace"</li> - * <li>"value": "the new {@link javax.json.JsonValue}"</li> - * </ul> - * </p> - * <p> - * this operation is identical to {@link #REMOVE} followed by {@link #ADD} - * </p> - */ - REPLACE, - - /** - * <p> - * required members are: - * <ul> - * <li>"op": "move"</li> - * <li>"from": "path/to/move/from"</li> - * <li>"path": "path/to/move/to"</li> - * </ul> - * </p> - * <p> - * the operation will fail it the "path/to/move/from" does not exist - * </p> - * <p> - * NOTICE: a location can not be moved into one of it's children. (from /a/b/c to /a/b/c/d) - * </p> - * <p> - * this operation is identical to {@link #REMOVE} from "from" and {@link #ADD} to the "path" - * </p> - */ - MOVE, - - /** - * <p> - * required members are: - * <ul> - * <li>"op": "copy"</li> - * <li>"from": "path/to/copy/from"</li> - * <li>"path": "path/to/add"</li> - * </ul> - * </p> - * <p> - * the operation will result in an error if the "from" location does not exist - * </p> - * <p> - * this operation is identical to {@link #ADD} with the "from" value - * </p> - */ - COPY, - - /** - * <p> - * required members are: - * <ul> - * <li>"op": "test"</li> - * <li>"path": "/path/to/test"</li> - * <li>"value": "{@link javax.json.JsonValue} to test"</li> - * </ul> - * </p> - * <p> - * this operation fails, if the value is NOT equal with the /path/to/test - * </p> - * <p> - * ordering of the elements in a {@link javax.json.JsonObject} is NOT significant however - * the position of an element in a {@link javax.json.JsonArray} is significant for equality. - * </p> - */ - TEST - -} http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/johnzon-core/src/test/java/org/apache/johnzon/core/JsonBuilderFactoryTest.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonBuilderFactoryTest.java b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonBuilderFactoryTest.java new file mode 100644 index 0000000..1a8ba54 --- /dev/null +++ b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonBuilderFactoryTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.johnzon.core; + +import java.util.Collections; + +import javax.json.Json; +import javax.json.JsonBuilderFactory; +import javax.json.JsonObject; + +import org.junit.Assert; +import org.junit.Test; + + +public class JsonBuilderFactoryTest { + + @Test + public void testCreateBuilderFactory() { + JsonBuilderFactory factory = Json.createBuilderFactory(Collections.emptyMap()); + JsonObject jsonObject = factory.createObjectBuilder(). + add("name", "home"). + add("city", "Vienna") + .build(); + + //JsonObject + Assert.assertEquals("home", jsonObject.getString("name")); + Assert.assertEquals("Vienna", jsonObject.getString("city")); + + } +} http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/johnzon-core/src/test/java/org/apache/johnzon/core/JsonGeneratorImplTest.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonGeneratorImplTest.java b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonGeneratorImplTest.java index 797cca5..83561c6 100644 --- a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonGeneratorImplTest.java +++ b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonGeneratorImplTest.java @@ -18,6 +18,7 @@ */ package org.apache.johnzon.core; +import org.junit.Assert; import org.junit.Test; import javax.json.Json; @@ -50,6 +51,19 @@ public class JsonGeneratorImplTest { } @Test + public void testCreateGenerator() { + StringWriter sw = new StringWriter(); + JsonGenerator jsonGenerator = Json.createGenerator(sw); + jsonGenerator.writeStartObject() + .write("a", "b") + .write("c", "d") + .writeEnd(); + + jsonGenerator.close(); + + Assert.assertEquals("{\"a\":\"b\",\"c\":\"d\"}", sw.toString()); + } + @Test public void emptyArray() { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final JsonGenerator generator = Json.createGenerator(baos); http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/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 7fd2af0..d109646 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 @@ -32,12 +32,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddString() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo", null, new JsonStringImpl("bar"))); - JsonPatch patch = new JsonPatchBuilderImpl().add("/foo", "bar") + JsonPatch patch = Json.createPatchBuilder().add("/foo", "bar") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -46,13 +46,13 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddStringNull() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo", null, JsonValue.NULL)); String nullString = null; - JsonPatch patch = new JsonPatchBuilderImpl().add("/foo", nullString) + JsonPatch patch = Json.createPatchBuilder().add("/foo", nullString) .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -61,14 +61,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddJsonObject() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo", null, Json.createObjectBuilder() .add("bar", "qux") .build())); - JsonPatch patch = new JsonPatchBuilderImpl().add("/foo", Json.createObjectBuilder() + JsonPatch patch = Json.createPatchBuilder().add("/foo", Json.createObjectBuilder() .add("bar", "qux") .build()) .build(); @@ -79,14 +79,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddJsonArray() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/path", null, Json.createArrayBuilder() .add("test") .build())); - JsonPatch patch = new JsonPatchBuilderImpl().add("/path", Json.createArrayBuilder() + JsonPatch patch = Json.createPatchBuilder().add("/path", Json.createArrayBuilder() .add("test") .build()) .build(); @@ -97,12 +97,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddJsonValueNull() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/path", null, JsonValue.NULL)); - JsonPatch patch = new JsonPatchBuilderImpl().add("/path", JsonValue.NULL) + JsonPatch patch = Json.createPatchBuilder().add("/path", JsonValue.NULL) .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -111,12 +111,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddInt() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo", null, new JsonStringImpl("bar"))); - JsonPatch patch = new JsonPatchBuilderImpl().add("/foo", "bar") + JsonPatch patch = Json.createPatchBuilder().add("/foo", "bar") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -125,37 +125,37 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderAddBoolean() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/path/true", null, JsonValue.TRUE), - new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/path/false", null, JsonValue.FALSE)); - JsonPatch patch = new JsonPatchBuilderImpl().add("/path/true", true) - .add("/path/false", false) - .build(); + JsonPatch patch = Json.createPatchBuilder().add("/path/true", true) + .add("/path/false", false) + .build(); assertNotNull(patch); assertEquals(expected, patch); } @Test(expected = NullPointerException.class) public void testPatchBuilderAddMissingPath() { - new JsonPatchBuilderImpl().add(null, 0); + Json.createPatchBuilder().add(null, 0); } @Test public void testPatchBuilderRemove() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/path/to/remove", null, null)); - JsonPatch patch = new JsonPatchBuilderImpl().remove("/path/to/remove") + JsonPatch patch = Json.createPatchBuilder().remove("/path/to/remove") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -163,19 +163,19 @@ public class JsonPatchBuilderTest { @Test(expected = NullPointerException.class) public void testPatchBuilderRemoveMissingPath() { - new JsonPatchBuilderImpl().remove(null); + Json.createPatchBuilder().remove(null); } @Test public void testPatchBuilderReplaceString() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/path/to/replace", null, new JsonStringImpl("new value"))); - JsonPatch patch = new JsonPatchBuilderImpl().replace("/path/to/replace", "new value") + JsonPatch patch = Json.createPatchBuilder().replace("/path/to/replace", "new value") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -184,12 +184,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceInt() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/replace/me", null, new JsonLongImpl(42))); - JsonPatch patch = new JsonPatchBuilderImpl().replace("/replace/me", 42) + JsonPatch patch = Json.createPatchBuilder().replace("/replace/me", 42) .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -198,16 +198,16 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceBoolean() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/true/to/replace", null, JsonValue.FALSE), - new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/false/to/replace", null, JsonValue.TRUE)); - JsonPatch patch = new JsonPatchBuilderImpl().replace("/true/to/replace", false) + JsonPatch patch = Json.createPatchBuilder().replace("/true/to/replace", false) .replace("/false/to/replace", true) .build(); assertNotNull(patch); @@ -217,14 +217,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceJsonObject() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/replace/the/object", null, Json.createObjectBuilder() .add("foo", "bar") .build())); - JsonPatch patch = new JsonPatchBuilderImpl().replace("/replace/the/object", Json.createObjectBuilder() + JsonPatch patch = Json.createPatchBuilder().replace("/replace/the/object", Json.createObjectBuilder() .add("foo", "bar") .build()) .build(); @@ -235,14 +235,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderReplaceJsonArray() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/replace/my/array", null, Json.createArrayBuilder() .add("test") .build())); - JsonPatch patch = new JsonPatchBuilderImpl().replace("/replace/my/array", Json.createArrayBuilder() + JsonPatch patch = Json.createPatchBuilder().replace("/replace/my/array", Json.createArrayBuilder() .add("test") .build()) .build(); @@ -252,19 +252,19 @@ public class JsonPatchBuilderTest { @Test(expected = NullPointerException.class) public void testPatchBuilderReplaceMissingPath() { - new JsonPatchBuilderImpl().replace(null, "ignored"); + Json.createPatchBuilder().replace(null, "ignored"); } @Test public void testPatchBuilderMove() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/move/to", "/move/from", null)); - JsonPatch patch = new JsonPatchBuilderImpl().move("/move/to", "/move/from") + JsonPatch patch = Json.createPatchBuilder().move("/move/to", "/move/from") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -272,24 +272,24 @@ public class JsonPatchBuilderTest { @Test(expected = NullPointerException.class) public void testPatchBuilderMoveMissingPath() { - new JsonPatchBuilderImpl().move(null, "/ignored"); + Json.createPatchBuilder().move(null, "/ignored"); } @Test(expected = NullPointerException.class) public void testPatchBuilderMoveMissingFrom() { - new JsonPatchBuilderImpl().move("/the/path", null); + Json.createPatchBuilder().move("/the/path", null); } @Test public void testPatchBuilderCopy() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/to", "/from", null)); - JsonPatch patch = new JsonPatchBuilderImpl().copy("/to", "/from") + JsonPatch patch = Json.createPatchBuilder().copy("/to", "/from") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -297,24 +297,24 @@ public class JsonPatchBuilderTest { @Test(expected = NullPointerException.class) public void testPatchBuilderCopyMissingPath() { - new JsonPatchBuilderImpl().copy(null, "/ignored"); + Json.createPatchBuilder().copy(null, "/ignored"); } @Test(expected = NullPointerException.class) public void testPatchBuilderCopyMissingFrom() { - new JsonPatchBuilderImpl().copy("/the/path", null); + Json.createPatchBuilder().copy("/the/path", null); } @Test public void testPatchBuilderTestString() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/to/test", null, new JsonStringImpl("value"))); - JsonPatch patch = new JsonPatchBuilderImpl().test("/to/test", "value") + JsonPatch patch = Json.createPatchBuilder().test("/to/test", "value") .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -323,16 +323,16 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestBoolean() { - JsonPatchImpl exptected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl exptected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/true/to/test", null, JsonValue.TRUE), - new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/false/to/test", null, JsonValue.FALSE)); - JsonPatch patch = new JsonPatchBuilderImpl().test("/true/to/test", true) + JsonPatch patch = Json.createPatchBuilder().test("/true/to/test", true) .test("/false/to/test", false) .build(); assertNotNull(patch); @@ -342,12 +342,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestInt() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/test/int", null, new JsonLongImpl(16))); - JsonPatch patch = new JsonPatchBuilderImpl().test("/test/int", 16) + JsonPatch patch = Json.createPatchBuilder().test("/test/int", 16) .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -356,12 +356,12 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestJsonValue() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/test/value", null, JsonValue.NULL)); - JsonPatch patch = new JsonPatchBuilderImpl().test("/test/value", JsonValue.NULL) + JsonPatch patch = Json.createPatchBuilder().test("/test/value", JsonValue.NULL) .build(); assertNotNull(patch); assertEquals(expected, patch); @@ -370,14 +370,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestJsonObject() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/test/the/object", null, Json.createObjectBuilder() .add("foo", "bar") .build())); - JsonPatch patch = new JsonPatchBuilderImpl().test("/test/the/object", Json.createObjectBuilder() + JsonPatch patch = Json.createPatchBuilder().test("/test/the/object", Json.createObjectBuilder() .add("foo", "bar") .build()) .build(); @@ -388,14 +388,14 @@ public class JsonPatchBuilderTest { @Test public void testPatchBuilderTestJsonArray() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/test/my/array", null, Json.createArrayBuilder() .add("element") .build())); - JsonPatch patch = new JsonPatchBuilderImpl().test("/test/my/array", Json.createArrayBuilder() + JsonPatch patch = Json.createPatchBuilder().test("/test/my/array", Json.createArrayBuilder() .add("element") .build()) .build(); @@ -405,20 +405,20 @@ public class JsonPatchBuilderTest { @Test(expected = NullPointerException.class) public void testPatchBuilderTestMissingPath() { - new JsonPatchBuilderImpl().test(null, "ignored"); + Json.createPatchBuilder().test(null, "ignored"); } @Test public void testPatchBuilderWithinitialData() { - JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl expected = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/add/an/object", null, Json.createObjectBuilder() .add("name", "Cassius") .build()), - new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/replace/me", null, Json.createArrayBuilder() @@ -426,7 +426,7 @@ public class JsonPatchBuilderTest { .add(27) .add("test") .build()), - new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/remove/it", null, null)); http://git-wip-us.apache.org/repos/asf/johnzon/blob/3fec5685/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 7e8ad67..b572030 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 @@ -24,6 +24,7 @@ import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonException; import javax.json.JsonObject; +import javax.json.JsonPatch; import javax.json.JsonStructure; import javax.json.JsonValue; import java.io.StringReader; @@ -43,7 +44,7 @@ public class JsonPatchTest { JsonObject object = Json.createReader(new StringReader("{ \"foo\": \"bar\" }")) .readObject(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/baz", null, // no from new JsonStringImpl("qux"))); @@ -65,7 +66,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo/1", null, // no from new JsonStringImpl("qux"))); @@ -91,7 +92,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo/-", null, // no from new JsonStringImpl("qux"))); @@ -115,7 +116,7 @@ public class JsonPatchTest { .add("baz") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/-", null, // no from new JsonStringImpl("qux"))); @@ -137,7 +138,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/baz/bat", null, // no from new JsonStringImpl("qux"))); @@ -152,7 +153,7 @@ public class JsonPatchTest { .add("bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/5", null, new JsonStringImpl("baz"))); @@ -169,7 +170,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/baz", null, null)); @@ -192,7 +193,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/foo/1", null, null)); @@ -218,7 +219,7 @@ public class JsonPatchTest { .add("baz") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/1", null, null)); @@ -240,7 +241,7 @@ public class JsonPatchTest { .add("baz", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/nomatch", null, null)); @@ -255,7 +256,7 @@ public class JsonPatchTest { .add("bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/5", null, null)); @@ -272,7 +273,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/baz", null, new JsonStringImpl("boo"))); @@ -295,7 +296,7 @@ public class JsonPatchTest { .add("qux")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/foo/1", null, new JsonStringImpl("boo"))); @@ -322,7 +323,7 @@ public class JsonPatchTest { .add("qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/0", null, new JsonStringImpl("boo"))); @@ -344,7 +345,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/nomatch", null, new JsonStringImpl("notneeded"))); @@ -359,7 +360,7 @@ public class JsonPatchTest { .add("foo") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.REPLACE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.REPLACE, "/1", null, new JsonStringImpl("notneeded"))); @@ -379,7 +380,7 @@ public class JsonPatchTest { .add("corge", "grault")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/qux/thud", "/foo/waldo", null)); @@ -412,7 +413,7 @@ public class JsonPatchTest { .add("eat")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/foo/3", "/foo/1", null)); @@ -441,7 +442,7 @@ public class JsonPatchTest { .add("one") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/0", "/3", null)); @@ -465,7 +466,7 @@ public class JsonPatchTest { .add("dog")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/bar", "/foo/2", null)); @@ -491,7 +492,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/baz", "/nomatch", null)); @@ -507,7 +508,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/nomatch/child", "/foo", null)); @@ -523,7 +524,7 @@ public class JsonPatchTest { .add("key", "value")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/object/key", "/object", null)); @@ -539,7 +540,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/baz", "/foo", null)); @@ -562,7 +563,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/foo/-", "/foo/0", null)); @@ -588,7 +589,7 @@ public class JsonPatchTest { .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/0", "/1", null)); @@ -614,7 +615,7 @@ public class JsonPatchTest { .add("partner", JsonValue.EMPTY_JSON_OBJECT)) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/partner/partner/name", "/name", null)); @@ -640,7 +641,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/notneeded", "/nomatch", null)); @@ -655,7 +656,7 @@ public class JsonPatchTest { .add("foo", "bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/path/nomatch", "/foo", null)); @@ -671,7 +672,7 @@ public class JsonPatchTest { .add("bar") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/-", "/2", null)); @@ -686,7 +687,7 @@ public class JsonPatchTest { .add("foo") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/1", "/-", null)); @@ -702,7 +703,7 @@ public class JsonPatchTest { .add("foo", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/foo", null, new JsonStringImpl("qux"))); @@ -719,7 +720,7 @@ public class JsonPatchTest { .add("foo", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/foo", null, Json.createArrayBuilder().build())); @@ -737,7 +738,7 @@ public class JsonPatchTest { .add("Forjgyn")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/parents", null, Json.createArrayBuilder() // yessss, we really want to create a new JsonArray ;) @@ -760,7 +761,7 @@ public class JsonPatchTest { .add(2)) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/numbers", null, Json.createArrayBuilder() // different ordering @@ -780,7 +781,7 @@ public class JsonPatchTest { .add("baz")) .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/foo/1", null, new JsonStringImpl("baz"))); @@ -799,7 +800,7 @@ public class JsonPatchTest { .add("qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/2", null, new JsonStringImpl("qux"))); @@ -818,7 +819,7 @@ public class JsonPatchTest { .add("qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/0", null, new JsonStringImpl("bar"))); @@ -829,7 +830,7 @@ public class JsonPatchTest { @Test(expected = JsonException.class) public void testTestingObjectMemeberNonexistentTarget() { - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/nomatch", null, JsonValue.EMPTY_JSON_OBJECT)); @@ -840,7 +841,7 @@ public class JsonPatchTest { @Test(expected = JsonException.class) public void testTestingArrayElementIndexOutOfBounds() { - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.TEST, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.TEST, "/3", null, JsonValue.EMPTY_JSON_OBJECT)); @@ -857,7 +858,7 @@ public class JsonPatchTest { .add("baz", "qux") .build(); - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/foo", null, new JsonStringImpl("abcd"))); @@ -874,7 +875,7 @@ public class JsonPatchTest { @Test public void testAddArrayElementToEmptyArray() { - JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/-", null, new JsonStringImpl("foo"))); @@ -895,33 +896,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(JsonPatchOperation.ADD, + JsonPatchImpl patch = new JsonPatchImpl(new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/family/father", null, Json.createObjectBuilder() .add("name", "Gaio Modry Effect") .build()), - new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/family/mother", null, Json.createObjectBuilder() .add("name", "Cassius vom Hause Clarabella") .build()), - new JsonPatchImpl.PatchValue(JsonPatchOperation.MOVE, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.MOVE, "/family/children/0", "/family/mother", null), - new JsonPatchImpl.PatchValue(JsonPatchOperation.ADD, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.ADD, "/family/mother", null, Json.createObjectBuilder() .add("name", "Aimee vom Hause Clarabella") .build()), - new JsonPatchImpl.PatchValue(JsonPatchOperation.COPY, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.COPY, "/pedigree", "/family", null), - new JsonPatchImpl.PatchValue(JsonPatchOperation.REMOVE, + new JsonPatchImpl.PatchValue(JsonPatch.Operation.REMOVE, "/family", null, null));
