Search in sources :

Example 6 with AsyncQueryResult

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());
}
Also used : ElideResponse(com.yahoo.elide.ElideResponse) AsyncQuery(com.yahoo.elide.async.models.AsyncQuery) AsyncQueryResult(com.yahoo.elide.async.models.AsyncQueryResult) Test(org.junit.jupiter.api.Test)

Aggregations

AsyncQueryResult (com.yahoo.elide.async.models.AsyncQueryResult)6 ElideResponse (com.yahoo.elide.ElideResponse)5 AsyncQuery (com.yahoo.elide.async.models.AsyncQuery)5 Test (org.junit.jupiter.api.Test)4 Elide (com.yahoo.elide.Elide)1 ElideSettings (com.yahoo.elide.ElideSettings)1 ElideSettingsBuilder (com.yahoo.elide.ElideSettingsBuilder)1 DataStore (com.yahoo.elide.core.datastore.DataStore)1 DataStoreTransaction (com.yahoo.elide.core.datastore.DataStoreTransaction)1 EntityDictionary (com.yahoo.elide.core.dictionary.EntityDictionary)1 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)1 Check (com.yahoo.elide.core.security.checks.Check)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1