use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class FlowOperationStatisticsServiceTest method createFlowProgressResponse.
private FlowProgressResponse createFlowProgressResponse() {
FlowProgressResponse response = new FlowProgressResponse();
response.setProgress(DUMMY_PROGRESS);
response.setFinalized(false);
response.setFlowId("flowid");
response.setCreated(new Date().getTime());
return response;
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse 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.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class FlowProgressResponseConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
given(flowProgressHolder.getProgressPercentageForState(TestFlowConfig.class.getCanonicalName(), "FINISHED")).willReturn(100);
// WHEN
FlowProgressResponse response = underTest.convert(createFlowLogs(false), DUMMY_CRN);
// THEN
assertEquals("flow1", response.getFlowId());
assertEquals(2, response.getTransitions().size());
assertEquals(0.001, response.getElapsedTimeInSeconds());
assertEquals(100, response.getProgress());
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationViewWithFailedState.
@Test
public void testCreateOperationViewWithFailedState() {
// GIVEN
Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("FAILED", true).get());
OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(MAX_PROGRESS, operationView.getProgress());
assertEquals(OperationProgressStatus.FAILED, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationViewWithPendingState.
@Test
public void testCreateOperationViewWithPendingState() {
// GIVEN
Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("SUCCESSFUL", false).get());
OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(IN_PROGRESS_FROM_HISTORY, operationView.getProgress());
assertEquals(OperationProgressStatus.RUNNING, operationView.getProgressStatus());
}
Aggregations