use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientErrorTest method convertToGraphQLClientException.
/**
* Test the `ResponseImpl.throwExceptionIfErrors` method that should throw a `GraphQLClientException` if the Response
* contains any errors.
*/
@Test
public void convertToGraphQLClientException() throws ExecutionException, InterruptedException {
Response response = client.executeSync(document(operation(field("dummy", field("foo"), field("bar")))));
try {
((ResponseImpl) response).throwExceptionIfErrors();
fail("`throwExceptionIfErrors` call should throw a GraphQLClientException");
} catch (GraphQLClientException e) {
assertArrayEquals(new Object[] { "dummy", "bar" }, e.getErrors().get(0).getPath());
}
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class AbstractDynamicClientSubscriptionTest method testFailingImmediately.
@Test
public void testFailingImmediately() throws InterruptedException {
Document document = document(operation(OperationType.SUBSCRIPTION, field("failingImmediately")));
AtomicReference<Response> response = new AtomicReference<>();
CountDownLatch finished = new CountDownLatch(1);
client.subscription(document).subscribe().with(item -> {
response.set(item);
}, throwable -> {
// nothing
}, () -> {
finished.countDown();
});
finished.await(10, TimeUnit.SECONDS);
Response actualResponse = response.get();
assertNotNull("One response was expected to arrive", actualResponse);
Assert.assertEquals(JsonValue.NULL, actualResponse.getData().get("failingImmediately"));
// FIXME: add an assertion about the contained error message
// right now, there is no error message present, which is a bug
}
Aggregations