-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement #28 (add serializers for JsonPatch, JsonMergePatch)
- Loading branch information
1 parent
8fb2081
commit aa7aa3a
Showing
8 changed files
with
260 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...p/src/test/java/com/fasterxml/jackson/datatype/jsonp/JsonMergePatchSerializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.fasterxml.jackson.datatype.jsonp; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import jakarta.json.JsonMergePatch; | ||
|
||
public class JsonMergePatchSerializationTest extends TestBase | ||
{ | ||
private static final ObjectMapper MAPPER = newMapper(); | ||
|
||
public void testSimpleSerialization() throws Exception | ||
{ | ||
// First need a patch so deserialization must work | ||
final String input = "{" + | ||
"\"name\":\"Json\"" + | ||
"}"; | ||
final JsonMergePatch patch1 = MAPPER.readValue(input, JsonMergePatch.class); | ||
final String output = MAPPER.writeValueAsString(patch1); | ||
|
||
// and read back | ||
final JsonMergePatch patch2 = MAPPER.readValue(output, JsonMergePatch.class); | ||
assertEquals(patch1.toJsonValue(), patch2.toJsonValue()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...-jsonp/src/test/java/com/fasterxml/jackson/datatype/jsonp/JsonPatchSerializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.fasterxml.jackson.datatype.jsonp; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import jakarta.json.JsonPatch; | ||
|
||
public class JsonPatchSerializationTest extends TestBase | ||
{ | ||
private static final ObjectMapper MAPPER = newMapper(); | ||
|
||
public void testSimpleSerialization() throws Exception | ||
{ | ||
// First need a patch so deserialization must work | ||
final String input = "[" + | ||
"{" + | ||
"\"op\":\"replace\"," + | ||
"\"path\":\"/name\"," + | ||
"\"value\":\"Json\"" + | ||
"}" + | ||
"]"; | ||
final JsonPatch jsonPatch = MAPPER.readValue(input, JsonPatch.class); | ||
final String output = MAPPER.writeValueAsString(jsonPatch); | ||
|
||
// and read back | ||
final JsonPatch jsonPatch2 = MAPPER.readValue(output, JsonPatch.class); | ||
assertEquals(jsonPatch, jsonPatch2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../src/test/java/com/fasterxml/jackson/datatype/jsr353/JsonMergePatchSerializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.fasterxml.jackson.datatype.jsr353; | ||
|
||
import javax.json.JsonMergePatch; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class JsonMergePatchSerializationTest extends TestBase | ||
{ | ||
private static final ObjectMapper MAPPER = newMapper(); | ||
|
||
public void testSimpleSerialization() throws Exception | ||
{ | ||
// First need a patch so deserialization must work | ||
final String input = "{" + | ||
"\"name\":\"Json\"" + | ||
"}"; | ||
final JsonMergePatch patch1 = MAPPER.readValue(input, JsonMergePatch.class); | ||
final String output = MAPPER.writeValueAsString(patch1); | ||
|
||
// and read back | ||
final JsonMergePatch patch2 = MAPPER.readValue(output, JsonMergePatch.class); | ||
assertEquals(patch1.toJsonValue(), patch2.toJsonValue()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
jsr-353/src/test/java/com/fasterxml/jackson/datatype/jsr353/JsonPatchSerializationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.fasterxml.jackson.datatype.jsr353; | ||
|
||
import javax.json.JsonPatch; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class JsonPatchSerializationTest extends TestBase | ||
{ | ||
private static final ObjectMapper MAPPER = newMapper(); | ||
|
||
public void testSimpleSerialization() throws Exception | ||
{ | ||
// First need a patch so deserialization must work | ||
final String input = "[" + | ||
"{" + | ||
"\"op\":\"replace\"," + | ||
"\"path\":\"/name\"," + | ||
"\"value\":\"Json\"" + | ||
"}" + | ||
"]"; | ||
final JsonPatch jsonPatch = MAPPER.readValue(input, JsonPatch.class); | ||
final String output = MAPPER.writeValueAsString(jsonPatch); | ||
|
||
// and read back | ||
final JsonPatch jsonPatch2 = MAPPER.readValue(output, JsonPatch.class); | ||
assertEquals(jsonPatch, jsonPatch2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters