aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy3
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy83
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy16
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java245
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java112
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java24
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java29
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java95
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java34
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy8
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy10
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java384
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java63
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java11
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/vfModuleCount.xml44
28 files changed, 916 insertions, 292 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml
index abf53f96f5..b115d36a0a 100644
--- a/bpmn/MSOCommonBPMN/pom.xml
+++ b/bpmn/MSOCommonBPMN/pom.xml
@@ -363,12 +363,12 @@
<dependency>
<groupId>org.onap.sdc.sdc-tosca</groupId>
<artifactId>sdc-tosca</artifactId>
- <version>1.4.1</version>
+ <version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.onap.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.4.1</version>
+ <version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
index 2f240fb70d..4f0b530a3b 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy
@@ -931,7 +931,8 @@ class MsoUtils {
if (moduleIndexList == null || moduleIndexList.size() == 0) {
return "0"
}
- def sortedModuleIndexList = moduleIndexList.sort { a, b -> a.compareTo b }
+
+ def sortedModuleIndexList = moduleIndexList.sort{ a, b -> a as Integer <=> b as Integer}
for (i in 0..sortedModuleIndexList.size()-1) {
if (Integer.parseInt(sortedModuleIndexList[i]) != i) {
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index 5659c7affa..5e949fd8d2 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -35,7 +35,7 @@ import org.onap.so.client.HttpClientFactory
import org.onap.so.logger.MsoLogger
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
-
+import org.onap.so.db.catalog.beans.HomingInstance
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.utils.TargetEntity
@@ -209,17 +209,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
for (int j = 0; j < arrSol.length(); j++) {
JSONObject placement = arrSol.getJSONObject(j)
utils.log("DEBUG", "****** Placement Solution is: " + placement + " *****", "true")
- String jsonServiceResourceId = placement.getString("serviceResourceId")
- String jsonResourceModuleName = placement.getString("resourceModuleName")
+ String jsonServiceResourceId = jsonUtil.getJsonValue( placement.toString(), "serviceResourceId")
+ utils.log("DEBUG", "****** homing serviceResourceId is: " + jsonServiceResourceId + " *****", "true")
for (Resource resource : resourceList) {
String serviceResourceId = resource.getResourceId()
- String resourceModuleName = ""
- if (resource.getResourceType() == ResourceType.ALLOTTED_RESOURCE ||
- resource.getResourceType() == ResourceType.VNF) {
- resourceModuleName = resource.getNfFunction()
- }
- if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId) ||
- resourceModuleName.equalsIgnoreCase(jsonResourceModuleName)) {
+ utils.log("DEBUG", "****** decomp serviceResourceId is: " + serviceResourceId + " *****", "true")
+ if (serviceResourceId.equalsIgnoreCase(jsonServiceResourceId)) {
JSONObject solution = placement.getJSONObject("solution")
String solutionType = solution.getString("identifierType")
String inventoryType = ""
@@ -228,20 +223,26 @@ class OofHoming extends AbstractServiceTaskProcessor {
} else {
inventoryType = "cloud"
}
+ utils.log("DEBUG", "****** homing inventoryType is: " + inventoryType + " *****", "true")
resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType))
JSONArray assignmentArr = placement.getJSONArray("assignmentInfo")
+ utils.log("DEBUG", "****** assignmentInfo is: " + assignmentArr.toString() + " *****", "true")
+
+ Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
+ assignmentArr.toString(), "key", "value")
String oofDirectives = null
- assignmentArr.each { element ->
- JSONObject jsonObject = new JSONObject(element.toString())
- if (jsonUtil.getJsonRawValue(jsonObject.toString(), "key") == "oof_directives") {
- oofDirectives = jsonUtil.getJsonRawValue(jsonObject.toString(), "value")
+ assignmentMap.each { key, value ->
+ utils.log("DEBUG", "****** element: " + key + " *****", "true")
+ if (key == "oof_directives") {
+ oofDirectives = value
+ utils.log("DEBUG", "****** homing oofDirectives: " + oofDirectives + " *****", "true")
}
}
- Map<String, String> assignmentMap = jsonUtil.entryArrayToMap(execution,
- assignmentArr.toString(), "key", "value")
String cloudOwner = assignmentMap.get("cloudOwner")
+ utils.log("DEBUG", "****** homing cloudOwner: " + cloudOwner + " *****", "true")
String cloudRegionId = assignmentMap.get("locationId")
+ utils.log("DEBUG", "****** homing cloudRegionId: " + cloudRegionId + " *****", "true")
resource.getHomingSolution().setCloudOwner(cloudOwner)
resource.getHomingSolution().setCloudRegionId(cloudRegionId)
@@ -249,12 +250,26 @@ class OofHoming extends AbstractServiceTaskProcessor {
cloudSite.setId(cloudRegionId)
cloudSite.setRegionId(cloudRegionId)
String orchestrator = execution.getVariable("orchestrator")
- if ((orchestrator != null) || (orchestrator != "")) {
+ if ((orchestrator != null) && (orchestrator != "")) {
cloudSite.setOrchestrator(orchestrator)
+ utils.log("DEBUG", "****** orchestrator: " + orchestrator + " *****", "true")
+ } else {
+ cloudSite.setOrchestrator("multicloud")
}
CloudIdentity cloudIdentity = new CloudIdentity()
cloudIdentity.setId(cloudRegionId)
+ cloudIdentity.setIdentityServerType(ServerType."KEYSTONE")
+ cloudIdentity.setAdminTenant("service")
+ cloudIdentity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD)
+ String msoMulticloudUserName = UrnPropertiesReader
+ .getVariable("mso.multicloud.api.username", execution,
+ "apih")
+ String msoMulticloudPassword = UrnPropertiesReader
+ .getVariable("mso.multicloud.api.password", execution,
+ "abc123")
+ cloudIdentity.setMsoId(msoMulticloudUserName)
+ cloudIdentity.setMsoPass(msoMulticloudPassword)
// Get MSB Url
String msbHost = oofUtils.getMsbHost(execution)
String multicloudApiEndpoint = UrnPropertiesReader
@@ -263,19 +278,39 @@ class OofHoming extends AbstractServiceTaskProcessor {
cloudIdentity.setIdentityUrl(msbHost + multicloudApiEndpoint
+ "/" + cloudOwner + "/" +
cloudRegionId + "/infra_workload")
-
+ utils.log("DEBUG", "****** Cloud IdentityUrl: " + msbHost + multicloudApiEndpoint
+ + "/" + cloudOwner + "/" +
+ cloudRegionId + "/infra_workload"
+ + " *****", "true")
+ utils.log("DEBUG", "****** CloudIdentity: " + cloudIdentity.toString()
+ + " *****", "true")
cloudSite.setIdentityService(cloudIdentity)
+ utils.log("DEBUG", "****** CloudSite: " + cloudSite.toString()
+ + " *****", "true")
// Set cloudsite in catalog DB here
- oofUtils.createCloudSiteCatalogDb(cloudSite)
+ oofUtils.createCloudSite(cloudSite, execution)
if (oofDirectives != null && oofDirectives != "") {
resource.getHomingSolution().setOofDirectives(oofDirectives)
execution.setVariable("oofDirectives", oofDirectives)
- utils.log("DEBUG", "***** OofDirectives is: " + oofDirectives +
+ utils.log("DEBUG", "***** OofDirectives set to: " + oofDirectives +
" *****", "true")
}
+ // Set Homing Instance
+ String serviceInstanceId = decomposition.getServiceInstance().getInstanceId()
+ HomingInstance homingInstance = new HomingInstance()
+ homingInstance.setServiceInstanceId(serviceInstanceId)
+ homingInstance.setCloudOwner(cloudOwner)
+ homingInstance.setCloudRegionId(cloudRegionId)
+ if (oofDirectives != null && oofDirectives != "") {
+ homingInstance.setOofDirectives(oofDirectives)}
+ else {
+ homingInstance.setOofDirectives("{}")
+ }
+ oofUtils.createHomingInstance(homingInstance, execution)
+
if (inventoryType.equalsIgnoreCase("service")) {
resource.getHomingSolution().setRehome(assignmentMap.get("isRehome").toBoolean())
VnfResource vnf = new VnfResource()
@@ -283,6 +318,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
resource.getHomingSolution().setVnf(vnf)
resource.getHomingSolution().setServiceInstanceId(solution.getJSONArray("identifiers")[0].toString())
}
+ } else {
+ utils.log("DEBUG", "ProcessHomingSolution Exception: no matching serviceResourceIds returned in " +
+ "homing solution", isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - " +
+ "Occurred in Homing ProcessHomingSolution: no matching serviceResourceIds returned")
+
}
}
}
@@ -312,8 +353,10 @@ class OofHoming extends AbstractServiceTaskProcessor {
utils.log("DEBUG", "*** Completed Homing Process Homing Solution ***", isDebugEnabled)
} catch (BpmnError b) {
+ utils.log("DEBUG", "ProcessHomingSolution Error: " + b, isDebugEnabled)
throw b
} catch (Exception e) {
+ utils.log("DEBUG", "ProcessHomingSolution Exception: " + e, isDebugEnabled)
msoLogger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution")
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index c0da8881fb..af33f38a64 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -36,6 +36,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
import org.onap.so.db.catalog.beans.CloudSite
+import org.onap.so.db.catalog.beans.HomingInstance
import org.onap.so.utils.TargetEntity
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
@@ -495,6 +496,7 @@ class OofUtils {
if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)}
return candidatesJson
}
+
/**
* This method creates a cloudsite in catalog database.
*
@@ -524,9 +526,19 @@ class OofUtils {
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.")
}
}
-
+
+ /**
+ * This method creates a HomingInstance in catalog database.
+ *
+ * @param HomingInstance homingInstance
+ *
+ * @return void
+ */
+ Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+ oofInfraUtils.createHomingInstance(homingInstance, execution)
+ }
String getMsbHost(DelegateExecution execution) {
- msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
+ String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger()
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
index 12a4b2a9c3..025b533dc0 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
@@ -20,29 +20,18 @@
package org.onap.so.bpmn.common.resource;
-import java.io.File;
import java.io.IOException;
-import java.nio.file.Paths;
+import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Optional;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import org.camunda.bpm.engine.runtime.Execution;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.sdc.toscaparser.api.RequirementAssignment;
-import org.onap.sdc.toscaparser.api.RequirementAssignments;
-import org.onap.sdc.toscaparser.api.functions.GetInput;
-import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.onap.so.bpmn.core.json.JsonUtils;
import org.onap.so.client.HttpClient;
@@ -58,86 +47,34 @@ import com.google.gson.reflect.TypeToken;
public class ResourceRequestBuilder {
- private static String CUSTOMIZATION_UUID = "customizationUUID";
+ private static String CUSTOMIZATION_UUID = "cuserviceResourcesstomizationUUID";
- private static String SERVICE_URL_TOSCA_CSAR = "/v3/serviceToscaCsar";
+ private static String SERVICE_URL_SERVICE_INSTANCE = "/v2/serviceResources";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ResourceRequestBuilder.class);
static JsonUtils jsonUtil = new JsonUtils();
- public static List<String> getResourceSequence(Execution execution, String serviceUuid) {
- List<String> resouceSequence = new ArrayList<String>();
- List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
- String csarpath = null;
- try {
- csarpath = getCsarFromUuid(serviceUuid);
-
- SdcToscaParserFactory toscaParser = SdcToscaParserFactory.getInstance();
- ISdcCsarHelper iSdcCsarHelper = toscaParser.getSdcCsarHelper(csarpath, false);
- List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
-
- if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
- resultList.add(nodeTemplate);
- nodes.remove(nodeTemplate);
- }
- }
-
- resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
-
- for (NodeTemplate node : resultList) {
- String templateName = node.getMetaData().getValue("name");
- if (!resouceSequence.contains(templateName)) {
- resouceSequence.add(templateName);
- }
- }
-
- } catch (SdcToscaParserException toscarParserE) {
- LOGGER.debug("sdc tosca parser failed for csar: " + csarpath, toscarParserE);
- return resouceSequence;
- } catch (Exception e) {
- LOGGER.debug("csar file is not available for service uuid:" + serviceUuid, e);
- return resouceSequence;
- }
-
- return resouceSequence;
- }
+ public static List<String> getResourceSequence(String serviceUuid) {
+
+ List<String> resourceSequence = new ArrayList();
+ try {
+ Map<String, Object> serviceResponse = getServiceInstnace(serviceUuid);
+
+ if (serviceResponse.containsKey("serviceResources")) {
+ Map<String, Object> serviceResources = (Map<String, Object>) serviceResponse.get("serviceResources");
- private static List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
- ISdcCsarHelper iSdcCsarHelper) {
-
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
- List<RequirementAssignment> reqAs = requirement.getAll();
- for (RequirementAssignment ra : reqAs) {
- String reqNode = ra.getNodeTemplateName();
- for (NodeTemplate rNode : resultList) {
- if (rNode.getName().equals(reqNode)) {
- if(!resultList.contains(nodeTemplate)) {
- resultList.add(nodeTemplate);
- }
- if(nodes.contains(nodeTemplate)) {
- nodes.remove(nodeTemplate);
- }
- break;
- }
- }
- }
- }
-
- if (!nodes.isEmpty()) {
- getRequirementList(resultList, nodes, iSdcCsarHelper);
- }
-
- return resultList;
+ if (serviceResources.containsKey("resourceOrder")) {
+ String resourceOrder = (String) serviceResources.get("resourceOrder");
+ if (resourceOrder!= null) {
+ resourceSequence.addAll(Arrays.asList(resourceOrder.split(",")));
+ }
+ }
+ }
+ } catch (Exception e) {
+ LOGGER.error("not able to retrieve service order.");
+ }
+ return resourceSequence;
}
/* build the resource Parameters detail.
@@ -184,12 +121,8 @@ public class ResourceRequestBuilder {
resourceInputsFromUuiMap = new HashMap();
}
- try {
- Map<String, Object> resourceInputsFromServiceDeclaredLevel = buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput);
- resourceInputsFromUuiMap.putAll(resourceInputsFromServiceDeclaredLevel);
- } catch(SdcToscaParserException e) {
- LOGGER.error("SdcToscaParserException", e);
- }
+ Map<String, Object> resourceInputsFromServiceDeclaredLevel = buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput);
+ resourceInputsFromUuiMap.putAll(resourceInputsFromServiceDeclaredLevel);
String resourceInputsStr = getJsonString(resourceInputsFromUuiMap);
String result = "{\n"
+ "\"locationConstraints\":" + locationConstraints +",\n"
@@ -198,91 +131,95 @@ public class ResourceRequestBuilder {
return result;
}
- public static Map<String, Object> buildResouceRequest(String serviceUuid, String resourceCustomizationUuid, Map<String, Object> serviceInputs)
- throws SdcToscaParserException {
-
- Map<String, Object> resouceRequest = new HashMap<>();
-
- String csarpath = null;
+ @SuppressWarnings("unchecked")
+ public static Map<String, Object> buildResouceRequest(String serviceUuid, String resourceCustomizationUuid, Map<String, Object> serviceInputs) {
try {
- csarpath = getCsarFromUuid(serviceUuid);
- } catch(Exception e) {
- LOGGER.debug("csar file is not available for service uuid:" + serviceUuid, e);
- return resouceRequest;
- }
+ Map<String, Object> serviceInstnace = getServiceInstnace(serviceUuid);
- SdcToscaParserFactory toscaParser = SdcToscaParserFactory.getInstance();
- ISdcCsarHelper iSdcCsarHelper = toscaParser.getSdcCsarHelper(csarpath, false);
+ // find match of customization uuid in vnf
+ Map<String, Map<String, Object>> serviceResources = (Map<String, Map<String, Object>>) serviceInstnace.get("serviceResources");
- List<Input> serInput = iSdcCsarHelper.getServiceInputs();
- Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
- .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
+ List<Map<String, Object>> serviceVnfCust = (List<Map<String, Object>>) serviceResources.get("serviceVnfs");
+ String resourceInputStr = getResourceInputStr(serviceVnfCust, resourceCustomizationUuid);
- if(nodeTemplateOpt.isPresent()) {
- NodeTemplate nodeTemplate = nodeTemplateOpt.get();
- LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
+ // find match in network resource
+ if (resourceInputStr == null) {
+ List<Map<String, Object>> serviceNetworkCust = (List<Map<String, Object>>) serviceResources.get("serviceNetworks");
+ resourceInputStr = getResourceInputStr(serviceNetworkCust, resourceCustomizationUuid);
- for(String key : resourceProperties.keySet()) {
- Property property = resourceProperties.get(key);
-
- Object value = getValue(property.getValue(), serviceInputs, serInput);
- resouceRequest.put(key, value);
+ // find match in AR resource
+ if (resourceInputStr == null) {
+ List<Map<String, Object>> serviceArCust = (List<Map<String, Object>>) serviceResources.get("serviceAllottedResources");
+ resourceInputStr = getResourceInputStr(serviceArCust, resourceCustomizationUuid);
+ }
}
+
+ if (resourceInputStr != null || !resourceInputStr.equals("")) {
+ return getResourceInput(resourceInputStr, serviceInputs);
+ }
+
+ } catch (Exception e) {
+ LOGGER.error("not able to retrieve service instance");
}
- return resouceRequest;
+ return new HashMap();
}
- private static Object getValue(Object value, Map<String, Object> serviceInputs, List<Input> servInputs) {
- if(value instanceof Map) {
- Map<String, Object> valueMap = new HashMap<>();
+ private static String getResourceInputStr(List<Map<String, Object>> resources, String resCustomizationUuid) {
- Map<String, Object> propertyMap = (Map<String, Object>)value;
+ for (Map<String, Object> resource : resources) {
+ Map<String, String> modelInfo = (Map<String, String>) resource.get("modelInfo");
- for(String key : propertyMap.keySet()) {
- valueMap.put(key, getValue(propertyMap.get(key), serviceInputs, servInputs));
+ if (modelInfo.get("modelCustomizationUuid").equalsIgnoreCase(resCustomizationUuid)) {
+ return (String) resource.get("resourceInput");
}
- return valueMap; // return if the value is nested hashmap
- } else if(value instanceof GetInput) {
- String inputName = ((GetInput)value).getInputName();
-
- if(serviceInputs.get(inputName) != null) {
- value = serviceInputs.get(inputName);
- } else {
- for(Input input : servInputs) {
- if(input.getName().equals(inputName)) {
- return input.getDefault(); // return default value
- }
+ }
+ return null;
+ }
+
+ // this method combines resource input with service input
+ private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> serviceInputs) {
+ Gson gson = new Gson();
+ Type type = new TypeToken<Map<String, String>>(){}.getType();
+ Map<String, Object> resourceInput = gson.fromJson(resourceInputStr, type);
+
+ // replace value if key is available in service input
+ for (String key: resourceInput.keySet()) {
+ String value = (String) resourceInput.get(key);
+
+ if (value.contains("|")) {
+ // node it type of getinput
+ String[] split = value.split("\\|");
+ String tmpKey = split[0];
+ if (serviceInputs.containsKey(tmpKey)) {
+ value = (String) serviceInputs.get(tmpKey);
+ } else {
+ value = split[1];
}
}
+ resourceInput.put(key,value);
}
- return value; // return property value
+ return resourceInput;
}
- private static String getCsarFromUuid(String uuid) throws Exception {
- String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
- HttpClient client = new HttpClientFactory().newJsonClient(
- UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(),
- TargetEntity.CATALOG_DB);
-
- client.addAdditionalHeader("Accept", "application/json");
-// client.addBasicAuthHeader (UrnPropertiesReader.getVariable("mso.adapters.db.auth"), UrnPropertiesReader.getVariable("mso.msoKey"));
- client.addAdditionalHeader("Authorization", UrnPropertiesReader.getVariable("mso.db.auth"));
- Response response = client.get();
- String value = response.readEntity(String.class);
+ public static Map<String, Object> getServiceInstnace(String uuid) throws Exception {
+ String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
- HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
+ HttpClient client = new HttpClientFactory().newJsonClient(
+ UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_SERVICE_INSTANCE).queryParam("serviceModelUuid", uuid).build().toURL(),
+ TargetEntity.CATALOG_DB);
- String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", map.get("version"), map.get("name")).normalize().toString();
+ client.addAdditionalHeader("Accept", "application/json");
+ client.addAdditionalHeader("Authorization", UrnPropertiesReader.getVariable("mso.db.auth"));
- File csarFile = new File(filePath);
+ Response apiResponse = client.get();
- if(!csarFile.exists()) {
- throw new Exception("csar file does not exist in filePath:" + csarFile.getAbsolutePath());
- }
+ String value = apiResponse.readEntity(String.class);
- return csarFile.getAbsolutePath();
+ ObjectMapper objectMapper = new ObjectMapper();
+ HashMap<String, Object> map = objectMapper.readValue(value, HashMap.class);
+ return map;
}
-
+
public static <T> T getJsonObject(String jsonstr, Class<T> type) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
new file mode 100644
index 0000000000..df7b57f3a3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. 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.common.util;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+public class OofInfraUtils {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofInfraUtils.class);
+
+ /**
+ * This method creates a cloudsite in catalog database.
+ *
+ * @param cloudSite
+ *
+ * @return void
+ */
+ public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+ try {
+ CloudSite getCloudsite;
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+
+ getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")).orElse(new CloudSite());
+ if (!cloudSite.getId().equals(getCloudsite.getId())) {
+ client.postCloudSite(cloudSite);
+ LOGGER.debug("Did not findd cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Will create cloudSite: " + cloudSite.toString());
+ }
+ else {
+ LOGGER.debug("Found cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Will not create cloudSite: " + cloudSite.toString());
+ }
+ } catch (Exception e) {
+ LOGGER.debug("Error looking up or creating cloudsite : " + cloudSite.getId());
+ LOGGER.debug("CloudSite Lookup/Creation Error: " + e);
+ }
+
+
+ }
+
+ /**
+ * This method creates a HomingInstance in catalog database.
+ *
+ * @param homingInstance
+ *
+ * @return void
+ */
+ public void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ client.postHomingInstance(homingInstance);
+ } catch (Exception exception) {
+ LOGGER.debug("Could not create HomingInstance : " + homingInstance.getServiceInstanceId());
+ LOGGER.debug("HomingInstance Creation Error: " + exception);
+ }
+
+ }
+
+ /**
+ * This method gets a HomingInstance in catalog database.
+ *
+ * @param serviceInstanceId
+ *
+ * @return HomingInstance
+ */
+ public HomingInstance getHomingInstance(String serviceInstanceId, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ return client.getHomingInstance(serviceInstanceId, endpoint + "/homingInstance/");
+ } catch (Exception exception) {
+ LOGGER.debug("Could not get HomingInstance for serviceInstanceId : " + serviceInstanceId);
+ LOGGER.debug("Get HomingInstance Error: " + exception);
+ }
+ return null;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java
index 91cd2ad791..a727162415 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java
@@ -31,10 +31,10 @@ public class Candidate implements Serializable {
private static final long serialVersionUID = -3959572501582849328L;
- @JsonProperty("candidateType")
- private CandidateType candidateType;
- @JsonProperty("candidates")
- private List<String> candidates;
+ @JsonProperty("identifierType")
+ private CandidateType identifierType;
+ @JsonProperty("identifiers")
+ private List<String> identifiers;
@JsonProperty("cloudOwner")
private String cloudOwner;
@@ -42,32 +42,32 @@ public class Candidate implements Serializable {
* list of candidates
* i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc.
*/
- public List<String> getCandidates() {
- return candidates;
+ public List<String> getIdentifiers() {
+ return identifiers;
}
/**
* list of candidates
* i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc.
*/
- public void setCandidates(List<String> candidates) {
- this.candidates = candidates;
+ public void setIdentifiers(List<String> identifiers) {
+ this.identifiers = identifiers;
}
/**
* Way to identify the type of candidate
* i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc.
*/
- public CandidateType getCandidateType(){
- return candidateType;
+ public CandidateType getIdentifierType(){
+ return identifierType;
}
/**
* Way to identify the type of candidate
* i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc.
*/
- public void setCandidateType(CandidateType candidateType){
- this.candidateType = candidateType;
+ public void setIdentifierType(CandidateType identifierType){
+ this.identifierType = identifierType;
}
/**
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 63f832d706..fbff0620a3 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -107,6 +107,7 @@ public class BBInputSetup implements JavaDelegate {
private static final String NETWORK = "Network";
private static final String VNF = "Vnf";
private static final String NETWORK_COLLECTION = "NetworkCollection";
+ private static final String PREPROV = "PREPROV";
@Autowired
private BBInputSetupUtils bbInputSetupUtils;
@@ -273,10 +274,11 @@ public class BBInputSetup implements JavaDelegate {
throws Exception {
ModelInfo modelInfo = requestDetails.getModelInfo();
String instanceName = requestDetails.getRequestInfo().getInstanceName();
+ String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId();
ModelType modelType = modelInfo.getModelType();
RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
- org.onap.so.serviceinstancebeans.Platform platform = requestDetails.getPlatform();
+ org.onap.so.serviceinstancebeans.Platform platform = requestDetails.getPlatform();
org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = requestDetails.getLineOfBusiness();
if (modelType.equals(ModelType.network)) {
@@ -285,7 +287,7 @@ public class BBInputSetup implements JavaDelegate {
} else if (modelType.equals(ModelType.vnf)) {
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, resourceId);
this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance,
- lookupKeyMap, relatedInstanceList, resourceId, vnfType, null);
+ lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
} else if (modelType.equals(ModelType.volumeGroup)) {
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId);
this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
@@ -404,17 +406,16 @@ public class BBInputSetup implements JavaDelegate {
if (lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null
&& vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) {
vfModule = vfModuleTemp;
- String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId();
- modelInfo.setModelCustomizationId(vfModuleCustId);
- break;
}
+ String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModuleTemp.getVfModuleId()).getModelCustomizationId();
+ ModelInfo modelInfoVfModule = new ModelInfo();
+ modelInfoVfModule.setModelCustomizationId(vfModuleCustId);
+ mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID);
}
if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) {
vfModule = createVfModule(lookupKeyMap,
resourceId, instanceName, instanceParams);
vnf.getVfModules().add(vfModule);
- }
- if(vfModule != null) {
mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
}
} else {
@@ -579,7 +580,8 @@ public class BBInputSetup implements JavaDelegate {
org.onap.so.serviceinstancebeans.Platform platform,
org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap,
- RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, List<Map<String, String>> instanceParams) {
+ RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, List<Map<String, String>> instanceParams,
+ String productFamilyId) {
GenericVnf vnf = null;
ModelInfo instanceGroupModelInfo = null;
String instanceGroupId = null;
@@ -607,7 +609,7 @@ public class BBInputSetup implements JavaDelegate {
}
if (vnf == null && bbName.equalsIgnoreCase(AssignFlows.VNF.toString())) {
vnf = createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, generatedVnfType, instanceParams);
+ resourceId, generatedVnfType, instanceParams, productFamilyId);
serviceInstance.getVnfs().add(vnf);
mapVnfcCollectionInstanceGroup(vnf, modelInfo, service);
}
@@ -658,13 +660,16 @@ public class BBInputSetup implements JavaDelegate {
protected GenericVnf createGenericVnf(Map<ResourceKey, String> lookupKeyMap, String instanceName,
org.onap.so.serviceinstancebeans.Platform platform,
- org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, String vnfId, String vnfType, List<Map<String, String>> instanceParams) {
+ org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, String vnfId, String vnfType, List<Map<String, String>> instanceParams,
+ String productFamilyId) {
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
GenericVnf genericVnf = new GenericVnf();
genericVnf.setVnfId(vnfId);
genericVnf.setVnfName(instanceName);
genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
genericVnf.setVnfType(vnfType);
+ genericVnf.setProvStatus(PREPROV);
+ genericVnf.setServiceId(productFamilyId);
if (platform != null) {
genericVnf.setPlatform(this.mapperLayer.mapRequestPlatform(platform));
}
@@ -1169,8 +1174,10 @@ public class BBInputSetup implements JavaDelegate {
if (request != null) {
this.bbInputSetupUtils.updateInfraActiveRequestVnfId(request, vnfId);
}
+ String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId();
this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(),
- vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, vnfs.getInstanceParams());
+ vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, vnfs.getInstanceParams(),
+ productFamilyId);
} else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP)) {
Pair<Vnfs, VfModules> vnfsAndVfModules = getVfModulesAndItsVnfsByKey(key, resources);
vfModules = vnfsAndVfModules.getValue1();
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
index d2e0b07dd1..ee7999f995 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
@@ -40,20 +40,22 @@ import org.springframework.stereotype.Component;
@Component
public class ExecuteBuildingBlockRainyDay {
-
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExecuteBuildingBlockRainyDay.class);
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
+ ExecuteBuildingBlockRainyDay.class);
public static final String HANDLING_CODE = "handlingCode";
-
+
@Autowired
private CatalogDbClient catalogDbClient;
@Autowired
private RequestsDbClient requestDbclient;
private static final String ASTERISK = "*";
-
+
@Autowired
- private Environment environment;
+ private Environment environment;
protected String retryDurationPath = "mso.rainyDay.retryDurationMultiplier";
protected String defaultCode = "mso.rainyDay.defaultCode";
+ protected String maxRetries = "mso.rainyDay.maxRetries";
public void setRetryTimer(DelegateExecution execution) {
try {
@@ -67,7 +69,7 @@ public class ExecuteBuildingBlockRainyDay {
throw new BpmnError("Unknown error incrementing retry counter");
}
}
-
+
public void queryRainyDayTable(DelegateExecution execution, boolean primaryPolicy) {
try {
ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
@@ -79,18 +81,20 @@ public class ExecuteBuildingBlockRainyDay {
boolean aLaCarte = (boolean) execution.getVariable("aLaCarte");
boolean suppressRollback = (boolean) execution.getVariable("suppressRollback");
String handlingCode = "";
- if(suppressRollback){
+ if (suppressRollback) {
handlingCode = "Abort";
- }else{
+ } else {
try {
- serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType();
+ serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0)
+ .getModelInfoServiceInstance().getServiceType();
} catch (Exception ex) {
// keep default serviceType value
}
String vnfType = ASTERISK;
try {
- for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) {
- if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
+ for (GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0)
+ .getVnfs()) {
+ if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
vnfType = vnf.getVnfType();
}
}
@@ -104,58 +108,85 @@ public class ExecuteBuildingBlockRainyDay {
} catch (Exception ex) {
// keep default errorCode value
}
+ try {
+ errorCode = "" + (String) execution.getVariable("WorkflowExceptionCode");
+ } catch (Exception ex) {
+ // keep default errorCode value
+ }
+
String workStep = ASTERISK;
try {
workStep = workflowException.getWorkStep();
} catch (Exception ex) {
// keep default workStep value
}
- //Extract error data to be returned to WorkflowAction
- execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage());
+
+ try {
+ // Extract error data to be returned to WorkflowAction
+ execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage());
+ } catch (Exception e) {
+ msoLogger.error("No WorkflowException Found",e);
+ }
RainyDayHandlerStatus rainyDayHandlerStatus;
- rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep);
- if(rainyDayHandlerStatus==null){
- rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK);
- if(rainyDayHandlerStatus==null){
+ rainyDayHandlerStatus = catalogDbClient
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,
+ serviceType, vnfType, errorCode, workStep);
+ if (rainyDayHandlerStatus == null) {
+ rainyDayHandlerStatus = catalogDbClient
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,
+ ASTERISK, ASTERISK, errorCode, ASTERISK);
+ }
+
+ if (rainyDayHandlerStatus == null) {
+ rainyDayHandlerStatus = catalogDbClient
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,
+ ASTERISK, ASTERISK, ASTERISK, ASTERISK);
+ if (rainyDayHandlerStatus == null) {
handlingCode = "Abort";
- }else{
- if(primaryPolicy){
+ } else {
+ if (primaryPolicy) {
handlingCode = rainyDayHandlerStatus.getPolicy();
- }else{
+ } else {
handlingCode = rainyDayHandlerStatus.getSecondaryPolicy();
}
}
- }else{
- if(primaryPolicy){
+ } else {
+ if (primaryPolicy) {
handlingCode = rainyDayHandlerStatus.getPolicy();
- }else{
+ } else {
handlingCode = rainyDayHandlerStatus.getSecondaryPolicy();
}
}
- if(!primaryPolicy){
- try{
+ if (!primaryPolicy) {
+ try {
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
request.setRetryStatusMessage("Retries have been exhausted.");
requestDbclient.updateInfraActiveRequests(request);
- } catch(Exception ex){
- msoLogger.debug(ex.toString());
- msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status");
+ } catch (Exception ex) {
+ msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status",ex);
}
}
- if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){
+ if (handlingCode.equals("RollbackToAssigned") && !aLaCarte) {
handlingCode = "Rollback";
}
}
msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode);
execution.setVariable(HANDLING_CODE, handlingCode);
} catch (Exception e) {
- msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort");
String code = this.environment.getProperty(defaultCode);
+ msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = "+ code, e);
execution.setVariable(HANDLING_CODE, code);
}
+ try{
+ int envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
+ execution.setVariable("maxRetries", envMaxRetries);
+ } catch (Exception ex) {
+ msoLogger.error("Could not read maxRetries from config file. Setting max to 5 retries");
+ execution.setVariable("maxRetries", 5);
+ }
}
-
- public void setHandlingStatusSuccess(DelegateExecution execution){
+
+ public void setHandlingStatusSuccess(DelegateExecution execution) {
execution.setVariable(HANDLING_CODE, "Success");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
index 42da72528f..459ef66e5b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
@@ -61,6 +61,34 @@ public class ExceptionBuilder {
msg = msg.concat(exception.getMessage());
buildAndThrowWorkflowException(execution, errorCode, msg);
}
+
+ public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception) {
+ String msg = "Exception in %s.%s ";
+ try{
+ msoLogger.error(exception);
+
+ String errorVariable = "Error%s%s";
+
+ StackTraceElement[] trace = Thread.currentThread().getStackTrace();
+ for (StackTraceElement traceElement : trace) {
+ if (!traceElement.getClassName().equals(this.getClass().getName()) && !traceElement.getClassName().equals(Thread.class.getName())) {
+ msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName());
+ String shortClassName = traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1);
+ errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName());
+ break;
+ }
+ }
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, msg.toString());
+ execution.setVariable(errorVariable, exception.getMessage());
+ } catch (Exception ex){
+ //log trace, allow process to complete gracefully
+ msoLogger.error(ex);
+ }
+
+ if (exception.getMessage() != null)
+ msg = msg.concat(exception.getMessage());
+ buildAndThrowWorkflowException(execution, errorCode, msg);
+ }
public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage) {
if (execution instanceof DelegateExecutionImpl) {
@@ -74,10 +102,16 @@ public class ExceptionBuilder {
WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage);
execution.setVariable("WorkflowException", exception);
+ execution.setVariable("WorkflowExceptionErrorMessage", errorMessage);
msoLogger.info("Outgoing WorkflowException is " + exception);
msoLogger.info("Throwing MSOWorkflowException");
throw new BpmnError("MSOWorkflowException");
}
+
+ public void buildAndThrowWorkflowException(DelegateExecution execution, String errorCode, String errorMessage) {
+ execution.setVariable("WorkflowExceptionErrorMessage", errorMessage);
+ throw new BpmnError(errorCode,errorMessage);
+ }
public String getProcessKey(DelegateExecution execution) {
String testKey = (String) execution.getVariable("testProcessKey");
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy
index 3da126f7a9..97db9775c9 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtilsTest.groovy
@@ -34,9 +34,9 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import javax.ws.rs.core.UriBuilder
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertTrue
-import static org.mockito.Matchers.any
-import static org.mockito.Matchers.anyObject
-import static org.mockito.Matchers.isA
+import static org.mockito.ArgumentMatchers.any
+import static org.mockito.ArgumentMatchers.anyObject
+import static org.mockito.ArgumentMatchers.isA
import static org.mockito.Mockito.atLeastOnce
import static org.mockito.Mockito.doNothing
import static org.mockito.Mockito.doThrow
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
index 70068c849b..99c351c465 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
@@ -33,7 +33,7 @@ import org.onap.so.bpmn.core.WorkflowException
import static org.assertj.core.api.Assertions.assertThat
import static org.assertj.core.api.Assertions.assertThatThrownBy
-import static org.mockito.Matchers.eq
+import static org.mockito.ArgumentMatchers.eq
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy
index 55f68f665e..dac038fab3 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleTest.groovy
@@ -97,7 +97,7 @@ class CreateAAIVfModuleTest extends MsoGroovyTest{
@Test
void testCreateGenericVnf(){
when(mockExecution.getVariable("CAAIVfMod_vnfName")).thenReturn("vnfName")
- Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject())
+ Mockito.doNothing().when(client).create(any(AAIResourceUri.class) as AAIResourceUri,anyObject())
createAAIVfModule.createGenericVnf(mockExecution)
Mockito.verify(mockExecution).setVariable("CAAIVfMod_createGenericVnfResponseCode", 201)
Mockito.verify(mockExecution).setVariable("CAAIVfMod_createGenericVnfResponse","Vnf Created")
@@ -112,7 +112,7 @@ class CreateAAIVfModuleTest extends MsoGroovyTest{
when(mockExecution.getVariable("CAAIVfMod_personaId")).thenReturn("model1")
when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("vfModuleName")
- Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject())
+ Mockito.doNothing().when(client).create(any(AAIResourceUri.class) as AAIResourceUri,anyObject())
createAAIVfModule.createVfModule(mockExecution,false)
Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponseCode", 201)
Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponse","Vf Module Created")
@@ -173,7 +173,7 @@ class CreateAAIVfModuleTest extends MsoGroovyTest{
Optional<GenericVnf> genericVnf = getAAIObjectFromJson(GenericVnf.class,"__files/aai/GenericVnfVfModule.json");
when(mockExecution.getVariable("CAAIVfMod_queryGenericVnfResponse")).thenReturn(genericVnf.get())
when(mockExecution.getVariable("CAAIVfMod_moduleName")).thenReturn("vfModuleName")
- Mockito.doNothing().when(client).create(any(AAIResourceUri.class),anyObject())
+ Mockito.doNothing().when(client).create(any(AAIResourceUri.class) as AAIResourceUri,anyObject())
createAAIVfModule.createVfModule(mockExecution,true)
Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponseCode", 201)
Mockito.verify(mockExecution).setVariable("CAAIVfMod_createVfModuleResponse","Vf Module Created")
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
index 4b6f8aa918..2a872511e7 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
@@ -92,7 +92,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{
void testDeleteGenericVnf() {
ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
- doNothing().when(client).delete(isA(AAIResourceUri.class))
+ doNothing().when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri)
deleteAAIVfModule.deleteGenericVnf(mockExecution)
Mockito.verify(mockExecution).setVariable(prefix + "deleteGenericVnfResponseCode", 200)
}
@@ -169,7 +169,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{
ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
try {
- doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class))
+ doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri)
deleteAAIVfModule.deleteGenericVnf(mockExecution)
} catch (Exception ex) {
println " Test End - Handle catch-throw BpmnError()! "
@@ -186,7 +186,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{
ExecutionEntity mockExecution = setupMock()
when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("vfModuleId1")
- doNothing().when(client).delete(isA(AAIResourceUri.class))
+ doNothing().when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri)
deleteAAIVfModule.deleteVfModule(mockExecution)
Mockito.verify(mockExecution).setVariable(prefix + "deleteVfModuleResponseCode", 200)
}
@@ -197,7 +197,7 @@ class DeleteAAIVfModuleTest extends MsoGroovyTest{
when(mockExecution.getVariable("DAAIVfMod_vnfId")).thenReturn("vnfId1")
when(mockExecution.getVariable("DAAIVfMod_vfModuleId")).thenReturn("vfModuleId1")
try {
- doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class))
+ doThrow(new NotFoundException("Vnf Not Found")).when(client).delete(isA(AAIResourceUri.class) as AAIResourceUri)
deleteAAIVfModule.deleteVfModule(mockExecution)
} catch (Exception ex) {
println " Test End - Handle catch-throw BpmnError()! "
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
index dfaf5d2140..c6a68c0e7a 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
@@ -277,5 +277,13 @@ class MsoUtilsTest {
}
}
-
+ @Test
+ public void testGetLowestUnusedIndex() {
+ def responseAsString = getFile("vfModuleCount.xml")
+ def index = utils.getLowestUnusedIndex(responseAsString)
+ println " lowest module count test: "
+ println " actual - " + index
+ println " expected - " + "14"
+ assertEquals("expected vs actual", "14", index)
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
index 5641c5e12f..2bd5181c31 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
@@ -40,8 +40,8 @@ import org.onap.so.bpmn.mock.FileUtil
import org.onap.so.bpmn.mock.StubResponseAAI
import static com.github.tomakehurst.wiremock.client.WireMock.*
-import static org.mockito.Matchers.any
-import static org.mockito.Matchers.refEq
+import static org.mockito.ArgumentMatchers.any
+import static org.mockito.ArgumentMatchers.refEq
import static org.mockito.Mockito.*
@RunWith(MockitoJUnitRunner.class)
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
index 2d2f58b415..72bcfcf359 100644
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
@@ -111,7 +111,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
vfModule.setVfModuleId("supercool")
vfModule.setResourceVersion("12345")
when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
- doNothing().when(client).update(isA(AAIResourceUri.class), anyObject())
+ doNothing().when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject())
updateAAIVfModule.updateVfModule(mockExecution)
verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 200)
}
@@ -126,7 +126,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
vfModule.setVfModuleId("supercool")
vfModule.setResourceVersion("12345")
when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
- doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class), anyObject())
+ doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject())
thrown.expect(BpmnError.class)
updateAAIVfModule.updateVfModule(mockExecution)
verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 404)
@@ -143,7 +143,7 @@ class UpdateAAIVfModuleTest extends MsoGroovyTest {
vfModule.setVfModuleId("supercool")
vfModule.setResourceVersion("12345")
when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
- doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class), anyObject())
+ doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class) as AAIResourceUri, anyObject())
thrown.expect(BpmnError.class)
updateAAIVfModule.updateVfModule(mockExecution)
verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 500)
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
index cf74356fa2..32a18d5a7a 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
@@ -25,7 +25,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.contains;
+import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.Mockito.mock;
import java.io.Serializable;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
index 5598e3d2e4..e5e13268b2 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
@@ -19,24 +19,390 @@
*/
package org.onap.so.bpmn.common.resource;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.so.BaseTest;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.springframework.core.env.Environment;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+
-public class ResourceRequestBuilderTest {
+public class ResourceRequestBuilderTest extends BaseTest {
@Test
- public void buildResouceRequestTest() throws Exception {
+ public void getResourceInputTest() throws Exception {
- ResourceRequestBuilder.buildResouceRequest("xxxxxx",
- "a1074969-944f-4ddc-b687-9550b0c8cd57", new HashMap<>());
+
+
+ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" +
+ "\t\"modelInfo\" : {\n" +
+ "\t\t\"modelName\" : \"demoVFWCL\",\n" +
+ "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
+ "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
+ "\t\t\"modelVersion\" : \"1.0\"\n" +
+ "\t},\n" +
+ "\t\"serviceType\" : \"\",\n" +
+ "\t\"serviceRole\" : \"\",\n" +
+ "\t\"environmentContext\" : null,\n" +
+ "\t\"resourceOrder\" : \"res1,res2\",\n" +
+ "\t\"workloadContext\" : \"Production\",\n" +
+ "\t\"serviceVnfs\": [\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
+ "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t},\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
+ "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t}\n" +
+ "\t],\n" +
+ "\t\"serviceNetworks\": [],\n" +
+ "\t\"serviceAllottedResources\": []\n" +
+ "\t}}")));
+
+// when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ HashMap serviceInput = new HashMap();
+ serviceInput.put("key", "value");
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ assertEquals(stringObjectMap.get("a"), "value");
}
@Test
- public void buildResouceRequestParametersTest() throws Exception {
+ public void getResourceInputDefaultValueTest() throws Exception {
+
+ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" +
+ "\t\"modelInfo\" : {\n" +
+ "\t\t\"modelName\" : \"demoVFWCL\",\n" +
+ "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
+ "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
+ "\t\t\"modelVersion\" : \"1.0\"\n" +
+ "\t},\n" +
+ "\t\"serviceType\" : \"\",\n" +
+ "\t\"serviceRole\" : \"\",\n" +
+ "\t\"environmentContext\" : null,\n" +
+ "\t\"workloadContext\" : \"Production\",\n" +
+ "\t\"serviceVnfs\": [\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
+ "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t},\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
+ "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t}\n" +
+ "\t],\n" +
+ "\t\"serviceNetworks\": [],\n" +
+ "\t\"serviceAllottedResources\": []\n" +
+ "\t}}")));
+
+// when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ HashMap serviceInput = new HashMap();
+ serviceInput.put("key1", "value");
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ assertEquals(stringObjectMap.get("a"), "default_value");
+ }
+
+ @Test
+ public void getResourceInputValueNoDefaultTest() throws Exception {
+
+ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" +
+ "\t\"modelInfo\" : {\n" +
+ "\t\t\"modelName\" : \"demoVFWCL\",\n" +
+ "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
+ "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
+ "\t\t\"modelVersion\" : \"1.0\"\n" +
+ "\t},\n" +
+ "\t\"serviceType\" : \"\",\n" +
+ "\t\"serviceRole\" : \"\",\n" +
+ "\t\"environmentContext\" : null,\n" +
+ "\t\"workloadContext\" : \"Production\",\n" +
+ "\t\"serviceVnfs\": [\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
+ "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t},\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
+ "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\"," +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t}\n" +
+ "\t],\n" +
+ "\t\"serviceNetworks\": [],\n" +
+ "\t\"serviceAllottedResources\": []\n" +
+ "\t}}")));
+
+// when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ HashMap serviceInput = new HashMap();
+ serviceInput.put("key1", "value");
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
+ "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ assertEquals(stringObjectMap.get("a"), "value");
+ }
+
+ @Test
+ public void getResourceSequenceTest() throws Exception {
+
+ stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" +
+ "\t\"modelInfo\" : {\n" +
+ "\t\t\"modelName\" : \"demoVFWCL\",\n" +
+ "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
+ "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
+ "\t\t\"modelVersion\" : \"1.0\"\n" +
+ "\t},\n" +
+ "\t\"serviceType\" : \"\",\n" +
+ "\t\"serviceRole\" : \"\",\n" +
+ "\t\"environmentContext\" : null,\n" +
+ "\t\"resourceOrder\" : \"res1,res2\",\n" +
+ "\t\"workloadContext\" : \"Production\",\n" +
+ "\t\"serviceVnfs\": [\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
+ "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t},\n" +
+ "\t\n" +
+ "\t\t{ \"modelInfo\" : {\n" +
+ "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
+ "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
+ "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
+ "\t\t\t\"modelVersion\" : \"1.0\",\n" +
+ "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
+ "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
+ "\t\t\t},\n" +
+ "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
+ "\t\t\"nfFunction\" \t: null,\n" +
+ "\t\t\"nfType\" \t\t: null,\n" +
+ "\t\t\"nfRole\" \t\t: null,\n" +
+ "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," +
+ "\t\t\"nfNamingCode\" \t: null,\n" +
+ "\t\t\"multiStageDesign\" : \"false\",\n" +
+ "\t\t\t\"vfModules\": [\n" +
+ "\t\t\t\t{\n" +
+ "\t\t\t\t\t\"modelInfo\" : { \n" +
+ "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
+ "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
+ "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
+ "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
+ "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
+ "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
+ "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
+ "\t\t\t\t\t\"initialCount\" : 1,\n" +
+ "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
+ "\t\t\t\t}\n" +
+ "\t\t\t]\n" +
+ "\t\t}\n" +
+ "\t],\n" +
+ "\t\"serviceNetworks\": [],\n" +
+ "\t\"serviceAllottedResources\": []\n" +
+ "\t}}")));
- String parameters =
- "{ \"locationConstraints\":[ ], \"resources\":[ { \"resourceName\":\"vEPC_ONAP01\", \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\", \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\", \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed231\", \"parameters\":{ \"locationConstraints\":[ { \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\", \"locationConstraints\":{ \"vimId\":\"vmware_vio\" } }, { \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\", \"locationConstraints\":{ \"vimId\":\"core-dc_RegionOne\" } } ], \"resources\":[ ], \"requestInputs\":{ \"sdncontroller\":\"\" } } }, { \"resourceName\":\"VL OVERLAYTUNNEL\", \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\", \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\", \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ ], \"requestInputs\":{ } } } ], \"requestInputs\":{ \"vlunderlayvpn0_name\":\"l3connect\", \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\", \"vlunderlayvpn0_site2_id\":\"SPTNController\", \"vlunderlayvpn0_site1_networkName\":\"network1,network2\", \"vlunderlayvpn0_site2_networkName\":\"network3,network4\", \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\", \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\", \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\", \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\", \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\", \"vlunderlayvpn0_site1_vni\":\"2000\", \"vlunderlayvpn0_site2_vni\":\"3000\", \"vlunderlayvpn0_tunnelType\":\"L3-DCI\" } }";
- ResourceRequestBuilder.buildResourceRequestParameters(null, "1bd0eae6-2dcc-4461-9ae6-56d641f369d6", "27a0e235-b67a-4ea4-a0cf-25761afed231", parameters);
+ List<String> resourceSequence = ResourceRequestBuilder.getResourceSequence("c3954379-4efe-431c-8258-f84905b158e5");
+ assertEquals(resourceSequence.size(), 2);
+ assertEquals(resourceSequence.get(0), "res1");
+ assertEquals(resourceSequence.get(1), "res2");
}
} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index 78238f0271..56875d315b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -47,7 +47,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
-import org.mockito.Matchers;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
@@ -711,11 +711,12 @@ public class BBInputSetupTest {
String instanceName = "instanceName";
String vnfType = "vnfType";
String resourceId = "networkId";
+ String productFamilyId = "productFamilyId";
Service service = Mockito.mock(Service.class);
ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
RequestDetails requestDetails = Mockito.mock(RequestDetails.class);
ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
- RequestInfo requestInfo = Mockito.mock(RequestInfo.class);
+ RequestInfo requestInfo = Mockito.mock(RequestInfo.class);
RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[] {};
CloudConfiguration cloudConfiguration = new CloudConfiguration();
org.onap.so.serviceinstancebeans.Platform platform = Mockito
@@ -727,13 +728,14 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
lookupKeyMap, resourceId, null);
doReturn(modelInfo).when(requestDetails).getModelInfo();
+ doReturn(productFamilyId).when(requestInfo).getProductFamilyId();
doReturn(requestInfo).when(requestDetails).getRequestInfo();
doReturn(instanceName).when(requestInfo).getInstanceName();
doReturn(platform).when(requestDetails).getPlatform();
doReturn(lineOfBusiness).when(requestDetails).getLineOfBusiness();
doReturn(relatedInstanceList).when(requestDetails).getRelatedInstanceList();
doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration();
-
+
doReturn(ModelType.network).when(modelInfo).getModelType();
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
lookupKeyMap, resourceId, vnfType);
@@ -744,11 +746,11 @@ public class BBInputSetupTest {
doReturn(ModelType.vnf).when(modelInfo).getModelType();
resourceId = "vnfId";
doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
- service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null);
+ service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
lookupKeyMap, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
- service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null);
+ service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
doReturn(ModelType.volumeGroup).when(modelInfo).getModelType();
@@ -1208,26 +1210,29 @@ public class BBInputSetupTest {
doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
instanceName = "vnfName2";
GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null);
+ resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
doReturn(vnf2).when(SPY_bbInputSetup).createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null);
+ resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2");
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
@@ -1297,17 +1302,19 @@ public class BBInputSetupTest {
doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
instanceName = "vnfName2";
GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null);
+ resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf();
vnfAAI.setModelCustomizationId("modelCustId2");
@@ -1315,7 +1322,8 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service);
doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null);
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
@@ -1768,7 +1776,7 @@ public class BBInputSetupTest {
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any());
+ isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), any(String.class));
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -1943,7 +1951,7 @@ public class BBInputSetupTest {
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(),ArgumentMatchers.isNull(), any(String.class), ArgumentMatchers.isNull(), any());
+ isA(ServiceInstance.class), any(),ArgumentMatchers.isNull(), any(String.class), ArgumentMatchers.isNull(), any(), any(String.class));
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -2006,7 +2014,8 @@ public class BBInputSetupTest {
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any());
+ isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
+ any(String.class));
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -2456,6 +2465,7 @@ public class BBInputSetupTest {
String vnfType = "vnfType";
String platformName = "platformName";
String lineOfBusinessName = "lineOfBusinessName";
+ String productFamilyId = "productFamilyId";
Platform platform = new Platform();
platform.setPlatformName(platformName);
LineOfBusiness lineOfBusiness = new LineOfBusiness();
@@ -2470,6 +2480,8 @@ public class BBInputSetupTest {
expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
expected.setPlatform(platform);
expected.setLineOfBusiness(lineOfBusiness);
+ expected.setProvStatus("PREPROV");
+ expected.setServiceId(productFamilyId);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
List<Map<String, String>> instanceParams = new ArrayList<>();
instanceParams.add(cloudParams);
@@ -2481,13 +2493,14 @@ public class BBInputSetupTest {
doReturn(platform).when(bbInputSetupMapperLayer).mapRequestPlatform(requestPlatform);
doReturn(lineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(requestLineOfBusiness);
- GenericVnf actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, instanceParams);
+ GenericVnf actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, instanceParams,
+ productFamilyId);
assertThat(actual, sameBeanAs(expected));
assertEquals("LookupKeyMap is populated", vnfId, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
expected.getCloudParams().clear();
- actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, null);
+ actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, null, productFamilyId);
assertThat(actual, sameBeanAs(expected));
}
@@ -2538,6 +2551,12 @@ public class BBInputSetupTest {
volumeGroup.setVolumeGroupId(volumeGroupId);
vnf.getVolumeGroups().add(volumeGroup);
serviceInstance.getVnfs().add(vnf);
+ VfModule vfModule1 = new VfModule();
+ vfModule1.setVfModuleId("vfModuleId1");
+ VfModule vfModule2 = new VfModule();
+ vfModule2.setVfModuleId("vfModuleId2");
+ vnf.getVfModules().add(vfModule1);
+ vnf.getVfModules().add(vfModule2);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
String resourceId = vfModuleId;
@@ -2550,16 +2569,20 @@ public class BBInputSetupTest {
vnfAAI.setModelCustomizationId("vnfModelCustId");
org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup();
volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId);
+ org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule();
+ vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId);
doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER,
cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class));
doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), isA(Service.class));
doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration);
+ verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index f70912f725..ae1af8f960 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -25,7 +25,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
index d53b2ae713..af7dc582e0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
@@ -24,7 +24,7 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.isA;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import java.io.File;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
index cb5683dcc8..6344a3f1a6 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
@@ -93,7 +93,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
delegateExecution.setVariable("suppressRollback", false);
-
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
@@ -116,7 +116,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
delegateExecution.setVariable("suppressRollback", false);
-
+ delegateExecution.setVariable("WorkflowExceptionCode", ASTERISK);
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode(ASTERISK);
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
@@ -131,6 +131,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
+ assertEquals(5,delegateExecution.getVariable("maxRetries"));
}
@Test
@@ -164,7 +165,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
delegateExecution.setVariable("suppressRollback", false);
-
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
@@ -188,7 +189,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", false);
delegateExecution.setVariable("suppressRollback", false);
-
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
@@ -212,7 +213,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
vnf.setVnfType("vnft1");
delegateExecution.setVariable("aLaCarte", true);
delegateExecution.setVariable("suppressRollback", false);
-
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
rainyDayHandlerStatus.setErrorCode("7000");
rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java
index dbf2eb75fd..c50a6db178 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java
@@ -26,6 +26,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -46,6 +47,7 @@ public class DmaapPropertiesClientTest extends BaseTest{
@Autowired
private DmaapPropertiesClient dmaapPropertiesClient;
+
private final String file = "src/test/resources/org/onap/so/client/avpn/dmaap/avpnDmaapAsyncRequestStatus.json";
private String requestId = "rq1234d1-5a33-55df-13ab-12abad84e331";
private String clientSource = "SPP";
@@ -73,7 +75,7 @@ public class DmaapPropertiesClientTest extends BaseTest{
@Test
public void testDmaapPublishRequest() throws JsonProcessingException, MapperException {
- stubFor(post(urlEqualTo("/events/com.att.mso.asyncStatusUpdate?timeout=20000"))
+ stubFor(post(urlEqualTo("/events/com.att.mso.asyncStatusUpdate?timeout=60000"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_ACCEPTED)));
dmaapPropertiesClient.dmaapPublishRequest(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope,
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java
index d380536a48..fc69f812be 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java
@@ -21,6 +21,7 @@
package org.onap.so.client.dmaapproperties;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.so.BaseTest;
@@ -30,7 +31,8 @@ public class GlobalDmaapPublisherTest extends BaseTest{
@Autowired
private GlobalDmaapPublisher globalDmaapPublisher;
-
+
+
@Test
public void testGetters() {
assertEquals("81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54", globalDmaapPublisher.getAuth());
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
index d1013e7541..2e25449937 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
@@ -21,7 +21,7 @@
package org.onap.so.client.exception;
import static org.junit.Assert.assertEquals;
-
+import static org.junit.Assert.assertTrue;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Test;
import org.onap.so.bpmn.mock.FileUtil;
@@ -32,6 +32,7 @@ public class ExceptionBuilderTest extends BaseTest {
private static final String RESOURCE_PATH = "__files/";
private static final String VALID_ERROR_MESSAGE = "{test error message}";
+
@Test
public void buildAndThrowWorkflowExceptionTest() {
try {
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
index b229fbd26a..afdb800ffe 100644
--- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
+++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml
@@ -84,7 +84,7 @@ mso:
callbackRetryAttempts: '5'
catalog:
db:
- endpoint: http://localhost:${wiremock.server.port}/
+ endpoint: http://localhost:${wiremock.server.port}/ecomp/mso/catalog
spring:
endpoint: http://localhost:${wiremock.server.port}
correlation:
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/vfModuleCount.xml b/bpmn/MSOCommonBPMN/src/test/resources/vfModuleCount.xml
new file mode 100644
index 0000000000..b7dee68a77
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/vfModuleCount.xml
@@ -0,0 +1,44 @@
+<vfModules>
+ <vf-module>
+ <module-index>0</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>1</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>2</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>3</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>4</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>5</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>6</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>7</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>8</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>9</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>10</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>11</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>12</module-index>
+ </vf-module>
+ <vf-module>
+ <module-index>13</module-index>
+ </vf-module>
+</vfModules> \ No newline at end of file