Search in sources :

Example 11 with RoutingPair

use of org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair in project mule by mulesoft.

the class JoinOnlyForkJoinStrategyTestCase method joinOnly.

@Test
@Description("This strategy waits for all routes to return and then returns the original event.")
public void joinOnly() throws Throwable {
    CoreEvent original = testEvent();
    Processor processor1 = createProcessorSpy(of(1));
    Processor processor2 = createProcessorSpy(of(2));
    Processor processor3 = createProcessorSpy(of(3));
    RoutingPair pair1 = createRoutingPair(processor1);
    RoutingPair pair2 = createRoutingPair(processor2);
    RoutingPair pair3 = createRoutingPair(processor3);
    CoreEvent result = invokeStrategyBlocking(strategy, original, asList(pair1, pair2, pair3));
    assertThat(result, is(original));
    verify(processor1, times(1)).process(any(CoreEvent.class));
    verify(processor2, times(1)).process(any(CoreEvent.class));
    verify(processor2, times(1)).process(any(CoreEvent.class));
}
Also used : Processor(org.mule.runtime.core.api.processor.Processor) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) RoutingPair(org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 12 with RoutingPair

use of org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair 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)));
}
Also used : MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) RoutingPair(org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)12 Test (org.junit.Test)12 RoutingPair (org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair)12 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)9 Processor (org.mule.runtime.core.api.processor.Processor)7 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)6 InternalProcessor (org.mule.runtime.core.privileged.processor.InternalProcessor)6 Message (org.mule.runtime.api.message.Message)5 CompositeRoutingException (org.mule.runtime.core.privileged.routing.CompositeRoutingException)4 RoutingResult (org.mule.runtime.core.privileged.routing.RoutingResult)4 List (java.util.List)3 TimeoutException (java.util.concurrent.TimeoutException)3 Arrays.asList (java.util.Arrays.asList)2 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)2 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)2 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)2 Feature (io.qameta.allure.Feature)1 MAX_VALUE (java.lang.Integer.MAX_VALUE)1 Thread.sleep (java.lang.Thread.sleep)1 ArrayList (java.util.ArrayList)1