use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class SplitAggregateScopeTestCase method customTargetDefaultPayload.
@Test
@Description("When a custom target is configured the router result is set in a variable and the input event is output.")
public void customTargetDefaultPayload() throws Exception {
final String variableName = "foo";
CoreEvent original = createListEvent();
MessageProcessorChain nested = newChain(empty(), event -> event);
nested.setMuleContext(muleContext);
router.setMessageProcessors(singletonList(nested));
router.setTarget(variableName);
muleContext.getInjector().inject(router);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
router.initialise();
Event result = router.process(original);
assertThat(result.getMessage(), equalTo(original.getMessage()));
final TypedValue<?> typedValue = result.getVariables().get(variableName);
assertThat(typedValue.getValue(), instanceOf(List.class));
assertThat(List.class.isAssignableFrom(typedValue.getDataType().getType()), is(true));
List<Message> resultList = (List<Message>) typedValue.getValue();
assertThat(resultList, hasSize(2));
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class SplitAggregateScopeTestCase method defaultTarget.
@Test
@Description("By default the router result populates the outgoing message payload.")
public void defaultTarget() throws Exception {
CoreEvent original = createListEvent();
MessageProcessorChain nested = newChain(empty(), event -> event);
nested.setMuleContext(muleContext);
router.setMessageProcessors(singletonList(nested));
muleContext.getInjector().inject(router);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
router.initialise();
Event result = router.process(original);
assertThat(result.getMessage().getPayload().getValue(), instanceOf(List.class));
List<Message> resultList = (List<Message>) result.getMessage().getPayload().getValue();
assertThat(resultList, hasSize(2));
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class ScatterGatherRouterTestCase method consumablePayload.
@Test
@Description("Consumable payloads are not supported.")
public void consumablePayload() throws Exception {
MessageProcessorChain route1 = newChain(empty(), event -> event);
MessageProcessorChain route2 = newChain(empty(), event -> event);
router.setRoutes(asList(route1, route2));
muleContext.getInjector().inject(router);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
router.initialise();
expectedException.expect(instanceOf(MuleRuntimeException.class));
router.process(CoreEvent.builder(testEvent()).message(Message.of(new StringBufferInputStream(TEST_PAYLOAD))).build());
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class SplitAggregateScopeTestCase method customTargetMessage.
@Test
@Description("When a custom target is configured the router result is set in a variable and the input event is output.")
public void customTargetMessage() throws Exception {
final String variableName = "foo";
CoreEvent original = createListEvent();
MessageProcessorChain nested = newChain(empty(), event -> event);
nested.setMuleContext(muleContext);
router.setMessageProcessors(singletonList(nested));
router.setTarget(variableName);
router.setTargetValue("#[message]");
muleContext.getInjector().inject(router);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
router.initialise();
Event result = router.process(original);
assertThat(result.getMessage(), equalTo(original.getMessage()));
assertThat(((Message) result.getVariables().get(variableName).getValue()).getPayload().getValue(), instanceOf(List.class));
List<Message> resultList = (List<Message>) ((Message) result.getVariables().get(variableName).getValue()).getPayload().getValue();
assertThat(resultList, hasSize(2));
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class ChoiceRouterTestCase method testAddAndDeleteRoute.
@Test
public void testAddAndDeleteRoute() throws Exception {
MessageProcessorChain mp = newChain(empty(), new TestMessageProcessor("bar"));
choiceRouter.addRoute(payloadZapExpression(), mp);
choiceRouter.removeRoute(mp);
choiceRouter.setRouterStatistics(new RouterStatistics(TYPE_OUTBOUND));
choiceRouter.setMuleContext(muleContext);
choiceRouter.initialise();
CoreEvent inputEvent = zapEvent();
assertThat(process(choiceRouter, inputEvent), is(inputEvent));
}
Aggregations