use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationDetailsPopulator method createOperationView.
public OperationView createOperationView(OperationFlowsView operationFlowsView, OperationResource resource, List<Class<?>> expectedTypeOrder) {
OperationView response = new OperationView();
response.setOperationType(operationFlowsView.getOperationType());
response.setOperationResource(resource);
response.setOperationId(operationFlowsView.getOperationId());
List<String> typeOrderList = CollectionUtils.isNotEmpty(expectedTypeOrder) ? expectedTypeOrder.stream().map(Class::getCanonicalName).collect(Collectors.toList()) : operationFlowsView.getTypeOrderList();
int expectedNumberOfFlows = typeOrderList.size();
Map<String, FlowProgressResponse> flowTypeProgressMap = operationFlowsView.getFlowTypeProgressMap();
List<Optional<FlowProgressResponse>> responseListToProcess = new ArrayList<>();
for (String typeName : typeOrderList) {
if (flowTypeProgressMap != null && flowTypeProgressMap.containsKey(typeName)) {
responseListToProcess.add(Optional.of(flowTypeProgressMap.get(typeName)));
} else {
responseListToProcess.add(Optional.empty());
}
}
populateOperationDetails(response, responseListToProcess, expectedNumberOfFlows, operationFlowsView.getProgressFromHistory());
return response;
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationViewWithoutFlows.
@Test
public void testCreateOperationViewWithoutFlows() {
// GIVEN
OperationFlowsView operationFlowsView = createOperationFlowsView(new HashMap<>());
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(DEFAULT_PROGRESS, operationView.getProgress());
assertEquals(OperationProgressStatus.UNKNOWN, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.operation.OperationView 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.operation.OperationView in project cloudbreak by hortonworks.
the class OperationServiceTest method testGetOperationProgressByResourceCrnWithDatahub.
@Test
public void testGetOperationProgressByResourceCrnWithDatahub() {
// GIVEN
given(flowService.getLastFlowOperationByResourceCrn(anyString())).willReturn(Optional.of(operationFlowsView));
given(operationFlowsView.getOperationType()).willReturn(OperationType.PROVISION);
given(operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.DATAHUB, EXPECTED_TYPE_LIST)).willReturn(new OperationView());
given(stackOperations.getStackByCrn(anyString())).willReturn(stack);
given(stack.getExternalDatabaseCreationType()).willReturn(DatabaseAvailabilityType.NON_HA);
given(databaseService.getRemoteDatabaseOperationProgress(any(), anyBoolean())).willReturn(Optional.of(remoteDatabaseOperationView));
// WHEN
OperationView result = underTest.getOperationProgressByResourceCrn(TEST_CLUSTER_CRN, true);
// THEN
assertEquals(remoteDatabaseOperationView, result.getSubOperations().get(OperationResource.REMOTEDB));
verify(databaseService, times(1)).getRemoteDatabaseOperationProgress(any(), anyBoolean());
verify(operationDetailsPopulator, times(1)).createOperationView(operationFlowsView, OperationResource.DATAHUB, EXPECTED_TYPE_LIST);
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class FlowOperationServiceTest method testGetOperationProgressByResourceCrn.
@Test
public void testGetOperationProgressByResourceCrn() {
// GIVEN
ProvisionFlowEventChainFactory provisionFlowEventChainFactory = new ProvisionFlowEventChainFactory();
FlowTriggerEventQueue eventQueue = provisionFlowEventChainFactory.createFlowTriggerEventQueue(new StackEvent(null, null));
given(flowService.getLastFlowOperationByResourceCrn(anyString())).willReturn(Optional.of(operationFlowsView));
given(operationFlowsView.getOperationType()).willReturn(OperationType.PROVISION);
given(operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.FREEIPA, EXPECTED_TYPE_LIST)).willReturn(new OperationView());
// WHEN
underTest.getOperationProgressByEnvironmentCrn(TEST_ENV_CRN, false);
// THEN
verify(operationDetailsPopulator, times(1)).createOperationView(operationFlowsView, OperationResource.FREEIPA, EXPECTED_TYPE_LIST);
// Checks that the number of provision flows are the same as in the operation check
assertEquals(EXPECTED_TYPE_LIST.size(), eventQueue.getQueue().size());
}
Aggregations