use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategy in project mule by mulesoft.
the class DefaultFlowBuilderTestCase method buildsFullFlow.
@Test
public void buildsFullFlow() throws Exception {
Processor processor1 = mock(Processor.class);
Processor processor2 = mock(Processor.class);
List<Processor> messageProcessors = new ArrayList<>();
messageProcessors.add(processor1);
messageProcessors.add(processor2);
MessageSource messageSource = mock(MessageSource.class);
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
FlowExceptionHandler exceptionListener = mock(FlowExceptionHandler.class);
Flow flow = flowBuilder.processors(messageProcessors).source(messageSource).processingStrategyFactory(processingStrategyFactory).messagingExceptionHandler(exceptionListener).build();
assertThat(flow.getName(), equalTo(FLOW_NAME));
assertThat(flow.getMuleContext(), is(muleContext));
assertThat(flow.getProcessors(), contains(processor1, processor2));
assertThat(flow.getSource(), is(messageSource));
assertThat(flow.getExceptionListener(), is(exceptionListener));
assertThat(flow.getProcessingStrategy(), sameInstance(processingStrategy));
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategy in project mule by mulesoft.
the class FlowProcessingStrategyTestCase method fixedProcessingStrategyIsHonoured.
@Test
public void fixedProcessingStrategyIsHonoured() throws Exception {
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
createFlow(processingStrategyFactory);
flow.initialise();
assertThat(flow.getProcessingStrategy(), is(sameInstance(processingStrategy)));
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategy in project mule by mulesoft.
the class FlowProcessingStrategyTestCase method defaultProcessingStrategyInConfigIsHonoured.
@Test
public void defaultProcessingStrategyInConfigIsHonoured() throws Exception {
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
when(configuration.getDefaultProcessingStrategyFactory()).thenReturn(processingStrategyFactory);
createFlow(null);
flow.initialise();
assertThat(flow.getProcessingStrategy(), is(sameInstance(processingStrategy)));
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategy in project mule by mulesoft.
the class DefaultFlowTestCase method lifecycleOrder.
@Test
public void lifecycleOrder() throws MuleException {
Sink sink = mock(Sink.class, withSettings().extraInterfaces(Disposable.class));
Processor processor = mock(Processor.class, withSettings().extraInterfaces(Startable.class, Stoppable.class));
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class, withSettings().extraInterfaces(Startable.class, Stoppable.class));
when(processingStrategy.createSink(any(FlowConstruct.class), any(ReactiveProcessor.class))).thenReturn(sink);
flow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext).source(directInboundMessageSource).processors(singletonList(processor)).processingStrategyFactory((muleContext, s) -> processingStrategy).build();
flow.initialise();
flow.start();
InOrder inOrder = inOrder(sink, processor, processingStrategy);
inOrder.verify((Startable) processingStrategy).start();
inOrder.verify(processingStrategy).createSink(any(FlowConstruct.class), any(ReactiveProcessor.class));
inOrder.verify((Startable) processor).start();
flow.stop();
inOrder.verify((Disposable) sink).dispose();
inOrder.verify((Stoppable) processor).stop();
inOrder.verify((Stoppable) processingStrategy).stop();
}
use of org.mule.runtime.core.api.processor.strategy.ProcessingStrategy in project mule by mulesoft.
the class FlowProcessingStrategyTestCase method fixedProcessingStrategyTakesPrecedenceOverConfig.
@Test
public void fixedProcessingStrategyTakesPrecedenceOverConfig() throws Exception {
ProcessingStrategyFactory configProcessingStrategyFactory = mock(ProcessingStrategyFactory.class);
when(configuration.getDefaultProcessingStrategyFactory()).thenReturn(configProcessingStrategyFactory);
ProcessingStrategyFactory processingStrategyFactory = mock(ProcessingStrategyFactory.class);
ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class);
when(processingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
createFlow(processingStrategyFactory);
flow.initialise();
assertThat(flow.getProcessingStrategy(), is(sameInstance(processingStrategy)));
}
Aggregations