Class JsonAssertions
java.lang.Object
net.javacrumbs.jsonunit.assertj.JsonAssertions
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.assertj.core.api.InstanceOfAssertFactory<Object, JsonAssert.ConfigurableJsonAssert> Allows to move from standard AssertJ asserts to JsonUnit. -
Method Summary
Modifier and TypeMethodDescriptionassertThatJson(@Nullable Object actual) assertThatJson(Object actual, JsonAssertions.JsonAssertionCallback... callbacks) Assert json properties with possibility to chain assertion callbacks like thisstatic ObjectJSON to be used in expected part of the assertion,static org.assertj.core.api.AssertFactory<Object, JsonAssert.ConfigurableJsonAssert> Returns AssertFactory allowing to move from standard AssertJ to JsonUnit.static ObjectValue passed here is not parsed as JSON but used as it is
-
Field Details
-
JSON
public static final org.assertj.core.api.InstanceOfAssertFactory<Object, JsonAssert.ConfigurableJsonAssert> JSONAllows to move from standard AssertJ asserts to JsonUnit. For exampleassertThat(resp) .hasFieldOrPropertyWithValue("trackingId", "abcd-0001") // <- Assertj API .extracting("json").asInstanceOf(JSON) .isObject().containsEntry("foo", "bar"); // <- JsonUnit API
-
-
Method Details
-
assertThatJson
-
assertThatJson
public static JsonAssert.ConfigurableJsonAssert assertThatJson(Object actual, JsonAssertions.JsonAssertionCallback... callbacks) Assert json properties with possibility to chain assertion callbacks like thisassertThatJson("{\"test1\":2, \"test2\":1}", json -> json.inPath("test1").isEqualTo(2), json -> json.inPath("test2").isEqualTo(1) ); -
json
-
value
-
jsonUnitJson
public static org.assertj.core.api.AssertFactory<Object, JsonAssert.ConfigurableJsonAssert> jsonUnitJson()Returns AssertFactory allowing to move from standard AssertJ to JsonUnit. For example:assertThat(mvc.get().uri("/sample")) .hasStatusOk() .bodyJson() .convertTo(jsonUnitJson()) .inPath("result.array") <-- JsonUnit assert .isArray() .containsExactly(1, 2, 3);
-