use of org.mule.runtime.core.api.processor.Sink 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();
}
Aggregations