use of io.crate.operation.count.CountOperation in project crate by crate.
the class CountContextTest method testClose.
@Test
public void testClose() throws Exception {
SettableFuture<Long> future = SettableFuture.create();
CountOperation countOperation = mock(CountOperation.class);
when(countOperation.count(anyMap(), any(WhereClause.class))).thenReturn(future);
CountContext countContext = new CountContext(1, countOperation, new TestingBatchConsumer(), null, WhereClause.MATCH_ALL);
countContext.prepare();
countContext.start();
future.set(1L);
assertTrue(countContext.future.closed());
// assure that there was no exception
countContext.completionFuture().get();
// on error
future = SettableFuture.create();
when(countOperation.count(anyMap(), any(WhereClause.class))).thenReturn(future);
countContext = new CountContext(2, countOperation, new TestingBatchConsumer(), null, WhereClause.MATCH_ALL);
countContext.prepare();
countContext.start();
future.setException(new UnknownUpstreamFailure());
assertTrue(countContext.future.closed());
expectedException.expectCause(CauseMatcher.cause(UnknownUpstreamFailure.class));
countContext.completionFuture().get();
}
use of io.crate.operation.count.CountOperation in project crate by crate.
the class CountContextTest method testKillOperationFuture.
@Test
public void testKillOperationFuture() throws Exception {
ListenableFuture<Long> future = mock(ListenableFuture.class);
CountOperation countOperation = new FakeCountOperation(future);
CountContext countContext = new CountContext(1, countOperation, new TestingBatchConsumer(), null, WhereClause.MATCH_ALL);
countContext.prepare();
countContext.start();
countContext.kill(null);
verify(future, times(1)).cancel(true);
assertTrue(countContext.future.closed());
}
Aggregations