Package org.springframework.test.json
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
ConstructorDescriptionJsonContentAssert
(CharSequence json, Class<?> resourceLoadClass) Create a newJsonContentAssert
instance that will load resources relative to the givenresourceLoadClass
, usingUTF-8
.JsonContentAssert
(CharSequence json, Class<?> resourceLoadClass, Charset charset) Create a newJsonContentAssert
instance that will load resources relative to the givenresourceLoadClass
, using the givencharset
. -
Method Summary
Modifier and TypeMethodDescriptionisEqualTo
(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.Verify that the actual value is equal to the given JSONResource
.Verify that the actual value is equal to the given JSONResource
.isLenientlyEqualTo
(CharSequence expected) Verify that the actual value isleniently
equal to the given JSON.isLenientlyEqualTo
(Resource expected) Verify that the actual value isleniently
equal to the given JSONResource
.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 JSONResource
.isNotEqualTo
(Resource expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode) Verify that the actual value is not equal to the given JSONResource
.isNotLenientlyEqualTo
(CharSequence expected) Verify that the actual value is notleniently
equal to the given JSON.isNotLenientlyEqualTo
(Resource expected) Verify that the actual value is notleniently
equal to the given JSONResource
.isNotStrictlyEqualTo
(CharSequence expected) Verify that the actual value is notstrictly
equal to the given JSON.isNotStrictlyEqualTo
(Resource expected) Verify that the actual value is notstrictly
equal to the given JSONResource
.isStrictlyEqualTo
(CharSequence expected) Verify that the actual value isstrictly
equal to the given JSON.isStrictlyEqualTo
(Resource expected) Verify that the actual value isstrictly
equal to the given JSONResource
.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 newJsonContentAssert
instance that will load resources relative to the givenresourceLoadClass
, using the givencharset
.- Parameters:
json
- the actual JSON contentresourceLoadClass
- the class used to load resourcescharset
- the charset of the JSON resources
-
JsonContentAssert
Create a newJsonContentAssert
instance that will load resources relative to the givenresourceLoadClass
, usingUTF-8
.- Parameters:
json
- the actual JSON contentresourceLoadClass
- 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. Theexpected
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 JSONcompareMode
- 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 JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSONcompareMode
- the compare mode used when checking
- a
-
isEqualTo
public JsonContentAssert isEqualTo(@Nullable CharSequence expected, org.skyscreamer.jsonassert.comparator.JSONComparator comparator) Verify that the actual value is equal to the given JSON. Theexpected
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 JSONcomparator
- 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 JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSONcomparator
- the comparator used when checking
- a
-
isLenientlyEqualTo
Verify that the actual value isleniently
equal to the given JSON. Theexpected
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
Verify that the actual value isleniently
equal to the given JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSON
- a
-
isStrictlyEqualTo
Verify that the actual value isstrictly
equal to the given JSON. Theexpected
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
Verify that the actual value isstrictly
equal to the given JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSON
- a
-
isNotEqualTo
public JsonContentAssert isNotEqualTo(@Nullable CharSequence expected, org.skyscreamer.jsonassert.JSONCompareMode compareMode) Verify that the actual value is not equal to the given JSON. Theexpected
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 JSONcompareMode
- 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 JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSONcompareMode
- the compare mode used when checking
- a
-
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. Theexpected
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 JSONcomparator
- 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 JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSONcomparator
- the comparator used when checking
- a
-
isNotLenientlyEqualTo
Verify that the actual value is notleniently
equal to the given JSON. Theexpected
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
Verify that the actual value is notleniently
equal to the given JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSON
- a
-
isNotStrictlyEqualTo
Verify that the actual value is notstrictly
equal to the given JSON. Theexpected
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
Verify that the actual value is notstrictly
equal to the given JSONResource
.The resource abstraction allows to provide several input types:
- a
byte
array, usingByteArrayResource
- a
classpath
resource, usingClassPathResource
- a
File
orPath
, usingFileSystemResource
- an
InputStream
, usingInputStreamResource
- Parameters:
expected
- a resource containing the expected JSON
- a
-