use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientFormatAnnotationsTest method testParsingDateWithJsonbFormatAnnotation.
/**
* Test parsing a date formatted using a @JsonbDateFormat annotation
*/
@Test
public void testParsingDateWithJsonbFormatAnnotation() throws ExecutionException, InterruptedException {
Document document = document(operation(field("something", field("dateWithJsonbAnnotation"))));
Response response = client.executeSync(document);
ObjectWithFormattedFields objectWithFormattedFields = response.getObject(ObjectWithFormattedFields.class, "something");
Date parsedDate = objectWithFormattedFields.getDateWithJsonbAnnotation();
Calendar calendar = toCalendar(parsedDate);
assertEquals(Calendar.MAY, calendar.get(Calendar.MONTH));
assertEquals(13, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(1997, calendar.get(Calendar.YEAR));
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientFormatAnnotationsTest method testParsingLongWithCustomFormat.
/**
* Test parsing a long formatted using a @NumberFormat annotation
*/
@Test
public void testParsingLongWithCustomFormat() throws ExecutionException, InterruptedException {
Document document = document(operation(field("something", field("longNumber"))));
Response response = client.executeSync(document);
ObjectWithFormattedFields objectWithFormattedFields = response.getObject(ObjectWithFormattedFields.class, "something");
Long parsedNumber = objectWithFormattedFields.getLongNumber();
assertEquals((Long) 123456789L, parsedNumber);
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientFormatAnnotationsTest method testParsingDoubleWithCustomFormat.
/**
* Test parsing a double formatted using a @NumberFormat annotation
*/
@Test
public void testParsingDoubleWithCustomFormat() throws ExecutionException, InterruptedException {
Document document = document(operation(field("something", field("doubleNumber"))));
Response response = client.executeSync(document);
assertEquals("Sanity check failed: the server did not return the number in the desired custom format", "12.345.678,9", response.getData().getJsonObject("something").getString("doubleNumber"));
ObjectWithFormattedFields objectWithFormattedFields = response.getObject(ObjectWithFormattedFields.class, "something");
Double parsedNumber = objectWithFormattedFields.getDoubleNumber();
assertEquals(12345678.9, parsedNumber, 0.00001);
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientFormatAnnotationsTest method testParsingDateWithCustomFormat.
/**
* Test parsing a date formatted using a @DateFormat annotation
*/
@Test
public void testParsingDateWithCustomFormat() throws ExecutionException, InterruptedException {
Document document = document(operation(field("something", field("date"))));
Response response = client.executeSync(document);
// a sanity check to make sure that the server really returned the custom format
// because if not, then this test would not be actually verifying anything
assertEquals("Sanity check failed: the server did not return the date in the desired custom format", "May 1997 13 04,20,03 May Tue", response.getData().getJsonObject("something").getString("date"));
ObjectWithFormattedFields objectWithFormattedFields = response.getObject(ObjectWithFormattedFields.class, "something");
Date parsedDate = objectWithFormattedFields.getDate();
Calendar calendar = toCalendar(parsedDate);
assertEquals(Calendar.MAY, calendar.get(Calendar.MONTH));
assertEquals(13, calendar.get(Calendar.DAY_OF_MONTH));
assertEquals(1997, calendar.get(Calendar.YEAR));
}
use of io.smallrye.graphql.client.Response in project quarkus-quickstarts by quarkusio.
the class StarWarsResource method getAllFilmsUsingDynamicClient.
@GET
@Path("/dynamic")
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public List<Film> getAllFilmsUsingDynamicClient() throws Exception {
Document query = document(operation(field("allFilms", field("films", field("title"), field("planetConnection", field("planets", field("name")))))));
Response response = dynamicClient.executeSync(query);
// translate it into an instance of the corresponding model class
return response.getObject(FilmConnection.class, "allFilms").getFilms();
}
Aggregations