summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java13
-rw-r--r--bpmn/mso-infrastructure-bpmn/pom.xml13
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn70
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java255
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java187
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java63
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java129
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json29
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml11
14 files changed, 668 insertions, 186 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
index 750b7ace35..083a6b6e1f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
@@ -130,19 +130,12 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener {
ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution
.getVariable("executionServiceInput");
- //CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils();
-
- CDSProcessingClient cdsClient = null;
- CountDownLatch countDownLatch;
- try {
- cdsClient = new CDSProcessingClient(this);
- countDownLatch = cdsClient.sendRequest(executionServiceInput);
+ try(CDSProcessingClient cdsClient = new CDSProcessingClient(this)) {
+ CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
- } catch (InterruptedException ex) {
+ } catch (InterruptedException ex){
logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
Thread.currentThread().interrupt();
- } finally {
- cdsClient.close();
}
if (cdsResponse != null) {
diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml
index 6f0b1f6fc9..2abea6e31f 100644
--- a/bpmn/mso-infrastructure-bpmn/pom.xml
+++ b/bpmn/mso-infrastructure-bpmn/pom.xml
@@ -155,18 +155,19 @@
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
- <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
- <version>${camunda.springboot.version}</version>
- </dependency>
- <dependency>
- <groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
<version>${camunda.springboot.version}</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
- <version>2.3.0</version>
+ <version>${camunda.springboot.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.camunda.bpmn</groupId>
+ <artifactId>camunda-engine-rest-core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
index 0be7c55596..7339b23802 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
<bpmn:process id="SDNCHandler" name="SDNC" isExecutable="true">
<bpmn:startEvent id="SDNC_Start">
<bpmn:outgoing>SequenceFlow_1n0j3hz</bpmn:outgoing>
@@ -38,7 +38,7 @@
<bpmn:boundaryEvent id="BoundaryEvent_1quvxva" name="Timeout" attachedToRef="SubProcess_0y8yozw">
<bpmn:outgoing>SequenceFlow_1yifu46</bpmn:outgoing>
<bpmn:timerEventDefinition>
- <bpmn:timeDuration xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("sdncTimeout")}]]></bpmn:timeDuration>
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">${execution.getVariable("sdncTimeout")}</bpmn:timeDuration>
</bpmn:timerEventDefinition>
</bpmn:boundaryEvent>
<bpmn:sequenceFlow id="SequenceFlow_1ecej8g" sourceRef="SubProcess_0y8yozw" targetRef="ExclusiveGateway_09ehhaf" />
@@ -48,7 +48,7 @@
<bpmn:outgoing>SequenceFlow_0i4u8g4</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="SequenceFlow_0rh24pq" name="Final Ack = N" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SubProcess_0y8yozw">
- <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isCallbackCompleted")}]]></bpmn:conditionExpression>
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isCallbackCompleted") == false}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_1yifu46" sourceRef="BoundaryEvent_1quvxva" targetRef="Task_1un0flc" />
<bpmn:sequenceFlow id="SequenceFlow_1n0j3hz" sourceRef="SDNC_Start" targetRef="SNDC_SetupCallback" />
@@ -62,7 +62,7 @@
<bpmn:sequenceFlow id="SequenceFlow_0flbj8a" sourceRef="SNDC_SetupCallback" targetRef="Call_SDNC" />
<bpmn:sequenceFlow id="SequenceFlow_0i4u8g4" name="Final Ack = Y" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SDNC_End" />
<bpmn:sequenceFlow id="SequenceFlow_0puiqga" name="Final Ack = Y" sourceRef="isAsync_Gateway" targetRef="SDNC_End">
- <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isSDNCCompleted")}]]></bpmn:conditionExpression>
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isSDNCCompleted")}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:serviceTask id="SNDC_SetupCallback" name="Setup Callback Variables" camunda:expression="${SDNCRequestTasks.createCorrelationVariables(execution)}">
<bpmn:incoming>SequenceFlow_1n0j3hz</bpmn:incoming>
@@ -72,7 +72,7 @@
<bpmn:incoming>SequenceFlow_1yifu46</bpmn:incoming>
</bpmn:serviceTask>
</bpmn:process>
- <bpmn:message id="Message_06oc4iz" name="SDNCCallbackMessage" />
+ <bpmn:message id="Message_06oc4iz" name="WorkflowMessage" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="SDNCHandler">
<bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="SDNC_Start">
@@ -118,23 +118,23 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1qxm8ot_di" bpmnElement="SequenceFlow_1qxm8ot">
- <di:waypoint xsi:type="dc:Point" x="347" y="-72" />
- <di:waypoint xsi:type="dc:Point" x="376" y="-72" />
+ <di:waypoint x="347" y="-72" />
+ <di:waypoint x="376" y="-72" />
<bpmndi:BPMNLabel>
<dc:Bounds x="316.5" y="-93.5" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_05eggbt_di" bpmnElement="SequenceFlow_05eggbt">
- <di:waypoint xsi:type="dc:Point" x="412" y="-72" />
- <di:waypoint xsi:type="dc:Point" x="438" y="-72" />
+ <di:waypoint x="412" y="-72" />
+ <di:waypoint x="438" y="-72" />
<bpmndi:BPMNLabel>
<dc:Bounds x="380" y="-93.5" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1ecej8g_di" bpmnElement="SequenceFlow_1ecej8g">
- <di:waypoint xsi:type="dc:Point" x="618" y="-67" />
- <di:waypoint xsi:type="dc:Point" x="798" y="-67" />
- <di:waypoint xsi:type="dc:Point" x="798" y="28" />
+ <di:waypoint x="618" y="-67" />
+ <di:waypoint x="798" y="-67" />
+ <di:waypoint x="798" y="28" />
<bpmndi:BPMNLabel>
<dc:Bounds x="663" y="-88.5" width="90" height="13" />
</bpmndi:BPMNLabel>
@@ -146,23 +146,23 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0rh24pq_di" bpmnElement="SequenceFlow_0rh24pq">
- <di:waypoint xsi:type="dc:Point" x="773" y="53" />
- <di:waypoint xsi:type="dc:Point" x="449" y="53" />
- <di:waypoint xsi:type="dc:Point" x="449" y="9" />
+ <di:waypoint x="773" y="53" />
+ <di:waypoint x="449" y="53" />
+ <di:waypoint x="449" y="9" />
<bpmndi:BPMNLabel>
<dc:Bounds x="579.9877300613497" y="32" width="66" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1yifu46_di" bpmnElement="SequenceFlow_1yifu46">
- <di:waypoint xsi:type="dc:Point" x="636" y="-144" />
- <di:waypoint xsi:type="dc:Point" x="748" y="-145" />
+ <di:waypoint x="636" y="-144" />
+ <di:waypoint x="748" y="-145" />
<bpmndi:BPMNLabel>
<dc:Bounds x="647" y="-166" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1n0j3hz_di" bpmnElement="SequenceFlow_1n0j3hz">
- <di:waypoint xsi:type="dc:Point" x="-231" y="152" />
- <di:waypoint xsi:type="dc:Point" x="-171" y="152" />
+ <di:waypoint x="-231" y="152" />
+ <di:waypoint x="-171" y="152" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-201" y="130.5" width="0" height="13" />
</bpmndi:BPMNLabel>
@@ -174,47 +174,47 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0yve6l6_di" bpmnElement="SequenceFlow_0yve6l6">
- <di:waypoint xsi:type="dc:Point" x="253" y="127" />
- <di:waypoint xsi:type="dc:Point" x="253" y="92" />
- <di:waypoint xsi:type="dc:Point" x="253" y="92" />
- <di:waypoint xsi:type="dc:Point" x="253" y="-67" />
- <di:waypoint xsi:type="dc:Point" x="278" y="-67" />
+ <di:waypoint x="253" y="127" />
+ <di:waypoint x="253" y="92" />
+ <di:waypoint x="253" y="92" />
+ <di:waypoint x="253" y="-67" />
+ <di:waypoint x="278" y="-67" />
<bpmndi:BPMNLabel>
<dc:Bounds x="263" y="57" width="65" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_07vnhri_di" bpmnElement="SequenceFlow_07vnhri">
- <di:waypoint xsi:type="dc:Point" x="115" y="152" />
- <di:waypoint xsi:type="dc:Point" x="228" y="152" />
+ <di:waypoint x="115" y="152" />
+ <di:waypoint x="228" y="152" />
<bpmndi:BPMNLabel>
<dc:Bounds x="171.5" y="130" width="0" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0flbj8a_di" bpmnElement="SequenceFlow_0flbj8a">
- <di:waypoint xsi:type="dc:Point" x="-71" y="152" />
- <di:waypoint xsi:type="dc:Point" x="15" y="152" />
+ <di:waypoint x="-71" y="152" />
+ <di:waypoint x="15" y="152" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-28" y="130.5" width="0" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0i4u8g4_di" bpmnElement="SequenceFlow_0i4u8g4">
- <di:waypoint xsi:type="dc:Point" x="798" y="78" />
- <di:waypoint xsi:type="dc:Point" x="798" y="174" />
+ <di:waypoint x="798" y="78" />
+ <di:waypoint x="798" y="174" />
<bpmndi:BPMNLabel>
<dc:Bounds x="809" y="119" width="66" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0puiqga_di" bpmnElement="SequenceFlow_0puiqga">
- <di:waypoint xsi:type="dc:Point" x="253" y="177" />
- <di:waypoint xsi:type="dc:Point" x="253" y="192" />
- <di:waypoint xsi:type="dc:Point" x="780" y="192" />
+ <di:waypoint x="253" y="177" />
+ <di:waypoint x="253" y="192" />
+ <di:waypoint x="780" y="192" />
<bpmndi:BPMNLabel>
<dc:Bounds x="310" y="161" width="66" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0oh3ye4_di" bpmnElement="SequenceFlow_0oh3ye4">
- <di:waypoint xsi:type="dc:Point" x="538" y="-72" />
- <di:waypoint xsi:type="dc:Point" x="562" y="-72" />
+ <di:waypoint x="538" y="-72" />
+ <di:waypoint x="562" y="-72" />
<bpmndi:BPMNLabel>
<dc:Bounds x="550" y="-93.5" width="0" height="13" />
</bpmndi:BPMNLabel>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
index 113f05d3ca..9b878afb7c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java
@@ -22,15 +22,18 @@
package org.onap.so.bpmn.infrastructure.workflow.service;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.ParseException;
@@ -68,17 +71,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.util.UriUtils;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
public class ServicePluginFactory {
// SOTN calculate route
public static final String OOF_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/oof/sotncalc";
public static final String THIRD_SP_DEFAULT_ENDPOINT = "http://192.168.1.223:8443/sp/resourcemgr/querytps";
-
+
public static final String INVENTORY_OSS_DEFAULT_ENDPOINT = "http://192.168.1.199:8443/oss/inventory";
private static final int DEFAULT_TIME_OUT = 60000;
@@ -88,7 +87,7 @@ public class ServicePluginFactory {
private static Logger logger = LoggerFactory.getLogger(ServicePluginFactory.class);
private static ServicePluginFactory instance;
-
+
public static synchronized ServicePluginFactory getInstance() {
if (null == instance) {
@@ -100,11 +99,11 @@ public class ServicePluginFactory {
private ServicePluginFactory() {
}
-
+
private String getInventoryOSSEndPoint(){
return UrnPropertiesReader.getVariable("mso.service-plugin.inventory-oss-endpoint", INVENTORY_OSS_DEFAULT_ENDPOINT);
}
-
+
private String getThirdSPEndPoint(){
return UrnPropertiesReader.getVariable("mso.service-plugin.third-sp-endpoint", THIRD_SP_DEFAULT_ENDPOINT);
}
@@ -118,18 +117,23 @@ public class ServicePluginFactory {
if(!isNeedProcessSite(uuiRequest)) {
return uuiRequest;
}
-
- Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
- Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
- Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
- Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
- List<Object> resources = (List<Object>) serviceParametersObject.get("resources");
-
- if (isSiteLocationLocal(serviceRequestInputs, resources)) {
- // resources changed : added TP info
- String newRequest = getJsonString(uuiObject);
- return newRequest;
- }
+
+ Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
+ if (uuiObject == null) {
+ return uuiRequest;
+ }
+ Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+ .getOrDefault("service", Collections.emptyMap());
+ Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+ .getOrDefault("parameters", Collections.emptyMap());
+ Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+ .getOrDefault("requestInputs", Collections.emptyMap());
+ List<Object> resources = (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList());
+
+ if (isSiteLocationLocal(serviceRequestInputs, resources)) {
+ // resources changed : added TP info
+ return getJsonString(uuiObject);
+ }
List<Resource> addResourceList = new ArrayList<>();
addResourceList.addAll(serviceDecomposition.getServiceResources());
@@ -155,9 +159,9 @@ public class ServicePluginFactory {
}
@SuppressWarnings("unchecked")
- private boolean isSiteLocationLocal(Map<String, Object> serviceRequestInputs, List<Object> resources) {
- Map<String, Object> tpInfoMap = getTPforVPNAttachment(serviceRequestInputs);
-
+ private boolean isSiteLocationLocal(Map<String, Object> serviceRequestInputs, List<Object> resources) {
+ Map<String, Object> tpInfoMap = getTPforVPNAttachment(serviceRequestInputs);
+
if(tpInfoMap.isEmpty()) {
return true;
}
@@ -166,7 +170,7 @@ public class ServicePluginFactory {
if (!host.isEmpty()) {
return false;
}
-
+
Map<String, Object> accessTPInfo = new HashMap<String, Object>();
accessTPInfo.put("access-provider-id", tpInfoMap.get("access-provider-id"));
accessTPInfo.put("access-client-id", tpInfoMap.get("access-client-id"));
@@ -180,7 +184,7 @@ public class ServicePluginFactory {
Map<String, Object> resource = (Map<String, Object>)curResource;
String curResourceName = (String) resource.get("resourceName");
curResourceName = curResourceName.replaceAll(" ", "");
- if(resourceName.equalsIgnoreCase(curResourceName)) {
+ if(resourceName.equalsIgnoreCase(curResourceName)) {
putResourceRequestInputs(resource, accessTPInfo);
break;
}
@@ -188,7 +192,7 @@ public class ServicePluginFactory {
return true;
}
-
+
@SuppressWarnings("unchecked")
private Map<String, Object> getTPforVPNAttachment(Map<String, Object> serviceRequestInputs) {
Object location = null;
@@ -199,24 +203,24 @@ public class ServicePluginFactory {
// logic for R2 uuiRequest params in service level
for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) {
String key = entry.getKey();
- if (key.toLowerCase().contains("site_address")) {
+ if (key.toLowerCase().contains("site_address")) {
location = entry.getValue();
- }
- if (key.toLowerCase().contains("sotncondition_clientsignal")) {
+ }
+ if (key.toLowerCase().contains("sotncondition_clientsignal")) {
clientSignal = entry.getValue();
vpnAttachmentResourceName = key.substring(0, key.indexOf("_"));
}
}
Map<String, Object> tpInfoMap = new HashMap<String, Object>();
-
+
// Site resource has location param and SOTNAttachment resource has clientSignal param
if(location == null || clientSignal == null ) {
return tpInfoMap;
}
-
- // Query terminal points from InventoryOSS system by location.
- String locationAddress = (String) location;
+
+ // Query terminal points from InventoryOSS system by location.
+ String locationAddress = (String) location;
List<Object> locationTPList = queryAccessTPbyLocationFromInventoryOSS(locationAddress);
if(locationTPList != null && !locationTPList.isEmpty()) {
for(Object tp: locationTPList) {
@@ -232,10 +236,10 @@ public class ServicePluginFactory {
logger.debug("Get Terminal TP from InventoryOSS");
return tpInfoMap;
}
-
+
return tpInfoMap;
}
-
+
@SuppressWarnings("unchecked")
private List<Object> queryAccessTPbyLocationFromInventoryOSS(String locationAddress) {
String url = getInventoryOSSEndPoint();
@@ -247,7 +251,7 @@ public class ServicePluginFactory {
}
return accessTPs;
}
-
+
@SuppressWarnings("unchecked")
private void putResourceRequestInputs(Map<String, Object> resource, Map<String, Object> resourceInputs) {
Map<String, Object> resourceParametersObject = new HashMap<>();
@@ -260,7 +264,7 @@ public class ServicePluginFactory {
if(resParametersObject.containsKey("requestInputs")) {
Map<String, Object> resRequestInputs = (Map<String, Object>) resourceRequestInputs.get("requestInputs");
Map<String, Object> oldRequestInputs = (Map<String, Object>) resParametersObject.get("requestInputs");
- if(oldRequestInputs != null) {
+ if(oldRequestInputs != null) {
oldRequestInputs.putAll(resRequestInputs);
}
else {
@@ -268,7 +272,7 @@ public class ServicePluginFactory {
}
}
else {
- resParametersObject.putAll(resourceRequestInputs);
+ resParametersObject.putAll(resourceRequestInputs);
}
}
else {
@@ -277,24 +281,29 @@ public class ServicePluginFactory {
return;
}
-
-
+
+
@SuppressWarnings("unchecked")
- public String doTPResourcesAllocation(DelegateExecution execution, String uuiRequest) {
- Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
- Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
- Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
- Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
-
- if(!isNeedAllocateCrossTPResources(serviceRequestInputs)) {
- return uuiRequest;
- }
-
- allocateCrossTPResources(execution, serviceRequestInputs);
- String newRequest = getJsonString(uuiObject);
- return newRequest;
- }
+ public String doTPResourcesAllocation(DelegateExecution execution, String uuiRequest) {
+ Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
+ if (uuiObject == null) {
+ return uuiRequest;
+ }
+ Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+ .getOrDefault("service", Collections.emptyMap());
+ Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+ .getOrDefault("parameters", Collections.emptyMap());
+ Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+ .getOrDefault("requestInputs", Collections.emptyMap());
+
+ if (!isNeedAllocateCrossTPResources(serviceRequestInputs)) {
+ return uuiRequest;
+ }
+
+ allocateCrossTPResources(execution, serviceRequestInputs);
+ return getJsonString(uuiObject);
+ }
@SuppressWarnings("unchecked")
private boolean isNeedAllocateCrossTPResources(Map<String, Object> serviceRequestInputs) {
@@ -303,7 +312,7 @@ public class ServicePluginFactory {
String callSource = (String) serviceRequestInputs.get("CallSource");
if("ExternalAPI".equalsIgnoreCase(callSource)) {
return false;
- }
+ }
}
for (String input : serviceRequestInputs.keySet())
{
@@ -313,12 +322,12 @@ public class ServicePluginFactory {
}
return false;
}
-
+
@SuppressWarnings("unchecked")
private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) {
Map<String, Object> crossTPs = this.getTPsfromAAI();
-
+
if(crossTPs == null || crossTPs.isEmpty()) {
serviceRequestInputs.put("local-access-provider-id", "");
serviceRequestInputs.put("local-access-client-id", "");
@@ -329,7 +338,7 @@ public class ServicePluginFactory {
serviceRequestInputs.put("remote-access-client-id", "");
serviceRequestInputs.put("remote-access-topology-id", "");
serviceRequestInputs.put("remote-access-node-id", "");
- serviceRequestInputs.put("remote-access-ltp-id", "");
+ serviceRequestInputs.put("remote-access-ltp-id", "");
}
else {
serviceRequestInputs.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
@@ -343,24 +352,24 @@ public class ServicePluginFactory {
serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-node-id"));
serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id"));
}
-
+
return;
}
- // This method returns Local and remote TPs information from AAI
+ // This method returns Local and remote TPs information from AAI
public Map getTPsfromAAI() {
Map<String, Object> tpInfo = new HashMap<>();
-
+
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK);
AAIResourcesClient client = new AAIResourcesClient();
Optional<LogicalLinks> result = client.get(LogicalLinks.class, uri);
-
+
if (result.isPresent()) {
LogicalLinks links = result.get();
boolean isRemoteLink = false;
-
+
links.getLogicalLink();
-
+
for (LogicalLink link : links.getLogicalLink()) {
AAIResultWrapper wrapper = new AAIResultWrapper(link);
Optional<Relationships> optRelationships = wrapper.getRelationships();
@@ -372,7 +381,7 @@ public class ServicePluginFactory {
}
pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE));
}
-
+
if (isRemoteLink) {
// find remote p interface
AAIResourceUri localTP = null;
@@ -393,7 +402,7 @@ public class ServicePluginFactory {
String tpUrl = localTP.build().toString();
PInterface intfLocal = client.get(PInterface.class, localTP).get();
tpInfo.put("local-access-node-id", tpUrl.split("/")[6]);
-
+
String[] networkRef = intfLocal.getNetworkRef().split("/");
if (networkRef.length == 6) {
tpInfo.put("local-access-provider-id", networkRef[1]);
@@ -404,7 +413,7 @@ public class ServicePluginFactory {
if (ltpIdStr.contains("-")) {
tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1));
}
-
+
// give remote tp
tpUrl = remoteTP.build().toString();
PInterface intfRemote = client.get(PInterface.class, remoteTP).get();
@@ -431,7 +440,7 @@ public class ServicePluginFactory {
// this method check if pInterface is remote
private boolean isRemotePInterface(AAIResourcesClient client, AAIResourceUri uri) {
-
+
String uriString = uri.build().toString();
if (uriString != null) {
@@ -447,7 +456,7 @@ public class ServicePluginFactory {
return !relationships.getRelatedAAIUris(AAIObjectType.EXT_AAI_NETWORK).isEmpty();
}
}
-
+
return false;
}
@@ -475,12 +484,19 @@ public class ServicePluginFactory {
return uuiRequest.contains("clientSignal") && uuiRequest.contains("vpnType");
}
+ @SuppressWarnings("unchecked")
private String preProcessSOTNService(ServiceDecomposition serviceDecomposition, String uuiRequest) {
Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
- Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
- Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
- Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
- List<Object> resources = (List<Object>) serviceParametersObject.get("resources");
+ if (uuiObject == null) {
+ return uuiRequest;
+ }
+ Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+ .getOrDefault("service", Collections.emptyMap());
+ Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+ .getOrDefault("parameters", Collections.emptyMap());
+ Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+ .getOrDefault("requestInputs", Collections.emptyMap());
+ List<Object> resources = (List<Object>) serviceParametersObject.getOrDefault("resources", Collections.emptyList());
// This is a logic for demo , it could not be finalized to community.
String srcLocation = "";
String dstLocation = "";
@@ -534,7 +550,7 @@ public class ServicePluginFactory {
vpnRequestInputs.put("src-client-signal", srcClientSignal);
vpnRequestInputs.put("dst-client-signal", dstClientSignal);
}
-
+
// Now we need to query terminal points from SP resourcemgr system.
List<Object> locationTerminalPointList = queryTerminalPointsFromServiceProviderSystem(srcLocation, dstLocation);
@@ -589,54 +605,61 @@ public class ServicePluginFactory {
}
return null;
}
-
+
public static void main(String args[]){
String str = "restconf/config/GENERIC-RESOURCE-API:services/service/eca7e542-12ba-48de-8544-fac59303b14e/service-data/networks/network/aec07806-1671-4af2-b722-53c8e320a633/network-data/";
-
+
int index1 = str.indexOf("/network/");
int index2 = str.indexOf("/network-data");
-
+
String str1 = str.substring(index1 + "/network/".length(), index2);
System.out.println(str1);
-
+
}
- private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) {
- // query the route for the service.
- Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
- Map<String, Object> serviceObject = (Map<String, Object>) uuiObject.get("service");
- Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject.get("parameters");
- Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject.get("requestInputs");
- Map<String, Object> oofQueryObject = new HashMap<>();
- List<Object> resources = (List<Object>) serviceParametersObject.get("resources");
- oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id"));
- oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id"));
- oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id"));
- oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id"));
- oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id"));
- oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id"));
- oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id"));
- oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id"));
- oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id"));
- oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id"));
- String oofRequestReq = getJsonString(oofQueryObject);
- String url = getOOFCalcEndPoint();
- String responseContent = sendRequest(url, "POST", oofRequestReq);
+ @SuppressWarnings("unchecked")
+ private String doSOTNServiceHoming(ServiceDecomposition serviceDecomposition, String uuiRequest) {
+ // query the route for the service.
+ Map<String, Object> uuiObject = getJsonObject(uuiRequest, Map.class);
+ if (uuiObject == null) {
+ return uuiRequest;
+ }
+ Map<String, Object> serviceObject = (Map<String, Object>) uuiObject
+ .getOrDefault("service", Collections.emptyMap());
+ Map<String, Object> serviceParametersObject = (Map<String, Object>) serviceObject
+ .getOrDefault("parameters", Collections.emptyMap());
+ Map<String, Object> serviceRequestInputs = (Map<String, Object>) serviceParametersObject
+ .getOrDefault("requestInputs", Collections.emptyMap());
+ Map<String, Object> oofQueryObject = new HashMap<>();
+ List<Object> resources = (List<Object>) serviceParametersObject
+ .getOrDefault("resources", Collections.emptyList());
+ oofQueryObject.put("src-access-provider-id", serviceRequestInputs.get("inner-src-access-provider-id"));
+ oofQueryObject.put("src-access-client-id", serviceRequestInputs.get("inner-src-access-client-id"));
+ oofQueryObject.put("src-access-topology-id", serviceRequestInputs.get("inner-src-access-topology-id"));
+ oofQueryObject.put("src-access-node-id", serviceRequestInputs.get("inner-src-access-node-id"));
+ oofQueryObject.put("src-access-ltp-id", serviceRequestInputs.get("inner-src-access-ltp-id"));
+ oofQueryObject.put("dst-access-provider-id", serviceRequestInputs.get("inner-dst-access-provider-id"));
+ oofQueryObject.put("dst-access-client-id", serviceRequestInputs.get("inner-dst-access-client-id"));
+ oofQueryObject.put("dst-access-topology-id", serviceRequestInputs.get("inner-dst-access-topology-id"));
+ oofQueryObject.put("dst-access-node-id", serviceRequestInputs.get("inner-dst-access-node-id"));
+ oofQueryObject.put("dst-access-ltp-id", serviceRequestInputs.get("inner-dst-access-ltp-id"));
+ String oofRequestReq = getJsonString(oofQueryObject);
+ String url = getOOFCalcEndPoint();
+ String responseContent = sendRequest(url, "POST", oofRequestReq);
+
+ List<Object> returnList = new ArrayList<>();
+ if (null != responseContent) {
+ returnList = getJsonObject(responseContent, List.class);
+ }
+ // in demo we have only one VPN. no cross VPNs, so get first item.
+ Map<String, Object> returnRoute = getReturnRoute(returnList);
+ Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources);
+ if (null != vpnRequestInputs) {
+ vpnRequestInputs.putAll(returnRoute);
+ }
+ return getJsonString(uuiObject);
+ }
- List<Object> returnList = new ArrayList<>();
- if (null != responseContent) {
- returnList = getJsonObject(responseContent, List.class);
- }
- // in demo we have only one VPN. no cross VPNs, so get first item.
- Map<String, Object> returnRoute = getReturnRoute(returnList);
- Map<String, Object> vpnRequestInputs = getVPNResourceRequestInputs(resources);
- if(null!=vpnRequestInputs) {
- vpnRequestInputs.putAll(returnRoute);
- }
- String newRequest = getJsonString(uuiObject);
- return newRequest;
- }
-
private Map<String, Object> getReturnRoute(List<Object> returnList){
Map<String, Object> returnRoute = new HashMap<>();
for(Object returnVpn :returnList){
@@ -681,7 +704,7 @@ public class ServicePluginFactory {
return resourceInputsFromUuiMap;
}
- public static <T> T getJsonObject(String jsonstr, Class<T> type) {
+ private static <T> T getJsonObject(String jsonstr, Class<T> type) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
try {
@@ -706,7 +729,7 @@ public class ServicePluginFactory {
}
private static String sendRequest(String url, String methodType, String content) {
-
+
String msbUrl = url;
HttpRequestBase method = null;
HttpResponse httpResponse = null;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java
new file mode 100644
index 0000000000..6e22123996
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Samsung Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.workflow.service;
+
+import static org.mockito.Mockito.doReturn;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.core.domain.ServiceDecomposition;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ServicePluginFactoryTest {
+
+ @Mock
+ ServiceDecomposition serviceDecomposition;
+
+ @Spy
+ ServicePluginFactory servicePluginFactory;
+
+ String uuiRequest = "{"
+ + " \"service\":{"
+ + " \"name\":\"ONAP_223531\","
+ + " \"description\":\"ONAP_1546\","
+ + " \"serviceInvariantUuid\":\"4a09419a-c9fd-4a53-b1bd-b49603169ca1\","
+ + " \"serviceUuid\":\"1bd0eae6-2dcc-4461-9ae6-56d641f369d6\","
+ + " \"globalSubscriberId\":\"test_custormer\","
+ + " \"serviceType\":\"example-service-type\","
+ + " \"parameters\":{"
+ + " \"locationConstraints\":["
+ + " ],"
+ + " \"resources\":["
+ + " {"
+ + " \"resourceName\":\"vEPC_ONAP01\","
+ + " \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\","
+ + " \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\","
+ + " \"resourceCustomizationUuid\":\"47a0e235-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\","
+ + " \"CallSource\":\"NOT-ExternalAPI\","
+ + " \"sotnconnectivity\":\"\""
+ + " }"
+ + " }"
+ + " }"
+ + "}";
+
+
+ @Test
+ public void doProcessSiteLocation_isNeedProcessSite() {
+ String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, uuiRequest);
+ Assert.assertEquals(result, uuiRequest);
+ }
+
+ @Test
+ public void doProcessSiteLocation_uuiObjectNull() {
+ String faultyJsonInput = "site_address,sotncondition_clientsignal";
+ String result = servicePluginFactory.doProcessSiteLocation(
+ serviceDecomposition, faultyJsonInput);
+ Assert.assertEquals(result, faultyJsonInput);
+ }
+
+ @Test
+ public void doProcessSiteLocation_isSiteLocationLocal() {
+ String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
+ String result = servicePluginFactory.doProcessSiteLocation(
+ serviceDecomposition, jsonWithOnlyNeededValues);
+ Assert.assertEquals(result, jsonWithOnlyNeededValues);
+ }
+
+
+ @Test
+ public void doTPResourcesAllocation_Success() {
+ doReturn(null).when(servicePluginFactory).getTPsfromAAI();
+ String result = servicePluginFactory.doTPResourcesAllocation(null, uuiRequest);
+ Assert.assertNotEquals(result, uuiRequest);
+ }
+
+ @Test
+ public void doTPResourcesAllocation_uuiObjectNull() {
+ String faultyJsonInput = "site_address,sotncondition_clientsignal";
+ String result = servicePluginFactory.doTPResourcesAllocation(null, faultyJsonInput);
+ Assert.assertEquals(result, faultyJsonInput);
+ }
+
+ @Test
+ public void doTPResourcesAllocation_isNeedAllocateCrossTPResources() {
+ //doReturn(null).when(servicePluginFactory).getTPsfromAAI();
+ String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
+ String result = servicePluginFactory.doTPResourcesAllocation(null, jsonWithOnlyNeededValues);
+ Assert.assertEquals(result, jsonWithOnlyNeededValues);
+ }
+
+ @Test
+ public void preProcessService_isSOTN() {
+ String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
+ String result = servicePluginFactory.preProcessService(null, invalidJsonWithOnlyNeededValues);
+ Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);
+ }
+
+ @Test
+ public void preProcessService() {
+ String result = servicePluginFactory.preProcessService(null, uuiRequest);
+ Assert.assertEquals(result, uuiRequest);
+ }
+
+ @Test
+ public void doServiceHoming() {
+ String result = servicePluginFactory.doServiceHoming(null, uuiRequest);
+ Assert.assertEquals(result, uuiRequest);
+ }
+
+ @Test
+ public void doServiceHoming_isSOTN() {
+ String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
+ String result = servicePluginFactory.doServiceHoming(null, invalidJsonWithOnlyNeededValues);
+ Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
index c4804c05c2..e13d1e4dda 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
@@ -2,6 +2,8 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Ericsson. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -85,8 +87,7 @@ public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask {
+ (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
LOGGER.error(message);
exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
- }
- if (operationStatusOption.isPresent()) {
+ } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
final OperationStateEnum operationStatus = operationStatusOption.get();
if (operationStatus != OperationStateEnum.COMPLETED) {
final String message =
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
new file mode 100644
index 0000000000..e0f88a20a5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
@@ -0,0 +1,13 @@
+package org.onap.so.bpmn.infrastructure.sdnc.exceptions;
+
+public class SDNCErrorResponseException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7807799223298140702L;
+
+ public SDNCErrorResponseException(String message) {
+ super(message);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
index a4ef28496e..24f642ae72 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
@@ -20,7 +20,15 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.exception.MapperException;
@@ -31,6 +39,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
@@ -44,6 +54,7 @@ public class SDNCRequestTasks {
private static final String MESSAGE = "_MESSAGE";
private static final String CORRELATOR = "_CORRELATOR";
protected static final String IS_CALLBACK_COMPLETED = "isCallbackCompleted";
+ protected static final String SDNC_SUCCESS = "200";
@Autowired
private ExceptionBuilder exceptionBuilder;
@@ -82,9 +93,24 @@ public class SDNCRequestTasks {
try {
SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
String asyncRequest = (String) execution.getVariable(request.getCorrelationName()+MESSAGE);
- String finalMessageIndicator = JsonPath.read(asyncRequest, "$.input.ack-final-indicator");
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
+
+ String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
+ if(isCallbackCompleted) {
+ String responseCode = getXmlElement(doc, "/input/response-code");
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+ if(!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
+ throw new SDNCErrorResponseException(responseMessage);
+ }
+ }
+ } catch (SDNCErrorResponseException e) {
+ logger.error("SDNC error response - " + e.getMessage());
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
} catch (Exception e) {
logger.error("Error procesing SDNC callback", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback");
@@ -99,4 +125,9 @@ public class SDNCRequestTasks {
return "Y".equals(finalMessageIndicator);
}
+ protected String getXmlElement(Document doc, String exp) throws Exception {
+ XPath xPath = XPathFactory.newInstance().newXPath();
+ return xPath.evaluate(exp, doc);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 867be2ec95..7562bd964e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -372,6 +372,31 @@ public class WorkflowAction {
return vnfcs;
}
+ protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) {
+
+ List<T> configurations = new ArrayList<>();
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+ AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
+ Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
+ if (!relationshipsOp.isPresent()) {
+ logger.debug("No relationships were found for VNFC in AAI");
+ } else {
+ Relationships relationships = relationshipsOp.get();
+ List<AAIResultWrapper> configurationResultWrappers = this.getResultWrappersFromRelationships(relationships, type);
+ for(AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
+ Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
+ if(configurationOp.isPresent()) {
+ configurations.add(configurationOp.get());
+ }
+ }
+ }
+ return configurations;
+ }
+
+ protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships, AAIObjectType type){
+ return relationships.getByType(type);
+ }
+
protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) {
for(OrchestrationFlow flow : orchFlows) {
if(flow.getFlowName().contains("Configuration")) {
@@ -384,6 +409,7 @@ public class WorkflowAction {
protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey,
String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType,
WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) {
+
List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
List<OrchestrationFlow> result = new ArrayList<>(orchFlows);
result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
@@ -392,22 +418,29 @@ public class WorkflowAction {
String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
- List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
-
- for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
- workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
- for(OrchestrationFlow orchFlow : result) {
- resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
- resourceKey.setCvnfModuleCustomizationId(configuration.getModelCustomizationId());
- resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
- ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
- requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
- String vnfcName = getVnfcNameForConfiguration(configuration);
- if(vnfcName == null || vnfcName.isEmpty()) {
- buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC);
+ for(org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
+ List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ if (configurations.size() > 1){
+ String multipleRelationshipsError = "Multiple relationships exist from VNFC "+vnfc.getVnfcName()+" to Configurations";
+ buildAndThrowException(execution, multipleRelationshipsError, new Exception(multipleRelationshipsError));
+ }
+ for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
+ workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
+ for(OrchestrationFlow orchFlow : result) {
+ resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
+ resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+ resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
+ ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
+ requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
+ String vnfcName = getVnfcNameForConfiguration(configuration);
+ if(vnfcName == null || vnfcName.isEmpty()) {
+ buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
+ }
+ ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
+ flowsToExecuteConfigs.add(ebb);
}
- ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
- flowsToExecuteConfigs.add(ebb);
}
}
return flowsToExecuteConfigs;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
index f1779cf119..043aad43b1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
@@ -27,9 +27,13 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.io.IOException;
+import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Paths;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -51,6 +55,8 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -131,12 +137,29 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks{
@Test
public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_ASYNC_Request.json")));
+ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
sndcRequestTasks.processCallback(delegateExecution);
assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
}
+ @Test
+ public void getXmlElementTest() throws Exception {
+ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+ DocumentBuilder db;
+ db = dbf.newDocumentBuilder ();
+ Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
+
+ String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
+ String responseCode = getXmlElement(doc, "/input/response-code");
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+
+ assertEquals("Y", finalMessageIndicator);
+ assertEquals("200", responseCode);
+ assertEquals("Success", responseMessage);
+ }
+
public SDNCRequest createSDNCRequest(){
SDNCRequest request = new SDNCRequest();
request.setCorrelationName("correlationName");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 0bc20c16f7..87e6daa58a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -53,6 +53,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Spy;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.Relationship;
@@ -60,6 +61,7 @@ import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
+import org.onap.aai.domain.yang.Vnfc;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -67,7 +69,11 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResource;
import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
@@ -100,9 +106,15 @@ public class WorkflowActionTest extends BaseTaskTest {
private DelegateExecution execution;
+ @InjectMocks
+ @Spy
+ protected WorkflowAction SPY_workflowAction;
+
@Rule
public ExpectedException thrown = ExpectedException.none();
+ private String RESOURCE_PATH = "src/test/resources/__files/";
+
@Before
public void before() throws Exception {
execution = new DelegateExecutionFake();
@@ -930,6 +942,123 @@ public class WorkflowActionTest extends BaseTaskTest {
assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
}
+ @Test
+ public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception{
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setModelCustomizationId("modelCustimizationId");
+ configuration.setConfigurationName("testConfigurationName");
+ configurations.add(configuration);
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs,"DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception{
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ execution.setVariable("requestAction", gAction);
+ String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ execution.setVariable("bpmnRequest", bpmnRequest);
+ execution.setVariable("aLaCarte", true);
+ execution.setVariable("apiVersion", "7");
+ execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+
+ SPY_workflowAction.selectExecutionList(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+ }
+
+ @Test
+ public void getRelatedResourcesInVfModuleTest() throws Exception{
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+
+ String vfncPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
+ AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
+
+ String configurationPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
+ AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
+ List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
+ configurationResultWrappers.add(configurationWrapper);
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+ when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
+
+ doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),anyObject());
+ List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ assertEquals(1,configurationsList.size());
+ assertEquals("testConfigurationId",configurationsList.get(0).getConfigurationId());
+ }
+
/**
* WorkflowActionBB Tests
*/
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json
new file mode 100644
index 0000000000..c8420a5fab
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json
@@ -0,0 +1,8 @@
+{
+ "configuration-id": "testConfigurationId",
+ "configuration-type": "...",
+ "orchestration-status": "...",
+ "tunnel-bandwidth": "100",
+ "vendor-allowed-max-bandwidth": "90",
+ "resource-version": "1234"
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json
new file mode 100644
index 0000000000..0b2d847e03
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json
@@ -0,0 +1,29 @@
+{
+ "vnfc-name": "vnfcName",
+ "nfc-naming-code": "oamfw",
+ "nfc-function": "FIREWALL",
+ "prov-status": "PREPROV",
+ "orchestration-status": "Active",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "model-invariant-id": "9dae8bb5-0709-4c0e-8f5b-6448232510ea",
+ "model-version-id": "b4e05ccb-01d0-4176-90ae-380308a35e5f",
+ "model-customization-id": "abf73d38-9da2-47af-bd53-26954318449f",
+ "resource-version": "1552319567126",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/testGenericVnfId",
+ "relationship-data": {
+ "relationship-key": "generic-vnf",
+ "relationship-value": "4a9184ac-5fad-44a1-b224-289bb490eaa9"
+ },
+ "related-to-property": {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "USBBBBmtwnjVVHP047"
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
new file mode 100644
index 0000000000..aa69dba803
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<input>
+ <service-information>
+ <service-type>MY-SERVICE-TYPE</service-type>
+ <service-instance-id>b8308928-de76-4ce6-9e58-ec6033ff43b3</service-instance-id>
+ </service-information>
+ <svc-request-id>aa243891-4575-4040-bceb-25d5b7bc8c61</svc-request-id>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</input>