Skip to content

Commit 10f611e

Browse files
committed
Test should not rely on ordering of entries in a JSON Map
1 parent 14fab1b commit 10f611e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@
106106
<scope>test</scope>
107107
</dependency>
108108

109+
<dependency>
110+
<groupId>net.javacrumbs.json-unit</groupId>
111+
<artifactId>json-unit</artifactId>
112+
<version>2.25.0</version>
113+
<scope>test</scope>
114+
</dependency>
115+
109116
</dependencies>
110117

111118
<build>

src/test/java/com/fusiondb/studio/api/QueryIT.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
import static io.restassured.http.ContentType.JSON;
3131
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
3232
import static java.nio.charset.StandardCharsets.UTF_8;
33+
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
3334
import static org.apache.http.HttpStatus.*;
35+
import static org.hamcrest.CoreMatchers.containsString;
3436
import static org.hamcrest.CoreMatchers.is;
37+
import static org.hamcrest.CoreMatchers.not;
3538

3639
public class QueryIT {
3740

@@ -276,7 +279,9 @@ public void serializeQueryAsJsonNoIndent() {
276279
then().
277280
statusCode(SC_OK).
278281
assertThat().
279-
body("results", is("{\"a\":\"b\",\"x\":[\"y\",\"z\"],\"t\":true,\"f\":false}"));
282+
body("results", jsonEquals("{\"a\":\"b\",\"x\":[\"y\",\"z\"],\"t\":true,\"f\":false}")).
283+
and().
284+
body("results", not(containsString("\n")));
280285
}
281286

282287
@Test
@@ -300,11 +305,10 @@ public void serializeQueryAsJsonIndent() {
300305
then().
301306
statusCode(SC_OK).
302307
assertThat().
303-
body("results", is("{\n" +
304-
" \"a\" : \"b\",\n" +
305-
" \"x\" : [ \"y\", \"z\" ],\n" +
306-
" \"t\" : true,\n" +
307-
" \"f\" : false\n" +
308-
"}"));
308+
body("results", jsonEquals("{\"a\":\"b\",\"x\":[\"y\",\"z\"],\"t\":true,\"f\":false}")).
309+
and().
310+
body("results", containsString("{\n")).
311+
and().
312+
body("results", containsString("\n}"));
309313
}
310314
}

0 commit comments

Comments
 (0)