Search in sources :

Example 71 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class Flow2HandlerTest method testRestartFlowNotRestartable.

@Test
public void testRestartFlowNotRestartable() throws TransactionExecutionException {
    FlowLog flowLog = new FlowLog(STACK_ID, FLOW_ID, "START_STATE", true, StateStatus.SUCCESSFUL, OperationType.UNKNOWN);
    flowLog.setFlowType(ClassValue.of(String.class));
    flowLog.setPayloadType(ClassValue.of(TestPayload.class));
    when(flowLogService.findFirstByFlowIdOrderByCreatedDesc(FLOW_ID)).thenReturn(Optional.of(flowLog));
    underTest.restartFlow(FLOW_ID);
    verify(flowLogService, times(1)).terminate(STACK_ID, FLOW_ID);
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 72 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class Flow2HandlerTest method createFlowLog.

private FlowLog createFlowLog(String flowChainId) {
    FlowLog flowLog = new FlowLog(STACK_ID, FLOW_ID, "START_STATE", true, StateStatus.SUCCESSFUL, OperationType.UNKNOWN);
    flowLog.setFlowType(ClassValue.of(HelloWorldFlowConfig.class));
    flowLog.setVariables(JsonWriter.objectToJson(new HashMap<>()));
    flowLog.setFlowChainId(flowChainId);
    flowLog.setNextEvent(NEXT_EVENT);
    flowLog.setFlowTriggerUserCrn(FLOW_TRIGGER_USERCRN);
    return flowLog;
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) HashMap(java.util.HashMap) HelloWorldFlowConfig(com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig)

Example 73 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class Flow2HandlerTest method testRestartFlowNoRestartActionNoFlowChainId.

@Test
public void testRestartFlowNoRestartActionNoFlowChainId() throws TransactionExecutionException {
    FlowLog flowLog = createFlowLog(null);
    Payload payload = new TestPayload(STACK_ID);
    flowLog.setPayloadType(ClassValue.of(TestPayload.class));
    flowLog.setPayload(JsonWriter.objectToJson(payload));
    when(flowLogService.findFirstByFlowIdOrderByCreatedDesc(FLOW_ID)).thenReturn(Optional.of(flowLog));
    HelloWorldFlowConfig helloWorldFlowConfig = new HelloWorldFlowConfig();
    setUpFlowConfigCreateFlow(helloWorldFlowConfig);
    List<FlowConfiguration<?>> flowConfigs = Lists.newArrayList(helloWorldFlowConfig);
    ReflectionTestUtils.setField(underTest, "flowConfigs", flowConfigs);
    underTest.restartFlow(FLOW_ID);
    verify(flowChainHandler, never()).restoreFlowChain(FLOW_CHAIN_ID);
    verify(flowLogService, times(1)).terminate(STACK_ID, FLOW_ID);
    verify(defaultRestartAction, never()).restart(any(), any(), any(), any());
}
Also used : FlowConfiguration(com.sequenceiq.flow.core.config.FlowConfiguration) FlowLog(com.sequenceiq.flow.domain.FlowLog) Payload(com.sequenceiq.cloudbreak.common.event.Payload) HelloWorldFlowConfig(com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig) Test(org.junit.jupiter.api.Test)

Example 74 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class FlowServiceTest method flowLog.

private FlowLog flowLog(String currentState, String nextEvent, long created) {
    FlowLog flowLog = new FlowLog();
    flowLog.setCurrentState(currentState);
    flowLog.setNextEvent(nextEvent);
    flowLog.setCreated(created);
    flowLog.setStateStatus(StateStatus.SUCCESSFUL);
    flowLog.setFinalized(true);
    return flowLog;
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog)

Example 75 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class FlowLogDBServiceTest method getLastFlowLog.

@Test
public void getLastFlowLog() {
    FlowLog flowLog = new FlowLog();
    flowLog.setId(ID);
    Optional<FlowLog> flowLogOptional = Optional.of(flowLog);
    when(flowLogRepository.findFirstByFlowIdOrderByCreatedDesc(FLOW_ID)).thenReturn(flowLogOptional);
    Optional<FlowLog> lastFlowLog = underTest.getLastFlowLog(FLOW_ID);
    assertEquals(flowLogOptional, lastFlowLog);
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) Test(org.junit.Test)

Aggregations

FlowLog (com.sequenceiq.flow.domain.FlowLog)92 Test (org.junit.jupiter.api.Test)25 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)21 List (java.util.List)13 FlowConfiguration (com.sequenceiq.flow.core.config.FlowConfiguration)12 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)11 Mockito.times (org.mockito.Mockito.times)11 Mockito.verify (org.mockito.Mockito.verify)11 Mockito.when (org.mockito.Mockito.when)11 HelloWorldFlowConfig (com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig)10 Map (java.util.Map)10 UUID (java.util.UUID)10 Collectors (java.util.stream.Collectors)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 Clock (com.sequenceiq.cloudbreak.common.service.Clock)9 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)9 FlowRegister (com.sequenceiq.flow.core.FlowRegister)9 SecureRandom (java.security.SecureRandom)9 Random (java.util.Random)9