public R apply(final T t) throws Exception { while (true) { try { return getUserFunction().apply(t); } catch (Exception e) { if (retryStrategy.shouldRetry()) { log.info(retryStrategy.retryMessage()); } else { log.info(retryStrategy.retryMessage()); throw e; } } } }
public void verifyRetry(int numFuncApply, int numShouldRetry) { Assert.assertEquals(count, numFuncApply); Mockito.verify(this.retryStrategy, times(numShouldRetry)).shouldRetry(); } }
public MockRetryableFunction(IFunctionThrowsException<T,R> func, IRetryStrategy retryStrategy) { super(func,spy(retryStrategy)); when(super.retryStrategy.shouldRetry()).thenCallRealMethod(); when(super.retryStrategy.retryMessage()).thenCallRealMethod(); }