use of io.crate.execution.engine.collect.count.CountOperation in project crate by crate.
the class CountTaskTest method testKillOperationFuture.
@Test
public void testKillOperationFuture() throws Exception {
CompletableFuture<Long> future = mock(CompletableFuture.class);
CountOperation countOperation = new FakeCountOperation(future);
CountTask countTask = new CountTask(countPhaseWithId(1), txnCtx, countOperation, new TestingRowConsumer(), null);
countTask.start();
countTask.kill(JobKilledException.of("dummy"));
verify(future, times(1)).cancel(true);
assertTrue(countTask.isClosed());
}
use of io.crate.execution.engine.collect.count.CountOperation in project crate by crate.
the class CountTaskTest method testClose.
@Test
public void testClose() throws Exception {
CompletableFuture<Long> future = new CompletableFuture<>();
CountOperation countOperation = mock(CountOperation.class);
when(countOperation.count(eq(txnCtx), any(), any(Symbol.class))).thenReturn(future);
CountTask countTask = new CountTask(countPhaseWithId(1), txnCtx, countOperation, new TestingRowConsumer(), null);
countTask.start();
future.complete(1L);
assertTrue(countTask.isClosed());
// assure that there was no exception
countTask.completionFuture().get();
// on error
future = new CompletableFuture<>();
when(countOperation.count(eq(txnCtx), any(), any(Symbol.class))).thenReturn(future);
countTask = new CountTask(countPhaseWithId(2), txnCtx, countOperation, new TestingRowConsumer(), null);
countTask.start();
future.completeExceptionally(new UnhandledServerException("dummy"));
assertTrue(countTask.isClosed());
expectedException.expectCause(CauseMatcher.cause(UnhandledServerException.class));
countTask.completionFuture().get();
}
Aggregations