Package net.javacrumbs.jsonunit.assertj
Class JsonAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<JsonAssert,Object>
-
- net.javacrumbs.jsonunit.assertj.JsonAssert
-
- All Implemented Interfaces:
org.assertj.core.api.Assert<JsonAssert,Object>,org.assertj.core.api.Descriptable<JsonAssert>,org.assertj.core.api.ExtensionPoints<JsonAssert,Object>
- Direct Known Subclasses:
JsonAssert.ConfigurableJsonAssert
public class JsonAssert extends org.assertj.core.api.AbstractAssert<JsonAssert,Object>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonAssert.ConfigurableJsonAssertJsonAssert that can be configured to prevent mistakes likeassertThatJson(...).isEqualsTo(...).when(...);
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonAssertand(JsonAssertion... assertions)Allows to do multiple comparisons on a document likeassertThatJson("{\"test\":{\"a\":1, \"b\":2, \"c\":3}}").and( a -> a.node("test").isObject(), a -> a.node("test.b").isEqualTo(3) );org.assertj.core.api.BigDecimalAssertasNumber()Asserts that given node is present and is of type number or a string that can be parsed as a number.org.assertj.core.api.AbstractStringAssert<?>asString()voidisAbsent()Asserts that given node is absent.org.assertj.core.api.ListAssert<Object>isArray()Asserts that given node is present and is of type array.org.assertj.core.api.BooleanAssertisBoolean()Asserts that given node is present and is of type boolean.JsonAssertisEqualTo(Object expected)Compares JSONs.JsonAssertisNotNull()Asserts that given node is present and is not null.voidisNull()Asserts that given node is present and is null.org.assertj.core.api.BigDecimalAssertisNumber()Asserts that given node is present and is of type number.org.assertj.core.api.MapAssert<String,Object>isObject()Asserts that given node is present and is of type object.JsonAssertisPresent()Asserts that given node is present.org.assertj.core.api.StringAssertisString()Asserts that given node is present and is of type string.JsonAssertnode(String node)Moves comparison to given node.-
Methods inherited from class org.assertj.core.api.AbstractAssert
as, as, asInstanceOf, asList, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotOfAnyClassIn, isNotSameAs, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
-
-
-
-
Method Detail
-
node
public JsonAssert node(String node)
Moves comparison to given node. Second call navigates from the last position in the JSON.
-
and
public JsonAssert and(JsonAssertion... assertions)
Allows to do multiple comparisons on a document likeassertThatJson("{\"test\":{\"a\":1, \"b\":2, \"c\":3}}").and( a -> a.node("test").isObject(), a -> a.node("test.b").isEqualTo(3) );
-
isEqualTo
public JsonAssert isEqualTo(Object expected)
Compares JSONs.- Specified by:
isEqualToin interfaceorg.assertj.core.api.Assert<JsonAssert,Object>- Overrides:
isEqualToin classorg.assertj.core.api.AbstractAssert<JsonAssert,Object>
-
isObject
public org.assertj.core.api.MapAssert<String,Object> isObject()
Asserts that given node is present and is of type object.- Returns:
- MapAssert where the object is serialized as Map
-
isNumber
public org.assertj.core.api.BigDecimalAssert isNumber()
Asserts that given node is present and is of type number.- Returns:
-
asNumber
public org.assertj.core.api.BigDecimalAssert asNumber()
Asserts that given node is present and is of type number or a string that can be parsed as a number.
-
isArray
public org.assertj.core.api.ListAssert<Object> isArray()
Asserts that given node is present and is of type array.- Returns:
-
isBoolean
public org.assertj.core.api.BooleanAssert isBoolean()
Asserts that given node is present and is of type boolean.- Returns:
-
isString
public org.assertj.core.api.StringAssert isString()
Asserts that given node is present and is of type string.- Returns:
-
asString
public org.assertj.core.api.AbstractStringAssert<?> asString()
- Specified by:
asStringin interfaceorg.assertj.core.api.Assert<JsonAssert,Object>- Overrides:
asStringin classorg.assertj.core.api.AbstractAssert<JsonAssert,Object>
-
isNull
public void isNull()
Asserts that given node is present and is null.- Specified by:
isNullin interfaceorg.assertj.core.api.Assert<JsonAssert,Object>- Overrides:
isNullin classorg.assertj.core.api.AbstractAssert<JsonAssert,Object>
-
isPresent
public JsonAssert isPresent()
Asserts that given node is present.- Returns:
-
isAbsent
public void isAbsent()
Asserts that given node is absent.
-
isNotNull
public JsonAssert isNotNull()
Asserts that given node is present and is not null.- Specified by:
isNotNullin interfaceorg.assertj.core.api.Assert<JsonAssert,Object>- Overrides:
isNotNullin classorg.assertj.core.api.AbstractAssert<JsonAssert,Object>- Returns:
-
-