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>
AssertJAssert
forJsonContent
.- Since:
- 1.4.0
Constructor Summary
Constructors Constructor Description JsonContentAssert(Class<?> resourceLoadClass, CharSequence json)
Create a newJsonContentAssert
instance that will load resources as UTF-8.JsonContentAssert(Class<?> resourceLoadClass, Charset charset, CharSequence json)
Create a newJsonContentAssert
instance that will load resources in the givencharset
.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonContentAssert
doesNotHaveEmptyJsonPathValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path does not produce anempty
result.JsonContentAssert
doesNotHaveJsonPathValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces no result.<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.org.assertj.core.api.AbstractBooleanAssert<?>
extractingJsonPathBooleanValue(CharSequence expression, Object... args)
Extract the boolean value at the given JSON path for further object assertions.<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.org.assertj.core.api.AbstractObjectAssert<?,Number>
extractingJsonPathNumberValue(CharSequence expression, Object... args)
Extract the number value at the given JSON path for further object assertions.org.assertj.core.api.AbstractCharSequenceAssert<?,String>
extractingJsonPathStringValue(CharSequence expression, Object... args)
Extract the string value at the given JSON path for further object assertions.org.assertj.core.api.AbstractObjectAssert<?,Object>
extractingJsonPathValue(CharSequence expression, Object... args)
Extract the value at the given JSON path for further object assertions.JsonContentAssert
hasEmptyJsonPathValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces anempty
result.JsonContentAssert
hasJsonPathArrayValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces a non-null array result.JsonContentAssert
hasJsonPathBooleanValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces a non-null boolean result.JsonContentAssert
hasJsonPathMapValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces a non-null map result.JsonContentAssert
hasJsonPathNumberValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces a non-null number result.JsonContentAssert
hasJsonPathStringValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces a non-null string result.JsonContentAssert
hasJsonPathValue(CharSequence expression, Object... args)
Verify that the actual value at the given JSON path produces a non-null result.JsonContentAssert
isEqualTo(Object expected)
Overridden version ofisEqualTo
to perform JSON tests based on the object type.JsonContentAssert
isEqualToJson(byte[] expected)
Verifies that the actual value isleniently
equal to the specified JSON bytes.JsonContentAssert
isEqualToJson(byte[] expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is equal to the specified JSON bytes.JsonContentAssert
isEqualToJson(byte[] expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is equal to the specified JSON bytes.JsonContentAssert
isEqualToJson(File expected)
Verifies that the actual value isleniently
equal to the specified JSON file.JsonContentAssert
isEqualToJson(File expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is equal to the specified JSON file.JsonContentAssert
isEqualToJson(File expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is equal to the specified JSON file.JsonContentAssert
isEqualToJson(InputStream expected)
Verifies that the actual value isleniently
equal to the specified JSON input stream.JsonContentAssert
isEqualToJson(InputStream expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is equal to the specified JSON input stream.JsonContentAssert
isEqualToJson(InputStream expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is equal to the specified JSON input stream.JsonContentAssert
isEqualToJson(CharSequence expected)
Verifies that the actual value isleniently
equal to the specified JSON.JsonContentAssert
isEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is equal to the specified JSON.JsonContentAssert
isEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is equal to the specified JSON.JsonContentAssert
isEqualToJson(String path, Class<?> resourceLoadClass)
Verifies that the actual value isleniently
equal to the specified JSON resource.JsonContentAssert
isEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is equal to the specified JSON resource.JsonContentAssert
isEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is equal to the specified JSON resource.JsonContentAssert
isEqualToJson(org.springframework.core.io.Resource expected)
Verifies that the actual value isleniently
equal to the specified JSON resource.JsonContentAssert
isEqualToJson(org.springframework.core.io.Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is equal to the specified JSON resource.JsonContentAssert
isEqualToJson(org.springframework.core.io.Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is equal to the specified JSON resource.JsonContentAssert
isNotEqualTo(Object expected)
Overridden version ofisNotEqualTo
to perform JSON tests based on the object type.JsonContentAssert
isNotEqualToJson(byte[] expected)
Verifies that the actual value is notleniently
equal to the specified JSON bytes.JsonContentAssert
isNotEqualToJson(byte[] expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is not equal to the specified JSON bytes.JsonContentAssert
isNotEqualToJson(byte[] expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is not equal to the specified JSON bytes.JsonContentAssert
isNotEqualToJson(File expected)
Verifies that the actual value is notleniently
equal to the specified JSON file.JsonContentAssert
isNotEqualToJson(File expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is not equal to the specified JSON file.JsonContentAssert
isNotEqualToJson(File expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is not equal to the specified JSON file.JsonContentAssert
isNotEqualToJson(InputStream expected)
Verifies that the actual value is notleniently
equal to the specified JSON input stream.JsonContentAssert
isNotEqualToJson(InputStream expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is not equal to the specified JSON input stream.JsonContentAssert
isNotEqualToJson(InputStream expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is not equal to the specified JSON input stream.JsonContentAssert
isNotEqualToJson(CharSequence expected)
Verifies that the actual value is notleniently
equal to the specified JSON.JsonContentAssert
isNotEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is not equal to the specified JSON.JsonContentAssert
isNotEqualToJson(CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is not equal to the specified JSON.JsonContentAssert
isNotEqualToJson(String path, Class<?> resourceLoadClass)
Verifies that the actual value is notleniently
equal to the specified JSON resource.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.JsonContentAssert
isNotEqualToJson(String path, Class<?> resourceLoadClass, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is not equal to the specified JSON resource.JsonContentAssert
isNotEqualToJson(org.springframework.core.io.Resource expected)
Verifies that the actual value is notleniently
equal to the specified JSON resource.JsonContentAssert
isNotEqualToJson(org.springframework.core.io.Resource expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator)
Verifies that the actual value is not equal to the specified JSON resource.JsonContentAssert
isNotEqualToJson(org.springframework.core.io.Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode)
Verifies that the actual value is not equal to the specified JSON resource.JsonContentAssert
isNotStrictlyEqualToJson(byte[] expected)
Verifies that the actual value is notstrictly
equal to the specified JSON bytes.JsonContentAssert
isNotStrictlyEqualToJson(File expected)
Verifies that the actual value is notstrictly
equal to the specified JSON file.JsonContentAssert
isNotStrictlyEqualToJson(InputStream expected)
Verifies that the actual value is notstrictly
equal to the specified JSON input stream.JsonContentAssert
isNotStrictlyEqualToJson(CharSequence expected)
Verifies that the actual value is notstrictly
equal to the specified JSON.JsonContentAssert
isNotStrictlyEqualToJson(String path, Class<?> resourceLoadClass)
Verifies that the actual value is notstrictly
equal to the specified JSON resource.JsonContentAssert
isNotStrictlyEqualToJson(org.springframework.core.io.Resource expected)
Verifies that the actual value is notstrictly
equal to the specified JSON resource.JsonContentAssert
isStrictlyEqualToJson(byte[] expected)
Verifies that the actual value isstrictly
equal to the specified JSON bytes.JsonContentAssert
isStrictlyEqualToJson(File expected)
Verifies that the actual value isstrictly
equal to the specified JSON file.JsonContentAssert
isStrictlyEqualToJson(InputStream expected)
Verifies that the actual value isstrictly
equal to the specified JSON input stream.JsonContentAssert
isStrictlyEqualToJson(CharSequence expected)
Verifies that the actual value isstrictly
equal to the specified JSON.JsonContentAssert
isStrictlyEqualToJson(String path, Class<?> resourceLoadClass)
Verifies that the actual value isstrictly
equal to the specified JSON resource.JsonContentAssert
isStrictlyEqualToJson(org.springframework.core.io.Resource expected)
Verifies that the actual value isstrictly
equal to the specified JSON resource.Methods inherited from class org.assertj.core.api.AbstractAssert
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
Constructor Detail
JsonContentAssert
public JsonContentAssert(Class<?> resourceLoadClass, CharSequence json)
Create a newJsonContentAssert
instance that will load resources as UTF-8.- Parameters:
resourceLoadClass
- the source class used to load resourcesjson
- the actual JSON content
JsonContentAssert
public JsonContentAssert(Class<?> resourceLoadClass, Charset charset, CharSequence json)
Create a newJsonContentAssert
instance that will load resources in the givencharset
.- Parameters:
resourceLoadClass
- the source class used to load resourcescharset
- the charset of the JSON resourcesjson
- the actual JSON content- Since:
- 1.4.1
Method Detail
isEqualTo
public JsonContentAssert isEqualTo(Object expected)
Overridden version ofisEqualTo
to perform JSON tests based on the object type.- Specified by:
isEqualTo
in interfaceorg.assertj.core.api.Assert<JsonContentAssert,CharSequence>
- Overrides:
isEqualTo
in classorg.assertj.core.api.AbstractAssert<JsonContentAssert,CharSequence>
- See Also:
AbstractAssert.isEqualTo(java.lang.Object)
isEqualToJson
public JsonContentAssert isEqualToJson(CharSequence expected)
Verifies that the actual value isleniently
equal to the specified JSON. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- 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 isleniently
equal to the specified JSON resource.- Parameters:
path
- the name of a resource containing the expected JSONresourceLoadClass
- 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 isleniently
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 isleniently
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 isleniently
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(org.springframework.core.io.Resource expected)
Verifies that the actual value isleniently
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 isstrictly
equal to the specified JSON. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- 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 isstrictly
equal to the specified JSON resource.- Parameters:
path
- the name of a resource containing the expected JSONresourceLoadClass
- 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 isstrictly
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 isstrictly
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 isstrictly
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(org.springframework.core.io.Resource expected)
Verifies that the actual value isstrictly
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. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- Parameters:
expected
- the expected JSON or the name of a resource containing the expected JSONcompareMode
- 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 JSONresourceLoadClass
- the source class used to load the resourcecompareMode
- 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 bytescompareMode
- 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 JSONcompareMode
- 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 JSONcompareMode
- 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(org.springframework.core.io.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 JSONcompareMode
- 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. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- Parameters:
expected
- the expected JSON or the name of a resource containing the expected JSONcomparator
- 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 JSONresourceLoadClass
- the source class used to load the resourcecomparator
- 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 bytescomparator
- 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 JSONcomparator
- 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 JSONcomparator
- 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(org.springframework.core.io.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 JSONcomparator
- 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 ofisNotEqualTo
to perform JSON tests based on the object type.- Specified by:
isNotEqualTo
in interfaceorg.assertj.core.api.Assert<JsonContentAssert,CharSequence>
- Overrides:
isNotEqualTo
in classorg.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 notleniently
equal to the specified JSON. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- 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 notleniently
equal to the specified JSON resource.- Parameters:
path
- the name of a resource containing the expected JSONresourceLoadClass
- 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 notleniently
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 notleniently
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 notleniently
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(org.springframework.core.io.Resource expected)
Verifies that the actual value is notleniently
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 notstrictly
equal to the specified JSON. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- 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 notstrictly
equal to the specified JSON resource.- Parameters:
path
- the name of a resource containing the expected JSONresourceLoadClass
- 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 notstrictly
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 notstrictly
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 notstrictly
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(org.springframework.core.io.Resource expected)
Verifies that the actual value is notstrictly
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. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- Parameters:
expected
- the expected JSON or the name of a resource containing the expected JSONcompareMode
- 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 JSONresourceLoadClass
- the source class used to load the resourcecompareMode
- 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 bytescompareMode
- 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 JSONcompareMode
- 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 JSONcompareMode
- 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(org.springframework.core.io.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 JSONcompareMode
- 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. Theexpected
value can contain the JSON itself or, if it ends with.json
, the name of a resource to be loaded usingresourceLoadClass
.- Parameters:
expected
- the expected JSON or the name of a resource containing the expected JSONcomparator
- 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 JSONresourceLoadClass
- the source class used to load the resourcecomparator
- 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 bytescomparator
- 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 JSONcomparator
- 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 JSONcomparator
- 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(org.springframework.core.io.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 JSONcomparator
- the comparator used when checking- Returns:
this
assertion object- Throws:
AssertionError
- if the actual JSON value is equal to the given one
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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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 anempty
result.- Parameters:
expression
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.format(String, Object...)
- Returns:
this
assertion object- Throws:
AssertionError
- if the value at the given path is not empty
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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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 anempty
result.- Parameters:
expression
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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 typeV
- value type- Parameters:
expression
- theJsonPath
expressionargs
- arguments to parameterize theJsonPath
expression with, using formatting specifiers defined inString.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