Search in sources :

Example 6 with DispatchQuery

use of io.prestosql.dispatcher.DispatchQuery in project hetu-core by openlookeng.

the class TestStateUpdater method testUpdateStates.

@Test
public void testUpdateStates() throws JsonProcessingException {
    DispatchQuery dispatchQuery = mockDispatchQueryData(false);
    StateStoreProvider stateStoreProvider = Mockito.mock(LocalStateStoreProvider.class);
    StateUpdater stateUpdater = new StateUpdater(stateStoreProvider, updateInterval);
    stateUpdater.registerQuery(STATE_COLLECTION_QUERY, dispatchQuery);
    when(stateStoreProvider.getStateStore()).then(new Returns(stateStore));
    when(stateStoreProvider.getStateStore().getStateCollection(any())).then(new Returns(Mockito.mock(StateMap.class)));
    when(stateStoreProvider.getStateStore().getStateCollection(any()).getType()).then(new Returns(StateCollection.Type.MAP));
    updateStateChange(dispatchQuery);
    stateUpdater.updateStates();
    int numberOfCalls = mockingDetails(stateStoreProvider.getStateStore().getStateCollection(any())).getInvocations().size();
    assertNotEquals(numberOfCalls, ERROR_CODE_VALUE_INDEX_TIME_NO_INVOCATION);
    stateUpdater.registerQuery(STATE_COLLECTION_QUERY, dispatchQuery);
}
Also used : Returns(org.mockito.internal.stubbing.answers.Returns) DispatchQuery(io.prestosql.dispatcher.DispatchQuery) LocalDispatchQuery(io.prestosql.dispatcher.LocalDispatchQuery) Test(org.testng.annotations.Test)

Aggregations

DispatchQuery (io.prestosql.dispatcher.DispatchQuery)6 LocalDispatchQuery (io.prestosql.dispatcher.LocalDispatchQuery)4 DataSize (io.airlift.units.DataSize)2 Duration (io.airlift.units.Duration)2 Returns (org.mockito.internal.stubbing.answers.Returns)2 Test (org.testng.annotations.Test)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 Inject (com.google.inject.Inject)1 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)1 Logger (io.airlift.log.Logger)1 Session (io.prestosql.Session)1 DataCenterStatementResource (io.prestosql.datacenter.DataCenterStatementResource)1 DispatchManager (io.prestosql.dispatcher.DispatchManager)1 QueryManager (io.prestosql.execution.QueryManager)1 AggregatedMemoryContext.newSimpleAggregatedMemoryContext (io.prestosql.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext)1 SimpleLocalMemoryContext (io.prestosql.memory.context.SimpleLocalMemoryContext)1