MaxNumberOfRetriesCondition implements RetryCondition { @Override public boolean shouldRetry(RetryPolicyContext context) { return context.retriesAttempted() < maxNumberOfRetries; } MaxNumberOfRetriesCondition(int maxNumberOfRetries); @Override boolean shouldRetry(RetryPolicyContext context);  }
@Test public void positiveMaxRetries_OneMoreAttemptToMax_ReturnsTrue() { assertTrue(new MaxNumberOfRetriesCondition(3).shouldRetry(RetryPolicyContexts.withRetriesAttempted(2))); }
@Test public void positiveMaxRetries_AtMaxAttempts_ReturnsFalse() { assertFalse(new MaxNumberOfRetriesCondition(3).shouldRetry(RetryPolicyContexts.withRetriesAttempted(3))); }
@Test public void positiveMaxRetries_PastMaxAttempts_ReturnsFalse() { assertFalse(new MaxNumberOfRetriesCondition(3).shouldRetry(RetryPolicyContexts.withRetriesAttempted(4))); }