|
15 | 15 | */ |
16 | 16 | package com.github.dockerjava.test.serdes; |
17 | 17 |
|
| 18 | +import com.fasterxml.jackson.databind.JsonNode; |
18 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; |
19 | 20 | import com.github.dockerjava.api.command.CommandJSONSamples; |
| 21 | + |
20 | 22 | import java.io.IOException; |
21 | 23 | import java.io.InputStream; |
| 24 | + |
22 | 25 | import org.apache.commons.io.IOUtils; |
| 26 | + |
23 | 27 | import static org.testng.Assert.assertEquals; |
24 | 28 | import static org.testng.Assert.assertNotNull; |
25 | 29 |
|
@@ -101,10 +105,14 @@ public static <TClass> TClass testRoundTrip(TClass item, Class<TClass> asclass) |
101 | 105 | throws IOException, AssertionError { |
102 | 106 | ObjectMapper mapper = new ObjectMapper(); |
103 | 107 |
|
104 | | - String inputItemString = mapper.writeValueAsString(item); |
105 | | - TClass convertedItem = mapper.readValue(inputItemString, asclass); |
106 | | - String convertedItemString = mapper.writeValueAsString(convertedItem); |
107 | | - assertEquals(convertedItemString, inputItemString, "JSONs must be equal after the second roundtrip"); |
108 | | - return convertedItem; |
| 108 | + String serialized1 = mapper.writeValueAsString(item); |
| 109 | + JsonNode json1 = mapper.readTree(serialized1); |
| 110 | + TClass deserialized1 = mapper.readValue(serialized1, asclass); |
| 111 | + String serialized2 = mapper.writeValueAsString(deserialized1); |
| 112 | + JsonNode json2 = mapper.readTree(serialized2); |
| 113 | + TClass deserialized2 = mapper.readValue(serialized2, asclass); |
| 114 | + |
| 115 | + assertEquals(json2, json1, "JSONs must be equal after the second roundtrip"); |
| 116 | + return deserialized2; |
109 | 117 | } |
110 | 118 | } |
0 commit comments