Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<javatuples.version>1.2</javatuples.version>
<javaassist.version>3.21.0-GA</javaassist.version>
<assertj.version>3.6.2</assertj.version>
<jsonassert.version>1.4.0</jsonassert.version>
<jsonassert.version>1.5.0</jsonassert.version>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.baeldung.jsonassert;


import static org.assertj.core.api.Assertions.assertThat;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Test;
Expand Down Expand Up @@ -64,6 +67,17 @@ public void givenNestedObjects_whenAssertEquals_thenPass() throws JSONException
JSONAssert.assertEquals("{id:1,name:\"Juergen\", address:{city:\"Hollywood\", "
+ "state:\"LA\", zip:91601}}", result, false);
}

@Test
public void whenMessageUsedInAssertion_thenDisplayMessageOnFailure() throws JSONException {
String actual = "{id:123,name:\"John\"}";
String failureMessage = "Only one field is expected: name";
try {
JSONAssert.assertEquals(failureMessage, "{name:\"John\"}", actual, JSONCompareMode.STRICT);
} catch (AssertionError ae) {
assertThat(ae.getMessage()).containsIgnoringCase(failureMessage);
}
}

@Test
public void givenArray_whenComparing_thenOrderMustMatchForStrict() throws JSONException {
Expand Down