use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class FlowProgressResponseConverterTest method testConvertList.
@Test
public void testConvertList() {
// GIVEN
given(flowProgressHolder.getProgressPercentageForState(TestFlowConfig.class.getCanonicalName(), "FINISHED")).willReturn(100);
given(flowProgressHolder.getProgressPercentageForState(TestFlowConfig.class.getCanonicalName(), "CANCELLED")).willReturn(100);
// WHEN
List<FlowProgressResponse> responses = underTest.convertList(createFlowLogs(true), DUMMY_CRN);
FlowProgressResponse latestResponse = responses.get(0);
FlowProgressResponse firstResponse = responses.get(1);
// THEN
assertEquals(2, responses.size());
assertEquals("flow2", latestResponse.getFlowId());
assertEquals(2, latestResponse.getTransitions().size());
assertEquals(0.002, latestResponse.getElapsedTimeInSeconds());
assertEquals(100, latestResponse.getProgress());
assertEquals("flow1", firstResponse.getFlowId());
assertEquals(2, firstResponse.getTransitions().size());
assertEquals(0.001, firstResponse.getElapsedTimeInSeconds());
assertEquals(100, firstResponse.getProgress());
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class FlowProgressResponseConverterTest method testConvertWithEmptyList.
@Test
public void testConvertWithEmptyList() {
// GIVEN
// WHEN
FlowProgressResponse response = underTest.convert(new ArrayList<>(), DUMMY_CRN);
// THEN
assertNull(response.getFlowId());
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class FlowProgressResponseConverterTest method testConvertWithNull.
@Test
public void testConvertWithNull() {
// GIVEN
// WHEN
FlowProgressResponse response = underTest.convert(null, DUMMY_CRN);
// THEN
assertNull(response.getFlowId());
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationView.
@Test
public void testCreateOperationView() {
// GIVEN
Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("SUCCESSFUL", true).get());
OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(MAX_PROGRESS, operationView.getProgress());
assertEquals(OperationProgressStatus.FINISHED, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.
the class FlowService method getLastFlowProgressByResourceCrn.
public FlowProgressResponse getLastFlowProgressByResourceCrn(String resourceCrn) {
checkState(Crn.isCrn(resourceCrn));
LOGGER.info("Getting flow logs (progress) by resource crn {}", resourceCrn);
List<FlowLog> flowLogs = flowLogDBService.getFlowLogsByResourceCrnOrName(resourceCrn);
FlowProgressResponse response = flowProgressResponseConverter.convert(flowLogs, resourceCrn);
if (StringUtils.isBlank(response.getFlowId())) {
throw new NotFoundException(String.format("Not found any historical flow data for requested resource (crn: %s)", resourceCrn));
}
return flowProgressResponseConverter.convert(flowLogs, resourceCrn);
}
Aggregations