@Override
    public boolean retryRequest(IOException exception, int executionCount, HttpContext ctx) {
        log.fine(() -> String.format("retryRequest(exception='%s', executionCount='%d', ctx='%s'",
                                     exception.getClass().getName(), executionCount, ctx));
        HttpClientContext clientCtx = HttpClientContext.adapt(ctx);
        if (!predicate.test(exception, clientCtx)) {
            log.fine(() -> String.format("Not retrying for '%s'", ctx));
            return false;
        }
        if (executionCount > maxRetries) {
            log.fine(() -> String.format("Max retries exceeded for '%s'", ctx));
            retryFailedConsumer.onRetryFailed(exception, executionCount, clientCtx);
            return false;
        }
        Duration delay = delaySupplier.getDelay(executionCount);
        log.fine(() -> String.format("Retrying after %s for '%s'", delay, ctx));
        retryConsumer.onRetry(exception, delay, executionCount, clientCtx);
        sleeper.sleep(delay);
        return true;
    }
@Test
    void retry_with_fixed_delay_sleeps_for_expected_duration() {
        Sleeper sleeper = mock(Sleeper.class);

        Duration delay = Duration.ofSeconds(2);
        int maxRetries = 2;

        DelayedConnectionLevelRetryHandler handler = DelayedConnectionLevelRetryHandler.Builder
                .withFixedDelay(delay, maxRetries)
                .withSleeper(sleeper)
                .build();

        IOException exception = new IOException();
        HttpClientContext ctx = new HttpClientContext();
        int lastExecutionCount = maxRetries + 1;
        for (int i = 1; i <= lastExecutionCount; i++) {
            handler.retryRequest(exception, i, ctx);
        }

        verify(sleeper, times(2)).sleep(delay);
    }