Repository: johnzon Updated Branches: refs/heads/JSONP-1.1 4b3ddf55b -> f34deb609
JOHNZON-95 initial JsonPatchBuilder impl Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/f34deb60 Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/f34deb60 Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/f34deb60 Branch: refs/heads/JSONP-1.1 Commit: f34deb60920e08cbce6c969209c0ea2ab5714265 Parents: 4b3ddf5 Author: Mark Struberg <[email protected]> Authored: Wed Nov 23 14:08:43 2016 +0100 Committer: Mark Struberg <[email protected]> Committed: Wed Nov 23 14:08:43 2016 +0100 ---------------------------------------------------------------------- .../johnzon/core/JsonPatchBuilderImpl.java | 124 +++++++++++++++++++ .../apache/johnzon/core/JsonPointerTest.java | 40 ++++-- 2 files changed, 155 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/johnzon/blob/f34deb60/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 new file mode 100644 index 0000000..f2e6a0d --- /dev/null +++ b/johnzon-core/src/main/java/org/apache/johnzon/core/JsonPatchBuilderImpl.java @@ -0,0 +1,124 @@ +/* + * 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 javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonPatchBuilder; +import javax.json.JsonStructure; +import javax.json.JsonValue; + +public class JsonPatchBuilderImpl implements JsonPatchBuilder { + public JsonPatchBuilderImpl() { + super(); + } + + @Override + public JsonStructure apply(JsonStructure target) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonObject apply(JsonObject target) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonArray apply(JsonArray target) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder add(String path, JsonValue value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder add(String path, String value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder add(String path, int value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder add(String path, boolean value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder remove(String path) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder replace(String path, JsonValue value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder replace(String path, String value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder replace(String path, int value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder replace(String path, boolean value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder move(String path, String from) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder copy(String path, String from) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder test(String path, JsonValue value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder test(String path, String value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder test(String path, int value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonPatchBuilder test(String path, boolean value) { + throw new UnsupportedOperationException("JSON-P 1.1"); + } + + @Override + public JsonArray build() { + throw new UnsupportedOperationException("JSON-P 1.1"); + } +} http://git-wip-us.apache.org/repos/asf/johnzon/blob/f34deb60/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPointerTest.java ---------------------------------------------------------------------- diff --git a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPointerTest.java b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPointerTest.java index 7a3d32a..57d52b9 100644 --- a/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPointerTest.java +++ b/johnzon-core/src/test/java/org/apache/johnzon/core/JsonPointerTest.java @@ -24,6 +24,7 @@ import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonException; import javax.json.JsonObject; +import javax.json.JsonPointer; import javax.json.JsonReader; import javax.json.JsonStructure; import javax.json.JsonValue; @@ -73,9 +74,16 @@ public class JsonPointerTest { public void testGetValue1() { JsonStructure jsonDocument = getJsonDocument(); - JsonPointerImpl jsonPointer = new JsonPointerImpl("/a~1b"); - JsonValue result = jsonPointer.getValue(jsonDocument); - assertEquals("1", result.toString()); + { + JsonPointerImpl jsonPointer = new JsonPointerImpl("/a~1b"); + JsonValue result = jsonPointer.getValue(jsonDocument); + assertEquals("1", result.toString()); + } + { + JsonPointer jsonPointer = Json.createJsonPointer("/a~1b"); + JsonValue result = jsonPointer.getValue(jsonDocument); + assertEquals("1", result.toString()); + } } @Test @@ -91,18 +99,32 @@ public class JsonPointerTest { public void testGetValue3() { JsonStructure jsonDocument = getJsonDocument(); - JsonPointerImpl jsonPointer = new JsonPointerImpl("/e^f"); - JsonValue result = jsonPointer.getValue(jsonDocument); - assertEquals("3", result.toString()); + { + JsonPointerImpl jsonPointer = new JsonPointerImpl("/e^f"); + JsonValue result = jsonPointer.getValue(jsonDocument); + assertEquals("3", result.toString()); + } + { + JsonPointer jsonPointer = Json.createJsonPointer("/e^f"); + JsonValue result = jsonPointer.getValue(jsonDocument); + assertEquals("3", result.toString()); + } } @Test public void testGetValue4() { JsonStructure jsonDocument = getJsonDocument(); - JsonPointerImpl jsonPointer = new JsonPointerImpl("/g|h"); - JsonValue result = jsonPointer.getValue(jsonDocument); - assertEquals("4", result.toString()); + { + JsonPointerImpl jsonPointer = new JsonPointerImpl("/g|h"); + JsonValue result = jsonPointer.getValue(jsonDocument); + assertEquals("4", result.toString()); + } + { + JsonPointer jsonPointer = Json.createJsonPointer("/g|h"); + JsonValue result = jsonPointer.getValue(jsonDocument); + assertEquals("4", result.toString()); + } } @Test
