Search in sources :

Example 31 with Document

use of io.smallrye.graphql.client.core.Document 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
}
Also used : Response(io.smallrye.graphql.client.Response) AtomicReference(java.util.concurrent.atomic.AtomicReference) Document(io.smallrye.graphql.client.core.Document) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

Document (io.smallrye.graphql.client.core.Document)31 Test (org.junit.Test)16 Test (org.junit.jupiter.api.Test)13 Response (io.smallrye.graphql.client.Response)11 JsonObject (javax.json.JsonObject)6 Variable (io.smallrye.graphql.client.core.Variable)5 BuildException (io.smallrye.graphql.client.core.exceptions.BuildException)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 SuperHero (examples.typesafeclient.SuperHero)1 Blocking (io.smallrye.common.annotation.Blocking)1 InputObject (io.smallrye.graphql.client.core.InputObject)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 JsonArray (javax.json.JsonArray)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 FilmConnection (org.acme.microprofile.graphql.client.model.FilmConnection)1