Search in sources :

Example 16 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method selectExecutionListALaCarteVfModuleNoFabricCreateTest.

@Test
public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception {
    String gAction = "createInstance";
    String resource = "VfModule";
    String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON);
    initExecution(gAction, bpmnRequest, true);
    execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB");
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 17 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method queryNorthBoundRequestCatalogDbNestedTest.

@Test
public void queryNorthBoundRequestCatalogDbNestedTest() throws MalformedURLException {
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "VNF-Macro-Replace", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    List<OrchestrationFlow> macroFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB");
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("replaceInstance", "Vnf", false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    when(catalogDbClient.getOrchestrationFlowByAction("VNF-Macro-Replace")).thenReturn(macroFlows);
    List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "replaceInstance", WorkflowType.VNF, false, "my-custom-cloud-owner");
    assertEquals(flows.get(0).getFlowName(), "AAICheckVnfInMaintBB");
    assertEquals(flows.get(1).getFlowName(), "AAISetVnfInMaintBB");
    assertEquals(flows.get(2).getFlowName(), "DeactivateVfModuleBB");
    assertEquals(flows.get(3).getFlowName(), "DeleteVfModuleBB");
    assertEquals(flows.get(4).getFlowName(), "DeactivateVnfBB");
    assertEquals(flows.get(5).getFlowName(), "CreateVfModuleBB");
    assertEquals(flows.get(6).getFlowName(), "ActivateVfModuleBB");
    assertEquals(flows.get(7).getFlowName(), "ActivateVnfBB");
    assertEquals(flows.get(8).getFlowName(), "SDNOVnfHealthCheckBB");
    assertEquals(flows.get(9).getFlowName(), "AAIUnsetVnfInMaintBB");
}
Also used : OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 18 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowActionTest method selectExecutionListALaCarteNetworkDeleteTest.

@Test
public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception {
    String gAction = "deleteInstance";
    String resource = "Network";
    String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
    initExecution(gAction, bpmnRequest, true);
    execution.setVariable("requestUri", "v6/networks/123");
    NorthBoundRequest northBoundRequest = new NorthBoundRequest();
    List<OrchestrationFlow> orchFlows = createFlowList("DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
    northBoundRequest.setOrchestrationFlowList(orchFlows);
    when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
    workflowAction.selectExecutionList(execution);
    List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
    assertEqualsBulkFlowName(ebbs, "DeactivateNetworkBB", "DeleteNetworkBB", "UnassignNetwork1802BB");
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NorthBoundRequest(org.onap.so.db.catalog.beans.macro.NorthBoundRequest) BaseTaskTest(org.onap.so.bpmn.BaseTaskTest) Test(org.junit.Test)

Example 19 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class ExecuteBuildingBlockBuilderTest method verifyLackOfNullPointerExceptionForNullResource.

@Test
public void verifyLackOfNullPointerExceptionForNullResource() {
    ExecuteBuildingBlock result = null;
    try {
        result = executeBBBuilder.buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, false, null, null, null, false, null, null, true, null);
    } catch (NullPointerException e) {
        fail("NullPointerException should not be thrown when 'resource' is null");
    }
    assertNotNull(result);
}
Also used : ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) Test(org.junit.Test)

Example 20 with OrchestrationFlow

use of org.onap.so.db.catalog.beans.macro.OrchestrationFlow in project so by onap.

the class WorkflowAction method selectExecutionList.

public void selectExecutionList(DelegateExecution execution) throws Exception {
    try {
        fillExecutionDefault(execution);
        final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
        ServiceInstancesRequest sIRequest = new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
        final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID);
        String uri = (String) execution.getVariable(BBConstants.G_URI);
        boolean isResume = isUriResume(uri);
        final boolean isALaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
        Resource resource = getResource(bbInputSetupUtils, isResume, isALaCarte, uri, requestId);
        WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
        RequestDetails requestDetails = sIRequest.getRequestDetails();
        String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
        String resourceId = getResourceId(resource, requestAction, requestDetails, workflowResourceIds);
        WorkflowType resourceType = resource.getResourceType();
        String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType);
        fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType);
        List<ExecuteBuildingBlock> flowsToExecute;
        if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) {
            String errorMessage = "Could not resume Macro flow. Error loading execution path.";
            flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
        } else if (isALaCarte && isResume) {
            String errorMessage = "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found";
            flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage);
        } else {
            String vnfType = (String) execution.getVariable(VNF_TYPE);
            String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration());
            List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW);
            final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION);
            final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
            if (isALaCarte) {
                flowsToExecute = loadExecuteBuildingBlocksForAlaCarte(orchFlows, execution, requestAction, resourceType, cloudOwner, serviceType, sIRequest, requestId, workflowResourceIds, requestDetails, resourceId, vnfType, apiVersion);
            } else {
                flowsToExecute = loadExecuteBuildingBlocksForMacro(sIRequest, resourceType, requestAction, execution, serviceInstanceId, resourceId, workflowResourceIds, orchFlows, cloudOwner, serviceType, requestId, apiVersion, vnfType, requestDetails);
            }
        }
        // enable it.
        if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) {
            List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
            for (Map<String, Object> params : userParams) {
                if (params.containsKey(HOMINGSOLUTION)) {
                    execution.setVariable(HOMING, !"none".equals(params.get(HOMINGSOLUTION)));
                }
            }
        }
        if (CollectionUtils.isEmpty(flowsToExecute)) {
            throw new IllegalStateException("Macro did not come up with a valid execution path.");
        }
        List<String> flowNames = new ArrayList<>();
        logger.info("List of BuildingBlocks to execute:");
        flowsToExecute.forEach(ebb -> {
            logger.info(ebb.getBuildingBlock().getBpmnFlowName());
            flowNames.add(ebb.getBuildingBlock().getBpmnFlowName());
        });
        if (!isResume) {
            bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute);
        }
        setExecutionVariables(execution, flowsToExecute, flowNames);
    } catch (Exception ex) {
        if (!(execution.hasVariable("WorkflowException") || execution.hasVariable("WorkflowExceptionExceptionMessage"))) {
            buildAndThrowException(execution, "Exception while setting execution list. ", ex);
        } else {
            throw ex;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) OrchestrationFlow(org.onap.so.db.catalog.beans.macro.OrchestrationFlow) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) VnfcMultipleRelationshipException(org.onap.so.bpmn.infrastructure.workflow.tasks.excpetion.VnfcMultipleRelationshipException) AAIEntityNotFoundException(org.onap.so.client.orchestration.AAIEntityNotFoundException) IOException(java.io.IOException) WorkflowResourceIds(org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds) ExecuteBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock) List(java.util.List) RelatedInstanceList(org.onap.so.serviceinstancebeans.RelatedInstanceList) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

OrchestrationFlow (org.onap.so.db.catalog.beans.macro.OrchestrationFlow)44 ArrayList (java.util.ArrayList)39 ExecuteBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock)37 Test (org.junit.Test)33 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)32 NorthBoundRequest (org.onap.so.db.catalog.beans.macro.NorthBoundRequest)32 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)31 List (java.util.List)30 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)27 RelationshipList (org.onap.aai.domain.yang.RelationshipList)27 VfModule (org.onap.aai.domain.yang.VfModule)15 GenericVnf (org.onap.aai.domain.yang.GenericVnf)11 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)9 Service (org.onap.so.db.catalog.beans.Service)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 WorkflowResourceIds (org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds)8 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)8 VolumeGroup (org.onap.aai.domain.yang.VolumeGroup)7 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)7