Class GraphQLFieldAssert
java.lang.Object
com.graphql.spring.boot.test.assertions.GraphQLFieldAssert
- All Implemented Interfaces:
GraphQLResponseAssertion
Provides fluent assertions for a field (specified by a json path) of the GraphQL response.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand()
<T> GraphQLGenericObjectAssert<T>
as
(com.fasterxml.jackson.databind.JavaType javaType) Returns an assertion for the content of the field as an instance of the specified type.<T> GraphQLGenericObjectAssert<T>
Returns an assertion for the content of the field as an instance of the specified class.Returns an assertion for the content of the field asBigDecimal
.Returns an assertion for the content of the field asBigInteger
.Returns an assertion for the content of the field asBoolean
.asByte()
Returns an assertion for the content of the field asByte
.Returns an assertion for the content of the field asInteger
.<T> GraphQLListAssert<T>
asList
(com.fasterxml.jackson.databind.JavaType javaListType) Returns an assertion for the content of the field as an instance of the specified list type.<T> GraphQLListAssert<T>
Returns an assertion for the content of the field as list of objects.asLong()
Returns an assertion for the content of the field asLong
.asShort()
Returns an assertion for the content of the field asShort
.asString()
Returns an assertion for the content of the field asString
.Asserts that the field specified by the provided JSON path is not null.Asserts that the field specified by the provided JSON path is not present in the response.Asserts that the field specified by the provided JSON path is not present in the response or its value is null.isNull()
Asserts that the field specified by the provided JSON path is null.
-
Field Details
-
EXPECTED_FIELD_S_TO_BE_PRESENT
- See Also:
-
EXPECTED_THAT_CONTENT_OF_FIELD_S_CAN_BE_CONVERTED_TO_S
- See Also:
-
-
Constructor Details
-
GraphQLFieldAssert
public GraphQLFieldAssert()
-
-
Method Details
-
isNotPresent
Asserts that the field specified by the provided JSON path is not present in the response.- Returns:
- self
- Throws:
AssertionError
- if the field is present in the response
-
isNotPresentOrNull
Asserts that the field specified by the provided JSON path is not present in the response or its value is null.- Returns:
- self
- Throws:
AssertionError
- if the field is present in the response and its value is not null.
-
isNull
Asserts that the field specified by the provided JSON path is null.- Returns:
- self
- Throws:
AssertionError
- if the field is not present in the response or its value is not null.
-
isNotNull
Asserts that the field specified by the provided JSON path is not null.- Returns:
- self
- Throws:
AssertionError
- if the field is not present in the response or its value is null.
-
asBigDecimal
Returns an assertion for the content of the field asBigDecimal
.- Returns:
- a
GraphQLBigDecimalAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toBigDecimal
-
asBigInteger
Returns an assertion for the content of the field asBigInteger
.- Returns:
- a
GraphQLBigIntegerAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toBigInteger
-
asLong
Returns an assertion for the content of the field asLong
.- Returns:
- a
GraphQLLongAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toLong
-
asInteger
Returns an assertion for the content of the field asInteger
.- Returns:
- a
GraphQLIntegerAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toInteger
-
asShort
Returns an assertion for the content of the field asShort
.- Returns:
- a
GraphQLShortAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toShort
-
asByte
Returns an assertion for the content of the field asByte
.- Returns:
- a
GraphQLByteAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toByte
-
asBoolean
Returns an assertion for the content of the field asBoolean
.- Returns:
- a
GraphQLBooleanAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toBoolean
-
asString
Returns an assertion for the content of the field asString
.- Returns:
- a
GraphQLStringAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted toString
-
as
Returns an assertion for the content of the field as an instance of the specified class.- Parameters:
clazz
- The class of the object. to assert- Returns:
- a
GraphQLGenericObjectAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted to the specified class
-
as
Returns an assertion for the content of the field as an instance of the specified type.- Parameters:
javaType
- The java type definition.- Returns:
- a
GraphQLGenericObjectAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted to the specified class
-
asList
Returns an assertion for the content of the field as an instance of the specified list type.- Parameters:
javaListType
- The java type definition. Expected to define a list type.- Returns:
- a
GraphQLListAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted to the specified class or if the provided type is not a list type.
-
asListOf
Returns an assertion for the content of the field as list of objects.- Parameters:
elementClass
- the type of objects in the list- Returns:
- a
GraphQLGenericObjectAssert
instance - Throws:
AssertionError
- if the path does not exist or the content could not be converted to the specified class
-
and
- Specified by:
and
in interfaceGraphQLResponseAssertion
- Returns:
- the instance of
GraphQLResponse
for which this assertion was created. Allows chaining fluent assertions.
-