ExtendedRetryTemplate extends RetryTemplate { public <T> T execute(final Callable<T> callable) throws Exception, ExhaustedRetryException { return execute(new RetryCallback<T, Exception>() { public T doWithRetry(RetryContext retryContext) throws Exception { return callable.call(); } }); } ExtendedRetryTemplate(); Callable<T> asCallable(final RetryCallback<T, Exception> callback); Callable<T> asCallable(final Callable<T> callable); T execute(final Callable<T> callable); T execute(final Callable<T> callable, RetryState retryState); T execute(final Callable<T> callable, RecoveryCallback<T> recoveryCallback, RetryState retryState);  }
@Test public void test_execute_callable() throws Exception { Callable<Long> callable = Mockito.mock(Callable.class); ExtendedRetryTemplate template = new ExtendedRetryTemplate(); Mockito.when(callable.call()).thenReturn(10L); Assert.assertEquals(10L, template.execute(callable).longValue()); Mockito.verify(callable, Mockito.times(1)).call(); }
@Test public void test_execute_callableWithState() throws Exception { Callable<Long> callable = Mockito.mock(Callable.class); RetryState retryState = Mockito.mock(RetryState.class); ExtendedRetryTemplate template = new ExtendedRetryTemplate(); Mockito.when(callable.call()).thenReturn(10L); Assert.assertEquals(10L, template.execute(callable, retryState).longValue()); Mockito.verify(callable, Mockito.times(1)).call(); }
@Test public void test_execute_callableWithRecoveryAndState() throws Exception { Callable<Long> callable = Mockito.mock(Callable.class); RetryState retryState = Mockito.mock(RetryState.class); RecoveryCallback<Long> recoveryCallback = Mockito.mock(RecoveryCallback.class); ExtendedRetryTemplate template = new ExtendedRetryTemplate(); Mockito.when(callable.call()).thenReturn(10L); Assert.assertEquals(10L, template.execute(callable, recoveryCallback, retryState).longValue()); Mockito.verify(callable, Mockito.times(1)).call(); }