use of org.mule.runtime.core.internal.construct.DefaultFlowBuilder.DefaultFlow 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.internal.construct.DefaultFlowBuilder.DefaultFlow in project mule by mulesoft.
the class DefaultFlowFactoryBean method getObject.
@Override
public Flow getObject() throws Exception {
Builder flowBuilder = Flow.builder(name, muleContext).messagingExceptionHandler(exceptionListener).initialState(initialState);
flowBuilder.processors(messageProcessors != null ? messageProcessors : emptyList());
if (messageSource != null) {
flowBuilder.source(messageSource);
}
if (processingStrategyFactory != null) {
flowBuilder.processingStrategyFactory(processingStrategyFactory);
}
if (maxConcurrency != null) {
flowBuilder.maxConcurrency(maxConcurrency.intValue());
}
final DefaultFlow build = (DefaultFlow) flowBuilder.build();
build.setAnnotations(getAnnotations());
return build;
}
Aggregations