aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java29
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java220
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java167
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java46
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java109
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java82
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java58
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java56
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java102
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java66
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java209
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java115
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java169
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignVnfAndPnf.json157
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/logback-test.xml36
21 files changed, 1417 insertions, 348 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
index 1220dc05c1..f49cf48ff5 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java
@@ -109,12 +109,15 @@ public class CnfAdapterCreateTasks {
protected InstanceRequest createInstanceRequest(VfModule vfModule, CloudRegion cloudRegion,
Map<String, String> sdncDirectives) {
InstanceRequest request = new InstanceRequest();
- request.setRbName(vfModule.getModelInfoVfModule().getModelInvariantUUID());
- request.setRbVersion(vfModule.getModelInfoVfModule().getModelUUID());
+ request.setModelInvariantId(vfModule.getModelInfoVfModule().getModelInvariantUUID());
+ request.setModelVersionId(vfModule.getModelInfoVfModule().getModelUUID());
+ request.setModelCustomizationId(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
request.setCloudRegion(cloudRegion.getLcpCloudRegionId());
request.setVfModuleUUID(vfModule.getVfModuleId());
request.setProfileName(sdncDirectives.get("k8s-rb-profile-name"));
request.setReleaseName(sdncDirectives.get("k8s-rb-instance-release-name"));
+ if (sdncDirectives.containsKey("k8s-rb-instance-status-check"))
+ request.setStatusCheck(sdncDirectives.get("k8s-rb-instance-status-check").equalsIgnoreCase("true"));
request.setOverrideValues(sdncDirectives);
return request;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java
index 8e6e8678ed..7c6473f79d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterImpl.java
@@ -2,12 +2,15 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import java.io.ByteArrayInputStream;
import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
import java.util.Optional;
+import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.commons.lang3.StringUtils;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
@@ -22,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import org.w3c.dom.Document;
@Component
public class NetworkAdapterImpl {
@@ -80,14 +84,16 @@ public class NetworkAdapterImpl {
return unmarshaller.unmarshal(reader);
}
- protected Optional<String> findResponseType(String xmlString) {
+ protected Optional<String> findResponseType(final String xmlString) {
try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- org.w3c.dom.Document doc;
- doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, StringUtils.EMPTY);
+ factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, StringUtils.EMPTY);
+
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes(StandardCharsets.UTF_8)));
return Optional.of(doc.getDocumentElement().getNodeName());
- } catch (Exception e) {
+ } catch (final Exception e) {
logger.error("Error Finding Response Type", e);
return Optional.empty();
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
index e55fa9e24b..7ed8447fa6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks;
import java.io.StringReader;
import java.io.StringWriter;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
@@ -30,14 +31,15 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
+import org.apache.commons.lang3.StringUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.logging.filter.base.ONAPComponents;
import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCRequest;
-import org.onap.logging.filter.base.ONAPComponents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -47,10 +49,17 @@ import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
+import net.sf.saxon.lib.NamespaceConstant;
+import net.sf.saxon.xpath.XPathFactoryImpl;
@Component
public class SDNCRequestTasks {
+ private static final String NET_SF_SAXON_XPATH_IMPL = "net.sf.saxon.xpath.XPathFactoryImpl";
+
+ private static final String XPATH_FACTORY_PROPERTY_NAME =
+ "javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_SAXON;
+
private static final Logger logger = LoggerFactory.getLogger(SDNCRequestTasks.class);
private static final String SDNC_REQUEST = "SDNCRequest";
@@ -143,14 +152,20 @@ public class SDNCRequestTasks {
return "Y".equals(finalMessageIndicator);
}
- protected String getXmlElement(Document doc, String exp) throws Exception {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer = tf.newTransformer();
- StringWriter writer = new StringWriter();
+ protected String getXmlElement(final Document doc, final String exp) throws Exception {
+ final TransformerFactory factory = TransformerFactory.newInstance();
+ factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, StringUtils.EMPTY);
+ factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, StringUtils.EMPTY);
+
+ final Transformer transformer = factory.newTransformer();
+ final StringWriter writer = new StringWriter();
transformer.transform(new DOMSource(doc), new StreamResult(writer));
logger.debug(writer.getBuffer().toString());
- XPath xPath = XPathFactory.newInstance().newXPath();
- String result = xPath.evaluate(exp, doc);
+
+ System.setProperty(XPATH_FACTORY_PROPERTY_NAME, NET_SF_SAXON_XPATH_IMPL);
+ final XPathFactory xPathFactory = XPathFactoryImpl.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
+ final XPath xPath = xPathFactory.newXPath();
+ final String result = xPath.evaluate(exp, doc);
if (result == null || result.isEmpty()) {
throw new Exception("XPath Failed to find element expression: " + exp);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
index 2138f489ee..2bd0f2c786 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
@@ -10,6 +10,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -26,6 +28,7 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import org.apache.commons.lang3.builder.ToStringBuilder;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
@@ -36,20 +39,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONFIGURATION;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.VOLUMEGROUP;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.*;
@Component
public class ExecuteBuildingBlockBuilder {
@@ -62,78 +56,117 @@ public class ExecuteBuildingBlockBuilder {
private static final String NETWORK = "Network";
protected List<ExecuteBuildingBlock> buildExecuteBuildingBlockList(List<OrchestrationFlow> orchFlows,
- List<Resource> resourceList, String requestId, String apiVersion, String resourceId, String requestAction,
- String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
- boolean replaceVnf) {
+ List<Resource> originalResourceList, String requestId, String apiVersion, String resourceId,
+ String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
+ RequestDetails requestDetails, boolean replaceVnf) {
+ List<Resource> resourceList = getOnlyRootResourceList(originalResourceList);
+
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+
+ boolean ascendingOrder = requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE)
+ || requestAction.equals(ACTIVATE_INSTANCE);
+
+ ExecutionPlan plan = ExecutionPlan.build(resourceList, ascendingOrder);
+
+ logger.info("Orchestration Flows");
for (OrchestrationFlow orchFlow : orchFlows) {
- if (orchFlow.getFlowName().contains(SERVICE)) {
- if (!replaceVnf) {
- workflowResourceIds.setServiceInstanceId(resourceId);
- }
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.SERVICE, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(VNF) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VNF, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(PNF) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.PNF, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- } else if (orchFlow.getFlowName().contains(NETWORK)
- && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORK, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
- false);
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VIRTUAL_LINK, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- true, false);
- } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
- && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- List<Resource> vfModuleResourcesSorted;
- if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)
- || requestAction.equals("activateInstance")) {
- vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
- } else {
- vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
- }
- for (Resource resource : vfModuleResourcesSorted) {
- flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
- requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
- false, null));
- }
- } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
- if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
- || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) {
- logger.debug("Replacing workflow resource id by volume group id");
- resourceId = workflowResourceIds.getVolumeGroupId();
- }
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.VOLUMEGROUP, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, false);
- } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.NETWORKCOLLECTION, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, false);
- } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
- addBuildingBlockToExecuteBBList(flowsToExecute, resourceList, WorkflowType.CONFIGURATION, orchFlow,
- requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
- false, true);
- } else {
- flowsToExecute
- .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction,
- false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null));
+ String flowDetails = new ToStringBuilder(this).append("id", orchFlow.getId())
+ .append("action", orchFlow.getAction()).append("sequenceNumber", orchFlow.getSequenceNumber())
+ .append("flowName", orchFlow.getFlowName()).append("flowVersion", orchFlow.getFlowVersion())
+ .append("bpmnAction", orchFlow.getBpmnAction()).append("bpmnScope", orchFlow.getBpmnScope())
+ .toString();
+ logger.info("Flow: " + flowDetails);
+ buildExecuteBuildingBlockListPlan(orchFlow, plan, requestId, apiVersion, resourceId, requestAction, vnfType,
+ workflowResourceIds, requestDetails, replaceVnf);
+ }
+
+ plan.flushBlocksFromCache(flowsToExecute);
+
+ return flowsToExecute;
+ }
+
+ protected void buildExecuteBuildingBlockListPlan(OrchestrationFlow flow, ExecutionPlan plan, String requestId,
+ String apiVersion, String resourceId, String requestAction, String vnfType,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean replaceVnf) {
+
+ List<ExecuteBuildingBlock> mainFlows = buildExecuteBuildingBlockListRaw(flow, plan.getResource(), requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, replaceVnf);
+
+ plan.pushBlockToCache(mainFlows);
+
+ for (ExecutionGroup nestedGroup : plan.getNestedExecutions()) {
+ for (ExecutionPlan nestedPlan : nestedGroup.getNestedExecutions()) {
+ buildExecuteBuildingBlockListPlan(flow, nestedPlan, requestId, apiVersion, resourceId, requestAction,
+ vnfType, workflowResourceIds, requestDetails, replaceVnf);
}
+ if (nestedGroup.getCacheSize() > 0)
+ plan.changeCurrentGroup(nestedGroup);
+ }
+ }
+
+ private List<ExecuteBuildingBlock> buildExecuteBuildingBlockListRaw(OrchestrationFlow orchFlow, Resource resource,
+ String requestId, String apiVersion, String resourceId, String requestAction, String vnfType,
+ WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean replaceVnf) {
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ if (orchFlow.getFlowName().contains(SERVICE) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (SERVICE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ if (!replaceVnf) {
+ workflowResourceIds.setServiceInstanceId(resourceId);
+ }
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.SERVICE, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ } else if (orchFlow.getFlowName().contains(VNF)
+ || (orchFlow.getFlowName().contains(CONTROLLER) && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VNF, orchFlow, requestId, apiVersion,
+ resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ } else if (orchFlow.getFlowName().contains(PNF)
+ || (orchFlow.getFlowName().contains(CONTROLLER) && (PNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.PNF, orchFlow, requestId, apiVersion,
+ resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ } else if (orchFlow.getFlowName().contains(NETWORK) && !orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.NETWORK, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VIRTUAL_LINK, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, true, false);
+ } else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
+ && (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VFMODULE, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ } else if (orchFlow.getFlowName().contains(VOLUMEGROUP)) {
+ if (requestAction.equalsIgnoreCase(REPLACEINSTANCE)
+ || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) {
+ logger.debug("Replacing workflow resource id by volume group id");
+ resourceId = workflowResourceIds.getVolumeGroupId();
+ }
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VOLUMEGROUP, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ } else if (orchFlow.getFlowName().contains(NETWORKCOLLECTION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.NETWORKCOLLECTION, orchFlow,
+ requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails,
+ false, false);
+ } else if (orchFlow.getFlowName().contains(CONFIGURATION)) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.CONFIGURATION, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, true);
+ } else {
+ flowsToExecute
+ .add(buildExecuteBuildingBlock(orchFlow, requestId, null, apiVersion, resourceId, requestAction,
+ false, vnfType, workflowResourceIds, requestDetails, false, null, null, false, null));
}
return flowsToExecute;
}
+ protected List<Resource> getOnlyRootResourceList(List<Resource> resourceList) {
+ return resourceList.stream().filter(x -> countResourceOnTheResourceList(x, resourceList) == 1)
+ .collect(Collectors.toList());
+ }
+
+ protected int countResourceOnTheResourceList(Resource resource, List<Resource> resourceList) {
+ int count = resourceList.stream()
+ .mapToInt(x -> (x.equals(resource) ? 1 : 0) + countResourceOnTheResourceList(resource, x.getChildren()))
+ .reduce(0, Integer::sum);
+ return count;
+ }
+
protected ExecuteBuildingBlock buildExecuteBuildingBlock(OrchestrationFlow orchFlow, String requestId,
Resource resource, String apiVersion, String resourceId, String requestAction, boolean aLaCarte,
String vnfType, WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails,
@@ -169,39 +202,16 @@ public class ExecuteBuildingBlockBuilder {
return executeBuildingBlock;
}
- protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, 0, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
-
- protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
-
- private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
+ private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, Resource resource,
WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion,
String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
RequestDetails requestDetails, boolean isVirtualLink, boolean isConfiguration) {
- resourceList.stream().filter(resource -> resource.getResourceType().equals(workflowType))
- .forEach(resource -> flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource,
- apiVersion, resourceId, requestAction, false, vnfType, workflowResourceIds, requestDetails,
- isVirtualLink, resource.getVirtualLinkKey(), null, isConfiguration, null)));
+ if (resource == null || !resource.getResourceType().equals(workflowType))
+ return;
+ flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
+ requestAction, false, vnfType, workflowResourceIds, requestDetails, isVirtualLink,
+ resource.getVirtualLinkKey(), null, isConfiguration, null));
}
protected ConfigurationResourceKeys getConfigurationResourceKeys(Resource resource, String vnfcName) {
@@ -212,6 +222,4 @@ public class ExecuteBuildingBlockBuilder {
configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
return configurationResourceKeys;
}
-
-
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java
new file mode 100644
index 0000000000..77cb616eb9
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecutionPlan.java
@@ -0,0 +1,167 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Orange Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
+
+class ExecutionPlan extends ExecutionCollection<ExecutionGroup> {
+ private final Resource resource;
+ private ExecutionGroup currentGroup = null;
+
+ public ExecutionPlan(Resource resource, ExecutionGroup group) {
+ super(resource != null ? resource.getResourceType() : WorkflowType.SERVICE);
+ this.resource = resource;
+ if (group != null) {
+ group.addNestedPlans(Collections.singletonList(this));
+ }
+ }
+
+ public void changeCurrentGroup(ExecutionGroup group) {
+ if (currentGroup == null || !currentGroup.equals(group)) {
+ logger.info("Change " + getName() + " group[" + group.getName() + "]");
+ if (currentGroup != null)
+ currentGroup.flushBlocksFromCache(this.blocksBuiltCache);
+ }
+ currentGroup = group;
+ }
+
+ Resource getResource() {
+ return resource;
+ }
+
+ protected String getName() {
+ return super.getName() + "["
+ + (resource != null ? (resource.getProcessingPriority() + ", " + resource.getResourceId()) : "") + "]";
+ }
+
+ public static ExecutionPlan build(List<Resource> resourceList, boolean ascendingOrder) {
+ ExecutionPlan plan = new ExecutionPlan(null, null);
+ buildExecutionPlan(plan, resourceList, ascendingOrder);
+ if (plan.getNestedExecutions().size() == 1
+ && plan.getNestedExecutions().get(0).getNestedExecutions().size() == 1)
+ plan = plan.getNestedExecutions().get(0).getNestedExecutions().get(0);
+ return plan;
+ }
+
+ private static void buildExecutionPlan(ExecutionPlan plan, List<Resource> resourceList, boolean ascendingOrder) {
+ Map<WorkflowType, List<Resource>> resourceGroups = new TreeMap<>();
+ for (Resource resource : resourceList) {
+ if (!resourceGroups.containsKey(resource.getResourceType())) {
+ resourceGroups.put(resource.getResourceType(), new ArrayList<>());
+ }
+ resourceGroups.get(resource.getResourceType()).add(resource);
+ }
+ for (WorkflowType type : resourceGroups.keySet()) {
+ ExecutionGroup nestedGroup = new ExecutionGroup(type, plan);
+ List<Resource> resourceGroupSorted = resourceGroups.get(type).stream()
+ .sorted(ascendingOrder ? Resource.sortByPriorityAsc : Resource.sortByPriorityDesc)
+ .collect(Collectors.toList());
+ for (Resource resource : resourceGroupSorted) {
+ ExecutionPlan planInGroup = new ExecutionPlan(resource, nestedGroup);
+ if (resource.getChildren().size() > 0)
+ buildExecutionPlan(planInGroup, resource.getChildren(), ascendingOrder);
+ }
+ }
+ }
+}
+
+
+class ExecutionGroup extends ExecutionCollection<ExecutionPlan> {
+
+ public ExecutionGroup(WorkflowType groupType, ExecutionPlan plan) {
+ super(groupType);
+ plan.addNestedPlans(Collections.singletonList(this));
+ }
+}
+
+
+class ExecutionCollection<T extends ExecutionCollection<?>> {
+
+ protected static final Logger logger = LoggerFactory.getLogger(ExecutionCollection.class);
+
+ protected final WorkflowType type;
+ protected List<ExecuteBuildingBlock> blocksBuiltCache;
+ protected final List<T> nestedExecutions;
+
+ public ExecutionCollection(WorkflowType type) {
+ this.type = type;
+ this.nestedExecutions = new ArrayList<>();
+ this.blocksBuiltCache = new ArrayList<>();
+ }
+
+ public WorkflowType getType() {
+ return type;
+ }
+
+ public List<T> getNestedExecutions() {
+ return nestedExecutions;
+ }
+
+ public void addNestedPlans(List<T> executions) {
+ nestedExecutions.addAll(executions);
+ }
+
+ public void pushBlockToCache(List<ExecuteBuildingBlock> blocksCache) {
+ if (blocksCache.size() == 0)
+ return;
+ this.flushNestedBlocksToCache();
+ String blocks =
+ blocksCache.stream().map(x -> x.getBuildingBlock().getBpmnFlowName() + ", ").reduce("", String::concat);
+ blocks = blocks.substring(0, blocks.length() - 2);
+ logger.info("Push " + getName() + " (" + blocksCache.size() + ") blocks [" + blocks + "]");
+ this.blocksBuiltCache.addAll(blocksCache);
+ }
+
+ private void flushNestedBlocksToCache() {
+ for (T collection : nestedExecutions) {
+ collection.flushBlocksFromCache(this.blocksBuiltCache);
+ }
+ }
+
+ public void flushBlocksFromCache(List<ExecuteBuildingBlock> blockList) {
+ flushNestedBlocksToCache();
+ if (this.blocksBuiltCache.size() > 0) {
+ String blocks = this.blocksBuiltCache.stream().map(x -> x.getBuildingBlock().getBpmnFlowName() + ", ")
+ .reduce("", String::concat);
+ blocks = blocks.substring(0, blocks.length() - 2);
+ logger.info("Flush " + getName() + " (" + blocksBuiltCache.size() + ") blocks [" + blocks + "]");
+ blockList.addAll(this.blocksBuiltCache);
+ this.blocksBuiltCache.clear();
+ }
+ }
+
+ public int getCacheSize() {
+ return blocksBuiltCache.size()
+ + getNestedExecutions().stream().mapToInt(x -> x.getCacheSize()).reduce(0, Integer::sum);
+ }
+
+ protected String getName() {
+ return type.name();
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
index 447f8994db..0d2844d08b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -20,6 +22,11 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
public class Resource {
private String resourceId;
@@ -30,11 +37,24 @@ public class Resource {
private String vnfCustomizationId;
private String vfModuleCustomizationId;
private String cvnfModuleCustomizationId;
+ private int processingPriority;
+ private Resource parent;
+ private List<Resource> children;
+
+ public static final Comparator<Resource> sortByPriorityAsc =
+ Comparator.comparingInt(Resource::getProcessingPriority);
+ public static final Comparator<Resource> sortByPriorityDesc =
+ Comparator.comparingInt(x -> -x.getProcessingPriority());
- public Resource(WorkflowType resourceType, String resourceId, boolean generated) {
+ public Resource(WorkflowType resourceType, String resourceId, boolean generated, Resource parent) {
this.resourceId = resourceId;
this.resourceType = resourceType;
this.generated = generated;
+ this.processingPriority = 0;
+ this.children = new ArrayList<>();
+ this.parent = parent;
+ if (parent != null)
+ this.parent.children.add(this);
}
public String getResourceId() {
@@ -100,4 +120,20 @@ public class Resource {
public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
}
+
+ public int getProcessingPriority() {
+ return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
+ }
+
+ public void setProcessingPriority(int processingPriority) {
+ this.processingPriority = processingPriority;
+ }
+
+ public Resource getParent() {
+ return this.parent;
+ }
+
+ public List<Resource> getChildren() {
+ return this.children;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 29206a6aa9..ce775af476 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -10,6 +10,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -26,13 +28,16 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.RECREATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPDATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
import java.io.IOException;
import java.util.ArrayList;
@@ -279,14 +284,14 @@ public class WorkflowAction {
List<Resource> resourceList = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- if (resourceType == WorkflowType.SERVICE) {
+ if (resourceType == WorkflowType.SERVICE || isVNFCreateOrDelete(resourceType, requestAction)) {
resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution,
serviceInstanceId, resourceId, aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
+ || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) {
vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
- } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
+ } else if (resourceType == WorkflowType.VNF && UPDATE_INSTANCE.equalsIgnoreCase(requestAction)) {
vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
} else {
@@ -315,14 +320,32 @@ public class WorkflowAction {
logger.info("Sorting for Vlan Tagging");
flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction);
}
+ logger.info("Building Block Execution Order");
+ for (ExecuteBuildingBlock block : flowsToExecute) {
+ Resource res = resourceList.stream()
+ .filter(resource -> resource.getResourceId() == block.getBuildingBlock().getKey()).findAny()
+ .orElse(null);
+ String log = "Block: " + block.getBuildingBlock().getBpmnFlowName();
+ if (res != null) {
+ log += ", Resource: " + res.getResourceType() + "[" + res.getResourceId() + "]";
+ log += ", Priority: " + res.getProcessingPriority();
+ if (res.getResourceType() == WorkflowType.VFMODULE)
+ log += ", Base: " + res.isBaseVfModule();
+ }
+ if (block.getBuildingBlock().getBpmnScope() != null)
+ log += ", Scope: " + block.getBuildingBlock().getBpmnScope();
+ if (block.getBuildingBlock().getBpmnAction() != null)
+ log += ", Action: " + block.getBuildingBlock().getBpmnAction();
+ logger.info(log);
+ }
// By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
- && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE))
+ && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE))
&& resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
execution.setVariable(HOMING, true);
execution.setVariable("calledHoming", false);
}
- if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
+ if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE)
|| requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
} else {
@@ -331,6 +354,11 @@ public class WorkflowAction {
return flowsToExecute;
}
+ private boolean isVNFCreateOrDelete(WorkflowType resourceType, String requestAction) {
+ return resourceType == WorkflowType.VNF
+ && (CREATE_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction));
+ }
+
private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute,
List<String> flowNames) {
execution.setVariable("flowNames", flowNames);
@@ -409,7 +437,7 @@ public class WorkflowAction {
resourceId = modelInfo.getModelCustomizationId();
}
}
- return new Resource(resourceType, resourceId, true);
+ return new Resource(resourceType, resourceId, true, null);
}
private String getCloudOwner(CloudConfiguration cloudConfiguration) {
@@ -724,7 +752,7 @@ public class WorkflowAction {
type = action;
}
}
- return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated);
+ return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated, null);
} else {
throw new IllegalArgumentException("Uri could not be parsed: " + uri);
}
@@ -887,7 +915,7 @@ public class WorkflowAction {
protected boolean isRequestMacroServiceResume(boolean aLaCarte, WorkflowType resourceType, String requestAction,
String serviceInstanceId) {
return (!aLaCarte && resourceType == WorkflowType.SERVICE
- && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
+ && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
&& (serviceInstanceId != null && serviceInstanceId.trim().length() > 1)
&& (bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId) != null));
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
index b2cc89545b..38ba0077e2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
@@ -32,16 +32,23 @@ public final class WorkflowActionConstants {
throw new IllegalStateException("Utility class");
}
- public static final String USER_PARAM_SERVICE = "service";
+ public static final String ACTIVATE_INSTANCE = "activateInstance";
+ public static final String ASSIGN_INSTANCE = "assignInstance";
+ public static final String CONFIGURATION = "Configuration";
+ public static final String CONTROLLER = "Controller";
public static final String CREATE_INSTANCE = "createInstance";
+ public static final String DEACTIVATE_INSTANCE = "deactivateInstance";
+ public static final String DELETE_INSTANCE = "deleteInstance";
public static final String FABRIC_CONFIGURATION = "FabricConfiguration";
- public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
- static final String SERVICE = "Service";
- static final String CONTROLLER = "Controller";
public static final String NETWORKCOLLECTION = "NetworkCollection";
- static final String CONFIGURATION = "Configuration";
- public static final String ASSIGNINSTANCE = "assignInstance";
- static final String REPLACEINSTANCE = "replaceInstance";
- static final String VOLUMEGROUP = "VolumeGroup";
- static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+ public static final String RECREATE_INSTANCE = "recreateInstance";
+ public static final String REPLACEINSTANCE = "replaceInstance";
+ public static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+ public static final String SERVICE = "Service";
+ public static final String UNASSIGN_INSTANCE = "unassignInstance";
+ public static final String UPDATE_INSTANCE = "updateInstance";
+ public static final String USER_PARAM_SERVICE = "service";
+ public static final String VOLUMEGROUP = "VolumeGroup";
+ public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
index 068c287ee7..e4c6d2951f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
@@ -1,3 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2020 Nokia
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -35,12 +57,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DEACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UNASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
@Component
@@ -77,7 +103,7 @@ public class ServiceEBBLoader {
boolean containsService = false;
List<Resource> resourceList = new ArrayList<>();
List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- if (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
+ if (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE)) {
// SERVICE-MACRO-ASSIGN will always get user params with a
// service.
@@ -108,17 +134,16 @@ public class ServiceEBBLoader {
if (!foundRelated(resourceList)) {
traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
}
- } else if (("activateInstance".equalsIgnoreCase(requestAction)
- || "unassignInstance".equalsIgnoreCase(requestAction)
- || "deleteInstance".equalsIgnoreCase(requestAction)
+ } else if ((ACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)
+ || UNASSIGN_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction)
|| requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
// SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
// SERVICE-MACRO-DELETE
// Will never get user params with service, macro will have
// to query the SI in AAI to find related instances.
traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
- } else if ("deactivateInstance".equalsIgnoreCase(requestAction)) {
- resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
+ } else if (DEACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)) {
+ resourceList.add(new Resource(WorkflowType.SERVICE, "", false, null));
}
return resourceList;
}
@@ -139,16 +164,18 @@ public class ServiceEBBLoader {
if (service == null) {
buildAndThrowException(execution, "Could not find the service model in catalog db.");
} else {
- resourceList.add(new Resource(WorkflowType.SERVICE, service.getModelUUID(), false));
+ Resource serviceResource = new Resource(WorkflowType.SERVICE, service.getModelUUID(), false, null);
+ resourceList.add(serviceResource);
RelatedInstance relatedVpnBinding =
bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.vpnBinding);
RelatedInstance relatedLocalNetwork =
bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.network);
if (relatedVpnBinding != null && relatedLocalNetwork != null) {
- traverseVrfConfiguration(aaiResourceIds, resourceList, service, relatedVpnBinding, relatedLocalNetwork);
+ traverseVrfConfiguration(aaiResourceIds, resourceList, serviceResource, service, relatedVpnBinding,
+ relatedLocalNetwork);
} else {
- traverseNetworkCollection(execution, resourceList, service);
+ traverseNetworkCollection(execution, resourceList, serviceResource, service);
}
}
}
@@ -166,14 +193,17 @@ public class ServiceEBBLoader {
ServiceInstance serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(resourceId);
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO =
bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
- resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
- traverseServiceInstanceMSOVnfs(resourceList, aaiResourceIds, serviceInstanceMSO);
- traverseServiceInstanceMSOPnfs(resourceList, aaiResourceIds, serviceInstanceMSO);
+ Resource serviceResource =
+ new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
+ resourceList.add(serviceResource);
+ traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
+ traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
if (serviceInstanceMSO.getNetworks() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO
.getNetworks()) {
aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
- resourceList.add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false));
+ resourceList
+ .add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false, serviceResource));
}
}
if (serviceInstanceMSO.getCollection() != null) {
@@ -181,7 +211,7 @@ public class ServiceEBBLoader {
aaiResourceIds
.add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION,
- serviceInstanceMSO.getCollection().getId(), false));
+ serviceInstanceMSO.getCollection().getId(), false, serviceResource));
}
if (serviceInstanceMSO.getConfigurations() != null) {
for (Configuration config : serviceInstanceMSO.getConfigurations()) {
@@ -192,8 +222,8 @@ public class ServiceEBBLoader {
if (relationship.getRelatedTo().contains("vnfc")
|| relationship.getRelatedTo().contains("vpn-binding")) {
aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
- resourceList.add(
- new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false));
+ resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(),
+ false, serviceResource));
break;
}
}
@@ -207,7 +237,7 @@ public class ServiceEBBLoader {
}
}
- private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList,
+ private void traverseServiceInstanceMSOVnfs(List<Resource> resourceList, Resource serviceResource,
List<Pair<WorkflowType, String>> aaiResourceIds,
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
if (serviceInstanceMSO.getVnfs() == null) {
@@ -215,18 +245,20 @@ public class ServiceEBBLoader {
}
for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
- resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
- traverseVnfModules(resourceList, aaiResourceIds, vnf);
+ Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource);
+ resourceList.add(vnfResource);
+ traverseVnfModules(resourceList, vnfResource, aaiResourceIds, vnf);
if (vnf.getVolumeGroups() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ resourceList.add(
+ new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource));
}
}
}
}
- private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList,
+ private void traverseServiceInstanceMSOPnfs(List<Resource> resourceList, Resource serviceResource,
List<Pair<WorkflowType, String>> aaiResourceIds,
org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) {
if (serviceInstanceMSO.getPnfs() == null) {
@@ -234,12 +266,12 @@ public class ServiceEBBLoader {
}
for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) {
aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId()));
- resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false));
+ resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false, serviceResource));
}
}
protected void traverseVrfConfiguration(List<Pair<WorkflowType, String>> aaiResourceIds,
- List<Resource> resourceList, org.onap.so.db.catalog.beans.Service service,
+ List<Resource> resourceList, Resource serviceResource, org.onap.so.db.catalog.beans.Service service,
RelatedInstance relatedVpnBinding, RelatedInstance relatedLocalNetwork)
throws VrfBondingServiceException, JsonProcessingException {
org.onap.aai.domain.yang.L3Network aaiLocalNetwork =
@@ -257,12 +289,12 @@ public class ServiceEBBLoader {
aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration));
}
resourceList.add(new Resource(WorkflowType.CONFIGURATION,
- service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false));
+ service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false, serviceResource));
}
protected void traverseNetworkCollection(DelegateExecution execution, List<Resource> resourceList,
- org.onap.so.db.catalog.beans.Service service) {
+ Resource serviceResource, org.onap.so.db.catalog.beans.Service service) {
if (isVnfCustomizationsInTheService(service)) {
buildAndThrowException(execution,
"Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows");
@@ -277,14 +309,16 @@ public class ServiceEBBLoader {
} else {
CollectionResourceCustomization collectionResourceCustomization =
findCatalogNetworkCollection(execution, service);
- traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization);
+ traverseNetworkCollectionResourceCustomization(resourceList, serviceResource,
+ collectionResourceCustomization);
}
- traverseNetworkCollectionCustomization(resourceList, service);
+ traverseNetworkCollectionCustomization(resourceList, serviceResource, service);
}
- private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList,
+ private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, Resource serviceResource,
CollectionResourceCustomization collectionResourceCustomization) {
- if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, collectionResourceCustomization))
+ if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, serviceResource,
+ collectionResourceCustomization))
return;
int minNetworks = 0;
org.onap.so.db.catalog.beans.InstanceGroup instanceGroup =
@@ -309,7 +343,7 @@ public class ServiceEBBLoader {
for (int i = 0; i < minNetworks; i++) {
if (collectionNetworkResourceCust != null) {
Resource resource = new Resource(WorkflowType.VIRTUAL_LINK,
- collectionNetworkResourceCust.getModelCustomizationUUID(), false);
+ collectionNetworkResourceCust.getModelCustomizationUUID(), false, serviceResource);
resource.setVirtualLinkKey(Integer.toString(i));
resourceList.add(resource);
}
@@ -331,13 +365,13 @@ public class ServiceEBBLoader {
}
private boolean collectionResourceCustomizationShouldNotBeProcessed(List<Resource> resourceList,
- CollectionResourceCustomization collectionResourceCustomization) {
+ Resource serviceResource, CollectionResourceCustomization collectionResourceCustomization) {
if (collectionResourceCustomization == null) {
logger.debug("No Network Collection Customization found");
return true;
}
resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION,
- collectionResourceCustomization.getModelCustomizationUUID(), false));
+ collectionResourceCustomization.getModelCustomizationUUID(), false, serviceResource));
logger.debug("Found a network collection");
if (collectionResourceCustomization.getCollectionResource() == null) {
logger.debug("No Network Collection found. collectionResource is null");
@@ -365,7 +399,7 @@ public class ServiceEBBLoader {
return toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION);
}
- private void traverseNetworkCollectionCustomization(List<Resource> resourceList,
+ private void traverseNetworkCollectionCustomization(List<Resource> resourceList, Resource serviceResource,
org.onap.so.db.catalog.beans.Service service) {
if (isNetworkCollectionInTheResourceList(resourceList)) {
return;
@@ -376,7 +410,7 @@ public class ServiceEBBLoader {
}
for (int i = 0; i < service.getNetworkCustomizations().size(); i++) {
resourceList.add(new Resource(WorkflowType.NETWORK,
- service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false));
+ service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false, serviceResource));
}
}
@@ -388,14 +422,15 @@ public class ServiceEBBLoader {
return !(service.getPnfCustomizations() == null || service.getPnfCustomizations().isEmpty());
}
- private void traverseVnfModules(List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds,
+ private void traverseVnfModules(List<Resource> resourceList, Resource vnfResource,
+ List<Pair<WorkflowType, String>> aaiResourceIds,
org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf) {
if (vnf.getVfModules() == null) {
return;
}
for (VfModule vfModule : vnf.getVfModules()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false);
+ Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource);
resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean());
resourceList.add(resource);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
index 4b1fdd8da1..1f932743ca 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
@@ -10,6 +10,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -89,38 +91,45 @@ public class UserParamsServiceTraversal {
private List<Resource> getResourceList(DelegateExecution execution, String serviceModelVersionId,
String requestAction, Service validate) {
List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false));
+ Resource serviceResource =
+ new Resource(WorkflowType.SERVICE, validate.getModelInfo().getModelVersionId(), false, null);
+ resourceList.add(serviceResource);
if (validate.getResources().getVnfs() != null) {
- setResourceListForVnfs(execution, resourceList, validate);
+ setResourceListForVnfs(execution, resourceList, serviceResource, validate);
}
if (validate.getResources().getPnfs() != null) {
- setResourceListForPnfs(resourceList, validate);
+ setResourceListForPnfs(resourceList, serviceResource, validate);
}
if (validate.getResources().getNetworks() != null) {
- setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, validate);
+ setResourceListForNetworks(execution, serviceModelVersionId, requestAction, resourceList, serviceResource,
+ validate);
}
return resourceList;
}
- private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList, Service validate) {
+ private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList,
+ Resource serviceResource, Service validate) {
for (Vnfs vnf : validate.getResources().getVnfs()) {
setVnfCustomizationUUID(vnf);
- resourceList.add(new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false));
- setResourceListForVfModules(execution, resourceList, validate, vnf);
+ Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getModelInfo().getModelCustomizationId(), false,
+ serviceResource);
+ vnfResource.setProcessingPriority(vnf.getProcessingPriority());
+ resourceList.add(vnfResource);
+ setResourceListForVfModules(execution, resourceList, vnfResource, validate, vnf);
}
}
- private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList, Service validate,
- Vnfs vnf) {
+ private void setResourceListForVfModules(DelegateExecution execution, List<Resource> resourceList,
+ Resource vnfResource, Service validate, Vnfs vnf) {
if (vnf.getVfModules() != null) {
for (VfModules vfModule : vnf.getVfModules()) {
setVfModuleCustomizationUUID(vfModule);
VfModuleCustomization vfModuleCustomization =
catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vfModuleCustomizationUUID);
if (vfModuleCustomization != null && vfModuleCustomization.getVfModule() != null) {
- setVolumeGroupWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
- setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule,
- vfModuleCustomization);
+ setVolumeGroupWorkFlowTypeToResourceList(resourceList, vnfResource, vfModuleCustomization);
+ setVfModuleAndConfigurationWorkFlowTypeToResourceList(resourceList, vnfResource, validate, vnf,
+ vfModule, vfModuleCustomization);
if (!foundVfModuleOrVG) {
buildAndThrowException(execution,
"Could not determine if vfModule was a vfModule or volume group. Heat template and Heat env are null");
@@ -130,46 +139,49 @@ public class UserParamsServiceTraversal {
}
}
- private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList,
+ private void setVolumeGroupWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource,
VfModuleCustomization vfModuleCustomization) {
if (vfModuleCustomization.getVfModule().getVolumeHeatTemplate() != null
&& vfModuleCustomization.getVolumeHeatEnv() != null) {
foundVfModuleOrVG = true;
- resourceList.add(
- new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(), false));
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, vfModuleCustomization.getModelCustomizationUUID(),
+ false, vnfResource));
}
}
- private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate,
- Vnfs vnf, VfModules vfModule, VfModuleCustomization vfModuleCustomization) {
+ private void setVfModuleAndConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList,
+ Resource vnfResource, Service validate, Vnfs vnf, VfModules vfModule,
+ VfModuleCustomization vfModuleCustomization) {
if ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
&& vfModuleCustomization.getHeatEnvironment() != null)
|| (vfModuleCustomization.getVfModule().getModelName() != null
&& vfModuleCustomization.getVfModule().getModelName().contains("helm"))) {
foundVfModuleOrVG = true;
- Resource resource = setVfModuleWorkFlowTypeToResourceList(resourceList, vfModuleCustomization);
- setConfigurationWorkFlowTypeToResourceList(resourceList, validate, vnf, vfModule, resource);
+ Resource resource =
+ setVfModuleWorkFlowTypeToResourceList(resourceList, vnfResource, vfModuleCustomization, vfModule);
+ setConfigurationWorkFlowTypeToResourceList(resourceList, vnfResource, validate, vnf, vfModule, resource);
}
}
- private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList,
- VfModuleCustomization vfModuleCustomization) {
- Resource resource =
- new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(), false);
+ private Resource setVfModuleWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource,
+ VfModuleCustomization vfModuleCustomization, VfModules vfModule) {
+ Resource resource = new Resource(WorkflowType.VFMODULE, vfModuleCustomization.getModelCustomizationUUID(),
+ false, vnfResource);
+ resource.setProcessingPriority(vfModule.getProcessingPriority());
resource.setBaseVfModule(vfModuleCustomization.getVfModule().getIsBase() != null
&& vfModuleCustomization.getVfModule().getIsBase());
resourceList.add(resource);
return resource;
}
- private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Service validate, Vnfs vnf,
- VfModules vfModule, Resource resource) {
+ private void setConfigurationWorkFlowTypeToResourceList(List<Resource> resourceList, Resource vnfResource,
+ Service validate, Vnfs vnf, VfModules vfModule, Resource resource) {
if (!vnfCustomizationUUID.isEmpty() && !vfModuleCustomizationUUID.isEmpty()) {
List<CvnfcConfigurationCustomization> configs =
traverseCatalogDbForConfiguration(validate.getModelInfo().getModelVersionId());
for (CvnfcConfigurationCustomization config : configs) {
Resource configResource = new Resource(WorkflowType.CONFIGURATION,
- config.getConfigurationResource().getModelUUID(), false);
+ config.getConfigurationResource().getModelUUID(), false, vnfResource);
resource.setVnfCustomizationId(vnf.getModelInfo().getModelCustomizationId());
resource.setVfModuleCustomizationId(vfModule.getModelInfo().getModelCustomizationId());
resourceList.add(configResource);
@@ -193,22 +205,28 @@ public class UserParamsServiceTraversal {
}
}
- private void setResourceListForPnfs(List<Resource> resourceList, Service validate) {
+ private void setResourceListForPnfs(List<Resource> resourceList, Resource serviceResource, Service validate) {
for (Pnfs pnf : validate.getResources().getPnfs()) {
- resourceList.add(new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false));
+ Resource pnfResource = new Resource(WorkflowType.PNF, pnf.getModelInfo().getModelCustomizationId(), false,
+ serviceResource);
+ pnfResource.setProcessingPriority(pnf.getProcessingPriority());
+ resourceList.add(pnfResource);
}
}
private void setResourceListForNetworks(DelegateExecution execution, String serviceModelVersionId,
- String requestAction, List<Resource> resourceList, Service validate) {
+ String requestAction, List<Resource> resourceList, Resource serviceResource, Service validate) {
for (Networks network : validate.getResources().getNetworks()) {
- resourceList
- .add(new Resource(WorkflowType.NETWORK, network.getModelInfo().getModelCustomizationId(), false));
+ Resource networkResource = new Resource(WorkflowType.NETWORK,
+ network.getModelInfo().getModelCustomizationId(), false, serviceResource);
+ networkResource.setProcessingPriority(network.getProcessingPriority());
+ resourceList.add(networkResource);
}
if (requestAction.equals(CREATE_INSTANCE)) {
String networkColCustId = queryCatalogDbForNetworkCollection(execution, serviceModelVersionId);
if (networkColCustId != null) {
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false));
+ resourceList
+ .add(new Resource(WorkflowType.NETWORKCOLLECTION, networkColCustId, false, serviceResource));
}
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
index b271226414..c1d1d7ad5a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
@@ -10,6 +10,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -73,9 +75,11 @@ public class VnfEBBLoader {
org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
- resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
+ Resource serviceResource =
+ new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
+ resourceList.add(serviceResource);
if (serviceInstanceMSO.getVnfs() != null) {
- findVnfWithGivenId(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList, execution);
+ findVnfWithGivenId(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList, serviceResource, execution);
}
} catch (Exception ex) {
logger.error("Exception in traverseAAIVnf", ex);
@@ -90,10 +94,12 @@ public class VnfEBBLoader {
org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
bbInputSetupUtils.getAAIServiceInstanceById(serviceId);
ServiceInstance serviceInstanceMSO = bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
- resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
+ Resource serviceResource =
+ new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
+ resourceList.add(serviceResource);
if (serviceInstanceMSO.getVnfs() != null) {
findVnfWithGivenIdAndAddCustomizationUUID(serviceInstanceMSO, vnfId, aaiResourceIds, resourceList,
- execution);
+ serviceResource, execution);
}
} catch (Exception ex) {
logger.error("Exception in customTraverseAAIVnf", ex);
@@ -104,34 +110,38 @@ public class VnfEBBLoader {
}
private void findVnfWithGivenId(ServiceInstance serviceInstanceMSO, String vnfId,
- List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, DelegateExecution execution) {
+ List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, Resource serviceResource,
+ DelegateExecution execution) {
for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
if (vnf.getVnfId().equals(vnfId)) {
aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
- resourceList.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
- processVfModules(vnf, aaiResourceIds, resourceList, execution);
- processVolumeGroups(vnf, aaiResourceIds, resourceList);
+ Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource);
+ resourceList.add(vnfResource);
+ processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution);
+ processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource);
break;
}
}
}
private void findVnfWithGivenIdAndAddCustomizationUUID(ServiceInstance serviceInstanceMSO, String vnfId,
- List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, DelegateExecution execution) {
+ List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceList, Resource serviceResource,
+ DelegateExecution execution) {
for (GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
if (vnf.getVnfId().equals(vnfId)) {
aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
- resourceList.add(new Resource(WorkflowType.VNF,
- bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(), false));
- processVfModules(vnf, aaiResourceIds, resourceList, execution);
- processVolumeGroups(vnf, aaiResourceIds, resourceList);
+ Resource vnfResource = new Resource(WorkflowType.VNF,
+ bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(), false, serviceResource);
+ resourceList.add(vnfResource);
+ processVfModules(vnf, aaiResourceIds, resourceList, vnfResource, execution);
+ processVolumeGroups(vnf, aaiResourceIds, resourceList, vnfResource);
break;
}
}
}
private void findConfigurationsInsideVfModule(DelegateExecution execution, String vnfId, String vfModuleId,
- List<Resource> resourceList, List<Pair<WorkflowType, String>> aaiResourceIds) {
+ List<Resource> resourceList, Resource vfModuleResource, List<Pair<WorkflowType, String>> aaiResourceIds) {
try {
org.onap.aai.domain.yang.VfModule aaiVfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId);
AAIResultWrapper vfModuleWrapper = new AAIResultWrapper(
@@ -140,7 +150,7 @@ public class VnfEBBLoader {
relationshipsOp = vfModuleWrapper.getRelationships();
if (relationshipsOp.isPresent()) {
relationshipsOp = workflowActionUtils.extractRelationshipsVnfc(relationshipsOp.get());
- addConfigToResources(relationshipsOp, resourceList, aaiResourceIds);
+ addConfigToResources(relationshipsOp, resourceList, vfModuleResource, aaiResourceIds);
}
} catch (Exception ex) {
logger.error("Exception in findConfigurationsInsideVfModule", ex);
@@ -149,35 +159,39 @@ public class VnfEBBLoader {
}
private void processVfModules(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds,
- List<Resource> resourceList, DelegateExecution execution) {
+ List<Resource> resourceList, Resource vnfResource, DelegateExecution execution) {
if (vnf.getVfModules() != null) {
for (VfModule vfModule : vnf.getVfModules()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
- resourceList.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
+ Resource vfModuleResource =
+ new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource);
+ resourceList.add(vfModuleResource);
findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), resourceList,
- aaiResourceIds);
+ vfModuleResource, aaiResourceIds);
}
}
}
private void processVolumeGroups(GenericVnf vnf, List<Pair<WorkflowType, String>> aaiResourceIds,
- List<Resource> resourceList) {
+ List<Resource> resourceList, Resource vnfResource) {
if (vnf.getVolumeGroups() != null) {
for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) {
aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
+ resourceList.add(
+ new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false, vnfResource));
}
}
}
private void addConfigToResources(Optional<Relationships> relationshipsOp, List<Resource> resourceList,
- List<Pair<WorkflowType, String>> aaiResourceIds) {
+ Resource vfModuleResource, List<Pair<WorkflowType, String>> aaiResourceIds) {
if (relationshipsOp.isPresent()) {
Optional<Configuration> config =
workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
if (config.isPresent()) {
aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
- resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
+ resourceList.add(new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false,
+ vfModuleResource));
}
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java
index f4b2a8b4b1..c4fbdc5359 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceRequest.java
@@ -7,83 +7,89 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"rb-name", "rb-version", "profile-name", "release-name", "cloud-region", "labels",
- "override-values"})
public class InstanceRequest {
@JsonProperty("modelInvariantId")
- private String rbName;
+ private String modelInvariantId;
@JsonProperty("modelVersionId")
- private String rbVersion;
+ private String modelVersionId;
+ @JsonProperty("modelCustomizationId")
+ private String modelCustomizationId;
@JsonProperty("k8sRBProfileName")
private String profileName;
@JsonProperty("k8sRBInstanceReleaseName")
private String releaseName;
+ @JsonProperty("k8sRBInstanceStatusCheck")
+ private Boolean statusCheck = false;
@JsonProperty("vfModuleUUID")
private String vfModuleUUID;
@JsonProperty("cloudRegionId")
private String cloudRegion;
@JsonProperty("labels")
private Map<String, String> labels;
- @JsonProperty(value = "override-values")
+ @JsonProperty("override-values")
private Map<String, String> overrideValues;
- @JsonProperty("rb-name")
- public String getRbName() {
- return rbName;
+ public String getModelInvariantId() {
+ return modelInvariantId;
}
- @JsonProperty("rb-name")
- public void setRbName(String rbName) {
- this.rbName = rbName;
+ public void setModelInvariantId(String modelInvariantId) {
+ this.modelInvariantId = modelInvariantId;
}
- @JsonProperty("rb-version")
- public String getRbVersion() {
- return rbVersion;
+ public String getModelVersionId() {
+ return modelVersionId;
}
- @JsonProperty("rb-version")
- public void setRbVersion(String rbVersion) {
- this.rbVersion = rbVersion;
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getModelCustomizationId() {
+ return modelCustomizationId;
+ }
+
+ public void setModelCustomizationId(String modelCustomizationId) {
+ this.modelCustomizationId = modelCustomizationId;
}
- @JsonProperty("profile-name")
public String getProfileName() {
return profileName;
}
- @JsonProperty("profile-name")
public void setProfileName(String profileName) {
this.profileName = profileName;
}
- @JsonProperty("release-name")
+ public Boolean getStatusCheck() {
+ return statusCheck;
+ }
+
+ public void setStatusCheck(Boolean statusCheck) {
+ this.statusCheck = statusCheck;
+ }
+
public String getReleaseName() {
return releaseName;
}
- @JsonProperty("release-name")
public void setReleaseName(String releaseName) {
this.releaseName = releaseName;
}
- @JsonProperty("cloud-region")
public String getCloudRegion() {
return cloudRegion;
}
- @JsonProperty("cloud-region")
public void setCloudRegion(String cloudRegion) {
this.cloudRegion = cloudRegion;
}
- @JsonProperty("labels")
public Map<String, String> getLabels() {
return labels;
}
- @JsonProperty("labels")
public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java
new file mode 100644
index 0000000000..f2687efeac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICommonTasksTest.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.aai.tasks;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Optional;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AAICommonTasksTest {
+
+ private static final String SERVICE_TYPE = "testService";
+
+ @Mock
+ private ExtractPojosForBB extractPojosForBBMock;
+ @Mock
+ private ExceptionBuilder exceptionBuilder;
+ @InjectMocks
+ private AAICommonTasks testedObject;
+
+ private ServiceInstance serviceInstance;
+ private BuildingBlockExecution buildingBlockExecution;
+
+ @Before
+ public void setup() {
+ serviceInstance = new ServiceInstance();
+ buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ }
+
+ @Test
+ public void getServiceType_success() throws Exception {
+ // given
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setServiceType(SERVICE_TYPE);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID))
+ .thenReturn(serviceInstance);
+ // when
+ Optional<String> resultOpt = testedObject.getServiceType(buildingBlockExecution);
+ // then
+ assertThat(resultOpt).isNotEmpty();
+ String result = resultOpt.get();
+ assertThat(result).isEqualTo(SERVICE_TYPE);
+ }
+
+ @Test
+ public void getServiceType_emptyWhenServiceInstanceModelIsNull() throws Exception {
+ // given
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID))
+ .thenReturn(serviceInstance);
+ // when
+ Optional<String> result = testedObject.getServiceType(buildingBlockExecution);
+ // then
+ assertThat(result).isEmpty();
+ }
+
+ @Test
+ public void getServiceType_exceptionHandling() throws Exception {
+ // given
+ BBObjectNotFoundException exception = new BBObjectNotFoundException();
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.SERVICE_INSTANCE_ID))
+ .thenThrow(exception);
+ // when
+ testedObject.getServiceType(buildingBlockExecution);
+ // then
+ verify(exceptionBuilder).buildAndThrowWorkflowException(buildingBlockExecution, 7000, exception);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java
index cfaa4040c7..fb15ffa2b3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/level/ServiceLevelTest.java
@@ -21,35 +21,85 @@
package org.onap.so.bpmn.infrastructure.service.level;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import java.util.ArrayList;
+import java.util.List;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
import org.junit.Test;
-import java.util.List;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.infrastructure.service.level.impl.ServiceLevelConstants;
+import org.onap.so.client.exception.ExceptionBuilder;
+@RunWith(MockitoJUnitRunner.class)
public class ServiceLevelTest {
private static final String EXECUTION_KEY_PNF_NAME_LIST = "pnfNameList";
private static final String EXECUTION_KEY_PNF_COUNTER = "pnfCounter";
+ private static final String PARAM_NAME = "param1";
+ private static final String SCOPE = "scope1";
+ private static final String PNF_NAME = "pnfName1";
+
+ @Mock
+ private ExceptionBuilder exceptionBuilderMock;
+ @InjectMocks
+ private ServiceLevel testedObject;
+
+ private DelegateExecution execution;
+
+ @Before
+ public void init() {
+ execution = new DelegateExecutionFake();
+ }
@Test
public void pnfCounterExecution_success() {
// given
- String pnfName = "pnfName1";
- DelegateExecution execution = new DelegateExecutionFake();
- execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList(pnfName));
+ execution.setVariable(EXECUTION_KEY_PNF_NAME_LIST, createPnfNameList());
execution.setVariable(EXECUTION_KEY_PNF_COUNTER, 0);
// when
- new ServiceLevel().pnfCounterExecution(execution);
+ testedObject.pnfCounterExecution(execution);
// then
- assertThat(execution.getVariable(ServiceLevelConstants.PNF_NAME)).isEqualTo(pnfName);
+ assertThat(execution.getVariable(ServiceLevelConstants.PNF_NAME)).isEqualTo(PNF_NAME);
assertThat(execution.getVariable(EXECUTION_KEY_PNF_COUNTER)).isEqualTo(1);
}
- private List<String> createPnfNameList(String pnfName) {
+ @Test
+ public void validateParams_success_paramExistsInExecution() {
+ // given
+ execution.setVariable(PARAM_NAME, "anyValue");
+ // when
+ testedObject.validateParamsWithScope(execution, "anyScope", createParamList());
+ // then
+ verify(exceptionBuilderMock, times(0)).buildAndThrowWorkflowException(any(DelegateExecution.class),
+ eq(ServiceLevelConstants.ERROR_CODE), any(String.class));
+ }
+
+ @Test
+ public void validateParams_exceptionParamDoesNotExistInExecution() {
+ // when
+ testedObject.validateParamsWithScope(execution, SCOPE, createParamList());
+ // then
+ verify(exceptionBuilderMock).buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
+ "Validation of health check workflow parameters failed for the scope: " + SCOPE);
+ }
+
+ private List<String> createParamList() {
+ List<String> params = new ArrayList<>();
+ params.add(PARAM_NAME);
+ return params;
+ }
+
+ private List<String> createPnfNameList() {
List<String> pnfNameList = new ArrayList<>();
- pnfNameList.add(pnfName);
+ pnfNameList.add(PNF_NAME);
return pnfNameList;
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
index fae2317c8d..61b5740238 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
@@ -10,6 +10,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Tech Mahindra
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -29,8 +31,10 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import org.junit.Test;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -41,43 +45,6 @@ public class ExecuteBuildingBlockBuilderTest {
final private ExecuteBuildingBlockBuilder executeBBBuilder = new ExecuteBuildingBlockBuilder();
@Test
- public void sortVfModulesByBaseFirstTest() {
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
- resource1.setBaseVfModule(false);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
- resource3.setBaseVfModule(true);
- resources.add(resource3);
-
- List<Resource> result = executeBBBuilder.sortVfModulesByBaseFirst(resources);
- assertEquals("333", result.get(0).getResourceId());
- assertEquals("222", result.get(1).getResourceId());
- assertEquals("111", result.get(2).getResourceId());
- }
-
- @Test
- public void sortVfModulesByBaseLastTest() {
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
- resource1.setBaseVfModule(true);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
- resource3.setBaseVfModule(false);
- resources.add(resource3);
- List<Resource> result = executeBBBuilder.sortVfModulesByBaseLast(resources);
- assertEquals("333", result.get(0).getResourceId());
- assertEquals("222", result.get(1).getResourceId());
- assertEquals("111", result.get(2).getResourceId());
- }
-
- @Test
public void verifyLackOfNullPointerExceptionForNullResource() {
ExecuteBuildingBlock result = null;
try {
@@ -96,7 +63,7 @@ public class ExecuteBuildingBlockBuilderTest {
String cvnfModuleCustomizationId = "2b1a3c";
String vnfCustomizationId = "zz12aa";
- Resource resource = new Resource(WorkflowType.SERVICE, "123", true);
+ Resource resource = new Resource(WorkflowType.SERVICE, "123", true, null);
resource.setCvnfModuleCustomizationId(vfModuleCustomizationId);
resource.setCvnfModuleCustomizationId(cvnfModuleCustomizationId);
@@ -110,4 +77,170 @@ public class ExecuteBuildingBlockBuilderTest {
assertEquals(vnfCustomizationId, confResourceKeys.getVnfResourceCustomizationUUID());
}
+
+ private Resource getResource(List<Resource> resources, ExecuteBuildingBlock block) {
+ Resource res =
+ resources.stream().filter(resource -> resource.getResourceId() == block.getBuildingBlock().getKey())
+ .findAny().orElse(null);
+ return res;
+ }
+
+ private void buildExecuteBuildingBlockListOrderOfVnf(int vnfCount, boolean addPnf, boolean priorities) {
+ WorkflowResourceIds wfIds = new WorkflowResourceIds();
+ wfIds.setServiceInstanceId("1");
+ List<Resource> resources = new ArrayList<>();
+ Resource r1 = new Resource(WorkflowType.SERVICE, "1", false, null);
+ resources.add(r1);
+ for (int i = 0; i < vnfCount; i++) {
+ Resource r2 = new Resource(WorkflowType.VNF, Integer.toString(2 + i * 3), false, r1);
+ Resource r3 = new Resource(WorkflowType.VFMODULE, Integer.toString(3 + i * 3), false, r2);
+ Resource r4 = new Resource(WorkflowType.VFMODULE, Integer.toString(4 + i * 3), false, r2);
+ r4.setBaseVfModule(true);
+ resources.add(r2);
+ resources.add(r3);
+ resources.add(r4);
+ if (priorities) {
+ r2.setProcessingPriority(vnfCount - i);
+ r3.setProcessingPriority(1);
+ r4.setProcessingPriority(2);
+ }
+ }
+ if (addPnf) {
+ Resource r5 = new Resource(WorkflowType.PNF, Integer.toString(5 + (vnfCount - 1) * 3), false, r1);
+ resources.add(r5);
+ }
+
+ OrchestrationFlow f1 = new OrchestrationFlow();
+ f1.setFlowName("AssignServiceInstanceBB");
+ OrchestrationFlow f2 = new OrchestrationFlow();
+ f2.setFlowName("AssignVnfBB");
+ OrchestrationFlow f3 = new OrchestrationFlow();
+ f3.setFlowName("AssignVfModuleBB");
+ OrchestrationFlow f4 = new OrchestrationFlow();
+ f4.setFlowName("ControllerExecutionBB");
+ f4.setBpmnAction("config-assign");
+ f4.setBpmnScope("vnf");
+ OrchestrationFlow f5 = new OrchestrationFlow();
+ f5.setFlowName("AssignPnfBB");
+ OrchestrationFlow f6 = new OrchestrationFlow();
+ f6.setFlowName("WaitForPnfReadyBB");
+ OrchestrationFlow f7 = new OrchestrationFlow();
+ f7.setFlowName("ControllerExecutionBB");
+ f7.setBpmnAction("config-assign");
+ f7.setBpmnScope("pnf");
+ OrchestrationFlow f8 = new OrchestrationFlow();
+ f8.setFlowName("ControllerExecutionBB");
+ f8.setBpmnAction("config-deploy");
+ f8.setBpmnScope("pnf");
+ OrchestrationFlow f9 = new OrchestrationFlow();
+ f9.setFlowName("ActivatePnfBB");
+ OrchestrationFlow f10 = new OrchestrationFlow();
+ f10.setFlowName("CreateVfModuleBB");
+ OrchestrationFlow f11 = new OrchestrationFlow();
+ f11.setFlowName("ActivateVfModuleBB");
+ OrchestrationFlow f12 = new OrchestrationFlow();
+ f12.setFlowName("ControllerExecutionBB");
+ f12.setBpmnAction("config-deploy");
+ f12.setBpmnScope("vnf");
+ OrchestrationFlow f13 = new OrchestrationFlow();
+ f13.setFlowName("ActivateVnfBB");
+ OrchestrationFlow f14 = new OrchestrationFlow();
+ f14.setFlowName("ActivateServiceInstanceBB");
+
+ List<OrchestrationFlow> flows = Arrays.asList(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14);
+ for (int i = 0; i < flows.size(); i++) {
+ OrchestrationFlow flow = flows.get(i);
+ flow.setId(i + 1);
+ flow.setSequenceNumber(i + 1);
+ flow.setFlowVersion(1.0);
+ flow.setAction("Service-Macro-Create");
+ }
+
+ List<ExecuteBuildingBlock> flowsToExecute = executeBBBuilder.buildExecuteBuildingBlockList(flows, resources,
+ "1", "1", "1", WorkflowActionConstants.CREATE_INSTANCE, "type", wfIds, null, false);
+
+ for (ExecuteBuildingBlock block : flowsToExecute) {
+ String name = block.getBuildingBlock().getBpmnFlowName();
+ if (name.equals("ControllerExecutionBB"))
+ name += " [" + block.getBuildingBlock().getBpmnScope() + ", " + block.getBuildingBlock().getBpmnAction()
+ + "]";
+ System.out.println(name);
+ }
+ assertNotNull(flowsToExecute);
+ assertEquals((addPnf ? 7 : 2) + vnfCount * 4L + vnfCount * 2L * 3, flowsToExecute.size());
+
+ for (ExecuteBuildingBlock block : flowsToExecute)
+ assertNotNull(getResource(resources, block));
+
+ if (priorities) {
+ if (vnfCount > 1)
+ assertEquals("5", getResource(resources, flowsToExecute.get(1)).getResourceId());
+ else
+ assertEquals("3", getResource(resources, flowsToExecute.get(2)).getResourceId());
+ } else {
+ if (vnfCount > 1)
+ assertEquals("2", getResource(resources, flowsToExecute.get(1)).getResourceId());
+ else
+ assertEquals("4", getResource(resources, flowsToExecute.get(2)).getResourceId());
+ }
+
+ // AssignVfModuleBB
+ assertEquals(f3.getFlowName(), flowsToExecute.get(2).getBuildingBlock().getBpmnFlowName());
+ // ControllerExecutionBB
+ assertEquals(f4.getFlowName(), flowsToExecute.get(4).getBuildingBlock().getBpmnFlowName());
+ if (vnfCount > 1) {
+ // AssignVnfBB
+ if (addPnf)
+ assertEquals(f2.getFlowName(), flowsToExecute.get(5).getBuildingBlock().getBpmnFlowName());
+ else
+ assertEquals(f2.getFlowName(), flowsToExecute.get(11).getBuildingBlock().getBpmnFlowName());
+ }
+ int pnfOffset = -5;
+ if (addPnf) {
+ pnfOffset = (vnfCount - 1) * 4;
+ // AssignPnfBB
+ assertEquals(f5.getFlowName(), flowsToExecute.get(5 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // WaitForPnfReadyBB
+ assertEquals(f6.getFlowName(), flowsToExecute.get(6 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // ControllerExecutionBB
+ assertEquals(f7.getFlowName(), flowsToExecute.get(7 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // ControllerExecutionBB
+ assertEquals(f8.getFlowName(), flowsToExecute.get(8 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // ActivatePnfBB
+ assertEquals(f9.getFlowName(), flowsToExecute.get(9 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ }
+ // CreateVfModuleBB
+ assertEquals(f10.getFlowName(), flowsToExecute.get(10 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // ActivateVfModuleBB
+ assertEquals(f11.getFlowName(), flowsToExecute.get(11 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // ControllerExecutionBB
+ assertEquals(f12.getFlowName(), flowsToExecute.get(14 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ // ActivateVnfBB
+ assertEquals(f13.getFlowName(), flowsToExecute.get(15 + pnfOffset).getBuildingBlock().getBpmnFlowName());
+ }
+
+ @Test
+ public void buildExecuteBuildingBlockListSortByBaseVfModuleTest() {
+ buildExecuteBuildingBlockListOrderOfVnf(1, false, false);
+ }
+
+ @Test
+ public void buildExecuteBuildingBlockListSortByPriorityTest() {
+ buildExecuteBuildingBlockListOrderOfVnf(1, false, true);
+ }
+
+ @Test
+ public void buildExecuteBuildingBlockListGroupByResourceTypeAndSortByPriorityTest() {
+ buildExecuteBuildingBlockListOrderOfVnf(2, false, true);
+ }
+
+ @Test
+ public void buildExecuteBuildingBlockListGroupByResourceTypeTest() {
+ buildExecuteBuildingBlockListOrderOfVnf(2, false, false);
+ }
+
+ @Test
+ public void buildExecuteBuildingBlockListGroupByResourceTypeVnfAndPnfTest() {
+ buildExecuteBuildingBlockListOrderOfVnf(2, true, false);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java
new file mode 100644
index 0000000000..cd98792938
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Bell Canada. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.workflow.tasks;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.Test;
+
+public class ResourceTest {
+
+ @Test
+ public void testBaseFirstComparator() {
+ Resource r1 = new Resource(null, "1", false, null);
+ Resource r2 = new Resource(null, "2", false, null);
+ r2.setBaseVfModule(true);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2).stream().sorted(Resource.sortByPriorityAsc).collect(Collectors.toList());
+
+ assertEquals("2", sorted.get(0).getResourceId());
+ }
+
+ @Test
+ public void testPriorityAscComparator() {
+ Resource r1 = new Resource(null, "1", false, null);
+ Resource r2 = new Resource(null, "2", false, null);
+ Resource r3 = new Resource(null, "3", false, null);
+ Resource r4 = new Resource(null, "4", false, null);
+ r1.setProcessingPriority(4);
+ r2.setBaseVfModule(true);
+ r3.setProcessingPriority(2);
+ r4.setProcessingPriority(1);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2, r3, r4).stream().sorted(Resource.sortByPriorityAsc).collect(Collectors.toList());
+
+ assertEquals("2", sorted.get(0).getResourceId());
+ assertEquals("4", sorted.get(1).getResourceId());
+ assertEquals("3", sorted.get(2).getResourceId());
+ }
+
+ @Test
+ public void testBaseLastComparator() {
+ Resource r1 = new Resource(null, "1", false, null);
+ Resource r2 = new Resource(null, "2", false, null);
+ r1.setBaseVfModule(true);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2).stream().sorted(Resource.sortByPriorityDesc).collect(Collectors.toList());
+
+ assertEquals("1", sorted.get(1).getResourceId());
+ }
+
+ @Test
+ public void testPriorityDescComparator() {
+ Resource r1 = new Resource(null, "1", false, null);
+ Resource r2 = new Resource(null, "2", false, null);
+ Resource r3 = new Resource(null, "3", false, null);
+ Resource r4 = new Resource(null, "4", false, null);
+ r1.setProcessingPriority(4);
+ r2.setBaseVfModule(true);
+ r3.setProcessingPriority(2);
+ r4.setProcessingPriority(1);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2, r3, r4).stream().sorted(Resource.sortByPriorityDesc).collect(Collectors.toList());
+
+ assertEquals("1", sorted.get(0).getResourceId());
+ assertEquals("3", sorted.get(1).getResourceId());
+ assertEquals("4", sorted.get(2).getResourceId());
+ }
+
+ @Test
+ public void testPriorityReplaceBase() {
+ Resource r1 = new Resource(null, "1", false, null);
+ Resource r2 = new Resource(null, "2", false, null);
+ Resource r3 = new Resource(null, "3", false, null);
+ Resource r4 = new Resource(null, "4", false, null);
+ r1.setProcessingPriority(4);
+ r2.setBaseVfModule(true);
+ r2.setProcessingPriority(6);
+ r3.setProcessingPriority(2);
+ r4.setProcessingPriority(1);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2, r3, r4).stream().sorted(Resource.sortByPriorityAsc).collect(Collectors.toList());
+
+ assertEquals("4", sorted.get(0).getResourceId());
+ assertEquals("3", sorted.get(1).getResourceId());
+ assertEquals("1", sorted.get(2).getResourceId());
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 10e6ed4895..e52d2dfecf 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -8,6 +8,8 @@
* ================================================================================
* Modifications Copyright (c) 2020 Nokia
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -115,6 +117,7 @@ public class WorkflowActionTest extends BaseTaskTest {
"VfModuleReplaceRebuildVolumeGroups.json";
private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json";
private static final String MACRO_VNF_MACRO_REPLACE_JSON = "Macro/VnfMacroReplace.json";
+ private static final String MACRO_CREATE_JSON = "Macro/ServiceMacroAssignVnfAndPnf.json";
@Mock
protected Environment environment;
@@ -298,7 +301,7 @@ public class WorkflowActionTest extends BaseTaskTest {
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
- .thenReturn(prepareListWithResources());
+ .thenReturn(prepareListWithResources(false, false));
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
@@ -349,7 +352,7 @@ public class WorkflowActionTest extends BaseTaskTest {
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
- .thenReturn(prepareListWithResources());
+ .thenReturn(prepareListWithResources(false, false));
when(environment.getProperty("org.onap.so.cloud-owner")).thenReturn("att-aic");
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "att-aic")).thenReturn(northBoundRequest);
@@ -406,13 +409,13 @@ public class WorkflowActionTest extends BaseTaskTest {
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
- "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+ "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
"ActivateServiceInstanceBB");
assertEquals("volumeGroup0", ebbs.get(0).getWorkflowResourceIds().getVolumeGroupId());
assertEquals("volumeGroup0", ebbs.get(1).getWorkflowResourceIds().getVolumeGroupId());
assertEquals("testVfModuleId1", ebbs.get(2).getWorkflowResourceIds().getVfModuleId());
- assertEquals("testVfModuleId2", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
- assertEquals("testVfModuleId1", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("testVfModuleId1", ebbs.get(3).getWorkflowResourceIds().getVfModuleId());
+ assertEquals("testVfModuleId2", ebbs.get(4).getWorkflowResourceIds().getVfModuleId());
assertEquals("testVfModuleId2", ebbs.get(5).getWorkflowResourceIds().getVfModuleId());
assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId());
assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId());
@@ -624,7 +627,7 @@ public class WorkflowActionTest extends BaseTaskTest {
vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
- .thenReturn(prepareListWithResources());
+ .thenReturn(prepareListWithResources(false, false));
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
@@ -638,8 +641,8 @@ public class WorkflowActionTest extends BaseTaskTest {
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
"AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "CreateVolumeGroupBB",
- "ActivateVolumeGroupBB", "CreateVfModuleBB", "CreateVfModuleBB", "CreateVfModuleBB",
- "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
+ "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB",
"ActivateServiceInstanceBB");
assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
@@ -663,6 +666,92 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
+ public void selectExecutionListServiceMacroCreateWithUserParamsAndPriorities() throws Exception {
+ String gAction = "createInstance";
+ String resource = "Service";
+ String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_JSON);
+ initExecution(gAction, bpmnRequest, false);
+ execution.setVariable("requestUri", "v6/serviceInstances/123");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
+ "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "AssignPnfBB",
+ "WaitForPnfReadyBB", "ActivatePnfBB", "CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB",
+ "ActivateVolumeGroupBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB",
+ "ActivateFabricConfigurationBB", "ActivateVnfBB", "ActivateNetworkCollectionBB",
+ "ActivateServiceInstanceBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ Service service = new Service();
+ service.setModelUUID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setModelCustomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ HeatEnvironment volumeHeatEnv = new HeatEnvironment();
+ vfModuleCustomization.setVolumeHeatEnv(volumeHeatEnv);
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate volumeHeatTemplate = new HeatTemplate();
+ vfModule.setVolumeHeatTemplate(volumeHeatTemplate);
+ vfModuleCustomization.setVfModule(vfModule);
+
+ VfModuleCustomization vfModuleCustomization2 = new VfModuleCustomization();
+ vfModuleCustomization2.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ vfModuleCustomization2.setHeatEnvironment(heatEnvironment);
+ org.onap.so.db.catalog.beans.VfModule vfModule2 = new org.onap.so.db.catalog.beans.VfModule();
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ vfModule2.setModuleHeatTemplate(moduleHeatTemplate);
+ vfModuleCustomization2.setVfModule(vfModule2);
+
+ VfModuleCustomization vfModuleCustomization3 = vfModuleCustomization2;
+ vfModuleCustomization3.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+
+ when(userParamsServiceTraversal.getResourceListFromUserParams(any(), anyList(), anyString(), anyString()))
+ .thenReturn(prepareListWithResources(true, true));
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"))
+ .thenReturn(vfModuleCustomization);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"))
+ .thenReturn(vfModuleCustomization2);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("da4d4327-fb7d-4311-ac7a-be7ba60cf969"))
+ .thenReturn(vfModuleCustomization3);
+ when(catalogDbClient.getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a")).thenReturn(service);
+ workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "AssignVnfBB", "AssignVolumeGroupBB",
+ "AssignVfModuleBB", "AssignVfModuleBB", "AssignVfModuleBB", "AssignPnfBB", "WaitForPnfReadyBB",
+ "ActivatePnfBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "ActivateVnfBB", "ActivateServiceInstanceBB");
+
+ assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
+ int randomUUIDLength = UUID.randomUUID().toString().length();
+ assertEquals(randomUUIDLength, ebbs.get(1).getWorkflowResourceIds().getVnfId().length());
+ assertEquals(randomUUIDLength, ebbs.get(2).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(3).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(4).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(5).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals("72d9d1cd-f46d-447a-abdb-451d6fb05fa8", ebbs.get(3).getBuildingBlock().getKey());
+ assertEquals("da4d4327-fb7d-4311-ac7a-be7ba60cf969", ebbs.get(4).getBuildingBlock().getKey());
+ assertEquals("3c40d244-808e-42ca-b09a-256d83d19d0a", ebbs.get(5).getBuildingBlock().getKey());
+ assertEquals(randomUUIDLength, ebbs.get(6).getWorkflowResourceIds().getPnfId().length());
+ assertEquals(randomUUIDLength, ebbs.get(7).getWorkflowResourceIds().getPnfId().length());
+ assertEquals(randomUUIDLength, ebbs.get(8).getWorkflowResourceIds().getPnfId().length());
+ assertEquals(randomUUIDLength, ebbs.get(9).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(10).getWorkflowResourceIds().getVolumeGroupId().length());
+ assertEquals(randomUUIDLength, ebbs.get(11).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(12).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(13).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(14).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(15).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(16).getWorkflowResourceIds().getVfModuleId().length());
+ assertEquals(randomUUIDLength, ebbs.get(17).getWorkflowResourceIds().getVnfId().length());
+ assertEquals(3, ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length());
+ assertEquals(true, execution.getVariable("homing"));
+ }
+
+ @Test
public void selectExecutionListServiceMacroDeleteTest() throws Exception {
String gAction = "deleteInstance";
String resource = "Service";
@@ -708,7 +797,7 @@ public class WorkflowActionTest extends BaseTaskTest {
false, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
+ assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVfModuleBB",
"DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB",
"DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB",
"UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB");
@@ -879,8 +968,8 @@ public class WorkflowActionTest extends BaseTaskTest {
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB",
- "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB",
- "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
+ "DeleteVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVnfBB", "SDNOVnfHealthCheckBB",
"AAIUnsetVnfInMaintBB");
}
@@ -940,12 +1029,13 @@ public class WorkflowActionTest extends BaseTaskTest {
false, "cloud-owner")).thenReturn(northBoundRequest);
workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
- assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateFabricConfigurationBB",
- "UnassignFabricConfigurationBB", "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB",
- "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB", "ChangeModelVfModuleBB",
- "CreateVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "ActivateVfModuleBB",
- "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB", "ChangeModelVnfBB", "ActivateVnfBB",
- "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB", "AAIUnsetVnfInMaintBB");
+ assertEqualsBulkFlowName(ebbs, "AAICheckVnfInMaintBB", "AAISetVnfInMaintBB", "DeactivateVfModuleBB",
+ "DeleteVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB",
+ "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVnfBB", "ChangeModelVfModuleBB",
+ "CreateVfModuleBB", "ActivateVfModuleBB", "ChangeModelVfModuleBB", "CreateVfModuleBB",
+ "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB",
+ "ChangeModelVnfBB", "ActivateVnfBB", "ChangeModelServiceInstanceBB", "SDNOVnfHealthCheckBB",
+ "AAIUnsetVnfInMaintBB");
for (ExecuteBuildingBlock executeBuildingBlock : ebbs) {
assertEquals("123", executeBuildingBlock.getWorkflowResourceIds().getServiceInstanceId());
}
@@ -1540,7 +1630,7 @@ public class WorkflowActionTest extends BaseTaskTest {
String vnfType = "vnfType";
String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
- Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
thrown.expect(AAIEntityNotFoundException.class);
@@ -1592,7 +1682,7 @@ public class WorkflowActionTest extends BaseTaskTest {
String vnfType = "vnfType";
String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
- Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
@@ -1667,7 +1757,7 @@ public class WorkflowActionTest extends BaseTaskTest {
String vnfType = "vnfType";
String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
- Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ Resource resourceKey = new Resource(resourceType, key, aLaCarte, null);
WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
@@ -1948,10 +2038,10 @@ public class WorkflowActionTest extends BaseTaskTest {
String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction";
String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace";
String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut";
- Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true);
- Resource expected2 = new Resource(WorkflowType.VNF, "1234", false);
- Resource expected3 = new Resource(WorkflowType.VNF, "1234", false);
- Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false);
+ Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true, null);
+ Resource expected2 = new Resource(WorkflowType.VNF, "1234", false, expected1);
+ Resource expected3 = new Resource(WorkflowType.VNF, "1234", false, expected1);
+ Resource expected4 = new Resource(WorkflowType.VFMODULE, "5678", false, expected2);
Resource result = workflowAction.extractResourceIdAndTypeFromUri(uri);
assertEquals(expected1.getResourceId(), result.getResourceId());
assertEquals(expected1.getResourceType(), result.getResourceType());
@@ -2091,14 +2181,31 @@ public class WorkflowActionTest extends BaseTaskTest {
return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName)));
}
- private List<Resource> prepareListWithResources() {
+ private List<Resource> prepareListWithResources(boolean addPnf, boolean addPriorites) {
List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
- resourceList.add(new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false));
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false));
- resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
- resourceList.add(new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
- resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
+ Resource r1 = new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false, null);
+ resourceList.add(r1);
+ Resource r2 = new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false, r1);
+ resourceList.add(r2);
+ Resource r3 = new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false, r2);
+ resourceList.add(r3);
+ Resource r4 = new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false, r2);
+ resourceList.add(r4);
+ Resource r5 = new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false, r2);
+ resourceList.add(r5);
+ Resource r6 = new Resource(WorkflowType.VFMODULE, "da4d4327-fb7d-4311-ac7a-be7ba60cf969", false, r2);
+ resourceList.add(r6);
+ if (addPnf) {
+ Resource r7 = new Resource(WorkflowType.PNF, "aa153b6e-c364-44c0-bef6-1f2982117f04", false, r1);
+ resourceList.add(r7);
+ }
+ if (addPriorites) {
+ r3.setProcessingPriority(2);
+ r4.setProcessingPriority(1);
+ r5.setProcessingPriority(4);
+ r5.setBaseVfModule(true);
+ r6.setProcessingPriority(3);
+ }
return resourceList;
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
index a5ecf364a6..7a26422eb9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (c) 2020 Nokia
* ================================================================================
+ * Modifications Copyright (c) 2021 Orange
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -171,10 +173,10 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
@Test
public void foundRelatedTest() {
List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.PNF, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.PNF, "model customization id", false, null));
+ resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false, null));
+ resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false, null));
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false, null));
assertTrue(serviceEBBLoader.foundRelated(resourceList));
}
@@ -182,10 +184,10 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
@Test
public void containsWorkflowTypeTest() {
List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.PNF, "resource id", false));
- resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.PNF, "resource id", false, null));
+ resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false, null));
+ resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false, null));
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false, null));
assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.PNF));
assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.VNF));
@@ -280,7 +282,8 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
doReturn(aaiLocalNetwork).when(mockBbInputSetupUtils).getAAIL3Network("localNetworkInstanceId");
- serviceEBBLoader.traverseVrfConfiguration(aaiResourceIds, resource, service, relatedVpnBinding,
+ Resource serviceResource = new Resource(WorkflowType.SERVICE, "1", false, null);
+ serviceEBBLoader.traverseVrfConfiguration(aaiResourceIds, resource, serviceResource, service, relatedVpnBinding,
relatedLocalNetwork);
assertEquals(resource.size(), 1);
assertEquals(aaiResourceIds.size(), 0);
@@ -346,12 +349,14 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
private List<Resource> prepareListWithResources() {
List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
- resourceList.add(new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false));
- resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false));
- resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
- resourceList.add(new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
- resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
+ Resource r1 = new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false, null);
+ resourceList.add(r1);
+ Resource r2 = new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false, r1);
+ resourceList.add(r2);
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false, r2));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false, r2));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false, r2));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false, r2));
return resourceList;
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
index 9f4bd97ac6..58fee86ade 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
@@ -59,6 +59,7 @@ import static org.mockito.Mockito.mock;
public class UserParamsServiceTraversalTest extends BaseTaskTest {
private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json";
+ private static final String MACRO_CREATE_JSON = "Macro/ServiceMacroAssignVnfAndPnf.json";
private static final String MACRO_ASSIGN_PNF_JSON = "Macro/ServiceMacroAssignPnf.json";
private static final String NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json";
private static final String MACRO_CREATE_WITHOUT_RESOURCES_JSON = "Macro/ServiceMacroCreateWithoutResources.json";
@@ -114,6 +115,26 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest {
}
@Test
+ public void getResourceListFromUserParamsForVnfsWithPriorities() throws Exception {
+ initExecution(requestAction, readBpmnRequestFromFile(MACRO_CREATE_JSON), false);
+ Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient)
+ .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(),
+ anyString(), anyString());
+
+ List<Resource> resourceListFromUserParams = userParamsServiceTraversal.getResourceListFromUserParams(execution,
+ getUserParams(), serviceInstanceId, requestAction);
+ List<WorkflowType> expected = List.of(WorkflowType.SERVICE, WorkflowType.VNF, WorkflowType.VOLUMEGROUP,
+ WorkflowType.VFMODULE, WorkflowType.CONFIGURATION, WorkflowType.PNF);
+ List<WorkflowType> result =
+ resourceListFromUserParams.stream().map(Resource::getResourceType).collect(Collectors.toList());
+
+ assertEquals(6, resourceListFromUserParams.size());
+ assertThat(expected, is(result));
+ assertEquals(2, resourceListFromUserParams.get(1).getChildren().get(1).getProcessingPriority());
+ }
+
+ @Test
public void getResourceListFromUserParamsForPnfs() throws Exception {
initExecution(requestAction, readBpmnRequestFromFile(MACRO_ASSIGN_PNF_JSON), false);
Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient)
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignVnfAndPnf.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignVnfAndPnf.json
new file mode 100644
index 0000000000..5a2c963135
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignVnfAndPnf.json
@@ -0,0 +1,157 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "Sample Service Model",
+ "modelVersion": "10.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner": "my-custom-cloud-owner"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "xxxxxx",
+ "instanceName": "test"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [
+ {
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "Sample Service Model",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceParams": [],
+ "resources": {
+ "pnfs": [
+ {
+ "modelInfo": {
+ "modelType": "pnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L-PNF",
+ "modelVersionId": "1f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L-PNF 0",
+ "modelCustomizationId": "aa153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "test"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "someValue"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceParams": []
+ }
+ ],
+ "vnfs": [
+ {
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelName": "2016-73_MOW-AVPN-vPE-BV-L",
+ "modelVersionId": "7f40c192-f63c-463e-ba94-286933b895f8",
+ "modelCustomizationName": "2016-73_MOW-AVPN-vPE-BV-L 0",
+ "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "platform": {
+ "platformName": "test"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "someValue"
+ },
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "instanceParams": [],
+ "processingPriority": 2,
+ "vfModules": [
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0",
+ "modelVersionId": "4c75f813-fa91-45a4-89d0-790ff5f1ae79",
+ "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"
+ },
+ "processingPriority": 2,
+ "instanceParams": [
+ {
+ "vmx_int_net_len": "24"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
+ "modelVersionId": "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8"
+ },
+ "processingPriority": 1,
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "100"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vPFE_BV..module-3",
+ "modelVersionId": "f555558f-d538-4876-8ffa-b102650fad64",
+ "modelCustomizationId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "processingPriority": 4,
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vmx_vpfe_int_ip_0": "192.168.0.16"
+ }
+ ]
+ },
+ {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelName": "201673MowAvpnVpeBvL..AVPN_vRE_BV..module-2",
+ "modelVersionId": "16e2b103-637c-4d1a-adc8-3a7f4a6c3240",
+ "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf969"
+ },
+ "processingPriority": 3,
+ "instanceParams": [
+ {
+ "availability_zone_0": "mtpocdv-kvm-az01",
+ "vre_a_volume_size_0": "50"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/logback-test.xml b/bpmn/so-bpmn-tasks/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..bb4aee6e05
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/logback-test.xml
@@ -0,0 +1,36 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP - SO
+ ================================================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.reflections" level="ERROR" />
+ <logger name="org.onap" level="DEBUG" />
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>