@Test
@Timeout(value = 1, unit = TimeUnit.SECONDS)
public void testDelay() throws InterruptedException {

    long duration = 5000;
    ScheduledCompletableFuture<Instant> future = scheduler.after(Duration.ofMillis(duration));
    Thread.sleep(500);
    long timeLeft = future.getDelay(TimeUnit.MILLISECONDS);
    long expectedTimeLeft = duration - 450; // add some slack so don't check at exact time
    assertTrue(timeLeft < expectedTimeLeft, "Delay should be less:" + timeLeft + " < " + expectedTimeLeft);
    future.cancel(true);
}