From 531baf9de449dcf686be21c4a1c1fb22eee8a3f2 Mon Sep 17 00:00:00 2001 From: Piotr Bugara Date: Mon, 3 Jul 2023 10:49:41 +0200 Subject: [PATCH 1/4] #50 Different data types in tests --- src/test/resources/jsonpatch/test.json | 135 +++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/src/test/resources/jsonpatch/test.json b/src/test/resources/jsonpatch/test.json index d5602480..851a46ec 100644 --- a/src/test/resources/jsonpatch/test.json +++ b/src/test/resources/jsonpatch/test.json @@ -1329,6 +1329,141 @@ }, "expensive": 10 } + }, + + { + "op": { + "op": "test", + "path": "$.store.book[0]", + "value": { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95 + } + }, + "node": { + "store": { + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95 + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + }, + "expensive": 10 + }, + "expected": { + "store": { + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95 + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + }, + "expensive": 10 + } + }, + + { + "op": { + "op": "test", + "path": "$.store.book[0].available", + "value": true + }, + "node": { + "store": { + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95, + "available": true + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + }, + "expensive": 10 + }, + "expected": { + "store": { + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95, + "available": true + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + }, + "expensive": 10 + } + }, + + { + "op": { + "op": "test", + "path": "$.store.book[0].tags", + "value": ["tag1", "tag2", 16.0, 11, true] + }, + "node": { + "store": { + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95, + "tags": ["tag1", "tag2", 16.0, 11, true] + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + }, + "expensive": 10 + }, + "expected": { + "store": { + "book": [ + { + "category": "reference", + "author": "Nigel Rees", + "title": "Sayings of the Century", + "price": 8.95, + "tags": ["tag1", "tag2", 16.0, 11, true] + } + ], + "bicycle": { + "color": "red", + "price": 19.95 + } + }, + "expensive": 10 + } } ] } \ No newline at end of file From 550aaff3be732fcd03f8fb6bf6ba0252a3cd1a3d Mon Sep 17 00:00:00 2001 From: Piotr Bugara Date: Mon, 3 Jul 2023 11:51:40 +0200 Subject: [PATCH 2/4] #50 Different data types in tests --- .../jsonpatch/model/DataTypesTest.java | 111 ++++++++++++++++++ .../jsonpatch/model/EmbeddedModel.java | 18 +++ .../gravity9/jsonpatch/model/SimpleModel.java | 85 ++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 src/test/java/com/gravity9/jsonpatch/model/DataTypesTest.java create mode 100644 src/test/java/com/gravity9/jsonpatch/model/EmbeddedModel.java create mode 100644 src/test/java/com/gravity9/jsonpatch/model/SimpleModel.java diff --git a/src/test/java/com/gravity9/jsonpatch/model/DataTypesTest.java b/src/test/java/com/gravity9/jsonpatch/model/DataTypesTest.java new file mode 100644 index 00000000..53343a3a --- /dev/null +++ b/src/test/java/com/gravity9/jsonpatch/model/DataTypesTest.java @@ -0,0 +1,111 @@ +package com.gravity9.jsonpatch.model; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.gravity9.jsonpatch.JsonPatch; +import com.gravity9.jsonpatch.JsonPatchException; +import org.testng.annotations.Test; + +public class DataTypesTest { + + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Test + void should_pass_test_operation_for_string_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/stringField\",\"value\":\"test\"}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } + + @Test + void should_pass_test_operation_for_float_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/floatField\",\"value\": 10.56}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } + + @Test + void should_pass_test_operation_for_int_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/intField\",\"value\": 10}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } + + @Test + void should_pass_test_operation_for_long_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/longField\",\"value\": 100}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } + + @Test + void should_pass_test_operation_for_double_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/doubleField\",\"value\": 10.56}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } + + @Test + void should_pass_test_operation_for_boolean_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/booleanField\",\"value\": true}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } + + @Test + void should_pass_test_operation_for_embedded_data_type() throws JsonProcessingException, JsonPatchException { + // given + SimpleModel simpleModel = new SimpleModel("test", 10, 100L, 10.56f, 10.56, true, new EmbeddedModel("embeddedValue")); + + // when + String operation = "[{\"op\":\"test\",\"path\":\"/embeddedField\",\"value\": {\"embeddedField\": \"embeddedValue\"}}]"; + JsonPatch jsonPatch = objectMapper.readValue(operation, JsonPatch.class); + + JsonNode jsonNode = objectMapper.valueToTree(simpleModel); + + jsonPatch.apply(jsonNode); + } +} diff --git a/src/test/java/com/gravity9/jsonpatch/model/EmbeddedModel.java b/src/test/java/com/gravity9/jsonpatch/model/EmbeddedModel.java new file mode 100644 index 00000000..c4b2d4b6 --- /dev/null +++ b/src/test/java/com/gravity9/jsonpatch/model/EmbeddedModel.java @@ -0,0 +1,18 @@ +package com.gravity9.jsonpatch.model; + +public class EmbeddedModel { + + private String embeddedField; + + public EmbeddedModel(String embeddedField) { + this.embeddedField = embeddedField; + } + + public String getEmbeddedField() { + return embeddedField; + } + + public void setEmbeddedField(String embeddedField) { + this.embeddedField = embeddedField; + } +} diff --git a/src/test/java/com/gravity9/jsonpatch/model/SimpleModel.java b/src/test/java/com/gravity9/jsonpatch/model/SimpleModel.java new file mode 100644 index 00000000..07293d02 --- /dev/null +++ b/src/test/java/com/gravity9/jsonpatch/model/SimpleModel.java @@ -0,0 +1,85 @@ +package com.gravity9.jsonpatch.model; + +public class SimpleModel { + + private String stringField; + + private int intField; + + private long longField; + + private float floatField; + + private double doubleField; + + private boolean booleanField; + + private EmbeddedModel embeddedField; + + public SimpleModel(String stringField, int intField, long longField, float floatField, double doubleField, + boolean booleanField, EmbeddedModel embeddedField) { + this.stringField = stringField; + this.intField = intField; + this.longField = longField; + this.floatField = floatField; + this.doubleField = doubleField; + this.booleanField = booleanField; + this.embeddedField = embeddedField; + } + + public String getStringField() { + return stringField; + } + + public void setStringField(String stringField) { + this.stringField = stringField; + } + + public int getIntField() { + return intField; + } + + public void setIntField(int intField) { + this.intField = intField; + } + + public long getLongField() { + return longField; + } + + public void setLongField(long longField) { + this.longField = longField; + } + + public float getFloatField() { + return floatField; + } + + public void setFloatField(float floatField) { + this.floatField = floatField; + } + + public double getDoubleField() { + return doubleField; + } + + public void setDoubleField(double doubleField) { + this.doubleField = doubleField; + } + + public boolean isBooleanField() { + return booleanField; + } + + public void setBooleanField(boolean booleanField) { + this.booleanField = booleanField; + } + + public EmbeddedModel getEmbeddedField() { + return embeddedField; + } + + public void setEmbeddedField(EmbeddedModel embeddedField) { + this.embeddedField = embeddedField; + } +} From 55ec4f219660181ce414638ff553a60295cbd7a7 Mon Sep 17 00:00:00 2001 From: Mateusz Zaremba Date: Mon, 3 Jul 2023 12:01:06 +0200 Subject: [PATCH 3/4] Fix data types equivalence logic --- .../com/gravity9/jsonpatch/TestOperation.java | 2 +- .../jsonpatch/diff/DiffProcessor.java | 3 +- .../com/gravity9/jsonpatch/diff/JsonDiff.java | 2 +- .../jsonpatch/jackson/JsonNumEquals.java | 243 ++++++++++++++++++ .../jsonpatch/JsonPatchOperationTest.java | 3 +- .../gravity9/jsonpatch/TestOperationTest.java | 34 +++ .../gravity9/jsonpatch/diff/JsonDiffTest.java | 3 +- .../mergepatch/NonObjectMergePatchTest.java | 3 +- .../mergepatch/ObjectMergePatchTest.java | 3 +- .../mergepatch/SerializationTest.java | 3 +- .../JsonPatchOperationSerializationTest.java | 3 +- 11 files changed, 293 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/gravity9/jsonpatch/jackson/JsonNumEquals.java diff --git a/src/main/java/com/gravity9/jsonpatch/TestOperation.java b/src/main/java/com/gravity9/jsonpatch/TestOperation.java index 14c041a8..19172e26 100644 --- a/src/main/java/com/gravity9/jsonpatch/TestOperation.java +++ b/src/main/java/com/gravity9/jsonpatch/TestOperation.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; -import com.github.fge.jackson.JsonNumEquals; +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import com.jayway.jsonpath.JsonPath; /** diff --git a/src/main/java/com/gravity9/jsonpatch/diff/DiffProcessor.java b/src/main/java/com/gravity9/jsonpatch/diff/DiffProcessor.java index fb74fd50..febced91 100644 --- a/src/main/java/com/gravity9/jsonpatch/diff/DiffProcessor.java +++ b/src/main/java/com/gravity9/jsonpatch/diff/DiffProcessor.java @@ -20,10 +20,11 @@ package com.gravity9.jsonpatch.diff; import com.fasterxml.jackson.databind.JsonNode; -import com.github.fge.jackson.JsonNumEquals; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.gravity9.jsonpatch.JsonPatch; import com.gravity9.jsonpatch.JsonPatchOperation; +import com.gravity9.jsonpatch.jackson.JsonNumEquals; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; diff --git a/src/main/java/com/gravity9/jsonpatch/diff/JsonDiff.java b/src/main/java/com/gravity9/jsonpatch/diff/JsonDiff.java index 03ab05bc..b3693a8f 100644 --- a/src/main/java/com/gravity9/jsonpatch/diff/JsonDiff.java +++ b/src/main/java/com/gravity9/jsonpatch/diff/JsonDiff.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.github.fge.jackson.JacksonUtils; -import com.github.fge.jackson.JsonNumEquals; import com.github.fge.jackson.NodeType; import com.github.fge.jackson.jsonpointer.JsonPointer; import com.github.fge.msgsimple.bundle.MessageBundle; @@ -34,6 +33,7 @@ import com.gravity9.jsonpatch.JsonPatchMessages; import com.gravity9.jsonpatch.JsonPatchOperation; import com.gravity9.jsonpatch.RemoveOperation; +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import com.jayway.jsonpath.PathNotFoundException; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/gravity9/jsonpatch/jackson/JsonNumEquals.java b/src/main/java/com/gravity9/jsonpatch/jackson/JsonNumEquals.java new file mode 100644 index 00000000..6dee838f --- /dev/null +++ b/src/main/java/com/gravity9/jsonpatch/jackson/JsonNumEquals.java @@ -0,0 +1,243 @@ +package com.gravity9.jsonpatch.jackson; + +import com.fasterxml.jackson.databind.JsonNode; +import com.github.fge.jackson.NodeType; + +import javax.annotation.Nullable; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * An {@code com.google.common.base.Equivalence} like strategy for JSON Schema equality + * + *

{@link JsonNode} does a pretty good job of obeying the {@link + * Object#equals(Object) equals()}/{@link Object#hashCode() hashCode()} + * contract. And in fact, it does it too well for JSON Schema.

+ * + *

For instance, it considers numeric nodes {@code 1} and {@code 1.0} to be + * different nodes, which is true. But some IETF RFCs and drafts (among them, + * JSON Schema and JSON Patch) mandate that numeric JSON values be considered + * equal if their mathematical value is the same. This class implements this + * kind of equality.

+ */ +public final class JsonNumEquals +{ + private static final com.gravity9.jsonpatch.jackson.JsonNumEquals INSTANCE + = new com.gravity9.jsonpatch.jackson.JsonNumEquals(); + + private JsonNumEquals() + { + } + + public static com.gravity9.jsonpatch.jackson.JsonNumEquals getInstance() + { + return INSTANCE; + } + + @SuppressWarnings("ReferenceEquality") + public final boolean equivalent(@Nullable JsonNode a, @Nullable JsonNode b) { + if (a == b) { + return true; + } + if (a == null || b == null) { + return false; + } + return doEquivalent(a, b); + } + + private boolean doEquivalent(final JsonNode a, final JsonNode b) + { + /* + * If both are numbers, delegate to the helper method + */ + if (a.isNumber() && b.isNumber()) + return numEquals(a, b); + + final NodeType typeA = NodeType.getNodeType(a); + final NodeType typeB = NodeType.getNodeType(b); + + /* + * If they are of different types, no dice + */ + if (typeA != typeB) + return false; + + /* + * For all other primitive types than numbers, trust JsonNode + */ + if (!a.isContainerNode()) + return a.equals(b); + + /* + * OK, so they are containers (either both arrays or objects due to the + * test on types above). They are obviously not equal if they do not + * have the same number of elements/members. + */ + if (a.size() != b.size()) + return false; + + /* + * Delegate to the appropriate method according to their type. + */ + return typeA == NodeType.ARRAY ? arrayEquals(a, b) : objectEquals(a, b); + } + + public int hash(@Nullable JsonNode t) { + if (t == null) { + return 0; + } + return doHash(t); + } + + private int doHash(final JsonNode t) + { + /* + * If this is a numeric node, we want the same hashcode for the same + * mathematical values. Go with double, its range is good enough for + * 99+% of use cases. + */ + if (t.isNumber()) + return Double.valueOf(t.doubleValue()).hashCode(); + + /* + * If this is a primitive type (other than numbers, handled above), + * delegate to JsonNode. + */ + if (!t.isContainerNode()) + return t.hashCode(); + + /* + * The following hash calculations work, yes, but they are poor at best. + * And probably slow, too. + * + * TODO: try and figure out those hash classes from Guava + */ + int ret = 0; + + /* + * If the container is empty, just return + */ + if (t.size() == 0) + return ret; + + /* + * Array + */ + if (t.isArray()) { + for (final JsonNode element: t) + ret = 31 * ret + hash(element); + return ret; + } + + /* + * Not an array? An object. + */ + final Iterator> iterator = t.fields(); + + Map.Entry entry; + + while (iterator.hasNext()) { + entry = iterator.next(); + ret = 31 * ret + + (entry.getKey().hashCode() ^ hash(entry.getValue())); + } + + return ret; + } + +// private static boolean numEquals(final JsonNode a, final JsonNode b) +// { +// /* +// * If both numbers are integers, delegate to JsonNode. +// */ +// if (a.isIntegralNumber() && b.isIntegralNumber()) +// return a.equals(b); +// +// /* +// * Otherwise, compare decimal values. +// */ +// return a.decimalValue().compareTo(b.decimalValue()) == 0; +// } + + private boolean numEquals(JsonNode a, JsonNode b) { + return a.isNumber() && b.isNumber() + ? areNumberNodesNumericallyEqual(a, b) + : a.equals(b); + } + + private boolean areNumberNodesNumericallyEqual(JsonNode a, JsonNode b) { + if (a.isIntegralNumber() && b.isIntegralNumber()) { + return a.canConvertToLong() && b.canConvertToLong() + ? a.longValue() == b.longValue() + : a.bigIntegerValue().equals(b.bigIntegerValue()); + } + + if(a.isFloatingPointNumber() && b.isFloatingPointNumber()){ + return a.isFloat() || b.isFloat() ? + Float.compare(a.floatValue(), b.floatValue()) == 0 + : Double.compare(a.doubleValue(), b.doubleValue()) == 0; + } + + return a.decimalValue().compareTo(b.decimalValue()) == 0; + } + + private boolean arrayEquals(final JsonNode a, final JsonNode b) + { + /* + * We are guaranteed here that arrays are the same size. + */ + final int size = a.size(); + + for (int i = 0; i < size; i++) + if (!equivalent(a.get(i), b.get(i))) + return false; + + return true; + } + + private boolean objectEquals(final JsonNode a, final JsonNode b) + { + /* + * Grab the key set from the first node + */ + final Set keys = new HashSet<>(); + Iterator iterator1 = a.fieldNames(); + while (iterator1.hasNext()) { + final String next = iterator1.next(); + if (next != null) { + keys.add(next); + } else { + throw new NullPointerException(); + } + } + + /* + * Grab the key set from the second node, and see if both sets are the + * same. If not, objects are not equal, no need to check for children. + */ + final Set set = new HashSet<>(); + Iterator iterator2 = b.fieldNames(); + while (iterator2.hasNext()) { + final String next = iterator2.next(); + if (next != null) { + set.add(next); + } else { + throw new NullPointerException(); + } + } + + if (!set.equals(keys)) + return false; + + /* + * Test each member individually. + */ + for (final String key: keys) + if (!equivalent(a.get(key), b.get(key))) + return false; + + return true; + } +} \ No newline at end of file diff --git a/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java b/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java index 6f47c22b..740f9044 100644 --- a/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java +++ b/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java @@ -23,13 +23,14 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.github.fge.msgsimple.bundle.MessageBundle; import com.github.fge.msgsimple.load.MessageBundles; import com.google.common.collect.Lists; import java.io.IOException; import java.util.Iterator; import java.util.List; + +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/src/test/java/com/gravity9/jsonpatch/TestOperationTest.java b/src/test/java/com/gravity9/jsonpatch/TestOperationTest.java index 6928ec2f..f6b47680 100644 --- a/src/test/java/com/gravity9/jsonpatch/TestOperationTest.java +++ b/src/test/java/com/gravity9/jsonpatch/TestOperationTest.java @@ -19,12 +19,46 @@ package com.gravity9.jsonpatch; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.testng.annotations.Test; + import java.io.IOException; public final class TestOperationTest extends JsonPatchOperationTest { + private static final TestDomain DOMAIN_TO_PATCH = new TestDomain(2022.4321f); + private static final String testOperation = "[{\"op\":\"test\",\"path\":\"/myValue\",\"value\":2022.4321}]"; + public TestOperationTest() throws IOException { super("test"); } + + @Test + void testPatchValueIsDoubleDomainValueIsFloat() throws Exception { + JsonPatch jsonPatch = new ObjectMapper().readValue(testOperation, JsonPatch.class); + + JsonNode jsonNode = new ObjectMapper().valueToTree(DOMAIN_TO_PATCH); + + jsonPatch.apply(jsonNode); + } + + @SuppressWarnings("UnusedMethod") + private static class TestDomain { + + private Float myValue; + + public TestDomain(Float myValue) { + this.myValue = myValue; + } + + public Float getMyValue() { + return myValue; + } + + public void setMyValue(Float myValue) { + this.myValue = myValue; + } + } } diff --git a/src/test/java/com/gravity9/jsonpatch/diff/JsonDiffTest.java b/src/test/java/com/gravity9/jsonpatch/diff/JsonDiffTest.java index 07128cde..9e5cdf2b 100644 --- a/src/test/java/com/gravity9/jsonpatch/diff/JsonDiffTest.java +++ b/src/test/java/com/gravity9/jsonpatch/diff/JsonDiffTest.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.google.common.collect.Lists; import com.gravity9.jsonpatch.JsonPatch; import com.gravity9.jsonpatch.JsonPatchException; @@ -31,6 +30,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/src/test/java/com/gravity9/jsonpatch/mergepatch/NonObjectMergePatchTest.java b/src/test/java/com/gravity9/jsonpatch/mergepatch/NonObjectMergePatchTest.java index 112839e4..9312a28d 100644 --- a/src/test/java/com/gravity9/jsonpatch/mergepatch/NonObjectMergePatchTest.java +++ b/src/test/java/com/gravity9/jsonpatch/mergepatch/NonObjectMergePatchTest.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.github.fge.msgsimple.bundle.MessageBundle; import com.github.fge.msgsimple.load.MessageBundles; import com.google.common.collect.Lists; @@ -31,6 +30,8 @@ import java.io.IOException; import java.util.Iterator; import java.util.List; + +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/src/test/java/com/gravity9/jsonpatch/mergepatch/ObjectMergePatchTest.java b/src/test/java/com/gravity9/jsonpatch/mergepatch/ObjectMergePatchTest.java index e6d2bc79..675b21be 100644 --- a/src/test/java/com/gravity9/jsonpatch/mergepatch/ObjectMergePatchTest.java +++ b/src/test/java/com/gravity9/jsonpatch/mergepatch/ObjectMergePatchTest.java @@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.github.fge.msgsimple.bundle.MessageBundle; import com.github.fge.msgsimple.load.MessageBundles; import com.google.common.collect.Lists; @@ -31,6 +30,8 @@ import java.io.IOException; import java.util.Iterator; import java.util.List; + +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/src/test/java/com/gravity9/jsonpatch/mergepatch/SerializationTest.java b/src/test/java/com/gravity9/jsonpatch/mergepatch/SerializationTest.java index e8ae4f25..fa507d90 100644 --- a/src/test/java/com/gravity9/jsonpatch/mergepatch/SerializationTest.java +++ b/src/test/java/com/gravity9/jsonpatch/mergepatch/SerializationTest.java @@ -23,11 +23,12 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.google.common.collect.Lists; import java.io.IOException; import java.util.Iterator; import java.util.List; + +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/src/test/java/com/gravity9/jsonpatch/serialization/JsonPatchOperationSerializationTest.java b/src/test/java/com/gravity9/jsonpatch/serialization/JsonPatchOperationSerializationTest.java index f194b8d5..994b8844 100644 --- a/src/test/java/com/gravity9/jsonpatch/serialization/JsonPatchOperationSerializationTest.java +++ b/src/test/java/com/gravity9/jsonpatch/serialization/JsonPatchOperationSerializationTest.java @@ -23,12 +23,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.google.common.collect.Lists; import com.gravity9.jsonpatch.JsonPatchOperation; import java.io.IOException; import java.util.Iterator; import java.util.List; + +import com.gravity9.jsonpatch.jackson.JsonNumEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; From 9f06a900435da7ce6e523a8aac6960d313804c03 Mon Sep 17 00:00:00 2001 From: Mateusz Zaremba Date: Mon, 3 Jul 2023 12:02:37 +0200 Subject: [PATCH 4/4] Merge additional tests --- src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java b/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java index b61f3676..73d8317d 100644 --- a/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java +++ b/src/test/java/com/gravity9/jsonpatch/JsonPatchOperationTest.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.github.fge.jackson.JacksonUtils; import com.github.fge.jackson.JsonLoader; -import com.github.fge.jackson.JsonNumEquals; import com.google.common.collect.Lists; import java.io.IOException; import java.util.Iterator;