Class JsonContentAssert

java.lang.Object
org.assertj.core.api.AbstractAssert<JsonContentAssert,CharSequence>
org.springframework.boot.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 Assert for JsonContent.
Since:
1.4.0
Author:
Phillip Webb, Andy Wilkinson, Diego Berrueta, Camille Vienot
  • Constructor Details

    • JsonContentAssert

      public JsonContentAssert(Class<?> resourceLoadClass, CharSequence json)
      Create a new JsonContentAssert instance that will load resources as UTF-8.
      Parameters:
      resourceLoadClass - the source class used to load resources
      json - the actual JSON content
    • JsonContentAssert

      public JsonContentAssert(Class<?> resourceLoadClass, Charset charset, CharSequence json)
      Create a new JsonContentAssert instance that will load resources in the given charset.
      Parameters:
      resourceLoadClass - the source class used to load resources
      charset - the charset of the JSON resources
      json - the actual JSON content
      Since:
      1.4.1
  • Method Details

    • isEqualTo

      public JsonContentAssert isEqualTo(Object expected)
      Overridden version of isEqualTo to perform JSON tests based on the object type.
      Specified by:
      isEqualTo in interface org.assertj.core.api.Assert<JsonContentAssert,CharSequence>
      Overrides:
      isEqualTo in class org.assertj.core.api.AbstractAssert<JsonContentAssert,CharSequence>
      See Also:
      • AbstractAssert.isEqualTo(java.lang.Object)
    • isEqualToJson

      public JsonContentAssert isEqualToJson(CharSequence expected)
      Verifies that the actual value is leniently equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(String path, Class<?> resourceLoadClass)
      Verifies that the actual value is leniently equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(byte[] expected)
      Verifies that the actual value is leniently equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(File expected)
      Verifies that the actual value is leniently equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(InputStream expected)
      Verifies that the actual value is leniently equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(Resource expected)
      Verifies that the actual value is leniently equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isStrictlyEqualToJson

      public JsonContentAssert isStrictlyEqualToJson(CharSequence expected)
      Verifies that the actual value is strictly equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isStrictlyEqualToJson

      public JsonContentAssert isStrictlyEqualToJson(String path, Class<?> resourceLoadClass)
      Verifies that the actual value is strictly equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isStrictlyEqualToJson

      public JsonContentAssert isStrictlyEqualToJson(byte[] expected)
      Verifies that the actual value is strictly equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isStrictlyEqualToJson

      public JsonContentAssert isStrictlyEqualToJson(File expected)
      Verifies that the actual value is strictly equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isStrictlyEqualToJson

      public JsonContentAssert isStrictlyEqualToJson(InputStream expected)
      Verifies that the actual value is strictly equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isStrictlyEqualToJson

      public JsonContentAssert isStrictlyEqualToJson(Resource expected)
      Verifies that the actual value is strictly equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(byte[] expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(File expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(InputStream expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(byte[] expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(File expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(InputStream expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isEqualToJson

      public JsonContentAssert isEqualToJson(Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is not equal to the given one
    • isNotEqualTo

      public JsonContentAssert isNotEqualTo(Object expected)
      Overridden version of isNotEqualTo to perform JSON tests based on the object type.
      Specified by:
      isNotEqualTo in interface org.assertj.core.api.Assert<JsonContentAssert,CharSequence>
      Overrides:
      isNotEqualTo in class org.assertj.core.api.AbstractAssert<JsonContentAssert,CharSequence>
      See Also:
      • AbstractAssert.isEqualTo(java.lang.Object)
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(CharSequence expected)
      Verifies that the actual value is not leniently equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(String path, Class<?> resourceLoadClass)
      Verifies that the actual value is not leniently equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(byte[] expected)
      Verifies that the actual value is not leniently equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(File expected)
      Verifies that the actual value is not leniently equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(InputStream expected)
      Verifies that the actual value is not leniently equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(Resource expected)
      Verifies that the actual value is not leniently equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotStrictlyEqualToJson

      public JsonContentAssert isNotStrictlyEqualToJson(CharSequence expected)
      Verifies that the actual value is not strictly equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotStrictlyEqualToJson

      public JsonContentAssert isNotStrictlyEqualToJson(String path, Class<?> resourceLoadClass)
      Verifies that the actual value is not strictly equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotStrictlyEqualToJson

      public JsonContentAssert isNotStrictlyEqualToJson(byte[] expected)
      Verifies that the actual value is not strictly equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotStrictlyEqualToJson

      public JsonContentAssert isNotStrictlyEqualToJson(File expected)
      Verifies that the actual value is not strictly equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotStrictlyEqualToJson

      public JsonContentAssert isNotStrictlyEqualToJson(InputStream expected)
      Verifies that the actual value is not strictly equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotStrictlyEqualToJson

      public JsonContentAssert isNotStrictlyEqualToJson(Resource expected)
      Verifies that the actual value is not strictly equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is not equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is not equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(byte[] expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is not equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(File expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is not equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(InputStream expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is not equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
      Verifies that the actual value is not equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      compareMode - the compare mode used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is not equal to the specified JSON. The expected value can contain the JSON itself or, if it ends with .json, the name of a resource to be loaded using resourceLoadClass.
      Parameters:
      expected - the expected JSON or the name of a resource containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is not equal to the specified JSON resource.
      Parameters:
      path - the name of a resource containing the expected JSON
      resourceLoadClass - the source class used to load the resource
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(byte[] expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is not equal to the specified JSON bytes.
      Parameters:
      expected - the expected JSON bytes
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(File expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is not equal to the specified JSON file.
      Parameters:
      expected - a file containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(InputStream expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is not equal to the specified JSON input stream.
      Parameters:
      expected - an input stream containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • isNotEqualToJson

      public JsonContentAssert isNotEqualToJson(Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
      Verifies that the actual value is not equal to the specified JSON resource.
      Parameters:
      expected - a resource containing the expected JSON
      comparator - the comparator used when checking
      Returns:
      this assertion object
      Throws:
      AssertionError - if the actual JSON value is equal to the given one
    • hasJsonPath

      public JsonContentAssert hasJsonPath(CharSequence expression, Object... args)
      Verify that the JSON path is present without checking if it has a value.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing
      Since:
      2.2.0
      See Also:
    • hasJsonPathValue

      public JsonContentAssert hasJsonPathValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces a non-null result. If the JSON path expression is not definite, this method verifies that the value at the given path is not empty.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing
    • hasJsonPathStringValue

      public JsonContentAssert hasJsonPathStringValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces a non-null string result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing or not a string
    • hasJsonPathNumberValue

      public JsonContentAssert hasJsonPathNumberValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces a non-null number result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing or not a number
    • hasJsonPathBooleanValue

      public JsonContentAssert hasJsonPathBooleanValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces a non-null boolean result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing or not a boolean
    • hasJsonPathArrayValue

      public JsonContentAssert hasJsonPathArrayValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces a non-null array result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing or not an array
    • hasJsonPathMapValue

      public JsonContentAssert hasJsonPathMapValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces a non-null map result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is missing or not a map
    • hasEmptyJsonPathValue

      public JsonContentAssert hasEmptyJsonPathValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces an empty result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is not empty
    • doesNotHaveJsonPath

      public JsonContentAssert doesNotHaveJsonPath(CharSequence expression, Object... args)
      Verify that the JSON path is not present, even if it has a null value.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is not missing
      Since:
      2.2.0
      See Also:
    • doesNotHaveJsonPathValue

      public JsonContentAssert doesNotHaveJsonPathValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path produces no result. If the JSON path expression is not definite, this method verifies that the value at the given path is empty.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is not missing
    • doesNotHaveEmptyJsonPathValue

      public JsonContentAssert doesNotHaveEmptyJsonPathValue(CharSequence expression, Object... args)
      Verify that the actual value at the given JSON path does not produce an empty result.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      this assertion object
      Throws:
      AssertionError - if the value at the given path is empty
    • extractingJsonPathValue

      public org.assertj.core.api.AbstractObjectAssert<?,Object> extractingJsonPathValue(CharSequence expression, Object... args)
      Extract the value at the given JSON path for further object assertions.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      a new assertion object whose object under test is the extracted item
      Throws:
      AssertionError - if the path is not valid
    • extractingJsonPathStringValue

      public org.assertj.core.api.AbstractCharSequenceAssert<?,String> extractingJsonPathStringValue(CharSequence expression, Object... args)
      Extract the string value at the given JSON path for further object assertions.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      a new assertion object whose object under test is the extracted item
      Throws:
      AssertionError - if the path is not valid or does not result in a string
    • extractingJsonPathNumberValue

      public org.assertj.core.api.AbstractObjectAssert<?,Number> extractingJsonPathNumberValue(CharSequence expression, Object... args)
      Extract the number value at the given JSON path for further object assertions.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      a new assertion object whose object under test is the extracted item
      Throws:
      AssertionError - if the path is not valid or does not result in a number
    • extractingJsonPathBooleanValue

      public org.assertj.core.api.AbstractBooleanAssert<?> extractingJsonPathBooleanValue(CharSequence expression, Object... args)
      Extract the boolean value at the given JSON path for further object assertions.
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      a new assertion object whose object under test is the extracted item
      Throws:
      AssertionError - if the path is not valid or does not result in a boolean
    • extractingJsonPathArrayValue

      public <E> org.assertj.core.api.ListAssert<E> extractingJsonPathArrayValue(CharSequence expression, Object... args)
      Extract the array value at the given JSON path for further object assertions.
      Type Parameters:
      E - element type
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      a new assertion object whose object under test is the extracted item
      Throws:
      AssertionError - if the path is not valid or does not result in an array
    • extractingJsonPathMapValue

      public <K, V> org.assertj.core.api.MapAssert<K,V> extractingJsonPathMapValue(CharSequence expression, Object... args)
      Extract the map value at the given JSON path for further object assertions.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      expression - the JsonPath expression
      args - arguments to parameterize the JsonPath expression with, using formatting specifiers defined in String.format(String, Object...)
      Returns:
      a new assertion object whose object under test is the extracted item
      Throws:
      AssertionError - if the path is not valid or does not result in a map