Search in sources :

Example 11 with ErrorType

use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.

the class DisjunctiveErrorTypeMatcherTestCase method noMatch.

@Test
public void noMatch() {
    ErrorType mockErrorType = mock(ErrorType.class);
    when(mockErrorType.getParentErrorType()).thenReturn(anyErrorType);
    ErrorTypeMatcher matcherWithTwoTransformation = createMatcher(transformationErrorType, expressionErrorType);
    assertThat(matcherWithTwoTransformation.match(mockErrorType), is(false));
}
Also used : ErrorType(org.mule.runtime.api.message.ErrorType) DisjunctiveErrorTypeMatcher(org.mule.runtime.core.api.exception.DisjunctiveErrorTypeMatcher) ErrorTypeMatcher(org.mule.runtime.core.api.exception.ErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) Test(org.junit.Test)

Example 12 with ErrorType

use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.

the class DisjunctiveErrorTypeMatcherTestCase method oneMatch.

@Test
public void oneMatch() {
    ErrorType mockErrorType = mock(ErrorType.class);
    when(mockErrorType.getParentErrorType()).thenReturn(transformationErrorType);
    ErrorTypeMatcher matcherWithTransformation = createMatcher(transformationErrorType, expressionErrorType);
    assertThat(matcherWithTransformation.match(transformationErrorType), is(true));
    assertThat(matcherWithTransformation.match(mockErrorType), is(true));
}
Also used : ErrorType(org.mule.runtime.api.message.ErrorType) DisjunctiveErrorTypeMatcher(org.mule.runtime.core.api.exception.DisjunctiveErrorTypeMatcher) ErrorTypeMatcher(org.mule.runtime.core.api.exception.ErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) Test(org.junit.Test)

Example 13 with ErrorType

use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.

the class SingleErrorTypeMatcherTestCase method matchChild.

@Test
public void matchChild() {
    ComponentIdentifier customTransformerIdentifier = ComponentIdentifier.builder().name("custom").namespace(CORE_NAMESPACE_NAME).build();
    ErrorTypeRepository errorTypeRepository = muleContext.getErrorTypeRepository();
    ErrorType customTransformerErrorType = errorTypeRepository.addErrorType(customTransformerIdentifier, transformationErrorType);
    ErrorTypeMatcher transformationMatcher = new SingleErrorTypeMatcher(transformationErrorType);
    assertThat(transformationMatcher.match(customTransformerErrorType), is(true));
}
Also used : ErrorTypeRepository(org.mule.runtime.api.exception.ErrorTypeRepository) ErrorType(org.mule.runtime.api.message.ErrorType) ErrorTypeMatcher(org.mule.runtime.core.api.exception.ErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) Test(org.junit.Test)

Example 14 with ErrorType

use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.

the class SingleErrorTypeMatcherTestCase method anyMatchsAll.

@Test
public void anyMatchsAll() {
    ErrorType mockErrorType = mock(ErrorType.class);
    when(mockErrorType.getParentErrorType()).thenReturn(transformationErrorType);
    ErrorTypeMatcher anyMatcher = new SingleErrorTypeMatcher(anyErrorType);
    assertThat(anyMatcher.match(anyErrorType), is(true));
    assertThat(anyMatcher.match(transformationErrorType), is(true));
    assertThat(anyMatcher.match(expressionErrorType), is(true));
    assertThat(anyMatcher.match(mockErrorType), is(true));
}
Also used : ErrorType(org.mule.runtime.api.message.ErrorType) ErrorTypeMatcher(org.mule.runtime.core.api.exception.ErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) SingleErrorTypeMatcher(org.mule.runtime.core.api.exception.SingleErrorTypeMatcher) Test(org.junit.Test)

Example 15 with ErrorType

use of org.mule.runtime.api.message.ErrorType in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method before.

@Before
public void before() throws MuleException {
    nonBlockingProcessorsExecuted.set(0);
    muleContext = spy(super.muleContext);
    ErrorTypeLocator errorTypeLocator = mock(ErrorTypeLocator.class);
    ErrorType errorType = mock(ErrorType.class);
    ExceptionContextProvider exceptionContextProvider = mock(ExceptionContextProvider.class);
    MuleConfiguration muleConfiguration = mock(MuleConfiguration.class);
    when(muleConfiguration.isContainerMode()).thenReturn(false);
    when(muleConfiguration.getId()).thenReturn(randomNumeric(3));
    when(muleConfiguration.getShutdownTimeout()).thenReturn(1000L);
    when(muleContext.getConfiguration()).thenReturn(muleConfiguration);
    when(((PrivilegedMuleContext) muleContext).getErrorTypeLocator()).thenReturn(errorTypeLocator);
    when(muleContext.getExceptionContextProviders()).thenReturn(singletonList(exceptionContextProvider));
    when(errorTypeLocator.lookupErrorType((Exception) any())).thenReturn(errorType);
    flow = builder("flow", muleContext).processingStrategyFactory(processingStrategyFactory).build();
    flow.initialise();
    flow.start();
}
Also used : ExceptionContextProvider(org.mule.runtime.core.api.execution.ExceptionContextProvider) MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) ErrorType(org.mule.runtime.api.message.ErrorType) ErrorTypeLocator(org.mule.runtime.core.privileged.exception.ErrorTypeLocator) PrivilegedMuleContext(org.mule.runtime.core.privileged.PrivilegedMuleContext) Before(org.junit.Before)

Aggregations

ErrorType (org.mule.runtime.api.message.ErrorType)35 Test (org.junit.Test)19 SmallTest (org.mule.tck.size.SmallTest)9 SingleErrorTypeMatcher (org.mule.runtime.core.api.exception.SingleErrorTypeMatcher)8 Error (org.mule.runtime.api.message.Error)7 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)6 ErrorTypeMatcher (org.mule.runtime.core.api.exception.ErrorTypeMatcher)6 ErrorTypeLocator (org.mule.runtime.core.privileged.exception.ErrorTypeLocator)6 ErrorTypeRepository (org.mule.runtime.api.exception.ErrorTypeRepository)5 Optional (java.util.Optional)4 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)4 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)4 PrivilegedMuleContext (org.mule.runtime.core.privileged.PrivilegedMuleContext)4 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Component (org.mule.runtime.api.component.Component)3 TypedException (org.mule.runtime.api.exception.TypedException)3 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)3 HashSet (java.util.HashSet)2