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());
}
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());
}
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));
}
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;
}
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());
}
Aggregations