### Question:
ExponentialBackoffPolicy { public Duration nextDelay(final Duration currentDelay) { if (currentDelay.compareTo(maxDelay) < 0) { return calculateNextDelay(currentDelay); } return maxDelay; } @Builder  ExponentialBackoffPolicy(final Duration initialDelay,
                                    final Duration maxDelay,
                                    final int maxRetries,
                                    final int backoffMultiplier); private  ExponentialBackoffPolicy(); Duration nextDelay(final Duration currentDelay); boolean reachedMaxRetries(final int retriesCount); static final ExponentialBackoffPolicy DEFAULT; static final int UNLIMITED_RETRIES; }### Answer:
@Test void testNextDelayDefaultPolicy_returnsDouble() { ExponentialBackoffPolicy exponentialBackoffPolicy = ExponentialBackoffPolicy.DEFAULT; assertEquals(Duration.ofSeconds(10), exponentialBackoffPolicy.nextDelay(Duration.ofSeconds(5))); }
@Test void testNextDelayDefaultPolicy_exceedsMaxDelay_returnsMaxDelay() { ExponentialBackoffPolicy exponentialBackoffPolicy = ExponentialBackoffPolicy .builder() .initialDelay(Duration.ofSeconds(1)) .maxDelay(Duration.ofSeconds(60)) .build(); assertEquals(Duration.ofSeconds(60), exponentialBackoffPolicy.nextDelay(Duration.ofSeconds(50))); }
@Test void testNextDelayDefaultPolicy_currentDelayExceedsMaxDelay_returnsMaxDelay() { ExponentialBackoffPolicy exponentialBackoffPolicy = ExponentialBackoffPolicy .builder() .initialDelay(Duration.ofSeconds(1)) .maxDelay(Duration.ofSeconds(60)) .build(); assertEquals(Duration.ofSeconds(60), exponentialBackoffPolicy.nextDelay(Duration.ofSeconds(70))); }
@Test void testNextDelayCustomPolicy() { ExponentialBackoffPolicy exponentialBackoffPolicy = ExponentialBackoffPolicy .builder() .maxDelay(Duration.ofSeconds(60)) .backoffMultiplier(5) .build(); assertEquals(Duration.ofSeconds(50), exponentialBackoffPolicy.nextDelay(Duration.ofSeconds(10))); }