use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class ScatterGatherRouterTestCase method defaultTarget.
@Test
@Description("By default the router result populates the outgoing message payload.")
public void defaultTarget() throws Exception {
CoreEvent original = testEvent();
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();
Event result = router.process(original);
assertThat(result.getMessage().getPayload().getValue(), instanceOf(Map.class));
Map<String, Message> resultMap = (Map) result.getMessage().getPayload().getValue();
assertThat(resultMap.values(), hasSize(2));
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class ScatterGatherRouterTestCase 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 = testEvent();
MessageProcessorChain route1 = newChain(empty(), event -> event);
MessageProcessorChain route2 = newChain(empty(), event -> event);
router.setRoutes(asList(route1, route2));
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(Map.class));
Map<String, Message> resultMap = (Map) ((Message) result.getVariables().get(variableName).getValue()).getPayload().getValue();
assertThat(resultMap.values(), hasSize(2));
}
Aggregations