@Override
  public <T> T endProcess(AsyncResult<T> asyncResult) throws ExecutionException,
      InterruptedException {
    if (!asyncResult.isCompleted()) {
      asyncResult.await();
    }
    return asyncResult.getValue();
  }
@Test
  void testEndProcess() {
    assertTimeout(ofMillis(5000), () -> {
      // Instantiate a new executor and start a new 'null' task ...
      final var executor = new ThreadAsyncExecutor();

      final var result = new Object();
      when(task.call()).thenAnswer(i -> {
        Thread.sleep(1500);
        return result;
      });

      final var asyncResult = executor.startProcess(task);
      assertNotNull(asyncResult);
      assertFalse(asyncResult.isCompleted());

      try {
        asyncResult.getValue();
        fail("Expected IllegalStateException when calling AsyncResult#getValue on a non-completed task");
      } catch (IllegalStateException e) {
        assertNotNull(e.getMessage());
      }

      assertSame(result, executor.endProcess(asyncResult));
      verify(task, times(1)).call();
      assertTrue(asyncResult.isCompleted());

      // Calling end process a second time while already finished should give the same result
      assertSame(result, executor.endProcess(asyncResult));
      verifyNoMoreInteractions(task);
    });
  }