use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method withAnnotatedFailingProcessorPathResolver.
@Test
public void withAnnotatedFailingProcessorPathResolver() {
AnnotatedProcessor mockProcessor = mock(AnnotatedProcessor.class);
when(mockProcessor.getAnnotation(eq(docNameAttrName))).thenReturn("Mock Component");
configureProcessorLocation(mockProcessor);
when(mockComponentLocation.getLocation()).thenReturn("flow/processor");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, mockProcessor);
exception.getInfo().putAll(locationProvider.getContextInfo(createInfo(testEvent, exception, mockProcessor), mockProcessor));
assertThat(exception.getInfo().get(INFO_LOCATION_KEY).toString(), is("flow/processor @ MessagingExceptionTestCase:muleApp.xml:10 (Mock Component)"));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method withFailingProcessorNotPathResolver.
@Test
public void withFailingProcessorNotPathResolver() {
AnnotatedProcessor mockProcessor = mock(AnnotatedProcessor.class);
when(mockProcessor.getLocation()).thenReturn(fromSingleComponent("Mock@1"));
when(mockProcessor.toString()).thenReturn("Mock@1");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, mockProcessor);
exception.getInfo().putAll(locationProvider.getContextInfo(createInfo(testEvent, exception, mockProcessor), mockProcessor));
assertThat(exception.getInfo().get(INFO_LOCATION_KEY).toString(), is("Mock@1 @ MessagingExceptionTestCase:unknown:-1"));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method withFailingProcessorPathResolver.
@Test
public void withFailingProcessorPathResolver() {
AnnotatedProcessor mockProcessor = mock(AnnotatedProcessor.class);
configureProcessorLocation(mockProcessor);
when(mockComponentLocation.getLocation()).thenReturn("flow/processor");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, mockProcessor);
exception.getInfo().putAll(locationProvider.getContextInfo(createInfo(testEvent, exception, mockProcessor), mockProcessor));
assertThat(exception.getInfo().get(INFO_LOCATION_KEY).toString(), is("flow/processor @ MessagingExceptionTestCase:muleApp.xml:10"));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method payloadInfoNonVerbose.
@Test
public void payloadInfoNonVerbose() throws Exception {
MuleException.verboseExceptions = false;
CoreEvent testEvent = mock(CoreEvent.class);
Message muleMessage = spy(of(""));
when(testEvent.getMessage()).thenReturn(muleMessage);
when(testEvent.getError()).thenReturn(empty());
MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
assertThat(e.getInfo().get(PAYLOAD_INFO_KEY), nullValue());
verify(muleMessage, never()).getPayload();
verify(transformationService, never()).transform(muleMessage, DataType.STRING);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class CompositeSourcePolicyTestCase method nextProcessorExecutionFailurePropagates.
@Test
public void nextProcessorExecutionFailurePropagates() throws Exception {
RuntimeException policyException = new RuntimeException("policy failure");
reset(flowExecutionProcessor);
when(flowExecutionProcessor.apply(any())).thenAnswer(invocation -> {
Mono<CoreEvent> mono = from(invocation.getArgumentAt(0, Publisher.class));
mono.doOnNext(event -> ((BaseEventContext) event.getContext()).error(new MessagingException(event, policyException))).subscribe();
return empty();
});
compositeSourcePolicy = new CompositeSourcePolicy(asList(firstPolicy, secondPolicy), sourcePolicyParametersTransformer, sourcePolicyProcessorFactory, flowExecutionProcessor, sourceParametersTransformer);
Either<SourcePolicyFailureResult, SourcePolicySuccessResult> sourcePolicyResult = from(compositeSourcePolicy.process(initialEvent)).block();
assertThat(sourcePolicyResult.isLeft(), is(true));
assertThat(sourcePolicyResult.getLeft().getMessagingException(), instanceOf(FlowExecutionException.class));
assertThat(sourcePolicyResult.getLeft().getMessagingException().getCause(), is(policyException));
}
Aggregations