FutureCommandCallback implements CommandCallback<ReturnType>, Future<ReturnType> { @Override public ReturnType get() throws InterruptedException, ExecutionException { if (!isDone()) { countDownLatch.await(); } return returnResultOrException(); }  @Override void onSuccess(ReturnType result); @Override void onFailure(RuntimeException exception); @Override boolean cancel(boolean mayInterruptIfRunning); @Override boolean isCancelled(); @Override boolean isDone(); @Override ReturnType get(); @Override ReturnType get(long timeout, TimeUnit unit);  }
@Test void whenGetWithTimeoutCalled_shouldTimeout() { FutureCommandCallback future = new FutureCommandCallback(); Assertions.assertThrows(TimeoutException.class, () -> future.get(1, TimeUnit.MILLISECONDS)); }