Search in sources :

Example 1 with APPLE_FLOW

use of org.mule.tck.MuleTestUtils.APPLE_FLOW in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method testAll.

@Test
public void testAll() throws Exception {
    createAndRegisterFlow(muleContext, APPLE_FLOW, componentLocator);
    ScatterGatherRouter scatterGatherRouter = new ScatterGatherRouter();
    scatterGatherRouter.setAnnotations(getAppleFlowComponentLocationAnnotations());
    scatterGatherRouter.setRoutes(asList(newChain(empty(), getAppendingMP("1")), newChain(empty(), getAppendingMP("2")), newChain(empty(), getAppendingMP("3"))));
    initialiseIfNeeded(scatterGatherRouter, true, muleContext);
    scatterGatherRouter.start();
    CoreEvent event = getTestEventUsingFlow("0");
    final MessageProcessorChain chain = newChain(empty(), singletonList(scatterGatherRouter));
    Message result = process(chain, CoreEvent.builder(event).message(event.getMessage()).build()).getMessage();
    assertThat(result.getPayload().getValue(), instanceOf(Map.class));
    Map<String, Message> resultMessage = (Map<String, Message>) result.getPayload().getValue();
    assertThat(resultMessage.values().stream().map(msg -> msg.getPayload().getValue()).collect(toList()).toArray(), is(equalTo(new String[] { "01", "02", "03" })));
    scatterGatherRouter.stop();
    scatterGatherRouter.dispose();
}
Also used : Flow.builder(org.mule.runtime.core.api.construct.Flow.builder) MessageProcessors.newChain(org.mule.runtime.core.privileged.processor.MessageProcessors.newChain) Message(org.mule.runtime.api.message.Message) Assert.assertNotSame(org.junit.Assert.assertNotSame) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ProcessingStrategyFactory(org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory) ExceptionContextProvider(org.mule.runtime.core.api.execution.ExceptionContextProvider) ScatterGatherRouter(org.mule.runtime.core.internal.routing.ScatterGatherRouter) Collections.singletonList(java.util.Collections.singletonList) MuleContextAware(org.mule.runtime.core.api.context.MuleContextAware) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) SmallTest(org.mule.tck.size.SmallTest) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays.asList(java.util.Arrays.asList) ReactorProcessingStrategyFactory(org.mule.runtime.core.internal.processor.strategy.ReactorProcessingStrategyFactory) NON_BLOCKING(org.mule.tck.junit4.AbstractReactiveProcessorTestCase.Mode.NON_BLOCKING) After(org.junit.After) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) REGISTRY_KEY(org.mule.runtime.api.component.location.ConfigurationComponentLocator.REGISTRY_KEY) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) LifecycleUtils.stopIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.stopIfNeeded) CPU_INTENSIVE(org.mule.runtime.core.api.processor.ReactiveProcessor.ProcessingType.CPU_INTENSIVE) PrivilegedMuleContext(org.mule.runtime.core.privileged.PrivilegedMuleContext) Parameterized(org.junit.runners.Parameterized) BLOCKING(org.mule.tck.junit4.AbstractReactiveProcessorTestCase.Mode.BLOCKING) Collection(java.util.Collection) MessageProcessorNotification(org.mule.runtime.api.notification.MessageProcessorNotification) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Message.of(org.mule.runtime.api.message.Message.of) MuleTestUtils.createAndRegisterFlow(org.mule.tck.MuleTestUtils.createAndRegisterFlow) Flow(org.mule.runtime.core.api.construct.Flow) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) ProactorStreamProcessingStrategyFactory(org.mule.runtime.core.internal.processor.strategy.ProactorStreamProcessingStrategyFactory) Matchers.any(org.mockito.Matchers.any) Lifecycle(org.mule.runtime.api.lifecycle.Lifecycle) List(java.util.List) AbstractReactiveProcessorTestCase(org.mule.tck.junit4.AbstractReactiveProcessorTestCase) Assert.assertFalse(org.junit.Assert.assertFalse) MESSAGE_PROCESSOR_PRE_INVOKE(org.mule.runtime.api.notification.MessageProcessorNotification.MESSAGE_PROCESSOR_PRE_INVOKE) ErrorType(org.mule.runtime.api.message.ErrorType) AbstractInterceptingMessageProcessor(org.mule.runtime.core.privileged.processor.AbstractInterceptingMessageProcessor) Mockito.mock(org.mockito.Mockito.mock) ErrorTypeLocator(org.mule.runtime.core.privileged.exception.ErrorTypeLocator) Optional.empty(java.util.Optional.empty) MessageProcessorBuilder(org.mule.runtime.core.privileged.processor.MessageProcessorBuilder) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Flux.from(reactor.core.publisher.Flux.from) InternalProcessor(org.mule.runtime.core.privileged.processor.InternalProcessor) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) Mockito.spy(org.mockito.Mockito.spy) Processor(org.mule.runtime.core.api.processor.Processor) DirectProcessingStrategyFactory(org.mule.runtime.core.internal.processor.strategy.DirectProcessingStrategyFactory) MESSAGE_PROCESSOR_POST_INVOKE(org.mule.runtime.api.notification.MessageProcessorNotification.MESSAGE_PROCESSOR_POST_INVOKE) ChoiceRouter(org.mule.runtime.core.internal.routing.ChoiceRouter) ArrayList(java.util.ArrayList) Assert.assertSame(org.junit.Assert.assertSame) MuleContext(org.mule.runtime.core.api.MuleContext) MuleException(org.mule.runtime.api.exception.MuleException) ObjectUtils(org.mule.runtime.core.api.util.ObjectUtils) Collections.singletonMap(java.util.Collections.singletonMap) LOCATION_KEY(org.mule.runtime.api.component.AbstractComponent.LOCATION_KEY) ExpectedException(org.junit.rules.ExpectedException) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Before(org.junit.Before) BlockingProcessingStrategyFactory(org.mule.runtime.core.internal.processor.strategy.BlockingProcessingStrategyFactory) MessageProcessors.processToApply(org.mule.runtime.core.privileged.processor.MessageProcessors.processToApply) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Publisher(org.reactivestreams.Publisher) EventContextFactory.create(org.mule.runtime.core.api.event.EventContextFactory.create) Assert.assertTrue(org.junit.Assert.assertTrue) MessageProcessorNotificationListener(org.mule.runtime.api.notification.MessageProcessorNotificationListener) SchedulerService(org.mule.runtime.api.scheduler.SchedulerService) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) APPLE_FLOW(org.mule.tck.MuleTestUtils.APPLE_FLOW) TransactionAwareWorkQueueProcessingStrategyFactory(org.mule.runtime.core.internal.processor.strategy.TransactionAwareWorkQueueProcessingStrategyFactory) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) Collectors.toList(java.util.stream.Collectors.toList) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) WorkQueueProcessingStrategyFactory(org.mule.runtime.core.internal.processor.strategy.WorkQueueProcessingStrategyFactory) RandomStringUtils.randomNumeric(org.apache.commons.lang3.RandomStringUtils.randomNumeric) ComponentLocation(org.mule.runtime.api.component.location.ComponentLocation) MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) Assert.assertEquals(org.junit.Assert.assertEquals) InternalEvent(org.mule.runtime.core.internal.message.InternalEvent) ScatterGatherRouter(org.mule.runtime.core.internal.routing.ScatterGatherRouter) Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional.empty (java.util.Optional.empty)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors.toList (java.util.stream.Collectors.toList)1 RandomStringUtils.randomNumeric (org.apache.commons.lang3.RandomStringUtils.randomNumeric)1 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)1 CoreMatchers.instanceOf (org.hamcrest.CoreMatchers.instanceOf)1 CoreMatchers.not (org.hamcrest.CoreMatchers.not)1 CoreMatchers.nullValue (org.hamcrest.CoreMatchers.nullValue)1 IsCollectionWithSize.hasSize (org.hamcrest.collection.IsCollectionWithSize.hasSize)1 Is.is (org.hamcrest.core.Is.is)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1