OrRetryCondition implements RetryCondition { @Override public boolean shouldRetry(RetryPolicyContext context) { for (RetryCondition retryCondition : conditions) { if (retryCondition.shouldRetry(context)) { return true; } } return false; } OrRetryCondition(RetryCondition... conditions); @Override boolean shouldRetry(RetryPolicyContext context);  }
@Test public void allFalseConditions_ReturnsFalse() { assertFalse(orCondition.shouldRetry(RetryPolicyContexts.EMPTY)); }
@Test public void firstConditionIsTrue_ReturnsTrue() { when(conditionOne.shouldRetry(any(RetryPolicyContext.class))) .thenReturn(true); assertTrue(orCondition.shouldRetry(RetryPolicyContexts.EMPTY)); }
@Test public void secondConditionIsTrue_ReturnsTrue() { when(conditionTwo.shouldRetry(any(RetryPolicyContext.class))) .thenReturn(true); assertTrue(orCondition.shouldRetry(RetryPolicyContexts.EMPTY)); }
@Test public void noConditions_ReturnsFalse() { assertFalse(new OrRetryCondition().shouldRetry(RetryPolicyContexts.EMPTY)); }
@Test public void singleConditionThatReturnsTrue_ReturnsTrue() { when(conditionOne.shouldRetry(RetryPolicyContexts.EMPTY)) .thenReturn(true); assertTrue(new OrRetryCondition(conditionOne).shouldRetry(RetryPolicyContexts.EMPTY)); }
@Test public void singleConditionThatReturnsFalse_ReturnsFalse() { when(conditionOne.shouldRetry(RetryPolicyContexts.EMPTY)) .thenReturn(false); assertFalse(new OrRetryCondition(conditionOne).shouldRetry(RetryPolicyContexts.EMPTY)); }