Class AbstractJsonValueAssert<SELF extends AbstractJsonValueAssert<SELF>>

java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractObjectAssert<SELF,Object>
org.springframework.test.json.AbstractJsonValueAssert<SELF>
Type Parameters:
SELF - the type of assertions
All Implemented Interfaces:
org.assertj.core.api.Assert<SELF,Object>, org.assertj.core.api.Descriptable<SELF>, org.assertj.core.api.ExtensionPoints<SELF,Object>
Direct Known Subclasses:
JsonPathValueAssert

public abstract class AbstractJsonValueAssert<SELF extends AbstractJsonValueAssert<SELF>> extends org.assertj.core.api.AbstractObjectAssert<SELF,Object>
Base AssertJ assertions that can be applied to a JSON value.

In JSON, values must be one of the following data types:

This base class offers direct access for each of those types as well as conversion methods based on an optional GenericHttpMessageConverter.
Since:
6.2
Author:
Stephane Nicoll
  • Field Summary

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

    actual, info, myself, objects, throwUnsupportedExceptionOnEquals
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractJsonValueAssert(Object actual, Class<?> selfType, GenericHttpMessageConverter<Object> httpMessageConverter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.assertj.core.api.ObjectArrayAssert<Object>
    Verify that the actual value is a non-null array, and return a new assertion object that provides dedicated array assertions for it.
    org.assertj.core.api.AbstractBooleanAssert<?>
    Verify that the actual value is a non-null Boolean, and return a new assertion object that provides dedicated Boolean assertions for it.
    org.assertj.core.api.AbstractMapAssert<?,Map<String,Object>,String,Object>
    Verify that the actual value is a non-null JSON object, and return a new assertion object that provides dedicated assertions on individual elements of the object.
    org.assertj.core.api.AbstractObjectAssert<?,Number>
    Verify that the actual value is a non-null Number, usually an Integer or Double, and return a new assertion object for it.
    org.assertj.core.api.AbstractStringAssert<?>
    Verify that the actual value is a non-null String, and return a new assertion object that provides dedicated String assertions for it.
    <T> org.assertj.core.api.AbstractObjectAssert<?,T>
    convertTo(Class<T> target)
    Verify that the actual value can be converted to an instance of the given target, and produce a new assertion object narrowed to that type.
    <T> org.assertj.core.api.AbstractObjectAssert<?,T>
    Verify that the actual value can be converted to an instance of the given target, and produce a new assertion object narrowed to that type.
    protected String
     
    Verify that the actual value is empty: either a null scalar value or an empty list or map.
    Verify that the actual value is not empty: either a non-null scalar value or a non-empty list or map.

    Methods inherited from class org.assertj.core.api.AbstractObjectAssert

    as, as, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison

    Methods inherited from class org.assertj.core.api.AbstractAssert

    areEqual, asInstanceOf, asList, assertionError, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.assertj.core.api.Descriptable

    as, describedAs, describedAs
  • Constructor Details

  • Method Details

    • asString

      public org.assertj.core.api.AbstractStringAssert<?> asString()
      Verify that the actual value is a non-null String, and return a new assertion object that provides dedicated String assertions for it.
      Specified by:
      asString in interface org.assertj.core.api.Assert<SELF extends AbstractJsonValueAssert<SELF>,Object>
      Overrides:
      asString in class org.assertj.core.api.AbstractAssert<SELF extends AbstractJsonValueAssert<SELF>,Object>
    • asNumber

      public org.assertj.core.api.AbstractObjectAssert<?,Number> asNumber()
      Verify that the actual value is a non-null Number, usually an Integer or Double, and return a new assertion object for it.
    • asBoolean

      public org.assertj.core.api.AbstractBooleanAssert<?> asBoolean()
      Verify that the actual value is a non-null Boolean, and return a new assertion object that provides dedicated Boolean assertions for it.
    • asArray

      public org.assertj.core.api.ObjectArrayAssert<Object> asArray()
      Verify that the actual value is a non-null array, and return a new assertion object that provides dedicated array assertions for it.
    • asMap

      public org.assertj.core.api.AbstractMapAssert<?,Map<String,Object>,String,Object> asMap()
      Verify that the actual value is a non-null JSON object, and return a new assertion object that provides dedicated assertions on individual elements of the object.

      The returned map assertion object uses attribute names as the keys, and the values can be any of the valid JSON values.

    • convertTo

      public <T> org.assertj.core.api.AbstractObjectAssert<?,T> convertTo(Class<T> target)
      Verify that the actual value can be converted to an instance of the given target, and produce a new assertion object narrowed to that type.
      Parameters:
      target - the type to convert the actual value to
    • convertTo

      public <T> org.assertj.core.api.AbstractObjectAssert<?,T> convertTo(ParameterizedTypeReference<T> target)
      Verify that the actual value can be converted to an instance of the given target, and produce a new assertion object narrowed to that type.
      Parameters:
      target - the parameterized type to convert the actual value to
    • isEmpty

      public SELF isEmpty()
      Verify that the actual value is empty: either a null scalar value or an empty list or map.

      Can also be used when the path uses a filter operator to validate that it did not match.

    • isNotEmpty

      public SELF isNotEmpty()
      Verify that the actual value is not empty: either a non-null scalar value or a non-empty list or map.

      Can also be used when the path uses a filter operator to validate that it did match at least one element.

    • getExpectedErrorMessagePrefix

      protected String getExpectedErrorMessagePrefix()