use of io.crate.exceptions.UnknownUpstreamFailure 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();
}
Aggregations