Search in sources :

Example 1 with DefaultExecutionMediator

use of org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator in project mule by mulesoft.

the class DefaultExecutionMediatorTestCase method enrichThrownException.

@Test
public void enrichThrownException() throws Throwable {
    expectedException.expectCause(instanceOf(HeisenbergException.class));
    expectedException.expectMessage(ERROR);
    mockExceptionEnricher(operationModel, () -> exceptionEnricher);
    when(operationExecutor.execute(any())).thenReturn(Mono.error(new Exception()));
    Mono.from(new DefaultExecutionMediator(extensionModel, operationModel, new DefaultConnectionManager(muleContext), muleContext.getErrorTypeRepository()).execute(operationExceptionExecutor, operationContext)).block();
}
Also used : DefaultConnectionManager(org.mule.runtime.core.internal.connection.DefaultConnectionManager) DefaultExecutionMediator(org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) MuleException(org.mule.runtime.api.exception.MuleException) ExpectedException(org.junit.rules.ExpectedException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 2 with DefaultExecutionMediator

use of org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator in project mule by mulesoft.

the class DefaultExecutionMediatorTestCase method before.

@Before
public void before() throws Exception {
    when(configurationInstance.getStatistics()).thenReturn(configurationStats);
    when(configurationInstance.getName()).thenReturn(DUMMY_NAME);
    when(configurationInstance.getModel()).thenReturn(configurationModel);
    when(extensionModel.getName()).thenReturn(DUMMY_NAME);
    when(extensionModel.getModelProperty(ClassLoaderModelProperty.class)).thenReturn(empty());
    mockExceptionEnricher(extensionModel, null);
    mockExceptionEnricher(operationModel, null);
    when(operationExecutor.execute(operationContext)).thenReturn(just(result));
    when(operationExceptionExecutor.execute(operationContext)).thenReturn(error(exception));
    when(operationContext.getConfiguration()).thenReturn(Optional.of(configurationInstance));
    when(operationContext.getExtensionModel()).thenReturn(extensionModel);
    when(operationContext.getTransactionConfig()).thenReturn(empty());
    when(operationContext.getRetryPolicyTemplate()).thenReturn(empty());
    when(operationContext.getCurrentScheduler()).thenReturn(IMMEDIATE_SCHEDULER);
    when(extensionModel.getXmlDslModel()).thenReturn(XmlDslModel.builder().setPrefix("test-extension").build());
    mediator = new DefaultExecutionMediator(extensionModel, operationModel, new DefaultConnectionManager(muleContext), muleContext.getErrorTypeRepository());
    final ReconnectableConnectionProviderWrapper<Object> connectionProviderWrapper = new ReconnectableConnectionProviderWrapper<>(null, new ReconnectionConfig(true, new SimpleRetryPolicyTemplate(10, RETRY_COUNT)));
    initialiseIfNeeded(connectionProviderWrapper, true, muleContext);
    Optional<ConnectionProvider> connectionProvider = Optional.of(connectionProviderWrapper);
    when(configurationInstance.getConnectionProvider()).thenReturn(connectionProvider);
    when(exceptionEnricher.enrichException(exception)).thenReturn(new HeisenbergException(ERROR));
    setInterceptors((Interceptable) configurationInstance, configurationInterceptor1, configurationInterceptor2);
    setInterceptors((Interceptable) operationExecutor, operationInterceptor1, operationInterceptor2);
    defineOrder(configurationInterceptor1, configurationInterceptor2, operationInterceptor1, operationInterceptor2);
}
Also used : DefaultConnectionManager(org.mule.runtime.core.internal.connection.DefaultConnectionManager) SimpleRetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate) DefaultExecutionMediator(org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) ReconnectionConfig(org.mule.runtime.core.internal.retry.ReconnectionConfig) ReconnectableConnectionProviderWrapper(org.mule.runtime.core.internal.connection.ReconnectableConnectionProviderWrapper) ConnectionProvider(org.mule.runtime.api.connection.ConnectionProvider) Before(org.junit.Before)

Aggregations

DefaultConnectionManager (org.mule.runtime.core.internal.connection.DefaultConnectionManager)2 DefaultExecutionMediator (org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator)2 HeisenbergException (org.mule.test.heisenberg.extension.exception.HeisenbergException)2 Before (org.junit.Before)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 ConnectionException (org.mule.runtime.api.connection.ConnectionException)1 ConnectionProvider (org.mule.runtime.api.connection.ConnectionProvider)1 MuleException (org.mule.runtime.api.exception.MuleException)1 SimpleRetryPolicyTemplate (org.mule.runtime.core.api.retry.policy.SimpleRetryPolicyTemplate)1 ReconnectableConnectionProviderWrapper (org.mule.runtime.core.internal.connection.ReconnectableConnectionProviderWrapper)1 ReconnectionConfig (org.mule.runtime.core.internal.retry.ReconnectionConfig)1 SmallTest (org.mule.tck.size.SmallTest)1