use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class SetPayloadMessageProcessorTestCase method setUp.
@Before
public void setUp() throws Exception {
setPayloadMessageProcessor = new SetPayloadMessageProcessor();
muleContext = mock(MuleContext.class);
setPayloadMessageProcessor.setMuleContext(muleContext);
expressionManager = mock(ExtendedExpressionManager.class);
when(muleContext.getExpressionManager()).thenReturn(expressionManager);
when(muleContext.getConfiguration()).thenReturn(mock(MuleConfiguration.class));
when(expressionManager.parse(anyString(), any(CoreEvent.class), any(ComponentLocation.class))).thenAnswer(invocation -> (String) invocation.getArguments()[0]);
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class DefaultMessageProcessorChainTestCase method testAll.
@Test
public void testAll() throws Exception {
createAndRegisterFlow(muleContext, APPLE_FLOW, componentLocator);
ScatterGatherRouter scatterGatherRouter = new ScatterGatherRouter();
scatterGatherRouter.setAnnotations(getAppleFlowComponentLocationAnnotations());
scatterGatherRouter.setRoutes(asList(newChain(empty(), getAppendingMP("1")), newChain(empty(), getAppendingMP("2")), newChain(empty(), getAppendingMP("3"))));
initialiseIfNeeded(scatterGatherRouter, true, muleContext);
scatterGatherRouter.start();
CoreEvent event = getTestEventUsingFlow("0");
final MessageProcessorChain chain = newChain(empty(), singletonList(scatterGatherRouter));
Message result = process(chain, CoreEvent.builder(event).message(event.getMessage()).build()).getMessage();
assertThat(result.getPayload().getValue(), instanceOf(Map.class));
Map<String, Message> resultMessage = (Map<String, Message>) result.getPayload().getValue();
assertThat(resultMessage.values().stream().map(msg -> msg.getPayload().getValue()).collect(toList()).toArray(), is(equalTo(new String[] { "01", "02", "03" })));
scatterGatherRouter.stop();
scatterGatherRouter.dispose();
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class CompositeConverterTestCase method appliesTransformerChainOnMessage.
@Test
public void appliesTransformerChainOnMessage() throws Exception {
CompositeConverter compositeConverter = new CompositeConverter(mockConverterA, mockConverterB);
MuleContext muleContext = mock(MuleContext.class, RETURNS_DEEP_STUBS);
compositeConverter.setMuleContext(muleContext);
final CoreEvent event = testEvent();
ExtendedTransformationService transformationService = mock(ExtendedTransformationService.class);
doReturn(mock(Message.class)).when(transformationService).applyTransformers(any(), eq(event), eq(compositeConverter));
doReturn(transformationService).when(muleContext).getTransformationService();
compositeConverter.process(event);
verify(transformationService, times(1)).applyTransformers(eq(testEvent().getMessage()), eq(testEvent()), eq(compositeConverter));
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class CompositeConverterTestCase method setMuleContext.
@Test
public void setMuleContext() {
MuleContext mockMuleContext = mock(MuleContext.class);
CompositeConverter compositeConverter = new CompositeConverter(mockConverterA, mockConverterB);
compositeConverter.setMuleContext(mockMuleContext);
verify(mockConverterA, atLeastOnce()).setMuleContext(mockMuleContext);
verify(mockConverterB, atLeastOnce()).setMuleContext(mockMuleContext);
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class AbstractLifecycleManager method doOnConnectException.
protected void doOnConnectException(ConnectException ce) throws LifecycleException {
MuleContext muleContext = ((LegacyConnector) ce.getFailed()).getMuleContext();
muleContext.getExceptionListener().handleException(ce);
}
Aggregations