@Test(timeout = 3000)
public void testSuccessfulTaskWithCallback() throws Exception {

  // Instantiate a new executor and start a new 'null' task ...
  final ThreadAsyncExecutor executor = new ThreadAsyncExecutor();
  final Object result = new Object();
  final Callable<Object> task = mock(Callable.class);
  when(task.call()).thenReturn(result);
  final AsyncCallback callback = mock(AsyncCallback.class);
  final AsyncResult<Object> asyncResult = executor.startProcess(task, callback);
  assertNotNull(asyncResult);
  asyncResult.await(); // Prevent timing issues, and wait until the result is available
  assertTrue(asyncResult.isCompleted());
  // Our task should only execute once ...
  verify(task, times(1)).call();
  // ... same for the callback, we expect our object
  final ArgumentCaptor<Optional<Exception>> optionalCaptor = ArgumentCaptor.forClass((Class) Optional.class);
  verify(callback, times(1)).onComplete(eq(result), optionalCaptor.capture());
  final Optional<Exception> optionalException = optionalCaptor.getValue();
  assertNotNull(optionalException);
  assertFalse(optionalException.isPresent());
  // ... and the result should be exactly the same object
  assertSame(result, asyncResult.getValue());
}