private CompletionStage<org.asynchttpclient.Response> executeWithRetries(Request request) {
RetryConfig retryConfig = RetryConfig.<org.asynchttpclient.Response>custom()
.maxAttempts(5)
.intervalFunction(IntervalFunction
.ofExponentialBackoff(TimeUnit.SECONDS.toMillis(2), 1.2))
.build();
Retry retry = Retry.of("proxy-retry" , retryConfig);
Supplier<CompletionStage<org.asynchttpclient.Response>> retryableSupplier = Retry.decorateCompletionStage(
retry , Executors.newScheduledThreadPool(10), () -> executeCall(request));
return retryableSupplier.get();
}
I am using this method hoping that the executeCall would get retried at least 3 times when it throws an exception. The executeCall(request) method returns a CompletionStage.
When I try to unit test this piece of code , the number of invocations of the executeCall(request) method is just once (I am throwing an exception inside this method).
How do I ensure that it retries atleast 5 times (this is the default value)