|
3 | 3 | import com.fasterxml.jackson.databind.JsonNode; |
4 | 4 | import com.fasterxml.jackson.databind.ObjectMapper; |
5 | 5 | import io.swagger.v3.core.util.Json; |
| 6 | +import io.swagger.v3.core.util.JsonAssert; |
6 | 7 | import io.swagger.v3.core.util.Json31; |
7 | 8 | import io.swagger.v3.core.util.ResourceUtils; |
8 | 9 | import io.swagger.v3.core.util.Yaml; |
@@ -70,7 +71,7 @@ public void testRoundTrip30Json() throws IOException { |
70 | 71 | String jsonAgain = Json.pretty(deserializedOpenAPI); |
71 | 72 |
|
72 | 73 | // Compare JSON strings |
73 | | - assertEquals(json, jsonAgain, "JSON round-trip failed"); |
| 74 | + JsonAssert.assertJsonEquals(Json.mapper(), json, jsonAgain, "JSON round-trip failed"); |
74 | 75 | } |
75 | 76 |
|
76 | 77 | /** |
@@ -106,7 +107,7 @@ public void testRoundTrip30Yaml() throws IOException { |
106 | 107 | String yamlAgain = Yaml.pretty(deserializedOpenAPI); |
107 | 108 |
|
108 | 109 | // Compare YAML strings |
109 | | - assertEquals(yaml, yamlAgain, "YAML round-trip failed"); |
| 110 | + JsonAssert.assertJsonEquals(Yaml.mapper(), yaml, yamlAgain, "YAML round-trip failed"); |
110 | 111 | } |
111 | 112 |
|
112 | 113 | /** |
@@ -148,7 +149,7 @@ public void testRoundTrip31Json() throws IOException { |
148 | 149 | String jsonAgain = Json31.pretty(deserializedOpenAPI); |
149 | 150 |
|
150 | 151 | // Compare JSON strings |
151 | | - assertEquals(json, jsonAgain, "JSON round-trip failed"); |
| 152 | + JsonAssert.assertJsonEquals(Json31.mapper(), json, jsonAgain, "JSON round-trip failed"); |
152 | 153 | } |
153 | 154 |
|
154 | 155 | /** |
@@ -190,7 +191,7 @@ public void testRoundTrip31Yaml() throws IOException { |
190 | 191 | String yamlAgain = Yaml31.pretty(deserializedOpenAPI); |
191 | 192 |
|
192 | 193 | // Compare YAML strings |
193 | | - assertEquals(yaml, yamlAgain, "YAML round-trip failed"); |
| 194 | + JsonAssert.assertJsonEquals(Yaml31.mapper(), yaml, yamlAgain, "YAML round-trip failed"); |
194 | 195 | } |
195 | 196 |
|
196 | 197 | /** |
@@ -242,7 +243,7 @@ public void testComplexRoundTrip31() throws IOException { |
242 | 243 | String jsonAgain = Json31.pretty(deserializedOpenAPI); |
243 | 244 |
|
244 | 245 | // Compare JSON strings |
245 | | - assertEquals(json, jsonAgain, "JSON round-trip failed"); |
| 246 | + JsonAssert.assertJsonEquals(Json31.mapper(), json, jsonAgain, "JSON round-trip failed"); |
246 | 247 | } |
247 | 248 |
|
248 | 249 | /** |
@@ -276,7 +277,7 @@ public void testBooleanSchemaRoundTrip() throws IOException { |
276 | 277 | String jsonAgain = Json31.pretty(deserializedOpenAPI); |
277 | 278 |
|
278 | 279 | // Compare JSON strings |
279 | | - assertEquals(json, jsonAgain, "JSON round-trip failed"); |
| 280 | + JsonAssert.assertJsonEquals(Json.mapper(), json, jsonAgain, "JSON round-trip failed"); |
280 | 281 | } |
281 | 282 |
|
282 | 283 | /** |
@@ -307,7 +308,7 @@ public void testNullValuesRoundTrip() throws IOException { |
307 | 308 | String jsonAgain = Json31.pretty(deserializedOpenAPI); |
308 | 309 |
|
309 | 310 | // Compare JSON strings |
310 | | - assertEquals(json, jsonAgain, "JSON round-trip failed"); |
| 311 | + JsonAssert.assertJsonEquals(Json.mapper(), json, jsonAgain, "JSON round-trip failed"); |
311 | 312 | } |
312 | 313 |
|
313 | 314 | /** |
@@ -350,14 +351,7 @@ public void testRealWorldRoundTrip31() throws IOException { |
350 | 351 | String yamlAgain = Yaml31.pretty(deserializedOpenAPI); |
351 | 352 |
|
352 | 353 | // Compare YAML strings (normalize whitespace) |
353 | | - assertEquals(normalizeWhitespace(serializedYaml), normalizeWhitespace(yamlAgain), "YAML round-trip failed"); |
354 | | - } |
355 | | - |
356 | | - /** |
357 | | - * Helper method to normalize whitespace in YAML strings for comparison |
358 | | - */ |
359 | | - private String normalizeWhitespace(String yaml) { |
360 | | - return yaml.replaceAll("\\s+", " ").trim(); |
| 354 | + JsonAssert.assertJsonEquals(Yaml31.mapper(), serializedYaml, yamlAgain, "YAML round-trip failed"); |
361 | 355 | } |
362 | 356 |
|
363 | 357 | /** |
|
0 commit comments