Search in sources :

Example 31 with FlowLog

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

the class FlowServiceTest method testGetLastFlowByResourceCrn.

@Test
public void testGetLastFlowByResourceCrn() {
    when(flowLogDBService.getLastFlowLogByResourceCrnOrName(anyString())).thenReturn(new FlowLog());
    underTest.getLastFlowByResourceCrn(Crn.fromString(STACK_CRN).toString());
    verify(flowLogDBService).getLastFlowLogByResourceCrnOrName(anyString());
    verify(flowLogConverter).convert(any());
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) Test(org.junit.Test)

Example 32 with FlowLog

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

the class FlowServiceTest method testGetLastFlowByResourceName.

@Test
public void testGetLastFlowByResourceName() {
    when(flowLogDBService.getLastFlowLogByResourceCrnOrName(anyString())).thenReturn(new FlowLog());
    underTest.getLastFlowByResourceName("myLittleSdx");
    verify(flowLogDBService).getLastFlowLogByResourceCrnOrName(anyString());
    verify(flowLogConverter).convert(any());
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) Test(org.junit.Test)

Example 33 with FlowLog

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

the class FlowService method getLastFlowProgressByResourceCrnAndType.

public <T extends AbstractFlowConfiguration> Optional<FlowProgressResponse> getLastFlowProgressByResourceCrnAndType(String resourceCrn, ClassValue classValue) {
    checkState(Crn.isCrn(resourceCrn));
    LOGGER.info("Getting flow logs (progress) by resource crn {} and type {}", resourceCrn, classValue.getClassValue().getCanonicalName());
    List<FlowLog> flowLogs = flowLogDBService.getFlowLogsByCrnAndType(resourceCrn, classValue);
    FlowProgressResponse response = flowProgressResponseConverter.convert(flowLogs, resourceCrn);
    if (StringUtils.isBlank(response.getFlowId())) {
        LOGGER.debug("Not found any historical flow data for requested resource (crn: {})", resourceCrn);
        return Optional.empty();
    }
    return Optional.ofNullable(flowProgressResponseConverter.convert(flowLogs, resourceCrn));
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse)

Example 34 with FlowLog

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

the class FlowServiceTest method pendingFlowLog.

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

Example 35 with FlowLog

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

the class FlowLogDBServiceTest method updateLastFlowLogPayload.

@Test
public void updateLastFlowLogPayload() {
    FlowLog flowLog = new FlowLog();
    flowLog.setId(ID);
    Payload payload = mock(Selectable.class);
    Map<Object, Object> variables = Map.of("repeated", 2);
    underTest.updateLastFlowLogPayload(flowLog, payload, variables);
    ArgumentCaptor<FlowLog> flowLogCaptor = ArgumentCaptor.forClass(FlowLog.class);
    verify(flowLogRepository, times(1)).save(flowLogCaptor.capture());
    FlowLog savedFlowLog = flowLogCaptor.getValue();
    assertEquals(flowLog.getId(), savedFlowLog.getId());
    String payloadJson = JsonWriter.objectToJson(payload, Map.of());
    String variablesJson = JsonWriter.objectToJson(variables, Map.of());
    assertEquals(payloadJson, savedFlowLog.getPayload());
    assertEquals(variablesJson, savedFlowLog.getVariables());
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) Payload(com.sequenceiq.cloudbreak.common.event.Payload) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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