ThreadPoolTimeout implements Timeout { @Override public void timeout() { cancellableTask.cancel(TimeoutableResult.TIMEOUT, new PrecipiceTimeoutException()); } ThreadPoolTimeout(CancellableTask<TimeoutableResult, T> cancellableTask); @Override void timeout();  }
@Test public void taskCancelledIfTimeout() { CancellableTask<TimeoutableResult, String> task = mock(CancellableTask.class); ThreadPoolTimeout<String> timeout = new ThreadPoolTimeout<>(task); timeout.timeout(); verify(task).cancel(eq(TimeoutableResult.TIMEOUT), any(PrecipiceTimeoutException.class)); }