use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveWithAnEventThatCarriesError.
@Test
public void resolveWithAnEventThatCarriesError() {
Optional<Error> surfaceError = mockError(TRANSFORMER, null);
when(event.getError()).thenReturn(surfaceError);
MessagingException me = newMessagingException(new Exception(), event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, TRANSFORMER);
assertExceptionMessage(resolved.getMessage(), ERROR_MESSAGE);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveCorrectConnectionException.
@Test
public void resolveCorrectConnectionException() {
ErrorType expected = ErrorTypeBuilder.builder().namespace("NS").identifier("CONNECTION").parentErrorType(CONNECTION).build();
ErrorTypeLocator locator = ErrorTypeLocator.builder(repository).addComponentExceptionMapper(ci, ExceptionMapper.builder().addExceptionMapping(ConnectionException.class, expected).build()).defaultExceptionMapper(ExceptionMapper.builder().build()).defaultError(UNKNOWN).build();
when(((PrivilegedMuleContext) context).getErrorTypeLocator()).thenReturn(locator);
MessagingException me = newMessagingException(CONNECTION_EXCEPTION, event, processor);
MessagingExceptionResolver anotherResolver = new MessagingExceptionResolver(new TestProcessor());
MessagingException resolved = anotherResolver.resolve(me, context);
assertExceptionErrorType(resolved, expected);
assertExceptionMessage(resolved.getMessage(), "CONNECTION PROBLEM");
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveWithParentInChain.
@Test
public void resolveWithParentInChain() {
ErrorType withParent = ErrorTypeBuilder.builder().parentErrorType(CONNECTION).identifier("CONNECT").namespace("TEST").build();
Optional<Error> surfaceError = mockError(withParent, new Exception());
when(event.getError()).thenReturn(surfaceError);
Exception cause = new ConnectionException("Some Connection Error", new Exception());
MessagingException me = newMessagingException(cause, event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, withParent);
assertExceptionMessage(resolved.getMessage(), ERROR_MESSAGE);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveWithoutAnyErrors.
@Test
public void resolveWithoutAnyErrors() {
MessagingException me = newMessagingException(new Exception(), event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, UNKNOWN);
assertExceptionMessage(resolved.getMessage(), ERROR_MESSAGE);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class ExceptionTestCase method exceptionCausedBy.
@Test
public void exceptionCausedBy() throws Exception {
CoreEvent event = createEvent();
Message message = event.getMessage();
MessagingException me = new MessagingException(CoreMessages.createStaticMessage(""), InternalEvent.builder(context).message(message).build(), new IllegalAccessException());
when(mockError.getCause()).thenReturn(me);
assertTrue((Boolean) evaluate("exception.causedBy(java.lang.IllegalAccessException)", event));
}
Aggregations