use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class ForeachTestCase method batchSize.
@Test
public void batchSize() throws Exception {
Foreach foreachMp = createForeach();
List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
foreachMp.setMessageProcessors(processors);
foreachMp.setBatchSize(2);
initialiseIfNeeded(foreachMp, muleContext);
foreachMp.process(eventBuilder(muleContext).message(of(asList(1, 2, 3))).build());
assertThat(processedEvents, hasSize(2));
assertThat(((PrivilegedEvent) processedEvents.get(0)).getMessageAsString(muleContext), is("[1, 2]:foo:zas"));
assertThat(((PrivilegedEvent) processedEvents.get(1)).getMessageAsString(muleContext), is("[3]:foo:zas"));
}
use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class RoundRobinTestCase method usesFirstRouteOnFirstRequest.
@Test
public void usesFirstRouteOnFirstRequest() throws Exception {
RoundRobin roundRobin = new RoundRobin();
roundRobin.setAnnotations(getAppleFlowComponentLocationAnnotations());
List<Processor> routes = new ArrayList<>(2);
Processor route1 = mock(Processor.class, "route1");
when(route1.apply(any(Publisher.class))).then(invocation -> invocation.getArguments()[0]);
routes.add(route1);
Processor route2 = mock(Processor.class, "route2");
when(route2.apply(any(Publisher.class))).then(invocation -> invocation.getArguments()[0]);
routes.add(route2);
roundRobin.setRoutes(new ArrayList<>(routes));
initialiseIfNeeded(roundRobin, muleContext);
Message message = of(singletonList(TEST_MESSAGE));
roundRobin.process(eventBuilder(muleContext).message(message).build());
verify(route1).apply(any(Publisher.class));
verify(route2, never()).apply(any(Publisher.class));
}
use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class FirstSuccessfulTestCase method testRouteReturnsNullMessage.
@Test
public void testRouteReturnsNullMessage() throws Exception {
Processor nullEventMp = event -> CoreEvent.builder(event).message(null).build();
FirstSuccessful fs = createFirstSuccessfulRouter(nullEventMp);
fs.setAnnotations(getAppleFlowComponentLocationAnnotations());
fs.initialise();
try {
fs.process(testEvent());
fail("Exception expected");
} catch (CouldNotRouteOutboundMessageException e) {
// this one was expected
}
}
Aggregations