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);
}
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"));
}
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());
}
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"));
}
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());
}
Aggregations