@Test
@Timeout(value = 300, unit = TimeUnit.MILLISECONDS)
public void testBeforeCancelled() throws InterruptedException, InvocationTargetException, ExecutionException {

    CompletableFuture<Integer> d = new CompletableFuture<>();
    ScheduledCompletableFuture<Integer> before = scheduler.before(d, Duration.ofMillis(100));
    before.cancel(true);
    assertTrue(before.getPromise().isCompletedExceptionally(), "Scheduled job cancelled before timeout");
    assertThrows(CancellationException.class, () -> {
        before.get();
    });
}