Class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTesterBuilder<B>>
java.lang.Object
org.springframework.graphql.test.tester.AbstractGraphQlTesterBuilder<B>
- Type Parameters:
B
- the type of builder
- All Implemented Interfaces:
GraphQlTester.Builder<B>
- Direct Known Subclasses:
DefaultRSocketGraphQlTesterBuilder
public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTesterBuilder<B>>
extends Object
implements GraphQlTester.Builder<B>
Abstract, base class for transport specific
GraphQlTester.Builder
implementations.
Subclasses must implement GraphQlTester.Builder.build()
and call
buildGraphQlTester(GraphQlTransport)
to obtain a default, transport
agnostic GraphQlTester
. A transport specific extension can then wrap
this default tester by extending AbstractDelegatingGraphQlTester
.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static GraphQlTransport
asTransport
(GraphQlClient client) For cases where the Tester needs theGraphQlTransport
, we can't use transports directly since they are package private, but we can adapt the correspondingGraphQlClient
and adapt it toGraphQlTransport
.protected GraphQlTester
buildGraphQlTester
(GraphQlTransport transport) Build the default transport-agnostic client that subclasses can then wrap withAbstractDelegatingGraphQlTester
.protected void
configureJsonPathConfig
(Function<com.jayway.jsonpath.Configuration, com.jayway.jsonpath.Configuration> configurer) Allow transport-specific subclass builders to register a JSON PathMappingProvider
that matches the JSON encoding/decoding they use.documentSource
(DocumentSource documentSource) Configure aDocumentSource
for use withGraphQlTester.documentName(String)
for resolving a document by name.errorFilter
(Predicate<ResponseError> predicate) Configure a globalfilter
that applies to all requests.protected Consumer<AbstractGraphQlTesterBuilder<?>>
Subclasses call this fromGraphQlTester.Builder.build()
to obtain aConsumer
to initialize new builder instances with, based on "this" builder.responseTimeout
(Duration timeout) Max amount of time to wait for a GraphQL response.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.graphql.test.tester.GraphQlTester.Builder
build
-
Constructor Details
-
AbstractGraphQlTesterBuilder
public AbstractGraphQlTesterBuilder()
-
-
Method Details
-
errorFilter
Description copied from interface:GraphQlTester.Builder
Configure a globalfilter
that applies to all requests.- Specified by:
errorFilter
in interfaceGraphQlTester.Builder<B extends AbstractGraphQlTesterBuilder<B>>
- Parameters:
predicate
- the error filter to add- Returns:
- the same builder instance
-
documentSource
Description copied from interface:GraphQlTester.Builder
Configure aDocumentSource
for use withGraphQlTester.documentName(String)
for resolving a document by name.By default, this is set to
ResourceDocumentSource
with classpath location"graphql-test/"
andResourceDocumentSource.FILE_EXTENSIONS
as extensions.- Specified by:
documentSource
in interfaceGraphQlTester.Builder<B extends AbstractGraphQlTesterBuilder<B>>
- Parameters:
documentSource
- the document content loader
-
responseTimeout
Description copied from interface:GraphQlTester.Builder
Max amount of time to wait for a GraphQL response.By default this is set to 5 seconds.
- Specified by:
responseTimeout
in interfaceGraphQlTester.Builder<B extends AbstractGraphQlTesterBuilder<B>>
- Parameters:
timeout
- the response timeout value
-
configureJsonPathConfig
protected void configureJsonPathConfig(Function<com.jayway.jsonpath.Configuration, com.jayway.jsonpath.Configuration> configurer) Allow transport-specific subclass builders to register a JSON PathMappingProvider
that matches the JSON encoding/decoding they use.- Parameters:
configurer
- a function applied to the JSON Path configuration
-
buildGraphQlTester
Build the default transport-agnostic client that subclasses can then wrap withAbstractDelegatingGraphQlTester
.- Parameters:
transport
- the graphql transport to use
-
getBuilderInitializer
Subclasses call this fromGraphQlTester.Builder.build()
to obtain aConsumer
to initialize new builder instances with, based on "this" builder. -
asTransport
For cases where the Tester needs theGraphQlTransport
, we can't use transports directly since they are package private, but we can adapt the correspondingGraphQlClient
and adapt it toGraphQlTransport
.- Parameters:
client
- the graphql client to use for extracting the transport
-