Class JsonContentAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<JsonContentAssert,CharSequence>
org.springframework.test.json.JsonContentAssert
All Implemented Interfaces:
org.assertj.core.api.Assert<JsonContentAssert,CharSequence>, org.assertj.core.api.Descriptable<JsonContentAssert>, org.assertj.core.api.ExtensionPoints<JsonContentAssert,CharSequence>

public class JsonContentAssert extends org.assertj.core.api.AbstractAssert<JsonContentAssert,CharSequence>
AssertJ assertions that can be applied to a CharSequence representation of a JSON document, mostly to compare the JSON document against a target, using JSON Assert.
Since:
6.2
Author:
Phillip Webb, Andy Wilkinson, Diego Berrueta, Camille Vienot, Stephane Nicoll
  • Field Summary

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

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

    Constructors
    Constructor
    Description
    JsonContentAssert(CharSequence json, Class<?> resourceLoadClass)
    Create a new JsonContentAssert instance that will load resources relative to the given resourceLoadClass, using UTF-8.
    JsonContentAssert(CharSequence json, Class<?> resourceLoadClass, Charset charset)
    Create a new JsonContentAssert instance that will load resources relative to the given resourceLoadClass, using the given charset.
  • Method Summary

    Modifier and Type
    Method
    Description
    isEqualTo(CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
    Verify that the actual value is equal to the given JSON.
    isEqualTo(CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
    Verify that the actual value is equal to the given JSON.
    isEqualTo(Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
    Verify that the actual value is equal to the given JSON Resource.
    isEqualTo(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
    Verify that the actual value is equal to the given JSON Resource.
    Verify that the actual value is leniently equal to the given JSON.
    Verify that the actual value is leniently equal to the given JSON Resource.
    isNotEqualTo(CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
    Verify that the actual value is not equal to the given JSON.
    isNotEqualTo(CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
    Verify that the actual value is not equal to the given JSON.
    isNotEqualTo(Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
    Verify that the actual value is not equal to the given JSON Resource.
    isNotEqualTo(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
    Verify that the actual value is not equal to the given JSON Resource.
    Verify that the actual value is not leniently equal to the given JSON.
    Verify that the actual value is not leniently equal to the given JSON Resource.
    Verify that the actual value is not strictly equal to the given JSON.
    Verify that the actual value is not strictly equal to the given JSON Resource.
    Verify that the actual value is strictly equal to the given JSON.
    Verify that the actual value is strictly equal to the given JSON Resource.

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

    areEqual, asInstanceOf, asList, assertionError, asString, 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, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, 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, as, as, describedAs, describedAs
  • Constructor Details

    • JsonContentAssert

      public JsonContentAssert(@Nullable CharSequence json, @Nullable Class<?> resourceLoadClass, @Nullable Charset charset)
      Create a new JsonContentAssert instance that will load resources relative to the given resourceLoadClass, using the given charset.
      Parameters:
      json - the actual JSON content
      resourceLoadClass - the class used to load resources
      charset - the charset of the JSON resources
    • JsonContentAssert

      public JsonContentAssert(@Nullable CharSequence json, @Nullable Class<?> resourceLoadClass)
      Create a new JsonContentAssert instance that will load resources relative to the given resourceLoadClass, using UTF-8.
      Parameters:
      json - the actual JSON content
      resourceLoadClass - the class used to load resources
  • Method Details

    • isEqualTo

      public JsonContentAssert isEqualTo(@Nullable CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verify that the actual value is equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      compareMode - the compare mode used when checking
    • isEqualTo

      public JsonContentAssert isEqualTo(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verify that the actual value is equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
      compareMode - the compare mode used when checking
    • isEqualTo

      public JsonContentAssert isEqualTo(@Nullable CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verify that the actual value is equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      comparator - the comparator used when checking
    • isEqualTo

      public JsonContentAssert isEqualTo(Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verify that the actual value is equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
      comparator - the comparator used when checking
    • isLenientlyEqualTo

      public JsonContentAssert isLenientlyEqualTo(@Nullable CharSequence expected)
      Verify that the actual value is leniently equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
    • isLenientlyEqualTo

      public JsonContentAssert isLenientlyEqualTo(Resource expected)
      Verify that the actual value is leniently equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
    • isStrictlyEqualTo

      public JsonContentAssert isStrictlyEqualTo(@Nullable CharSequence expected)
      Verify that the actual value is strictly equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
    • isStrictlyEqualTo

      public JsonContentAssert isStrictlyEqualTo(Resource expected)
      Verify that the actual value is strictly equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
    • isNotEqualTo

      public JsonContentAssert isNotEqualTo(@Nullable CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verify that the actual value is not equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      compareMode - the compare mode used when checking
    • isNotEqualTo

      public JsonContentAssert isNotEqualTo(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verify that the actual value is not equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
      compareMode - the compare mode used when checking
    • isNotEqualTo

      public JsonContentAssert isNotEqualTo(@Nullable CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verify that the actual value is not equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      comparator - the comparator used when checking
    • isNotEqualTo

      public JsonContentAssert isNotEqualTo(Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verify that the actual value is not equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
      comparator - the comparator used when checking
    • isNotLenientlyEqualTo

      public JsonContentAssert isNotLenientlyEqualTo(@Nullable CharSequence expected)
      Verify that the actual value is not leniently equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
    • isNotLenientlyEqualTo

      public JsonContentAssert isNotLenientlyEqualTo(Resource expected)
      Verify that the actual value is not leniently equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON
    • isNotStrictlyEqualTo

      public JsonContentAssert isNotStrictlyEqualTo(@Nullable CharSequence expected)
      Verify that the actual value is not strictly equal to the given JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded from the classpath.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
    • isNotStrictlyEqualTo

      public JsonContentAssert isNotStrictlyEqualTo(Resource expected)
      Verify that the actual value is not strictly equal to the given JSON Resource.

      The resource abstraction allows to provide several input types:

      Parameters:
      expected - a resource containing the expected JSON