use of org.mule.runtime.api.interception.ProcessorInterceptor in project mule by mulesoft.
the class ReactiveInterceptorAdapterTestCase method secondInterceptorFailsAround.
@Test
public void secondInterceptorFailsAround() throws Exception {
RuntimeException expectedException = new RuntimeException("Some Error");
ProcessorInterceptor interceptor1 = prepareInterceptor(new TestProcessorInterceptor("outer") {
});
ProcessorInterceptor interceptor2 = prepareInterceptor(new TestProcessorInterceptor("inner") {
@Override
public CompletableFuture<InterceptionEvent> around(ComponentLocation location, Map<String, ProcessorParameterValue> parameters, InterceptionEvent event, InterceptionAction action) {
return action.fail(expectedException);
}
});
startFlowWithInterceptors(interceptor1, interceptor2);
expected.expectCause(sameInstance(expectedException));
try {
process(flow, eventBuilder(muleContext).message(Message.of("")).build());
} finally {
if (useMockInterceptor) {
InOrder inOrder = inOrder(processor, interceptor1, interceptor2);
inOrder.verify(interceptor1).before(any(), any(), any());
inOrder.verify(interceptor2).before(any(), any(), any());
inOrder.verify(interceptor1).around(any(), any(), any(), any());
inOrder.verify(interceptor2).around(any(), any(), any(), any());
inOrder.verify(processor, never()).process(any());
inOrder.verify(interceptor2).after(any(), any(), eq(of(expectedException)));
inOrder.verify(interceptor1).after(any(), any(), eq(of(expectedException)));
verifyParametersResolvedAndDisposed(times(1));
}
}
}
use of org.mule.runtime.api.interception.ProcessorInterceptor in project mule by mulesoft.
the class ReactiveInterceptorAdapterTestCase method paramWithErrorExpression.
@Test
public void paramWithErrorExpression() throws Exception {
Component annotatedProcessor = (Component) processor;
Map<QName, Object> annotations = new HashMap<>(annotatedProcessor.getAnnotations());
Map<String, String> params = new HashMap<>((Map<String, String>) annotations.get(ANNOTATION_PARAMETERS));
params.put("errorExpr", "#[notAnExpression]");
annotations.put(ANNOTATION_PARAMETERS, params);
((Component) processor).setAnnotations(annotations);
ProcessorInterceptor interceptor = prepareInterceptor(new ProcessorInterceptor() {
});
startFlowWithInterceptors(interceptor);
process(flow, eventBuilder(muleContext).message(Message.of("")).build());
if (useMockInterceptor) {
InOrder inOrder = inOrder(processor, interceptor);
inOrder.verify(interceptor).before(any(), mapArgWithErrorEntry("errorExpr", instanceOf(ExpressionRuntimeException.class)), any());
inOrder.verify(interceptor).around(any(), mapArgWithErrorEntry("errorExpr", instanceOf(ExpressionRuntimeException.class)), any(), any());
inOrder.verify(processor).process(any());
inOrder.verify(interceptor).after(any(), any(), any());
verifyParametersResolvedAndDisposed(times(1));
}
}
use of org.mule.runtime.api.interception.ProcessorInterceptor in project mule by mulesoft.
the class ReactiveInterceptorAdapterTestCase method secondInterceptorThrowsExceptionAround.
@Test
public void secondInterceptorThrowsExceptionAround() throws Exception {
RuntimeException expectedException = new RuntimeException("Some Error");
ProcessorInterceptor interceptor1 = prepareInterceptor(new TestProcessorInterceptor("outer") {
});
ProcessorInterceptor interceptor2 = prepareInterceptor(new TestProcessorInterceptor("inner") {
@Override
public CompletableFuture<InterceptionEvent> around(ComponentLocation location, Map<String, ProcessorParameterValue> parameters, InterceptionEvent event, InterceptionAction action) {
throw expectedException;
}
});
startFlowWithInterceptors(interceptor1, interceptor2);
expected.expectCause(sameInstance(expectedException));
try {
process(flow, eventBuilder(muleContext).message(Message.of("")).build());
} finally {
if (useMockInterceptor) {
InOrder inOrder = inOrder(processor, interceptor1, interceptor2);
inOrder.verify(interceptor1).before(any(), any(), any());
inOrder.verify(interceptor2).before(any(), any(), any());
inOrder.verify(interceptor1).around(any(), any(), any(), any());
inOrder.verify(interceptor2).around(any(), any(), any(), any());
inOrder.verify(processor, never()).process(any());
inOrder.verify(interceptor2).after(any(), any(), eq(of(expectedException)));
inOrder.verify(interceptor1).after(any(), any(), eq(of(expectedException)));
verifyParametersResolvedAndDisposed(times(1));
}
}
}
Aggregations