Search in sources :

Example 1 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class ArraysTest method arraysTest.

@Test
public void arraysTest() throws IOException, URISyntaxException {
    String expectedRequest = Utils.getResourceFileContent("core/arrays.graphql");
    Document document = document(operation(QUERY, "arrayHolderQuery", field("arrayHolder", args(arg("arrayHolder", inputObject(prop("boolPrimitiveArray", new boolean[] { true, false, true }), prop("boolObjectArray", new Boolean[] { true, false, true }), prop("bytePrimitiveArray", new byte[] { 0, 2, 3 }), prop("byteObjectArray", new Byte[] { 0, 2, 3 }), prop("shortPrimitiveArray", new short[] { 78, 789, 645 }), prop("shortObjectArray", new Short[] { 78, 789, 645 }), prop("intPrimitiveArray", new int[] { 78, 65, 12354 }), prop("intObjectArray", new Integer[] { 78, 65, 12354 }), prop("longPrimitiveArray", new long[] { 789L, 947894L, 1874448L }), prop("longObjectArray", new Long[] { 789L, 947894L, 1874448L }), prop("floatPrimitiveArray", new float[] { 1567.654f, 8765f, 123789456.1851f }), prop("floatObjectArray", new Float[] { 1567.654f, 8765f, 123789456.1851f }), prop("doublePrimitiveArray", new double[] { 789.3242d, 1815d, 98765421.654897d }), prop("doubleObjectArray", new Double[] { 789.3242d, 1815d, 98765421.654897d }), prop("bigIntegerArray", new BigInteger[] { BigInteger.ZERO, BigInteger.ONE, BigInteger.TEN }), prop("bigDecimalArray", new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN }), prop("charPrimitiveArray", new char[] { 'f', 'o', 'o' }), prop("charObjectArray", new Character[] { 'f', 'o', 'o' }), prop("stringArray", new String[] { "foo", "bar", "baz" })))), field("boolPrimitiveArray"), field("boolObjectArray"), field("bytePrimitiveArray"), field("byteObjectArray"), field("shortPrimitiveArray"), field("shortObjectArray"), field("intPrimitiveArray"), field("intObjectArray"), field("longPrimitiveArray"), field("longObjectArray"), field("floatPrimitiveArray"), field("floatObjectArray"), field("doublePrimitiveArray"), field("doubleObjectArray"), field("bigIntegerArray"), field("bigDecimalArray"), field("charPrimitiveArray"), field("charObjectArray"), field("stringArray"))));
    String generatedRequest = document.build();
    AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
Also used : Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.Test)

Example 2 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class DynamicClientInjectionTest method testInjectedClient.

@Test
public void testInjectedClient() throws ExecutionException, InterruptedException {
    Document document = document(operation("SimpleQuery", field("simple", field("string"), field("integer"))));
    JsonObject data = client.executeSync(document).getData();
    assertEquals("asdf", data.getJsonObject("simple").getString("string"));
    assertEquals(30, data.getJsonObject("simple").getInt("integer"));
}
Also used : JsonObject(javax.json.JsonObject) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Example 3 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class DynamicClientSingleOperationsTestBase method testRenamedField.

/**
 * Parsing the response into a model class that contains a renamed field (using @Name)
 */
@Test
public void testRenamedField() throws ExecutionException, InterruptedException {
    Document document = document(operation(field("withRenamedField", field("renamedField:specialName"), field("string"))));
    Response response = client.executeSync(document);
    Dummy ret = response.getObject(Dummy.class, "withRenamedField");
    assertEquals("foo", ret.getRenamedField());
}
Also used : Response(io.smallrye.graphql.client.Response) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Example 4 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class DynamicClientSingleOperationsTestBase method testOneQueryInOneOperationSync.

@Test
public void testOneQueryInOneOperationSync() throws ExecutionException, InterruptedException {
    Document document = document(operation(field("simple", field("string"), field("integer"))));
    JsonObject data = client.executeSync(document).getData();
    assertEquals("asdf", data.getJsonObject("simple").getString("string"));
    assertEquals(30, data.getJsonObject("simple").getInt("integer"));
}
Also used : JsonObject(javax.json.JsonObject) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Example 5 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class DynamicClientSingleOperationsTestBase method testListWithRenamedField.

@Test
public void testListWithRenamedField() throws ExecutionException, InterruptedException {
    Document document = document(operation(field("listWithRenamedField", field("renamedField:specialName"), field("string"))));
    Response response = client.executeSync(document);
    List<Dummy> ret = response.getList(Dummy.class, "listWithRenamedField");
    assertEquals("foo", ret.get(0).getRenamedField());
    assertEquals("foo2", ret.get(1).getRenamedField());
}
Also used : Response(io.smallrye.graphql.client.Response) Document(io.smallrye.graphql.client.core.Document) 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