You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by rm...@apache.org on 2018/06/13 06:58:16 UTC
[1/2] johnzon git commit: JOHNZON-173 ensure all patch 'operations'
use the same JsonProvider
Repository: johnzon
Updated Branches:
refs/heads/master 4b331576e -> 25a2e9802
http://git-wip-us.apache.org/repos/asf/johnzon/blob/25a2e980/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 acab1c9..616b8bb 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
@@ -29,6 +29,8 @@ import javax.json.JsonReader;
import javax.json.JsonString;
import javax.json.JsonStructure;
import javax.json.JsonValue;
+import javax.json.spi.JsonProvider;
+
import java.util.Collections;
import static org.junit.Assert.assertEquals;
@@ -41,17 +43,17 @@ public class JsonPointerTest {
@Test(expected = NullPointerException.class)
public void testConstructorWithJsonPointerNull() {
- new JsonPointerImpl(null);
+ new JsonPointerImpl(JsonProvider.provider(), null);
}
@Test(expected = JsonException.class)
public void testConstructorWithInvalidJsonPointer() {
- new JsonPointerImpl("a");
+ new JsonPointerImpl(JsonProvider.provider(), "a");
}
@Test(expected = NullPointerException.class)
public void testGetValueWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
jsonPointer.getValue(null);
}
@@ -59,7 +61,7 @@ public class JsonPointerTest {
public void testGetValueWithWholeDocument() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals(jsonDocument.toString(), result.toString());
}
@@ -68,7 +70,7 @@ public class JsonPointerTest {
public void testGetValue0() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("0", result.toString());
}
@@ -78,7 +80,7 @@ public class JsonPointerTest {
JsonStructure jsonDocument = getJsonDocument();
{
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/a~1b");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/a~1b");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("1", result.toString());
}
@@ -93,7 +95,7 @@ public class JsonPointerTest {
public void testGetValue2() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/c%d");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/c%d");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("2", result.toString());
}
@@ -103,7 +105,7 @@ public class JsonPointerTest {
JsonStructure jsonDocument = getJsonDocument();
{
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/e^f");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/e^f");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("3", result.toString());
}
@@ -119,7 +121,7 @@ public class JsonPointerTest {
JsonStructure jsonDocument = getJsonDocument();
{
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/g|h");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/g|h");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("4", result.toString());
}
@@ -134,7 +136,7 @@ public class JsonPointerTest {
public void testGetValue5() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/i\\j");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/i\\j");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("5", result.toString());
}
@@ -143,7 +145,7 @@ public class JsonPointerTest {
public void testGetValue6() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/k\"l");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/k\"l");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("6", result.toString());
}
@@ -152,7 +154,7 @@ public class JsonPointerTest {
public void testGetValue7() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/ ");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/ ");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("7", result.toString());
}
@@ -161,7 +163,7 @@ public class JsonPointerTest {
public void testGetValue8() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/m~0n");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/m~0n");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("8", result.toString());
}
@@ -170,7 +172,7 @@ public class JsonPointerTest {
public void testGetValueWithElementNotExistent() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/fool");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/fool");
jsonPointer.getValue(jsonDocument);
}
@@ -178,7 +180,7 @@ public class JsonPointerTest {
public void testGetValueWithWholeJsonArray() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("[\"bar\",\"baz\"]", result.toString());
}
@@ -187,7 +189,7 @@ public class JsonPointerTest {
public void testGetValueWithJsonArray() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/0");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/0");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("\"bar\"", result.toString());
}
@@ -196,7 +198,7 @@ public class JsonPointerTest {
public void testGetValueWithJsonArrayIndexOutOfRange() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/2");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/2");
jsonPointer.getValue(jsonDocument);
}
@@ -204,7 +206,7 @@ public class JsonPointerTest {
public void testGetValueWithJsonArrayIndexNoNumber() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/a");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/a");
jsonPointer.getValue(jsonDocument);
}
@@ -212,7 +214,7 @@ public class JsonPointerTest {
public void testGetValueWithJsonArrayLeadingZeroIndex() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/01");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/01");
JsonValue result = jsonPointer.getValue(jsonDocument);
assertEquals("\"bar\"", result.toString());
}
@@ -221,19 +223,19 @@ public class JsonPointerTest {
public void testGetValueWithJsonArrayInvalidIndex() {
JsonStructure jsonDocument = getJsonDocument();
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/-1");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/-1");
jsonPointer.getValue(jsonDocument);
}
@Test(expected = NullPointerException.class)
public void testAddJsonStructureWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
jsonPointer.add((JsonStructure) null, new JsonStringImpl("qux"));
}
@Test(expected = JsonException.class)
public void testAddJsonStructureWithTypeValueNotTypeTarget() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonObject target = Json.createObjectBuilder().build();
JsonArray value = Json.createArrayBuilder().build();
@@ -242,7 +244,7 @@ public class JsonPointerTest {
@Test
public void testAddJsonStructureWithEmptyJsonPointer() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonStructure target = Json.createObjectBuilder().build();
JsonObject value = Json.createObjectBuilder()
.add("foo", "bar").build(); // { "foo": "bar" }
@@ -253,19 +255,19 @@ public class JsonPointerTest {
@Test(expected = NullPointerException.class)
public void testAddJsonObjectWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
jsonPointer.add((JsonObject) null, new JsonStringImpl("qux"));
}
@Test(expected = NullPointerException.class)
public void testAddJsonArrayWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
jsonPointer.add((JsonArray) null, new JsonStringImpl("qux"));
}
@Test(expected = JsonException.class)
public void testAddArrayElementWithInvalidIndex() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/+");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/+");
JsonStructure target = Json.createArrayBuilder().build();
jsonPointer.add(target, new JsonStringImpl("qux"));
@@ -273,7 +275,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testAddArrayElementWithIndexOutOfRange() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/1");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/1");
JsonStructure target = Json.createArrayBuilder().build();
jsonPointer.add(target, new JsonStringImpl("qux"));
@@ -281,7 +283,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testAddArrayElementWithLeadingZeroIndex() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/01");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/01");
JsonStructure target = Json.createArrayBuilder()
.add("foo").build();
@@ -290,7 +292,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testAddArrayElementWithIndexNoNumber() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/a");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/a");
JsonStructure target = Json.createArrayBuilder()
.add("foo").build();
@@ -299,7 +301,7 @@ public class JsonPointerTest {
@Test
public void testAddObject() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/child");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/child");
JsonStructure target = Json.createObjectBuilder()
.add("foo", "bar").build(); // {"foo":"bar"}
JsonObject value = Json.createObjectBuilder()
@@ -311,7 +313,7 @@ public class JsonPointerTest {
@Test
public void testAddObjectMember() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/baz");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/baz");
JsonStructure target = Json.createObjectBuilder()
.add("foo", "bar").build(); // {"foo":"bar"}
@@ -321,7 +323,7 @@ public class JsonPointerTest {
@Test
public void testAddFirstObjectMember() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo");
JsonStructure target = Json.createObjectBuilder().build(); // {}
JsonStructure result = jsonPointer.add(target, new JsonStringImpl("bar"));
@@ -330,7 +332,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testAddObjectMemberWithNonexistentTarget() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/baz/bat");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/baz/bat");
JsonStructure target = Json.createObjectBuilder()
.add("foo", "bar").build(); // {"foo":"bar"}
@@ -339,7 +341,7 @@ public class JsonPointerTest {
@Test
public void testAddReplaceObjectMember() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/baz");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/baz");
JsonStructure target = Json.createObjectBuilder()
.add("baz", "qux")
.add("foo", "bar").build(); // {"baz":"qux","foo":"bar"}
@@ -350,7 +352,7 @@ public class JsonPointerTest {
@Test
public void testAddArray() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/0/-");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/0/-");
JsonStructure target = Json.createArrayBuilder()
.add(Json.createArrayBuilder()
.add("bar")).build(); // [["bar"]]
@@ -364,7 +366,7 @@ public class JsonPointerTest {
@Test
public void testAddArrayElement() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/1");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/1");
JsonStructure target = Json.createObjectBuilder()
.add("foo", Json.createArrayBuilder()
.add("bar")
@@ -376,13 +378,13 @@ public class JsonPointerTest {
@Test(expected = NullPointerException.class)
public void testRemoveJsonObjectWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/");
jsonPointer.remove((JsonObject) null);
}
@Test(expected = JsonException.class)
public void testRemoveJsonObjectWithEmptyJsonPointer() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonObject target = Json.createObjectBuilder().build();
jsonPointer.remove(target);
@@ -390,13 +392,13 @@ public class JsonPointerTest {
@Test(expected = NullPointerException.class)
public void testRemoveJsonArrayWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/");
jsonPointer.remove((JsonArray) null);
}
@Test(expected = JsonException.class)
public void testRemoveJsonArrayWithEmptyJsonPointer() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonArray target = Json.createArrayBuilder().build();
jsonPointer.remove(target);
@@ -404,7 +406,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testRemoveArrayElementWithIndexNoNumber() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/a");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/a");
JsonStructure target = Json.createObjectBuilder()
.add("foo", Json.createArrayBuilder()
.add("bar")
@@ -416,7 +418,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testRemoveArrayElementWithIndexOutOfRange() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/3");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/3");
JsonStructure target = Json.createObjectBuilder()
.add("foo", Json.createArrayBuilder()
.add("bar")
@@ -428,7 +430,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testRemoveArrayElementWithInvalidIndex() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/+");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/+");
JsonStructure target = Json.createObjectBuilder()
.add("foo", Json.createArrayBuilder()
.add("bar")
@@ -440,7 +442,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testRemoveArrayElementWithLeadingZeroIndex() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/foo/01");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/foo/01");
JsonStructure target = Json.createObjectBuilder()
.add("foo", Json.createArrayBuilder()
.add("bar")
@@ -452,7 +454,7 @@ public class JsonPointerTest {
@Test
public void testRemoveArrayElement() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/0/1");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/0/1");
JsonStructure target = Json.createArrayBuilder()
.add(Json.createArrayBuilder()
.add("bar")
@@ -465,7 +467,7 @@ public class JsonPointerTest {
@Test
public void testRemoveObjectMember() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/baz");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/baz");
JsonStructure target = Json.createObjectBuilder()
.add("baz", "qux")
.add("foo", "bar").build(); // {"baz":"qux","foo":"bar"}
@@ -476,13 +478,13 @@ public class JsonPointerTest {
@Test(expected = NullPointerException.class)
public void testReplaceJsonObjectWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/");
jsonPointer.replace((JsonObject) null, new JsonStringImpl("qux"));
}
@Test(expected = JsonException.class)
public void testReplaceJsonObjectWithEmptyJsonPointer() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonObject target = Json.createObjectBuilder().build();
jsonPointer.replace(target, new JsonStringImpl("qux"));
@@ -490,13 +492,13 @@ public class JsonPointerTest {
@Test(expected = NullPointerException.class)
public void testReplaceJsonArrayWithTargetNull() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/");
jsonPointer.replace((JsonArray) null, new JsonStringImpl("qux"));
}
@Test(expected = JsonException.class)
public void testReplaceJsonArrayWithEmptyJsonPointer() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "");
JsonArray target = Json.createArrayBuilder().build();
jsonPointer.replace(target, new JsonStringImpl("qux"));
@@ -504,7 +506,7 @@ public class JsonPointerTest {
@Test
public void testReplaceArrayElement() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/1/1");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/1/1");
JsonStructure target = Json.createArrayBuilder()
.add("bar")
.add(Json.createArrayBuilder()
@@ -517,7 +519,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testReplaceArrayElementWithIndexOutOfRange() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/1/2");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/1/2");
JsonStructure target = Json.createArrayBuilder()
.add("bar")
.add(Json.createArrayBuilder()
@@ -529,7 +531,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testReplaceArrayElementWithIndexNoNumber() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/1/a");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/1/a");
JsonStructure target = Json.createArrayBuilder()
.add("bar")
.add(Json.createArrayBuilder()
@@ -541,7 +543,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testReplaceArrayElementWithLeadingZeroIndex() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/1/01");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/1/01");
JsonStructure target = Json.createArrayBuilder()
.add("bar")
.add(Json.createArrayBuilder()
@@ -553,7 +555,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testReplaceArrayElementWithInvalidIndex() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/1/+");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/1/+");
JsonStructure target = Json.createArrayBuilder()
.add("bar")
.add(Json.createArrayBuilder()
@@ -565,7 +567,7 @@ public class JsonPointerTest {
@Test
public void testReplaceObjectMember() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/baz");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/baz");
JsonStructure target = Json.createObjectBuilder()
.add("foo", "bar")
.add("baz", "qux").build(); // {"foo":"bar","baz":"qux"}
@@ -576,7 +578,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testReplaceObjectMemberWithNonexistentTarget1() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/baz/a");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/baz/a");
JsonStructure target = Json.createObjectBuilder()
.add("foo", "bar")
.add("baz", "qux").build(); // {"foo":"bar","baz":"qux"}
@@ -587,7 +589,7 @@ public class JsonPointerTest {
@Test(expected = JsonException.class)
public void testReplaceObjectMemberWithNonexistentTarget2() {
- JsonPointerImpl jsonPointer = new JsonPointerImpl("/fo");
+ JsonPointerImpl jsonPointer = new JsonPointerImpl(JsonProvider.provider(), "/fo");
JsonStructure target = Json.createObjectBuilder()
.add("foo", "bar")
.add("baz", "qux").build(); // {"foo":"bar","baz":"qux"}
@@ -598,15 +600,15 @@ public class JsonPointerTest {
@Test
public void testEqualsTrue() {
- JsonPointerImpl jsonPointer1 = new JsonPointerImpl("/foo/1");
- JsonPointerImpl jsonPointer2 = new JsonPointerImpl("/foo/1");
+ JsonPointerImpl jsonPointer1 = new JsonPointerImpl(JsonProvider.provider(), "/foo/1");
+ JsonPointerImpl jsonPointer2 = new JsonPointerImpl(JsonProvider.provider(), "/foo/1");
assertTrue(jsonPointer1.equals(jsonPointer2));
}
@Test
public void testEqualsFalse() {
- JsonPointerImpl jsonPointer1 = new JsonPointerImpl("/foo/1");
- JsonPointerImpl jsonPointer2 = new JsonPointerImpl("/foo/2");
+ JsonPointerImpl jsonPointer1 = new JsonPointerImpl(JsonProvider.provider(), "/foo/1");
+ JsonPointerImpl jsonPointer2 = new JsonPointerImpl(JsonProvider.provider(), "/foo/2");
assertFalse(jsonPointer1.equals(jsonPointer2));
}
@@ -620,7 +622,7 @@ public class JsonPointerTest {
.add("key2", "value2"))
.build();
- JsonPointerImpl pointer = new JsonPointerImpl("/object2/key3");
+ JsonPointerImpl pointer = new JsonPointerImpl(JsonProvider.provider(), "/object2/key3");
JsonObject pointered = pointer.add(object, new JsonStringImpl("value3"));
assertNotNull(pointered);
@@ -652,7 +654,7 @@ public class JsonPointerTest {
.add("name", "Leia Skywalker"))))
.build();
- JsonValue padme = new JsonPointerImpl("/family/mother/name").getValue(family);
+ JsonValue padme = new JsonPointerImpl(JsonProvider.provider(), "/family/mother/name").getValue(family);
assertTrue("padme must be instanceOf JsonString", padme instanceof JsonString);
assertEquals("Padme Amidala", ((JsonString) padme).getString());
}
[2/2] johnzon git commit: JOHNZON-173 ensure all patch 'operations'
use the same JsonProvider
Posted by rm...@apache.org.
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 <rm...@gmail.com>
Authored: Wed Jun 13 08:58:06 2018 +0200
Committer: Romain Manni-Bucau <rm...@gmail.com>
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));