Search in sources :

Example 1 with JSONAPIAsyncQueryOperation

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

Aggregations

AsyncQuery (com.yahoo.elide.async.models.AsyncQuery)1 JSONAPIAsyncQueryOperation (com.yahoo.elide.async.operation.JSONAPIAsyncQueryOperation)1 Test (org.junit.jupiter.api.Test)1