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();
}
Aggregations