Skip to content

Commit

Permalink
Use JSONAssert to check equal JSONs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhihao11ui authored and zhihao11 committed Oct 23, 2024
1 parent 43fda7d commit 4ec9717
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,11 @@
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.1</version> <!-- Use the latest version available -->
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.json.JSONObject;
import org.json.JSONPointer;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;

import com.google.re2j.Pattern;

Expand Down Expand Up @@ -396,23 +397,23 @@ public void equalsVerifier() {
public void toStringTest() {
JSONObject rawSchemaJson = loader.readObj("tostring/objectschema.json");
String actual = SchemaLoader.load(rawSchemaJson).toString();
assertThat(new JSONObject(actual), sameJsonAs(rawSchemaJson));
JSONAssert.assertEquals(rawSchemaJson.toString(), actual, false);
}

@Test
public void toStringNoExplicitType() {
JSONObject rawSchemaJson = loader.readObj("tostring/objectschema.json");
rawSchemaJson.remove("type");
String actual = SchemaLoader.load(rawSchemaJson).toString();
assertThat(new JSONObject(actual), sameJsonAs(rawSchemaJson));
JSONAssert.assertEquals(rawSchemaJson.toString(), actual, false);
}

@Test
public void toStringWithUnprocessedProps() {
JSONObject rawSchemaJson = loader.readObj("tostring/objectschema-unprocessed.json");
Schema schema = SchemaLoader.load(rawSchemaJson);
String actual = schema.toString();
assertThat(new JSONObject(actual), sameJsonAs(rawSchemaJson));
JSONAssert.assertEquals(rawSchemaJson.toString(), actual, false);
}

@Test
Expand Down

0 comments on commit 4ec9717

Please sign in to comment.