public class GraphQLTestSubscription
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GraphQLTestSubscription.TestWebSocketClient |
| Constructor and Description |
|---|
GraphQLTestSubscription() |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<GraphQLResponse> |
awaitAndGetAllResponses(int timeToWait)
Waits a specified amount time and returns all responses received during that time.
|
java.util.List<GraphQLResponse> |
awaitAndGetAllResponses(int timeToWait,
boolean stopAfter)
Waits a specified amount time and returns all responses received during that time.
|
GraphQLResponse |
awaitAndGetNextResponse(int timeout)
Awaits and returns the next response received from the subscription.
|
GraphQLResponse |
awaitAndGetNextResponse(int timeout,
boolean stopAfter)
Awaits and returns the next response received from the subscription.
|
java.util.List<GraphQLResponse> |
awaitAndGetNextResponses(int timeout,
int numExpectedResponses)
Awaits and returns the specified number of responses.
|
java.util.List<GraphQLResponse> |
awaitAndGetNextResponses(int timeout,
int numExpectedResponses,
boolean stopAfter)
Awaits and returns the specified number of responses.
|
java.util.List<GraphQLResponse> |
getRemainingResponses()
Returns the remaining responses that were not returned so far.
|
GraphQLTestSubscription |
init()
Sends the "connection_init" message to the GraphQL server without a payload.
|
GraphQLTestSubscription |
init(java.lang.Object payload)
Sends the "connection_init" message to the GraphQL server.
|
void |
reset()
Stops (if needed) and resets this instance.
|
GraphQLTestSubscription |
start(@NonNull java.lang.String graphQLResource)
Sends the "start" message to the GraphQL server.
|
GraphQLTestSubscription |
start(@NonNull java.lang.String graphGLResource,
java.lang.Object variables)
Sends the "start" message to the GraphQL Subscription.
|
GraphQLTestSubscription |
stop()
Sends the "stop" message to the server.
|
GraphQLTestSubscription |
waitAndExpectNoResponse(int timeToWait)
Waits a specified amount of time and asserts that no responses were received during that time.
|
GraphQLTestSubscription |
waitAndExpectNoResponse(int timeToWait,
boolean stopAfter)
Waits a specified amount of time and asserts that no responses were received during that time.
|
public GraphQLTestSubscription init()
public GraphQLTestSubscription init(@Nullable java.lang.Object payload)
payload - The payload of the connection_init message. May be null, if not needed.public GraphQLTestSubscription start(@NonNull @NonNull java.lang.String graphQLResource)
graphQLResource - the GraphQL resource, which contains the query for the subscription start payload. The
start message will be sent without variables.public GraphQLTestSubscription start(@NonNull @NonNull java.lang.String graphGLResource, @Nullable java.lang.Object variables)
graphGLResource - the GraphQL resource, which contains the query for the subscription start payload.variables - the variables needed for the query to be evaluated.public GraphQLTestSubscription stop()
public void reset()
public GraphQLResponse awaitAndGetNextResponse(int timeout)
timeout - timeout in milliseconds. Test will fail if no message received from the subscription until
the timeout expires.public GraphQLResponse awaitAndGetNextResponse(int timeout, boolean stopAfter)
timeout - timeout in milliseconds. Test will fail if no message received from the subscription until
the timeout expires.stopAfter - if true, the subscription will be stopped after the message was received (or timeout).public java.util.List<GraphQLResponse> awaitAndGetAllResponses(int timeToWait)
timeToWait - the time to wait, in millisecondspublic java.util.List<GraphQLResponse> awaitAndGetAllResponses(int timeToWait, boolean stopAfter)
timeToWait - the time to wait, in millisecondsstopAfter - if true, the subscription will be stopped after the time elapsed.public java.util.List<GraphQLResponse> awaitAndGetNextResponses(int timeout, int numExpectedResponses)
timeout - timeout in milliseconds. Test will fail if the expected number of responses is not received.numExpectedResponses - the number of expected responses. If negative, the method will wait the timeout
and return all responses received during that time. In this case, no assertion is
made regarding the number of responses, and the returned list may be empty. If
zero, it is expected that no responses are sent during the timeout period.getRemainingResponses() can
be used to retrieved them.public java.util.List<GraphQLResponse> awaitAndGetNextResponses(int timeout, int numExpectedResponses, boolean stopAfter)
timeout - timeout in milliseconds. Test will fail if the expected number of responses is not received.numExpectedResponses - the number of expected responses. If negative, the method will wait the timeout
and return all responses received during that time. In this case, no assertion is
made regarding the number of responses, and the returned list may be empty. If
zero, it is expected that no responses are sent during the timeout period.stopAfter - if true, the subscription will be stopped after the messages were received (or timeout).getRemainingResponses() can
be used to retrieved them.public GraphQLTestSubscription waitAndExpectNoResponse(int timeToWait, boolean stopAfter)
timeToWait - time to wait, in milliseconds.stopAfter - if true, the subscription will be stopped afterwards.public GraphQLTestSubscription waitAndExpectNoResponse(int timeToWait)
timeToWait - time to wait, in milliseconds.public java.util.List<GraphQLResponse> getRemainingResponses()