use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class GraphQLAsyncQueryOperationTest method testProcessQueryGraphQlInvalidResponse.
@Test
public void testProcessQueryGraphQlInvalidResponse() throws URISyntaxException {
AsyncQuery queryObj = new AsyncQuery();
String responseBody = "ResponseBody";
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(0, queryResultObj.getRecordCount());
}
use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class GraphQLAsyncQueryOperationTest method testProcessQueryGraphQlApiVersionNotSupported.
@Test
public void testProcessQueryGraphQlApiVersionNotSupported() {
AsyncQuery queryObj = new AsyncQuery();
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(requestScope.getApiVersion()).thenReturn("v2");
GraphQLAsyncQueryOperation graphQLOperation = new GraphQLAsyncQueryOperation(asyncExecutorService, queryObj, requestScope);
assertThrows(InvalidOperationException.class, () -> graphQLOperation.call());
}
use of com.yahoo.elide.async.models.AsyncQuery 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