use of org.mule.runtime.extension.api.runtime.operation.Interceptor in project mule by mulesoft.
the class DefaultExecutionMediator method before.
InterceptorsExecutionResult before(ExecutionContext executionContext, List<Interceptor> interceptors) {
List<Interceptor> interceptorList = new ArrayList<>();
try {
for (Interceptor interceptor : interceptors) {
interceptorList.add(interceptor);
interceptor.before(executionContext);
}
} catch (Exception e) {
return new InterceptorsExecutionResult(exceptionEnricherManager.handleThrowable(e), interceptorList);
}
return new InterceptorsExecutionResult(null, interceptorList);
}
use of org.mule.runtime.extension.api.runtime.operation.Interceptor in project mule by mulesoft.
the class DefaultExecutionMediatorTestCase method retry.
@Test
public void retry() throws Throwable {
stubException();
Interceptor interceptor = mock(Interceptor.class);
setInterceptors((Interceptable) configurationInstance, interceptor);
setInterceptors((Interceptable) operationExecutor);
defineOrder(interceptor);
assertException(exception -> {
assertThat(exception, instanceOf(ConnectionException.class));
try {
verify(interceptor, times(RETRY_COUNT + 1)).before(operationContext);
} catch (Exception e) {
throw new RuntimeException(e);
}
verify(interceptor, times(RETRY_COUNT + 1)).onError(same(operationContext), anyVararg());
verify(interceptor, times(RETRY_COUNT + 1)).after(operationContext, null);
});
}
Aggregations