@Test
public void executeAsyncCall_short_circuit_times_out_the_call_if_it_takes_longer_than_callTimeout() {

    // given
    long callTimeoutMillis = 50;
    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";
    });
    // when
    long startTimeMillis = System.currentTimeMillis();
    CompletableFuture<String> result = cbSpy.executeAsyncCall(() -> future);
    Exception exThrownByFuture = null;
    try {
        result.join();
    }
    catch (Exception ex) {
        exThrownByFuture = ex;
    }
    long endTimeMillis = System.currentTimeMillis();
    // then
    assertThat(result.isCompletedExceptionally()).isTrue();
    assertThat(exThrownByFuture)
        .isNotNull()
        .isInstanceOf(CompletionException.class)
        .hasCauseInstanceOf(CircuitBreakerTimeoutException.class);
    assertThat((endTimeMillis - startTimeMillis)).isLessThan(callExecutionTimeMillis);
}