use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class AsyncExecutorServiceTest method testExecuteQueryComplete.
// Test for executor hook execution
@Test
public void testExecuteQueryComplete() {
AsyncQuery queryObj = mock(AsyncQuery.class);
String query = "/group?sort=commonName&fields%5Bgroup%5D=commonName,description";
String id = "edc4a871-dff2-4054-804e-d80075cf827d";
when(queryObj.getQuery()).thenReturn(query);
when(queryObj.getId()).thenReturn(id);
when(queryObj.getRequestId()).thenReturn(id);
when(queryObj.getQueryType()).thenReturn(QueryType.JSONAPI_V1_0);
when(queryObj.getAsyncAfterSeconds()).thenReturn(10);
when(scope.getApiVersion()).thenReturn(NO_VERSION);
when(scope.getUser()).thenReturn(testUser);
JSONAPIAsyncQueryOperation jsonOperation = new JSONAPIAsyncQueryOperation(service, queryObj, scope);
service.executeQuery(queryObj, jsonOperation);
verify(queryObj, times(1)).setStatus(QueryStatus.PROCESSING);
verify(queryObj, times(1)).setStatus(QueryStatus.COMPLETE);
}
use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class AsyncExecutorServiceTest method testExecuteQueryFail.
// Test for executor hook execution
@Test
public void testExecuteQueryFail() throws Exception {
AsyncQuery queryObj = mock(AsyncQuery.class);
when(queryObj.getAsyncAfterSeconds()).thenReturn(10);
Callable<AsyncAPIResult> mockCallable = mock(Callable.class);
when(mockCallable.call()).thenThrow(new NoHttpResponseException(""));
service.executeQuery(queryObj, mockCallable);
verify(queryObj, times(1)).setStatus(QueryStatus.PROCESSING);
verify(queryObj, times(1)).setStatus(QueryStatus.FAILURE);
}
use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class DefaultAsyncAPIDAOTest method setupMocks.
@BeforeEach
public void setupMocks() {
dataStore = mock(DataStore.class);
asyncQuery = mock(AsyncQuery.class);
asyncQueryResult = mock(AsyncQueryResult.class);
filter = mock(FilterExpression.class);
tx = mock(DataStoreTransaction.class);
Map<String, Class<? extends Check>> checkMappings = new HashMap<>();
EntityDictionary dictionary = EntityDictionary.builder().checks(checkMappings).build();
dictionary.bindEntity(AsyncQuery.class);
dictionary.bindEntity(AsyncQueryResult.class);
ElideSettings elideSettings = new ElideSettingsBuilder(dataStore).withEntityDictionary(dictionary).withJoinFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withSubqueryFilterDialect(RSQLFilterDialect.builder().dictionary(dictionary).build()).withISO8601Dates("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC")).build();
elide = new Elide(elideSettings);
when(dataStore.beginTransaction()).thenReturn(tx);
asyncAPIDAO = new DefaultAsyncAPIDAO(elide.getElideSettings(), dataStore);
}
use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class AsyncAPICancelRunnableTest method createAsyncQueryTestObject.
public AsyncQuery createAsyncQueryTestObject(String id, Long createdOn, QueryStatus status) {
AsyncQuery asyncQuery = new AsyncQuery();
asyncQuery.setId(id);
asyncQuery.setRequestId(id);
asyncQuery.setCreatedOn(new Date(createdOn));
asyncQuery.setStatus(status);
return asyncQuery;
}
use of com.yahoo.elide.async.models.AsyncQuery in project elide by yahoo.
the class GraphQLAsyncQueryOperationTest method testProcessQueryGraphQlRunnerException.
@Test
public void testProcessQueryGraphQlRunnerException() {
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(runner.run(any(), any(), any(), any())).thenThrow(RuntimeException.class);
GraphQLAsyncQueryOperation graphQLOperation = new GraphQLAsyncQueryOperation(asyncExecutorService, queryObj, requestScope);
assertThrows(RuntimeException.class, () -> graphQLOperation.call());
}
Aggregations