@Test public void testNullTaskWithCallback() throws Exception { assertTimeout(ofMillis(3000), () -> { final ThreadAsyncExecutor executor = new ThreadAsyncExecutor(); final AsyncCallback<Object> callback = mock(AsyncCallback.class); final AsyncResult<Object> asyncResult = executor.startProcess(null, callback); assertNotNull(asyncResult, "The AsyncResult should not be 'null', even though the task was 'null'."); asyncResult.await(); assertTrue(asyncResult.isCompleted()); final ArgumentCaptor<Optional<Exception>> optionalCaptor = ArgumentCaptor.forClass((Class) Optional.class); verify(callback, times(1)).onComplete(Matchers.isNull(), optionalCaptor.capture()); final Optional<Exception> optionalException = optionalCaptor.getValue(); assertNotNull(optionalException); assertTrue(optionalException.isPresent()); final Exception exception = optionalException.get(); assertNotNull(exception); assertEquals(NullPointerException.class, exception.getClass()); try { asyncResult.getValue(); fail("Expected ExecutionException with NPE as cause"); } catch (final ExecutionException e) { assertNotNull(e.getMessage()); assertNotNull(e.getCause()); assertEquals(NullPointerException.class, e.getCause().getClass()); } }); }
@Override public <T> AsyncResult<T> startProcess(Callable<T> task) { return startProcess(task, null); }
ThreadAsyncExecutor implements AsyncExecutor { @Override public <T> AsyncResult<T> startProcess(Callable<T> task) { return startProcess(task, null); } }
ThreadAsyncExecutor implements AsyncExecutor { @Override public <T> AsyncResult<T> startProcess(Callable<T> task) { return startProcess(task, null); }  }
ThreadAsyncExecutor implements AsyncExecutor { @Override public <T> AsyncResult<T> startProcess(Callable<T> task) { return startProcess(task, null); }  @Override AsyncResult<T> startProcess(Callable<T> task); @Override AsyncResult<T> startProcess(Callable<T> task, AsyncCallback<T> callback); @Override T endProcess(AsyncResult<T> asyncResult); }
ThreadAsyncExecutor implements AsyncExecutor { @Override public <T> AsyncResult<T> startProcess(Callable<T> task) { return startProcess(task, null); }  @Override AsyncResult<T> startProcess(Callable<T> task); @Override AsyncResult<T> startProcess(Callable<T> task, AsyncCallback<T> callback); @Override T endProcess(AsyncResult<T> asyncResult);  }