@Test
@Timeout(value = 300, unit = TimeUnit.MILLISECONDS)
public void testAfterResolvedWithException() throws Throwable {

    Callable<Void> callable = () -> {
        // Pass a exception not very likely thrown by the scheduler it self to avoid missing real exceptions.
        throw new FileNotFoundException("testBeforeTimeoutException");
    };
    ScheduledCompletableFuture<Void> after = scheduler.after(callable, Duration.ofMillis(100));
    Thread.sleep(200);
    assertTrue(after.isDone(), "Scheduled job should be done");
    assertTrue(after.getPromise().isCompletedExceptionally(),
            "After CompletableFuture should have completed with an exception");
    assertThrows(FileNotFoundException.class, () -> {
        try {
            after.get();
        } catch (ExecutionException e) {
            throw e.getCause();
        }
    });
}