Class JsonAssert

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JsonAssert.ConfigurableJsonAssert
      JsonAssert that can be configured to prevent mistakes like assertThatJson(...).isEqualsTo(...).when(...);
    • Field Summary

      • Fields inherited from class org.assertj.core.api.AbstractAssert

        actual, info, myself, throwUnsupportedExceptionOnEquals
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JsonAssert and​(JsonAssertion... assertions)
      Allows to do multiple comparisons on a document like assertThatJson("{\"test\":{\"a\":1, \"b\":2, \"c\":3}}").and( a -> a.node("test").isObject(), a -> a.node("test.b").isEqualTo(3) );
      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.
      org.assertj.core.api.AbstractStringAssert<?> asString()  
      void isAbsent()
      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.BooleanAssert isBoolean()
      Asserts that given node is present and is of type boolean.
      JsonAssert isEqualTo​(Object expected)
      Compares JSONs.
      JsonAssert isNotNull()
      Asserts that given node is present and is not null.
      void isNull()
      Asserts that given node is present and is null.
      org.assertj.core.api.BigDecimalAssert isNumber()
      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.
      JsonAssert isPresent()
      Asserts that given node is present.
      org.assertj.core.api.StringAssert isString()
      Asserts that given node is present and is of type string.
      JsonAssert node​(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 like assertThatJson("{\"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:
        isEqualTo in interface org.assertj.core.api.Assert<JsonAssert,​Object>
        Overrides:
        isEqualTo in class org.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:
        asString in interface org.assertj.core.api.Assert<JsonAssert,​Object>
        Overrides:
        asString in class org.assertj.core.api.AbstractAssert<JsonAssert,​Object>
      • isNull

        public void isNull()
        Asserts that given node is present and is null.
        Specified by:
        isNull in interface org.assertj.core.api.Assert<JsonAssert,​Object>
        Overrides:
        isNull in class org.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:
        isNotNull in interface org.assertj.core.api.Assert<JsonAssert,​Object>
        Overrides:
        isNotNull in class org.assertj.core.api.AbstractAssert<JsonAssert,​Object>
        Returns: