@Test
public void executeAsyncCall_does_not_cancel_timeout_check_if_future_takes_too_long() throws InterruptedException {

    // given
    long callTimeoutMillis = 100;
    long callExecutionTimeMillis = 150;
    Whitebox
        .setInternalState(cbSpy, "callTimeoutNanos", Optional.of(Duration.ofMillis(callTimeoutMillis).toNanos()));
    CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
        try {
            Thread.sleep(callExecutionTimeMillis);
        }
        catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return "foo";
    });
    ScheduledExecutorService schedulerMock = mock(ScheduledExecutorService.class);
    ScheduledFuture scheduledFutureMock = mock(ScheduledFuture.class);
    doReturn(scheduledFutureMock).when(schedulerMock)
                                 .schedule(any(Runnable.class), any(Long.class), any(TimeUnit.class));
    doReturn(true).when(scheduledFutureMock).isDone();
    Whitebox.setInternalState(cbSpy, "scheduler", schedulerMock);
    // when
    CompletableFuture<String> result = cbSpy.executeAsyncCall(() -> future);
    result.join();
    Thread.sleep(50); // have to give the cancellation logic time to run before checking
    // then
    verify(scheduledFutureMock, times(0)).cancel(anyBoolean());
}