Package org.springframework.test.json
Class AbstractJsonValueAssert<SELF extends AbstractJsonValueAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractObjectAssert<SELF,Object>
org.springframework.test.json.AbstractJsonValueAssert<SELF>
- Type Parameters:
SELF
- the type of assertions
- All Implemented Interfaces:
org.assertj.core.api.Assert<SELF,
,Object> org.assertj.core.api.Descriptable<SELF>
,org.assertj.core.api.ExtensionPoints<SELF,
Object>
- Direct Known Subclasses:
JsonPathValueAssert
public abstract class AbstractJsonValueAssert<SELF extends AbstractJsonValueAssert<SELF>>
extends org.assertj.core.api.AbstractObjectAssert<SELF,Object>
Base AssertJ assertions that can be
applied to a JSON value.
In JSON, values must be one of the following data types:
This base class offers direct access for each of those types as well as conversion methods based on an optionalGenericHttpMessageConverter
.- Since:
- 6.2
- Author:
- Stephane Nicoll
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractJsonValueAssert
(Object actual, Class<?> selfType, HttpMessageContentConverter contentConverter) -
Method Summary
Modifier and TypeMethodDescriptionorg.assertj.core.api.ObjectArrayAssert<Object>
asArray()
Verify that the actual value is a non-null
array, and return a new assertion object that provides dedicated array assertions for it.org.assertj.core.api.AbstractBooleanAssert<?>
Verify that the actual value is a non-null
Boolean
, and return a new assertion object that provides dedicatedBoolean
assertions for it.asMap()
Verify that the actual value is a non-null
JSON object, and return a new assertion object that provides dedicated assertions on individual elements of the object.org.assertj.core.api.AbstractObjectAssert<?,
Number> asNumber()
org.assertj.core.api.AbstractStringAssert<?>
asString()
Verify that the actual value is a non-null
String
, and return a new assertion object that provides dedicatedString
assertions for it.<T> org.assertj.core.api.AbstractObjectAssert<?,
T> Verify that the actual value can be converted to an instance of the giventarget
, and produce a new assertion object narrowed to that type.<ASSERT extends org.assertj.core.api.AbstractAssert<?,
?>>
ASSERTconvertTo
(org.assertj.core.api.AssertFactory<?, ASSERT> assertFactory) Verify that the actual value can be converted to an instance of the type defined by the givenAssertFactory
and return a new Assert narrowed to that type.protected String
isEmpty()
Verify that the actual value is empty: either anull
scalar value or an empty list or map.Verify that the actual value is not empty: either a non-null
scalar value or a non-empty list or map.Methods inherited from class org.assertj.core.api.AbstractObjectAssert
as, as, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison
Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as, describedAs, describedAs
-
Constructor Details
-
AbstractJsonValueAssert
protected AbstractJsonValueAssert(@Nullable Object actual, Class<?> selfType, @Nullable HttpMessageContentConverter contentConverter)
-
-
Method Details
-
asString
public org.assertj.core.api.AbstractStringAssert<?> asString()Verify that the actual value is a non-null
String
, and return a new assertion object that provides dedicatedString
assertions for it.- Specified by:
asString
in interfaceorg.assertj.core.api.Assert<SELF extends AbstractJsonValueAssert<SELF>,
Object> - Overrides:
asString
in classorg.assertj.core.api.AbstractAssert<SELF extends AbstractJsonValueAssert<SELF>,
Object>
-
asNumber
-
asBoolean
public org.assertj.core.api.AbstractBooleanAssert<?> asBoolean()Verify that the actual value is a non-null
Boolean
, and return a new assertion object that provides dedicatedBoolean
assertions for it. -
asArray
Verify that the actual value is a non-null
array, and return a new assertion object that provides dedicated array assertions for it. -
asMap
Verify that the actual value is a non-null
JSON object, and return a new assertion object that provides dedicated assertions on individual elements of the object.The returned map assertion object uses attribute names as the keys, and the values can be any of the valid JSON values.
-
convertTo
Verify that the actual value can be converted to an instance of the giventarget
, and produce a new assertion object narrowed to that type.- Parameters:
target
- the type to convert the actual value to
-
convertTo
public <ASSERT extends org.assertj.core.api.AbstractAssert<?,?>> ASSERT convertTo(org.assertj.core.api.AssertFactory<?, ASSERT> assertFactory) Verify that the actual value can be converted to an instance of the type defined by the givenAssertFactory
and return a new Assert narrowed to that type.InstanceOfAssertFactories
provides static factories for all the types supported byAssertions.assertThat(java.util.function.Predicate<T>)
. Additional factories can be created by implementingAssertFactory
.Example:
// Check that the json value is an array of 3 users assertThat(jsonValue).convertTo(InstanceOfAssertFactories.list(User.class)) hasSize(3); // ListAssert of User
- Parameters:
assertFactory
- theAssertFactory
to use to produce a narrowed Assert for the type that it defines.
-
isEmpty
Verify that the actual value is empty: either anull
scalar value or an empty list or map.Can also be used when the path uses a filter operator to validate that it did not match.
-
isNotEmpty
Verify that the actual value is not empty: either a non-null
scalar value or a non-empty list or map.Can also be used when the path uses a filter operator to validate that it did match at least one element.
-
getExpectedErrorMessagePrefix
-