Search in sources :

Example 6 with HelloWorldFlowConfig

use of com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig in project cloudbreak by hortonworks.

the class Flow2ConfigTest method testFlowConfigurationMapInit.

@Test
public void testFlowConfigurationMapInit() {
    List<FlowConfiguration<?>> flowConfigs = new ArrayList<>();
    flowConfigs.add(new HelloWorldFlowConfig());
    flowConfigs.add(new TestFlowConfig());
    Map<String, FlowConfiguration<?>> flowConfigMap = underTest.flowConfigurationMap(flowConfigs);
    assertEquals("Not all flow type appeared in map!", countEvents(flowConfigs), flowConfigMap.size());
}
Also used : ArrayList(java.util.ArrayList) HelloWorldFlowConfig(com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig) Test(org.junit.Test)

Example 7 with HelloWorldFlowConfig

use of com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig in project cloudbreak by hortonworks.

the class Flow2ConfigTest method testRetryableEvents.

@Test
public void testRetryableEvents() {
    HelloWorldFlowConfig helloWorldFlowConfig = new HelloWorldFlowConfig();
    TestFlowConfig testFlowConfig = new TestFlowConfig();
    List<RetryableFlowConfiguration<?>> retryableFlowConfigurations = List.of(helloWorldFlowConfig, testFlowConfig);
    Set<String> retryableEvents = underTest.retryableEvents(retryableFlowConfigurations);
    Set<String> expected = Set.of(helloWorldFlowConfig.getRetryableEvent().event(), testFlowConfig.getRetryableEvent().event());
    assertEquals(expected, retryableEvents);
}
Also used : HelloWorldFlowConfig(com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig) Test(org.junit.Test)

Example 8 with HelloWorldFlowConfig

use of com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig 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 9 with HelloWorldFlowConfig

use of com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig 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

HelloWorldFlowConfig (com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig)9 Test (org.junit.jupiter.api.Test)6 Payload (com.sequenceiq.cloudbreak.common.event.Payload)4 ArrayList (java.util.ArrayList)4 FlowConfiguration (com.sequenceiq.flow.core.config.FlowConfiguration)3 FlowLog (com.sequenceiq.flow.domain.FlowLog)3 Test (org.junit.Test)3 FlowEventChainFactory (com.sequenceiq.flow.core.chain.FlowEventChainFactory)2 Selector (reactor.bus.selector.Selector)2 Consumer (reactor.fn.Consumer)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Event (reactor.bus.Event)1