use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class ModuleOperationMessageProcessorChainFactoryBean method doGetObject.
@Override
public MessageProcessorChain doGetObject() throws Exception {
MessageProcessorChainBuilder builder = getBuilderInstance();
for (Object processor : processors) {
if (processor instanceof Processor) {
builder.chain((Processor) processor);
} else {
throw new IllegalArgumentException(format("MessageProcessorBuilder should only have MessageProcessor's or MessageProcessorBuilder's configured. Found a %s", processor.getClass().getName()));
}
}
final MessageProcessorChain messageProcessorChain = newLazyProcessorChainBuilder((ModuleOperationMessageProcessorChainBuilder) builder, muleContext, () -> getProcessingStrategy(locator, getRootContainerLocation()).orElse(null));
messageProcessorChain.setAnnotations(getAnnotations());
messageProcessorChain.setMuleContext(muleContext);
return messageProcessorChain;
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class FlowRefFactoryBeanTestCase method createStaticFlowRefFactoryBean.
private FlowRefFactoryBean createStaticFlowRefFactoryBean(Processor target, Object targetBuilder) throws InitialisationException {
doReturn(false).when(expressionManager).isExpression(anyString());
if (targetBuilder != null) {
when(applicationContext.getBean(eq(STATIC_REFERENCED_FLOW))).thenReturn(targetBuilder);
} else {
when(applicationContext.getBean(eq(STATIC_REFERENCED_FLOW))).thenReturn(target);
}
if (target instanceof MessageProcessorChain) {
Processor processor = ((MessageProcessorChain) target).getMessageProcessors().get(0);
when(processor.apply(any())).thenAnswer(successAnswer());
} else {
when(target.apply(any())).thenAnswer(successAnswer());
}
return createFlowRefFactoryBean(STATIC_REFERENCED_FLOW);
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class MessageProcessorsTestCase method createChain.
private Processor createChain(ReactiveProcessor processor) throws InitialisationException {
MessageProcessorChain chain = newChain(Optional.empty(), new ReactiveProcessorToProcessorAdaptor(processor));
chain.setMuleContext(muleContext);
return chain;
}
use of org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain in project mule by mulesoft.
the class ScatterGatherRouterTestCase 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 = testEvent();
MessageProcessorChain route1 = newChain(empty(), event -> event);
MessageProcessorChain route2 = newChain(empty(), event -> event);
router.setRoutes(asList(route1, route2));
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(Map.class));
assertThat(Map.class.isAssignableFrom(typedValue.getDataType().getType()), is(true));
Map<String, Message> resultMap = (Map<String, Message>) typedValue.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 routingPairs.
@Test
@Description("RoutingPairs are created for each route configured. Each RoutingPair has the same input event.")
public void routingPairs() throws Exception {
CoreEvent event = mock(CoreEvent.class);
MessageProcessorChain route1 = mock(MessageProcessorChain.class);
MessageProcessorChain route2 = mock(MessageProcessorChain.class);
MessageProcessorChain route3 = mock(MessageProcessorChain.class);
router.setRoutes(asList(route1, route2, route3));
List<RoutingPair> routingPairs = from(router.getRoutingPairs(event)).collectList().block();
assertThat(routingPairs, hasSize(3));
assertThat(routingPairs.get(0), equalTo(of(event, route1)));
assertThat(routingPairs.get(1), equalTo(of(event, route2)));
assertThat(routingPairs.get(2), equalTo(of(event, route3)));
}
Aggregations