Search in sources :

Example 1 with FlowEventChainFactory

use of com.sequenceiq.flow.core.chain.FlowEventChainFactory in project cloudbreak by hortonworks.

the class Flow2InitializerTest method testInitialize.

@Test
public void testInitialize() {
    List<FlowConfiguration<?>> flowConfigs = new ArrayList<>();
    flowConfigs.add(new HelloWorldFlowConfig());
    given(this.flowConfigs.stream()).willReturn(flowConfigs.stream());
    given(flowEventChainFactory.initEvent()).willReturn("OTHER_SELECTOR");
    List<FlowEventChainFactory<?>> flowChainFactories = new ArrayList<>();
    flowChainFactories.add(flowEventChainFactory);
    given(this.flowChainFactories.stream()).willReturn(flowChainFactories.stream());
    underTest.init();
    verify(reactor, times(1)).on(any(Selector.class), any(Consumer.class));
}
Also used : Consumer(reactor.fn.Consumer) ArrayList(java.util.ArrayList) FlowEventChainFactory(com.sequenceiq.flow.core.chain.FlowEventChainFactory) HelloWorldFlowConfig(com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig) Selector(reactor.bus.selector.Selector) Test(org.junit.jupiter.api.Test)

Example 2 with FlowEventChainFactory

use of com.sequenceiq.flow.core.chain.FlowEventChainFactory in project cloudbreak by hortonworks.

the class Flow2InitializerTest method testInitializeFailsWithFlowSelectorIsFlowChainSelector.

@Test
public void testInitializeFailsWithFlowSelectorIsFlowChainSelector() {
    List<FlowConfiguration<?>> flowConfigs = new ArrayList<>();
    flowConfigs.add(new HelloWorldFlowConfig());
    given(this.flowConfigs.stream()).willReturn(flowConfigs.stream());
    given(flowEventChainFactory.initEvent()).willReturn(HelloWorldEvent.HELLOWORLD_TRIGGER_EVENT.name());
    List<FlowEventChainFactory<?>> flowChainFactories = new ArrayList<>();
    flowChainFactories.add(flowEventChainFactory);
    given(this.flowChainFactories.stream()).willReturn(flowChainFactories.stream());
    RuntimeException runtimeException = Assertions.assertThrows(RuntimeException.class, () -> underTest.init());
    assertEquals("HELLOWORLD_TRIGGER_EVENT is a flow selector and a flow chain selector. It should be only in one category.", runtimeException.getMessage());
    verify(reactor, times(0)).on(any(Selector.class), any(Consumer.class));
}
Also used : Consumer(reactor.fn.Consumer) ArrayList(java.util.ArrayList) FlowEventChainFactory(com.sequenceiq.flow.core.chain.FlowEventChainFactory) HelloWorldFlowConfig(com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig) Selector(reactor.bus.selector.Selector) Test(org.junit.jupiter.api.Test)

Aggregations

FlowEventChainFactory (com.sequenceiq.flow.core.chain.FlowEventChainFactory)2 HelloWorldFlowConfig (com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 Selector (reactor.bus.selector.Selector)2 Consumer (reactor.fn.Consumer)2