use of com.yahoo.elide.async.models.AsyncQueryResult in project elide by yahoo.
the class GraphQLAsyncQueryOperationTest method testProcessQueryGraphQl.
@Test
public void testProcessQueryGraphQl() throws URISyntaxException {
AsyncQuery queryObj = new AsyncQuery();
String responseBody = "{\"data\":{\"book\":{\"edges\":[{\"node\":{\"id\":\"1\",\"title\":\"Ender's Game\"}}," + "{\"node\":{\"id\":\"2\",\"title\":\"Song of Ice and Fire\"}}," + "{\"node\":{\"id\":\"3\",\"title\":\"For Whom the Bell Tolls\"}}]}}}";
ElideResponse response = new ElideResponse(200, responseBody);
String query = "{\"query\":\"{ group { edges { node { name commonName description } } } }\",\"variables\":null}";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
queryObj.setId(id);
queryObj.setQuery(query);
queryObj.setQueryType(QueryType.GRAPHQL_V1_0);
when(runner.run(any(), any(), any(), any(), any())).thenReturn(response);
GraphQLAsyncQueryOperation graphQLOperation = new GraphQLAsyncQueryOperation(asyncExecutorService, queryObj, requestScope);
AsyncQueryResult queryResultObj = (AsyncQueryResult) graphQLOperation.call();
assertEquals(responseBody, queryResultObj.getResponseBody());
assertEquals(200, queryResultObj.getHttpStatus());
assertEquals(3, queryResultObj.getRecordCount());
}
Aggregations