Search in sources :

Example 6 with RetryOperations

use of cn.taketoday.retry.RetryOperations in project today-framework by TAKETODAY.

the class StatefulRetryOperationsInterceptorTests method testKeyGeneratorReturningNull.

@SuppressWarnings("unchecked")
@Test
public void testKeyGeneratorReturningNull() throws Throwable {
    this.interceptor.setKeyGenerator(mock(MethodArgumentsKeyGenerator.class));
    this.interceptor.setLabel("foo");
    RetryOperations template = mock(RetryOperations.class);
    this.interceptor.setRetryOperations(template);
    MethodInvocation invocation = mock(MethodInvocation.class);
    when(invocation.getArguments()).thenReturn(new Object[] { new Object() });
    this.interceptor.invoke(invocation);
    ArgumentCaptor<DefaultRetryState> captor = ArgumentCaptor.forClass(DefaultRetryState.class);
    verify(template).execute(any(RetryCallback.class), any(RecoveryCallback.class), captor.capture());
    assertNull(captor.getValue().getKey());
}
Also used : RecoveryCallback(cn.taketoday.retry.RecoveryCallback) DefaultRetryState(cn.taketoday.retry.support.DefaultRetryState) RetryOperations(cn.taketoday.retry.RetryOperations) MethodInvocation(org.aopalliance.intercept.MethodInvocation) RetryCallback(cn.taketoday.retry.RetryCallback) Test(org.junit.jupiter.api.Test)

Aggregations

RetryOperations (cn.taketoday.retry.RetryOperations)6 RecoveryCallback (cn.taketoday.retry.RecoveryCallback)4 RetryCallback (cn.taketoday.retry.RetryCallback)4 DefaultRetryState (cn.taketoday.retry.support.DefaultRetryState)4 MethodInvocation (org.aopalliance.intercept.MethodInvocation)4 Test (org.junit.jupiter.api.Test)4 RetryTemplate (cn.taketoday.retry.support.RetryTemplate)2 Test (org.junit.Test)2