Search in sources :

Example 1 with HeisenbergConnectionExceptionEnricher

use of org.mule.test.heisenberg.extension.exception.HeisenbergConnectionExceptionEnricher in project mule by mulesoft.

the class ExtensionMessageSourceTestCase method enrichExceptionWithSourceExceptionEnricher.

@Test
public void enrichExceptionWithSourceExceptionEnricher() throws Exception {
    when(enricherFactory.createHandler()).thenReturn(new HeisenbergConnectionExceptionEnricher());
    mockExceptionEnricher(sourceModel, enricherFactory);
    mockExceptionEnricher(sourceModel, enricherFactory);
    ExtensionMessageSource messageSource = getNewExtensionMessageSourceInstance();
    messageSource.initialise();
    doThrow(new RuntimeException(ERROR_MESSAGE)).when(source).onStart(sourceCallback);
    Throwable t = catchThrowable(messageSource::start);
    assertThat(ExceptionUtils.containsType(t, ConnectionException.class), is(true));
    assertThat(t.getMessage(), containsString(ENRICHED_MESSAGE + ERROR_MESSAGE));
    messageSource.stop();
}
Also used : HeisenbergConnectionExceptionEnricher(org.mule.test.heisenberg.extension.exception.HeisenbergConnectionExceptionEnricher) ThrowableAssert.catchThrowable(org.assertj.core.api.ThrowableAssert.catchThrowable) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test)

Aggregations

ThrowableAssert.catchThrowable (org.assertj.core.api.ThrowableAssert.catchThrowable)1 Test (org.junit.Test)1 ConnectionException (org.mule.runtime.api.connection.ConnectionException)1 HeisenbergConnectionExceptionEnricher (org.mule.test.heisenberg.extension.exception.HeisenbergConnectionExceptionEnricher)1