summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2022-08-05 14:19:19 +0200
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2022-08-05 14:19:57 +0200
commitb0f785e99096f230281d17e0fa89c21aca00fbac (patch)
treeecaa9d853037faa87310ab8c6562a3454e687179 /bpmn
parent0d39f06a571e48ee3c8a05aca0c244d2595468e8 (diff)
parent2ef42cd813c85015322da874de668b79e790c5eb (diff)
Merge branch 'recursive-orch'
Issue-ID: SO-3980 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: Ie0cd0f973800196d5cb1e038db4a49208a6c4a3b
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java21
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java6
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml3
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn135
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteChildServiceBB.bpmn123
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java1
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml4
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilder.java231
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java134
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/DeleteChildServiceBB.java129
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ServiceCompositionConstants.java32
-rwxr-xr-xbpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java4
-rwxr-xr-xbpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java50
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java17
-rwxr-xr-xbpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java59
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java73
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClientException.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/RestTemplateApiClientConfig.java23
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java253
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java145
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java131
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java56
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java121
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml4
31 files changed, 1804 insertions, 20 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
index 641cd35027..cb4bd81918 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
@@ -36,5 +36,7 @@ public enum ResourceKey {
INSTANCE_GROUP_ID,
PNF,
VNF_INSTANCE_NAME,
- VF_MODULE_INSTANCE_NAME
+ VF_MODULE_INSTANCE_NAME,
+ CHILD_SERVICE_INSTANCE_ID,
+ CHILD_SERVICE_INSTANCE_NAME
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
index 5df7c60f74..cfcc1f9f3b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
@@ -42,6 +42,9 @@ public class WorkflowResourceIds implements Serializable {
private String instanceGroupId;
private String vnfInstanceName;
private String vfModuleInstanceName;
+ private String childServiceInstanceId;
+ private String childServiceInstanceName;
+
public WorkflowResourceIds() {
@@ -58,6 +61,8 @@ public class WorkflowResourceIds implements Serializable {
this.networkCollectionId = workflowResourceIds.networkCollectionId;
this.configurationId = workflowResourceIds.configurationId;
this.instanceGroupId = workflowResourceIds.instanceGroupId;
+ this.childServiceInstanceId = workflowResourceIds.childServiceInstanceId;
+ this.childServiceInstanceName = workflowResourceIds.childServiceInstanceName;
}
@@ -157,4 +162,20 @@ public class WorkflowResourceIds implements Serializable {
public void setVfModuleInstanceName(String vfModuleInstanceName) {
this.vfModuleInstanceName = vfModuleInstanceName;
}
+
+ public String getChildServiceInstanceId() {
+ return childServiceInstanceId;
+ }
+
+ public void setChildServiceInstanceId(String childServiceInstanceId) {
+ this.childServiceInstanceId = childServiceInstanceId;
+ }
+
+ public String getChildServiceInstanceName() {
+ return childServiceInstanceName;
+ }
+
+ public void setChildServiceInstanceName(String childServiceInstanceName) {
+ this.childServiceInstanceName = childServiceInstanceName;
+ }
}
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 6d5eb63b0d..b29b95a3b1 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
@@ -262,6 +262,8 @@ public class BBInputSetup implements JavaDelegate {
lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, workflowResourceIds.getInstanceGroupId());
lookupKeyMap.put(ResourceKey.VNF_INSTANCE_NAME, workflowResourceIds.getVnfInstanceName());
lookupKeyMap.put(ResourceKey.VF_MODULE_INSTANCE_NAME, workflowResourceIds.getVfModuleInstanceName());
+ lookupKeyMap.put(ResourceKey.CHILD_SERVICE_INSTANCE_ID, workflowResourceIds.getChildServiceInstanceId());
+ lookupKeyMap.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, workflowResourceIds.getChildServiceInstanceName());
}
protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB,
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 d405cff8bb..7f066af080 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
@@ -2121,6 +2121,8 @@ public class BBInputSetupTest {
String instanceGroupId = "instancegroupId";
String vnfInstanceName = "vnfInstanceName";
String vfModuleInstanceName = "vfModuleInstanceName";
+ String childServiceInstanceId = "childServiceInstanceId";
+ String childServiceInstanceName = "childServiceInstanceName";
expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
expected.put(ResourceKey.NETWORK_ID, networkId);
@@ -2132,6 +2134,8 @@ public class BBInputSetupTest {
expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
expected.put(ResourceKey.VNF_INSTANCE_NAME, vnfInstanceName);
expected.put(ResourceKey.VF_MODULE_INSTANCE_NAME, vfModuleInstanceName);
+ expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_ID, childServiceInstanceId);
+ expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, childServiceInstanceName);
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
@@ -2144,6 +2148,8 @@ public class BBInputSetupTest {
workflowResourceIds.setInstanceGroupId(instanceGroupId);
workflowResourceIds.setVnfInstanceName(vnfInstanceName);
workflowResourceIds.setVfModuleInstanceName(vfModuleInstanceName);
+ workflowResourceIds.setChildServiceInstanceId(childServiceInstanceId);
+ workflowResourceIds.setChildServiceInstanceName(childServiceInstanceName);
SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml b/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml
index 56a92cbd01..07c90bf529 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml
+++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml
@@ -59,6 +59,9 @@ mso:
requestDb:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
endpoint: http://localhost:8081
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn
new file mode 100644
index 0000000000..9d361bf101
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn
@@ -0,0 +1,135 @@
+<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1qv87sb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.12.0">
+ <bpmn:process id="CreateChildServiceBB" name="CreateChildServiceBB" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1">
+ <bpmn:outgoing>SequenceFlow_14q7e7i</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:endEvent id="EndEvent_0il9cjn">
+ <bpmn:incoming>SequenceFlow_143mdyp</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_14q7e7i" sourceRef="StartEvent_1" targetRef="Task_1axdixm" />
+ <bpmn:sequenceFlow id="SequenceFlow_0n5pwwk" sourceRef="Task_1axdixm" targetRef="Task_0892y22" />
+ <bpmn:sequenceFlow id="SequenceFlow_0x6xxb8" sourceRef="Task_0892y22" targetRef="Task_1olljx2" />
+ <bpmn:sequenceFlow id="SequenceFlow_0jahgui" sourceRef="Task_1olljx2" targetRef="ExclusiveGateway_1otl9mn" />
+ <bpmn:sequenceFlow id="SequenceFlow_143mdyp" sourceRef="Task_1oyb4b5" targetRef="EndEvent_0il9cjn" />
+ <bpmn:receiveTask id="Task_1olljx2" name="Wait for Completion" messageRef="Message_0kfkpsv">
+ <bpmn:incoming>SequenceFlow_0x6xxb8</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0jahgui</bpmn:outgoing>
+ </bpmn:receiveTask>
+ <bpmn:boundaryEvent id="IntermediateThrowEvent_1gh5vds" name="Timeout" attachedToRef="Task_1olljx2">
+ <bpmn:outgoing>SequenceFlow_0hmy1qr</bpmn:outgoing>
+ <bpmn:timerEventDefinition id="TimerEventDefinition_13keqs7">
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT5H</bpmn:timeDuration>
+ </bpmn:timerEventDefinition>
+ </bpmn:boundaryEvent>
+ <bpmn:endEvent id="EndEvent_11rdhm9">
+ <bpmn:incoming>SequenceFlow_0hmy1qr</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_12rxrrg" errorRef="Error_1d6c5q3" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0hmy1qr" sourceRef="IntermediateThrowEvent_1gh5vds" targetRef="EndEvent_11rdhm9" />
+ <bpmn:exclusiveGateway id="ExclusiveGateway_1otl9mn" name="Child Request Status" default="SequenceFlow_052tga4">
+ <bpmn:incoming>SequenceFlow_0jahgui</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0zfixj7</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_052tga4</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="SequenceFlow_0zfixj7" name="Completed" sourceRef="ExclusiveGateway_1otl9mn" targetRef="Task_1oyb4b5">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("CHILD_SVC_REQ_STATUS")=="COMPLETED"}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="SequenceFlow_052tga4" name="Failed" sourceRef="ExclusiveGateway_1otl9mn" targetRef="Task_0jc8k6m" />
+ <bpmn:serviceTask id="Task_1axdixm" name="Build Create Request" camunda:expression="${CreateChildServiceBB.buildRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_14q7e7i</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0n5pwwk</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Task_0892y22" name="Send Request" camunda:expression="${CreateChildServiceBB.sendRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0n5pwwk</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0x6xxb8</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Task_0jc8k6m" name="Handle Failure" camunda:expression="${CreateChildServiceBB.handleFailure(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_052tga4</bpmn:incoming>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Task_1oyb4b5" name="Update AAI" camunda:expression="${CreateChildServiceBB.updateRelations(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0zfixj7</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_143mdyp</bpmn:outgoing>
+ </bpmn:serviceTask>
+ </bpmn:process>
+ <bpmn:error id="Error_1d6c5q3" name="MSO Workflow Exception" errorCode="MSOWorkflowException" camunda:errorMessage="Child service creation timeout reached" />
+ <bpmn:message id="Message_0kfkpsv" name="ChildServiceRequest" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateChildServiceBB">
+ <bpmndi:BPMNEdge id="SequenceFlow_052tga4_di" bpmnElement="SequenceFlow_052tga4">
+ <di:waypoint x="900" y="145" />
+ <di:waypoint x="900" y="230" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="905" y="173" width="30" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0zfixj7_di" bpmnElement="SequenceFlow_0zfixj7">
+ <di:waypoint x="925" y="120" />
+ <di:waypoint x="1040" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="957" y="102" width="54" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0hmy1qr_di" bpmnElement="SequenceFlow_0hmy1qr">
+ <di:waypoint x="730" y="178" />
+ <di:waypoint x="730" y="252" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_143mdyp_di" bpmnElement="SequenceFlow_143mdyp">
+ <di:waypoint x="1140" y="120" />
+ <di:waypoint x="1232" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0jahgui_di" bpmnElement="SequenceFlow_0jahgui">
+ <di:waypoint x="750" y="120" />
+ <di:waypoint x="875" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0x6xxb8_di" bpmnElement="SequenceFlow_0x6xxb8">
+ <di:waypoint x="570" y="120" />
+ <di:waypoint x="650" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0n5pwwk_di" bpmnElement="SequenceFlow_0n5pwwk">
+ <di:waypoint x="380" y="120" />
+ <di:waypoint x="470" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_14q7e7i_di" bpmnElement="SequenceFlow_14q7e7i">
+ <di:waypoint x="178" y="120" />
+ <di:waypoint x="280" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="142" y="102" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0il9cjn_di" bpmnElement="EndEvent_0il9cjn">
+ <dc:Bounds x="1232" y="102" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ReceiveTask_1bptt2c_di" bpmnElement="Task_1olljx2">
+ <dc:Bounds x="650" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_03unhuu_di" bpmnElement="EndEvent_11rdhm9">
+ <dc:Bounds x="712" y="252" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ExclusiveGateway_1otl9mn_di" bpmnElement="ExclusiveGateway_1otl9mn" isMarkerVisible="true">
+ <dc:Bounds x="875" y="95" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="866" y="65" width="70" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0t3ilvf_di" bpmnElement="Task_1axdixm">
+ <dc:Bounds x="280" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0hbcben_di" bpmnElement="Task_0892y22">
+ <dc:Bounds x="470" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_1j024ya_di" bpmnElement="Task_0jc8k6m">
+ <dc:Bounds x="850" y="230" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_10o8qyu_di" bpmnElement="Task_1oyb4b5">
+ <dc:Bounds x="1040" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BoundaryEvent_0g07oag_di" bpmnElement="IntermediateThrowEvent_1gh5vds">
+ <dc:Bounds x="712" y="142" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="750" y="173" width="40" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteChildServiceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteChildServiceBB.bpmn
new file mode 100644
index 0000000000..3be6d32792
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteChildServiceBB.bpmn
@@ -0,0 +1,123 @@
+<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0n06ztl" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.12.0">
+ <bpmn:process id="DeleteChildServiceBB" name="DeleteChildServiceBB" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1m5641e">
+ <bpmn:outgoing>SequenceFlow_01wirq3</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:receiveTask id="ReceiveTask_0otx1r1" name="Wait for Completion" messageRef="Message_0xg6jua">
+ <bpmn:incoming>SequenceFlow_14d89qf</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1ufwh0a</bpmn:outgoing>
+ </bpmn:receiveTask>
+ <bpmn:endEvent id="EndEvent_02vkobe">
+ <bpmn:incoming>SequenceFlow_0o2ukb9</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_05rpxbj" errorRef="Error_1d6c5q3" />
+ </bpmn:endEvent>
+ <bpmn:boundaryEvent id="BoundaryEvent_1f4g2g1" name="Timeout" attachedToRef="ReceiveTask_0otx1r1">
+ <bpmn:outgoing>SequenceFlow_0o2ukb9</bpmn:outgoing>
+ <bpmn:timerEventDefinition id="TimerEventDefinition_01na1b7">
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT5H</bpmn:timeDuration>
+ </bpmn:timerEventDefinition>
+ </bpmn:boundaryEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_01wirq3" sourceRef="StartEvent_1m5641e" targetRef="Task_01gqeuu" />
+ <bpmn:sequenceFlow id="SequenceFlow_0q6aqsk" sourceRef="Task_01gqeuu" targetRef="Task_16o0qkj" />
+ <bpmn:sequenceFlow id="SequenceFlow_14d89qf" sourceRef="Task_16o0qkj" targetRef="ReceiveTask_0otx1r1" />
+ <bpmn:sequenceFlow id="SequenceFlow_0o2ukb9" sourceRef="BoundaryEvent_1f4g2g1" targetRef="EndEvent_02vkobe" />
+ <bpmn:exclusiveGateway id="ExclusiveGateway_1mxv8h6" name="Child Request Status" default="SequenceFlow_12rysg7">
+ <bpmn:incoming>SequenceFlow_1ufwh0a</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0v4loyx</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_12rysg7</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:endEvent id="EndEvent_0fh7ikt">
+ <bpmn:incoming>SequenceFlow_0v4loyx</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0v4loyx" name="Completed" sourceRef="ExclusiveGateway_1mxv8h6" targetRef="EndEvent_0fh7ikt">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("CHILD_SVC_REQ_STATUS")=="COMPLETED"}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="SequenceFlow_12rysg7" name="Failed" sourceRef="ExclusiveGateway_1mxv8h6" targetRef="Task_073m8fr" />
+ <bpmn:sequenceFlow id="SequenceFlow_1ufwh0a" sourceRef="ReceiveTask_0otx1r1" targetRef="ExclusiveGateway_1mxv8h6" />
+ <bpmn:serviceTask id="Task_01gqeuu" name="Build Delete Request" camunda:expression="${DeleteChildServiceBB.buildRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_01wirq3</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0q6aqsk</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Task_16o0qkj" name="Send Request" camunda:expression="${DeleteChildServiceBB.sendRequest(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0q6aqsk</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_14d89qf</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:serviceTask id="Task_073m8fr" name="Handle Failure" camunda:expression="${DeleteChildServiceBB.handleFailure(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_12rysg7</bpmn:incoming>
+ </bpmn:serviceTask>
+ </bpmn:process>
+ <bpmn:error id="Error_1d6c5q3" name="MSO Workflow Exception" errorCode="MSOWorkflowException" camunda:errorMessage="Child service deletion timeout reached" />
+ <bpmn:message id="Message_0xg6jua" name="ChildServiceRequest" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteChildServiceBB">
+ <bpmndi:BPMNEdge id="SequenceFlow_1ufwh0a_di" bpmnElement="SequenceFlow_1ufwh0a">
+ <di:waypoint x="760" y="120" />
+ <di:waypoint x="885" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_12rysg7_di" bpmnElement="SequenceFlow_12rysg7">
+ <di:waypoint x="910" y="145" />
+ <di:waypoint x="910" y="230" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="925" y="173" width="30" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0v4loyx_di" bpmnElement="SequenceFlow_0v4loyx">
+ <di:waypoint x="935" y="120" />
+ <di:waypoint x="1242" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="981" y="102" width="54" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0o2ukb9_di" bpmnElement="SequenceFlow_0o2ukb9">
+ <di:waypoint x="740" y="178" />
+ <di:waypoint x="740" y="252" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_14d89qf_di" bpmnElement="SequenceFlow_14d89qf">
+ <di:waypoint x="580" y="120" />
+ <di:waypoint x="660" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0q6aqsk_di" bpmnElement="SequenceFlow_0q6aqsk">
+ <di:waypoint x="390" y="120" />
+ <di:waypoint x="480" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_01wirq3_di" bpmnElement="SequenceFlow_01wirq3">
+ <di:waypoint x="188" y="120" />
+ <di:waypoint x="290" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="StartEvent_1m5641e_di" bpmnElement="StartEvent_1m5641e">
+ <dc:Bounds x="152" y="102" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ReceiveTask_0otx1r1_di" bpmnElement="ReceiveTask_0otx1r1">
+ <dc:Bounds x="660" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_02vkobe_di" bpmnElement="EndEvent_02vkobe">
+ <dc:Bounds x="722" y="252" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ExclusiveGateway_1mxv8h6_di" bpmnElement="ExclusiveGateway_1mxv8h6" isMarkerVisible="true">
+ <dc:Bounds x="885" y="95" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="875" y="65" width="70" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0fh7ikt_di" bpmnElement="EndEvent_0fh7ikt">
+ <dc:Bounds x="1242" y="102" width="36" height="36" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0aqgcg6_di" bpmnElement="Task_01gqeuu">
+ <dc:Bounds x="290" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0o8psus_di" bpmnElement="Task_16o0qkj">
+ <dc:Bounds x="480" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0hkopiv_di" bpmnElement="Task_073m8fr">
+ <dc:Bounds x="860" y="230" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="BoundaryEvent_1f4g2g1_di" bpmnElement="BoundaryEvent_1f4g2g1">
+ <dc:Bounds x="722" y="142" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="760" y="173" width="40" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
index f492326b0c..6c732a1edb 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
@@ -106,6 +106,7 @@ public class WorkflowActionBBTest extends BaseBPMNTest {
}
+
@Test
public void retrieveBBExecutionListerrorHandling() throws Exception {
variables.put("isTopLevelFlow", true);
diff --git a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml
index c36172c3bf..14640f4eec 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-building-blocks/src/test/resources/application-test.yaml
@@ -75,7 +75,9 @@ mso:
requestDb:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
endpoint: http://localhost:8081
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml
index fa753396cf..7a9c4ba914 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml
@@ -64,7 +64,9 @@ mso:
#${mso.adapters.requestDb.auth}: BBInputSetup
auth: Basic YnBlbDptc28tZGItMTUwNyE=
endpoint: http://localhost:${wiremock.server.port}
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilder.java
new file mode 100644
index 0000000000..2a008e3573
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilder.java
@@ -0,0 +1,231 @@
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.InstanceDirection;
+import org.onap.so.serviceinstancebeans.OwningEntity;
+import org.onap.so.serviceinstancebeans.Project;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.SubscriberInfo;
+import java.io.IOException;
+import java.util.Map;
+
+public class ChildServiceRequestBuilder {
+ private final BuildingBlockExecution buildingBlockExecution;
+ private Service parent;
+ private Service child;
+ private ServiceInstancesRequest sir;
+
+ private ChildServiceRequestBuilder(final BuildingBlockExecution buildingBlockExecution, Service parent,
+ Service child) {
+ this.buildingBlockExecution = buildingBlockExecution;
+ this.child = child;
+ this.parent = parent;
+
+ this.sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setRequestInfo(new RequestInfo());
+ this.sir.setRequestDetails(requestDetails);
+ }
+
+ public static ChildServiceRequestBuilder getInstance(final BuildingBlockExecution buildingBlockExecution,
+ String childSvcInstanceName) {
+ Service child = null;
+ Service parent = null;
+ try {
+ String USERPARAMSERVICE = "service";
+ for (Map<String, Object> params : buildingBlockExecution.getGeneralBuildingBlock().getRequestContext()
+ .getRequestParameters().getUserParams()) {
+ if (params.containsKey(USERPARAMSERVICE)) {
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
+ parent = obj.readValue(input, Service.class);
+ if (parent.getResources().getServices() != null) {
+ for (Service service : parent.getResources().getServices()) {
+ if (service.getInstanceName().equals(childSvcInstanceName)) {
+ child = service;
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Failed parsing context user parameters for parent or child service", e);
+ }
+ return new ChildServiceRequestBuilder(buildingBlockExecution, parent, child);
+ }
+
+ public static ChildServiceRequestBuilder getInstance(final BuildingBlockExecution buildingBlockExecution,
+ Service parentInstance, Service childInstance) {
+ Service child = null;
+ Service parent = null;
+ if (childInstance != null) {
+ parent = parentInstance;
+ child = childInstance;
+ }
+ return new ChildServiceRequestBuilder(buildingBlockExecution, parent, child);
+ }
+
+ public ChildServiceRequestBuilder setParentRequestId(String parentRequestId) {
+ sir.getRequestDetails().getRequestInfo().setRequestorId(parentRequestId);
+ return this;
+ }
+
+ public ChildServiceRequestBuilder setCorrelationId(String correlationId) {
+ sir.getRequestDetails().getRequestInfo().setCorrelator(correlationId);
+ return this;
+ }
+
+ public ChildServiceRequestBuilder setChildSvcInstanceId(String childSvcInstanceId) {
+ sir.setServiceInstanceId(childSvcInstanceId);
+ return this;
+ }
+
+ public ServiceInstancesRequest build() {
+ RequestContext context = buildingBlockExecution.getGeneralBuildingBlock().getRequestContext();
+
+ if (context.getAction().equals("deleteInstance")) {
+ sir.setRequestDetails(createRequestDetailsDeleteChild(context));
+ } else {
+ sir.setRequestDetails(createRequestDetails(context));
+ }
+ return sir;
+ }
+
+ private RequestDetails createRequestDetailsDeleteChild(RequestContext context) {
+ RequestDetails details = sir.getRequestDetails();
+
+ details.setRequestParameters(createRequestParameters(context, child));
+ details.setRequestInfo(createRequestInfo(context));
+ details.setCloudConfiguration(createCloudConfiguration());
+ details.setModelInfo(child.getModelInfo());
+ details.setSubscriberInfo(createSubscriberInfo());
+ details.setRelatedInstanceList(createRelatedInstanceList());
+
+ return details;
+ }
+
+ private RequestDetails createRequestDetails(RequestContext context) {
+ RequestDetails details = sir.getRequestDetails();
+
+ details.setRequestParameters(createRequestParameters(context, child));
+ details.setRequestInfo(createRequestInfo(context));
+ details.setCloudConfiguration(createCloudConfiguration());
+ details.setModelInfo(child.getModelInfo());
+ details.setSubscriberInfo(createSubscriberInfo());
+ details.setOwningEntity(createOwningEntity());
+ details.setProject(createProject());
+ details.setRelatedInstanceList(createRelatedInstanceList());
+
+ return details;
+ }
+
+ private RequestParameters createRequestParameters(RequestContext context, Service childService) {
+ RequestParameters requestParameters = new RequestParameters();
+
+ if (!context.getRequestParameters().getUserParams().isEmpty()) {
+ requestParameters.getUserParams().add(context.getRequestParameters().getUserParams().get(0));
+ if (context.getAction().equals("createInstance")) {
+ requestParameters.getUserParams().add(Map.of("service", childService));
+ }
+ }
+ requestParameters.setSubscriptionServiceType(context.getRequestParameters().getSubscriptionServiceType());
+ requestParameters.setaLaCarte(context.getRequestParameters().getALaCarte());
+ requestParameters.setPayload(context.getRequestParameters().getPayload());
+ requestParameters.setUsePreload(context.getRequestParameters().getUsePreload());
+
+ return requestParameters;
+ }
+
+ private RequestInfo createRequestInfo(RequestContext context) {
+ RequestInfo info = sir.getRequestDetails().getRequestInfo();
+ if (info != null) {
+ info.setProductFamilyId(context.getProductFamilyId());
+ info.setSource(context.getSource());
+ info.setRequestorId(context.getRequestorId());
+ info.setInstanceName(child.getInstanceName());
+ info.setSuppressRollback(false);
+ }
+ return info;
+ }
+
+ private CloudConfiguration createCloudConfiguration() {
+ if (child.getCloudConfiguration() != null) {
+ return child.getCloudConfiguration();
+ }
+
+ CloudConfiguration cloudConfiguration = null;
+ CloudRegion requestCloudConfiguration = buildingBlockExecution.getGeneralBuildingBlock().getCloudRegion();
+ if (requestCloudConfiguration != null) {
+ cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId(requestCloudConfiguration.getLcpCloudRegionId());
+ cloudConfiguration.setTenantId(requestCloudConfiguration.getTenantId());
+ cloudConfiguration.setCloudOwner(requestCloudConfiguration.getCloudOwner());
+ }
+ return cloudConfiguration;
+ }
+
+ private SubscriberInfo createSubscriberInfo() {
+ Customer requestCustomer = buildingBlockExecution.getGeneralBuildingBlock().getCustomer();
+
+ SubscriberInfo subscriberInfo = null;
+ if (requestCustomer != null) {
+ subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId(requestCustomer.getGlobalCustomerId());
+ subscriberInfo.setSubscriberName(requestCustomer.getSubscriberName());
+ }
+
+ return subscriberInfo;
+ }
+
+ private OwningEntity createOwningEntity() {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity requestOwningEntity =
+ buildingBlockExecution.getGeneralBuildingBlock().getServiceInstance().getOwningEntity();
+ OwningEntity owningEntity = null;
+ if (requestOwningEntity != null) {
+ owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId(requestOwningEntity.getOwningEntityId());
+ owningEntity.setOwningEntityName(requestOwningEntity.getOwningEntityName());
+ }
+
+ return owningEntity;
+ }
+
+ private Project createProject() {
+ org.onap.so.bpmn.servicedecomposition.bbobjects.Project requestProject =
+ buildingBlockExecution.getGeneralBuildingBlock().getServiceInstance().getProject();
+ Project project = null;
+
+ if (requestProject != null) {
+ project = new Project();
+ project.setProjectName(requestProject.getProjectName());
+ }
+ return project;
+ }
+
+ private RelatedInstanceList[] createRelatedInstanceList() {
+ RelatedInstance relatedInstance = new RelatedInstance();
+ relatedInstance.setModelInfo(parent.getModelInfo());
+ relatedInstance.setInstanceId(
+ buildingBlockExecution.getGeneralBuildingBlock().getServiceInstance().getServiceInstanceId());
+ relatedInstance.setInstanceDirection(InstanceDirection.source);
+
+ RelatedInstanceList relatedInstanceList = new RelatedInstanceList();
+ relatedInstanceList.setRelatedInstance(relatedInstance);
+
+ RelatedInstanceList[] relatedInstanceListsArray = new RelatedInstanceList[1];
+ relatedInstanceListsArray[0] = relatedInstanceList;
+
+ return relatedInstanceListsArray;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
new file mode 100644
index 0000000000..0486c529c6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (C) 2021 Bell Canada. 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.
+ */
+
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_PAYLOAD;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_INSTANCE_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.ApiHandlerClient;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.onap.aai.domain.yang.ComposedResource;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+
+
+@Component
+public class CreateChildServiceBB {
+
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ protected ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private ApiHandlerClient apiHandlerClient;
+
+ public void buildRequest(final BuildingBlockExecution buildingBlockExecution) {
+ try {
+ log.info("Building Create Service Request");
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+ String childSvcInstanceName = lookupMap.get(ResourceKey.CHILD_SERVICE_INSTANCE_NAME);
+ Objects.requireNonNull(childSvcInstanceName, "Child service instance name is required");
+
+ ServiceInstancesRequest sir = ChildServiceRequestBuilder
+ .getInstance(buildingBlockExecution, childSvcInstanceName)
+ .setParentRequestId(
+ buildingBlockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).build();
+ buildingBlockExecution.setVariable(CHILD_SVC_REQ_PAYLOAD, sir);
+ } catch (Exception e) {
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 10002, e.getMessage(),
+ ONAPComponents.SO);
+ }
+ }
+
+ public void sendRequest(final BuildingBlockExecution buildingBlockExecution) throws Exception {
+ try {
+ buildingBlockExecution.getLookupMap();
+ ServiceInstancesRequest sir = buildingBlockExecution.getVariable(CHILD_SVC_REQ_PAYLOAD);
+ log.info("Sending Create Service Request: \n{}", sir.toString());
+ buildingBlockExecution.setVariable(CHILD_SVC_REQ_CORRELATION_ID,
+ sir.getRequestDetails().getRequestInfo().getCorrelator());
+ ServiceInstancesResponse response = apiHandlerClient.createServiceInstance(sir);
+ buildingBlockExecution.setVariable(CHILD_SVC_REQ_ID, response.getRequestReferences().getRequestId());
+ buildingBlockExecution.setVariable(CHILD_SVC_INSTANCE_ID, response.getRequestReferences().getInstanceId());
+ } catch (Exception e) {
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 10003, e.getMessage(),
+ ONAPComponents.SO);
+ }
+ }
+
+ /*
+ * This method is to create Relation between Parent & Child Services with Node as Composed Resource.
+ *
+ */
+
+ public void updateRelations(BuildingBlockExecution buildingBlockExecution) throws Exception {
+
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+
+ String childSvcInstanceId = buildingBlockExecution.getVariable(CHILD_SVC_INSTANCE_ID);
+ String parentSvcInstanceId = lookupMap.get(ResourceKey.SERVICE_INSTANCE_ID);
+
+ ComposedResource composedResource = new ComposedResource();
+ composedResource.setId(UUID.randomUUID().toString());
+
+ AAIResourcesClient client = new AAIResourcesClient();
+
+ AAIResourceUri composedResourceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(buildingBlockExecution.getGeneralBuildingBlock().getCustomer().getGlobalCustomerId())
+ .serviceSubscription(buildingBlockExecution.getGeneralBuildingBlock().getRequestContext()
+ .getSubscriptionServiceType())
+ .serviceInstance(parentSvcInstanceId).composedResource(composedResource.getId()));
+
+ client.create(composedResourceURI, composedResource);
+
+ AAIResourceUri childURI =
+ AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(childSvcInstanceId));
+
+ client.connect(composedResourceURI, childURI);
+
+ }
+
+ public void handleFailure(final BuildingBlockExecution buildingBlockExecution) {
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+ String childSvcInstanceName = lookupMap.get(ResourceKey.CHILD_SERVICE_INSTANCE_NAME);
+ String childErrorMessage = buildingBlockExecution.getVariable(CHILD_SVC_REQ_ERROR);
+ String errorMessage =
+ String.format("Failed creating child service %s %s", childSvcInstanceName, childErrorMessage);
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 10001, errorMessage, ONAPComponents.SO);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/DeleteChildServiceBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/DeleteChildServiceBB.java
new file mode 100644
index 0000000000..52d1b68ccd
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/DeleteChildServiceBB.java
@@ -0,0 +1,129 @@
+/*-
+ * Copyright (C) 2021 Bell Canada. 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.
+ */
+
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.ApiHandlerClient;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.Map;
+import java.util.UUID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_INSTANCE_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_PAYLOAD;
+
+
+@Component
+public class DeleteChildServiceBB {
+
+ @Autowired
+ protected ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private ApiHandlerClient apiHandlerClient;
+
+ private AAIResourcesClient aaiResourcesClient = new AAIResourcesClient();
+
+ private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+ public void buildRequest(final BuildingBlockExecution buildingBlockExecution) {
+ log.info("Building Delete Service Request");
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+ String childSvcInstanceId = lookupMap.get(ResourceKey.CHILD_SERVICE_INSTANCE_ID);
+ String childServiceInstanceId =
+ buildingBlockExecution.getLookupMap().get(ResourceKey.CHILD_SERVICE_INSTANCE_ID);
+ String parentServiceInstanceId = buildingBlockExecution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID);
+ ServiceInstance childInstanceAAI = aaiResourcesClient.get(ServiceInstance.class,
+ AAIUriFactory
+ .createResourceUri(
+ AAIFluentTypeBuilder.Types.SERVICE_INSTANCE.getFragment(childServiceInstanceId))
+ .depth(Depth.TWO))
+ .orElse(null);
+ ServiceInstance parentInstanceAAI =
+ aaiResourcesClient.get(ServiceInstance.class,
+ AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.Types.SERVICE_INSTANCE.getFragment(parentServiceInstanceId))
+ .depth(Depth.TWO))
+ .orElse(null);
+ if (childInstanceAAI == null || parentInstanceAAI == null) {
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 10004, "Service AAI request failed",
+ ONAPComponents.SO);
+ }
+ Service parentInstance = serviceInstanceToServiceBeanMapper(parentInstanceAAI);
+ Service childInstance = serviceInstanceToServiceBeanMapper(childInstanceAAI);
+ ServiceInstancesRequest sir = ChildServiceRequestBuilder
+ .getInstance(buildingBlockExecution, parentInstance, childInstance)
+ .setParentRequestId(
+ buildingBlockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setChildSvcInstanceId(childSvcInstanceId).setCorrelationId(UUID.randomUUID().toString()).build();
+ buildingBlockExecution.setVariable(CHILD_SVC_REQ_PAYLOAD, sir);
+ }
+
+ public void sendRequest(final BuildingBlockExecution buildingBlockExecution) {
+ try {
+ ServiceInstancesRequest sir = buildingBlockExecution.getVariable(CHILD_SVC_REQ_PAYLOAD);
+ log.info("Sending Delete Service Request: \n{}", sir.toString());
+ buildingBlockExecution.setVariable(CHILD_SVC_REQ_CORRELATION_ID,
+ sir.getRequestDetails().getRequestInfo().getCorrelator());
+ ServiceInstancesResponse response = apiHandlerClient.deleteServiceInstance(sir);
+ buildingBlockExecution.setVariable(CHILD_SVC_REQ_ID, response.getRequestReferences().getRequestId());
+ buildingBlockExecution.setVariable(CHILD_SVC_INSTANCE_ID, response.getRequestReferences().getInstanceId());
+ } catch (Exception e) {
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 10003, e.getMessage(),
+ ONAPComponents.SO);
+ }
+ }
+
+ public void handleFailure(final BuildingBlockExecution buildingBlockExecution) {
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+ String childSvcInstanceName = lookupMap.get(ResourceKey.CHILD_SERVICE_INSTANCE_NAME);
+ String childErrorMessage = buildingBlockExecution.getVariable(CHILD_SVC_REQ_ERROR);
+ String errorMessage =
+ String.format("Failed deleting child service %:qqs %s", childSvcInstanceName, childErrorMessage);
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 10001, errorMessage, ONAPComponents.SO);
+ }
+
+ private static Service serviceInstanceToServiceBeanMapper(ServiceInstance serviceInstance) {
+ Service service = new Service();
+ service.setInstanceName(service.getInstanceName());
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelId(serviceInstance.getModelVersionId());
+ modelInfo.setModelType(ModelType.service);
+ modelInfo.setModelVersionId(serviceInstance.getModelVersionId());
+ modelInfo.setModelInstanceName(serviceInstance.getServiceInstanceName());
+ modelInfo.setModelInvariantId(serviceInstance.getModelInvariantId());
+ service.setModelInfo(modelInfo);
+ return service;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ServiceCompositionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ServiceCompositionConstants.java
new file mode 100644
index 0000000000..6b209bdcef
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ServiceCompositionConstants.java
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (C) 2021 Bell Canada. 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.
+ */
+
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+public class ServiceCompositionConstants {
+
+ public static final String CHILD_SVC_REQ_PAYLOAD = "childServiceRequestPayload";
+ public static final String CHILD_SVC_REQ_ID = "childServiceRequestId";
+ public static final String CHILD_SVC_INSTANCE_ID = "childServiceInstanceId";
+ public static final String IS_CHILD_PROCESS = "isChildProcess";
+ public static final String CHILD_SVC_REQ_CORRELATION_ID = "childServiceRequestCorrelationId";
+ public static final String CHILD_SVC_REQ_TIMEOUT = "childServiceRequestTimeout";
+ public static final String CHILD_SVC_REQ_STATUS = "CHILD_SVC_REQ_STATUS";
+ public static final String CHILD_SVC_REQ_ERROR = "CHILD_SVC_REQ_ERROR";
+ public static final String CHILD_SVC_REQ_MESSAGE_NAME = "ChildServiceRequest";
+ public static final String PARENT_CORRELATION_ID = "parentCorrelationId";
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
index 377d0bbf06..d7f2b85ea0 100755
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
@@ -110,13 +110,22 @@ public class ExecuteBuildingBlockBuilder {
String requestId, String apiVersion, String resourceId, String requestAction, String vnfType,
WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, boolean replaceVnf) {
List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
- if (orchFlow.getFlowName().contains(SERVICE) || (orchFlow.getFlowName().contains(CONTROLLER)
+ if (orchFlow.getFlowName().contains(CHILD_SERVICE)) {
+ if (WorkflowType.SERVICE.equals(resource.getResourceType()) && resource.hasParent()) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.SERVICE, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ }
+ } else if (orchFlow.getFlowName().contains(SERVICE) || (orchFlow.getFlowName().contains(CONTROLLER)
&& (SERVICE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
if (!replaceVnf) {
workflowResourceIds.setServiceInstanceId(resourceId);
}
- addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.SERVICE, orchFlow, requestId,
- apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false, false);
+ if (!resource.hasParent()) {
+ addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.SERVICE, orchFlow, requestId,
+ apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, false,
+ false);
+ }
} else if (orchFlow.getFlowName().contains(VNF)
|| (orchFlow.getFlowName().contains(CONTROLLER) && (VNF).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
addBuildingBlockToExecuteBBList(flowsToExecute, resource, WorkflowType.VNF, orchFlow, requestId, apiVersion,
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
index 57ff837740..3617512d7b 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
@@ -173,4 +173,8 @@ public class Resource implements Serializable {
public List<Resource> getChildren() {
return this.children;
}
+
+ public Boolean hasParent() {
+ return parent != null;
+ }
}
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 ef32ac5cbb..35e11963a3 100755
--- 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
@@ -28,6 +28,8 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
@@ -97,6 +99,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.serviceinstancebeans.InstanceDirection;
@Component
public class WorkflowAction {
@@ -351,6 +354,19 @@ public class WorkflowAction {
log += ", Action: " + block.getBuildingBlock().getBpmnAction();
logger.info(log);
}
+
+ RelatedInstanceList[] instanceList = sIRequest.getRequestDetails().getRelatedInstanceList();
+ execution.setVariable(IS_CHILD_PROCESS, Boolean.FALSE);
+ if (instanceList != null) {
+ for (RelatedInstanceList relatedInstanceList : instanceList) {
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if (InstanceDirection.source.equals(relatedInstance.getInstanceDirection())) {
+ execution.setVariable(IS_CHILD_PROCESS, Boolean.TRUE);
+ execution.setVariable(PARENT_CORRELATION_ID, requestDetails.getRequestInfo().getCorrelator());
+ }
+ }
+ }
+
// By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
&& (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE))
@@ -680,11 +696,11 @@ public class WorkflowAction {
logger.debug("{}, {}", pair.getValue0(), pair.getValue1());
}
Map<Resource, String> resourceInstanceIds = new HashMap<>();
- Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE))
- .forEach(type -> resourceList.stream().filter(resource -> type.equals(resource.getResourceType()))
- .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource,
- retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId,
- resourceInstanceIds)));
+ Arrays.stream(WorkflowType.values()).forEach(type -> resourceList.stream()
+ .filter(resource -> type.equals(resource.getResourceType())
+ && !(WorkflowType.SERVICE.equals(type) && !resource.hasParent()))
+ .forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource,
+ retrieveAAIResourceId(aaiResourceIds, type), null, serviceInstanceId, resourceInstanceIds)));
}
private String retrieveAAIResourceId(List<Pair<WorkflowType, String>> aaiResourceIds, WorkflowType resource) {
@@ -702,8 +718,9 @@ public class WorkflowAction {
private void generateResourceIds(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
String serviceInstanceId) {
Map<Resource, String> resourceInstanceIds = new HashMap<>();
- Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE))
- .forEach(type -> resourceList.stream().filter(resource -> type.equals(resource.getResourceType()))
+ Arrays.stream(WorkflowType.values())
+ .forEach(type -> resourceList.stream()
+ .filter(resource -> resource.hasParent() && type.equals(resource.getResourceType()))
.forEach(resource -> updateWorkflowResourceIds(flowsToExecute, type, resource, null,
resource.getVirtualLinkKey(), serviceInstanceId, resourceInstanceIds)));
}
@@ -731,13 +748,20 @@ public class WorkflowAction {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
Resource parent = resource.getParent();
- if (parent != null && resourceInstanceIds.containsKey(parent)) {
+ if (resource.hasParent() && resourceInstanceIds.containsKey(parent)) {
WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, parent.getResourceType(),
resourceInstanceIds.get(parent));
}
- WorkflowResourceIdsUtils.setInstanceNameByWorkflowType(workflowResourceIds, resourceType,
- resource.getInstanceName());
- WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, resourceType, resourceId);
+ if (resource.hasParent() && WorkflowType.SERVICE.equals(resourceType)
+ && WorkflowType.SERVICE.equals(parent.getResourceType())) {
+ String childServiceInstanceId = resource.isGenerated() ? resourceId : resource.getResourceId();
+ workflowResourceIds.setChildServiceInstanceId(childServiceInstanceId);
+ workflowResourceIds.setChildServiceInstanceName(resource.getInstanceName());
+ } else {
+ WorkflowResourceIdsUtils.setInstanceNameByWorkflowType(workflowResourceIds, resourceType,
+ resource.getInstanceName());
+ WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, resourceType, resourceId);
+ }
ebb.setWorkflowResourceIds(workflowResourceIds);
assignedFlows.add(flowName + action);
}
@@ -753,7 +777,9 @@ public class WorkflowAction {
private boolean isFlowAssignable(Set<String> assignedFlows, ExecuteBuildingBlock ebb, WorkflowType resourceType,
String assignedFlowName) {
- String id = WorkflowResourceIdsUtils.getResourceIdByWorkflowType(ebb.getWorkflowResourceIds(), resourceType);
+ String id = WorkflowType.SERVICE.equals(resourceType)
+ ? StringUtils.defaultString(ebb.getWorkflowResourceIds().getChildServiceInstanceId())
+ : WorkflowResourceIdsUtils.getResourceIdByWorkflowType(ebb.getWorkflowResourceIds(), resourceType);
return !assignedFlows.contains(assignedFlowName) && id.isEmpty();
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
index 8d9e020f67..38fe6a3157 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java
@@ -35,6 +35,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_MESSAGE_NAME;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
@Component
public class WorkflowActionBBFailure {
@@ -44,6 +50,7 @@ public class WorkflowActionBBFailure {
private static final String DELETE_FABRIC_CONFIGURATION_FLOW = "DeleteFabricConfigurationBB";
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class);
public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState";
+
@Autowired
private RequestsDbClient requestDbclient;
@Autowired
@@ -83,6 +90,7 @@ public class WorkflowActionBBFailure {
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
String rollbackErrorMsg = "";
String errorMsg = "";
+ String childErrorMessage = "";
Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete");
Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
@@ -94,6 +102,7 @@ public class WorkflowActionBBFailure {
if (rollbackCompletedSuccessfully) {
rollbackErrorMsg = "Rollback has been completed successfully.";
+ childErrorMessage = rollbackErrorMsg;
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
String rollbackTargetState = (String) execution.getVariable(ROLLBACK_TARGET_STATE);
@@ -116,6 +125,7 @@ public class WorkflowActionBBFailure {
} else {
rollbackErrorMsg = "Failed to determine rollback error message.";
}
+ childErrorMessage = rollbackErrorMsg;
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
request.setRequestStatus(Status.FAILED.toString());
@@ -126,6 +136,7 @@ public class WorkflowActionBBFailure {
} else {
errorMsg = "Failed to determine error message";
}
+ childErrorMessage = errorMsg;
request.setStatusMessage(errorMsg);
execution.setVariable("ErrorMessage", errorMsg);
String handlingCode = (String) execution.getVariable("handlingCode");
@@ -146,6 +157,16 @@ public class WorkflowActionBBFailure {
execution.setVariable("flowStatus", flowStatus);
}
+ if (Boolean.TRUE.equals(execution.getVariable(IS_CHILD_PROCESS))) {
+ String parentCorrelationId = (String) execution.getVariable(PARENT_CORRELATION_ID);
+ logger.info("Child service creation failed. Sending message to parent with correlationId: "
+ + parentCorrelationId);
+ execution.getProcessEngineServices().getRuntimeService()
+ .createMessageCorrelation(CHILD_SVC_REQ_MESSAGE_NAME)
+ .setVariable(CHILD_SVC_REQ_STATUS, "FAILED").setVariable(CHILD_SVC_REQ_ERROR, childErrorMessage)
+ .processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID, parentCorrelationId).correlate();
+ }
+
request.setProgress(Long.valueOf(100));
request.setLastModifiedBy("CamundaBPMN");
request.setEndTime(new Timestamp(System.currentTimeMillis()));
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
index ed41270da9..22d78bb672 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java
@@ -67,6 +67,12 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_MESSAGE_NAME;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
@Component
public class WorkflowActionBBTasks {
@@ -236,6 +242,17 @@ public class WorkflowActionBBTasks {
final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE);
final String resourceName = (String) execution.getVariable("resourceName");
String statusMessage = (String) execution.getVariable("StatusMessage");
+
+ if (Boolean.TRUE.equals(execution.getVariable(IS_CHILD_PROCESS))) {
+ String parentCorrelationId = (String) execution.getVariable(PARENT_CORRELATION_ID);
+ logger.info("Child service request completed. Sending message to parent process with correlationId: "
+ + parentCorrelationId);
+ execution.getProcessEngineServices().getRuntimeService()
+ .createMessageCorrelation(CHILD_SVC_REQ_MESSAGE_NAME)
+ .setVariable(CHILD_SVC_REQ_STATUS, "COMPLETED").setVariable(CHILD_SVC_REQ_ERROR, "")
+ .processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID, parentCorrelationId).correlate();
+ }
+
String macroAction;
if (statusMessage == null) {
if (aLaCarte) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
index 093bab66bf..7ffd066de5 100755
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
@@ -34,6 +34,7 @@ public final class WorkflowActionConstants {
public static final String ACTIVATE_INSTANCE = "activateInstance";
public static final String ASSIGN_INSTANCE = "assignInstance";
+ public static final String CHILD_SERVICE = "ChildService";
public static final String CONFIGURATION = "Configuration";
public static final String CONTROLLER = "Controller";
public static final String CREATE_INSTANCE = "createInstance";
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
index cb4ee014b7..9d76707e5a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
@@ -25,8 +25,12 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
+import org.onap.aai.domain.yang.ComposedResource;
+import org.onap.aai.domain.yang.ComposedResources;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
+import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VpnBinding;
import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
@@ -135,7 +139,7 @@ public class ServiceEBBLoader {
resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams,
serviceInstanceId, requestAction);
}
- if (!foundRelated(resourceList)) {
+ if (!isComposedService(resourceList) && !foundRelated(resourceList)) {
traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
}
} else if ((ACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)
@@ -192,6 +196,10 @@ public class ServiceEBBLoader {
|| containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION));
}
+ public boolean isComposedService(List<Resource> resourceList) {
+ return resourceList.stream().anyMatch(s -> s.getResourceType() == WorkflowType.SERVICE && s.hasParent());
+ }
+
public void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId,
List<Pair<WorkflowType, String>> aaiResourceIds) {
try {
@@ -203,6 +211,7 @@ public class ServiceEBBLoader {
serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId());
serviceResource.setModelVersionId(serviceInstanceAAI.getModelVersionId());
resourceList.add(serviceResource);
+ traverseServiceInstanceChildService(resourceList, serviceResource, serviceInstanceAAI);
traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
if (serviceInstanceMSO.getNetworks() != null) {
@@ -294,6 +303,54 @@ public class ServiceEBBLoader {
}
}
+ public void traverseServiceInstanceChildService(List<Resource> resourceList, Resource serviceResource,
+ ServiceInstance serviceInstanceAAI) {
+
+ ComposedResources composedResources = serviceInstanceAAI.getComposedResources();
+ if (composedResources == null) {
+ return;
+ }
+
+ List<ComposedResource> listOfComposedResource = composedResources.getComposedResource();
+
+ listOfComposedResource.forEach(composedResource -> {
+ // Get ServiceInstance from composedResource relationship List
+ RelationshipList relationshipList = composedResource.getRelationshipList();
+ if (relationshipList == null) {
+ return;
+ }
+ List<Relationship> composedResourceRelationshipList = relationshipList.getRelationship();
+ ServiceInstance childService = new ServiceInstance();
+ composedResourceRelationshipList.forEach(composedRelation -> {
+ if ("service-instance".equalsIgnoreCase(composedRelation.getRelatedTo())) {
+ List<RelationshipData> rData = composedRelation.getRelationshipData();
+ rData.forEach(data -> {
+ if ("service-instance.service-instance-id".equalsIgnoreCase(data.getRelationshipKey())) {
+ childService.setServiceInstanceId(data.getRelationshipValue());
+ }
+ });
+ composedRelation.getRelatedToProperty().forEach(relatedToProperty -> {
+ if ("service-instance.service-instance-name"
+ .equalsIgnoreCase(relatedToProperty.getPropertyKey())) {
+ childService.setServiceInstanceName(relatedToProperty.getPropertyValue());
+ }
+ });
+ }
+ });
+
+ if (childService.getServiceInstanceId() == null) {
+ return;
+ }
+
+ Resource childServiceResource =
+ new Resource(WorkflowType.SERVICE, childService.getServiceInstanceId(), false, serviceResource);
+
+ childServiceResource.setInstanceName(childService.getServiceInstanceName());
+ resourceList.add(childServiceResource);
+ });
+
+ }
+
protected void traverseVrfConfiguration(List<Pair<WorkflowType, String>> aaiResourceIds,
List<Resource> resourceList, Resource serviceResource, org.onap.so.db.catalog.beans.Service service,
RelatedInstance relatedVpnBinding, RelatedInstance relatedLocalNetwork)
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
index 77cd65b946..b56bd905a6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
@@ -100,6 +100,9 @@ public class UserParamsServiceTraversal {
serviceResource.setModelInvariantId(modelInfo.getModelInvariantUuid());
}
resourceList.add(serviceResource);
+ if (validate.getResources().getServices() != null) {
+ setResourceListForChildServices(execution, resourceList, serviceResource, validate);
+ }
if (validate.getResources().getVnfs() != null) {
setResourceListForVnfs(execution, resourceList, serviceResource, validate);
}
@@ -113,6 +116,17 @@ public class UserParamsServiceTraversal {
return resourceList;
}
+ private void setResourceListForChildServices(DelegateExecution execution, List<Resource> resourceList,
+ Resource serviceResource, Service validate) {
+ for (Service childService : validate.getResources().getServices()) {
+ Resource childServiceResource = new Resource(WorkflowType.SERVICE,
+ childService.getModelInfo().getModelVersionId(), false, serviceResource);
+ childServiceResource.setProcessingPriority(childService.getProcessingPriority());
+ childServiceResource.setInstanceName(childService.getInstanceName());
+ resourceList.add(childServiceResource);
+ }
+ }
+
private void setResourceListForVnfs(DelegateExecution execution, List<Resource> resourceList,
Resource serviceResource, Service validate) {
for (Vnfs vnf : validate.getResources().getVnfs()) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java
new file mode 100644
index 0000000000..132e618ba5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClient.java
@@ -0,0 +1,73 @@
+package org.onap.so.client.orchestration;
+
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+import static org.onap.so.client.orchestration.RestTemplateApiClientConfig.REST_TEMPLATE_API_HANDLER;
+
+@Component
+public class ApiHandlerClient {
+
+ @Value("${mso.adapters.apihandler.serviceInstantiationEndpoint:/onap/so/infra/serviceInstantiation/v7/serviceInstances}")
+ private String serviceInstantiationEndpoint;
+ @Value("${mso.adapters.apihandler.endpoint}")
+ private String baseUri;
+ @Value("${mso.adapters.apihandler.auth}")
+ private String auth;
+
+ private RestTemplate restTemplate;
+
+ public ApiHandlerClient(@Qualifier(REST_TEMPLATE_API_HANDLER) RestTemplate restTemplate) {
+ this.restTemplate = restTemplate;
+ }
+
+ public ServiceInstancesResponse createServiceInstance(ServiceInstancesRequest serviceInstancesRequest)
+ throws ApiHandlerClientException {
+ try {
+ HttpEntity<ServiceInstancesRequest> request = createRequest(serviceInstancesRequest);
+ return restTemplate.exchange(baseUri + serviceInstantiationEndpoint, HttpMethod.POST, request,
+ ServiceInstancesResponse.class).getBody();
+ } catch (HttpStatusCodeException e) {
+ throw new ApiHandlerClientException("Failed sending service createInstance request to api-handler."
+ + " Error: " + e.getResponseBodyAsString());
+ } catch (RestClientException e) {
+ throw new ApiHandlerClientException(
+ "Failed sending service createInstance request to api-handler." + " Error: " + e.getMessage());
+ }
+ }
+
+ public ServiceInstancesResponse deleteServiceInstance(ServiceInstancesRequest serviceInstancesRequest)
+ throws ApiHandlerClientException {
+ try {
+ HttpEntity<ServiceInstancesRequest> request = createRequest(serviceInstancesRequest);
+ return restTemplate.exchange(
+ baseUri + serviceInstantiationEndpoint
+ + String.format("/%s", serviceInstancesRequest.getServiceInstanceId()),
+ HttpMethod.DELETE, request, ServiceInstancesResponse.class).getBody();
+ } catch (HttpStatusCodeException e) {
+ throw new ApiHandlerClientException("Failed sending service deleteInstance request to api-handler."
+ + " Error: " + e.getResponseBodyAsString());
+ } catch (RestClientException e) {
+ throw new ApiHandlerClientException(
+ "Failed sending service deleteInstance request to api-handler." + " Error: " + e.getMessage());
+ }
+ }
+
+ private HttpEntity<ServiceInstancesRequest> createRequest(ServiceInstancesRequest serviceInstancesRequest) {
+ HttpHeaders headers = new HttpHeaders();
+ headers.add(HttpHeaders.AUTHORIZATION, auth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
+ headers.set(HttpHeaders.ACCEPT, String.valueOf(MediaType.APPLICATION_JSON));
+
+ return new HttpEntity<>(serviceInstancesRequest, headers);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClientException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClientException.java
new file mode 100644
index 0000000000..0a4c60cdf7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/ApiHandlerClientException.java
@@ -0,0 +1,8 @@
+package org.onap.so.client.orchestration;
+
+public class ApiHandlerClientException extends Exception {
+
+ public ApiHandlerClientException(String errorMessage) {
+ super(errorMessage);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/RestTemplateApiClientConfig.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/RestTemplateApiClientConfig.java
new file mode 100644
index 0000000000..a01fbe18f8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/RestTemplateApiClientConfig.java
@@ -0,0 +1,23 @@
+package org.onap.so.client.orchestration;
+
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class RestTemplateApiClientConfig {
+ public static final String REST_TEMPLATE_API_HANDLER = "restTemplateApiHandler";
+
+ @Bean(REST_TEMPLATE_API_HANDLER)
+ public RestTemplate restTemplate() {
+ final RestTemplate restTemplate = new RestTemplate();
+ restTemplate
+ .setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
+ return restTemplate;
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java
new file mode 100644
index 0000000000..e57232ebb7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java
@@ -0,0 +1,253 @@
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.InstanceDirection;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.SubscriberInfo;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+public class ChildServiceRequestBuilderTest {
+
+ private BuildingBlockExecution mockExecution;
+ private List<Map<String, Object>> userParamsExpected;
+
+ @Before
+ public void setUp() throws IOException {
+ String incomingRequest =
+ "{\"requestDetails\":{\"subscriberInfo\":{\"globalSubscriberId\":\"ubuntu-customer\"},\"requestInfo\":{\"suppressRollback\":false,\"instanceName\":\"LcmDemo\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"requestorId\":\"portal\",\"source\":\"postman\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"requestParameters\":{\"subscriptionServiceType\":\"ubuntu\",\"userParams\":[{\"Homing_Solution\":\"none\"},{\"service\":{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}],\"services\":[{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service1-instanceName\"},{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service2-instanceName\"}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-UbuntuDemo\"},\"owningEntity\":{\"owningEntityId\":\"33a8b609-1cfe-4d19-8dc2-5b95b921de1e\",\"owningEntityName\":\"demo\"},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ userParamsExpected = request.getRequestDetails().getRequestParameters().getUserParams();
+ RequestContext context = new RequestContext();
+ RequestParameters parameters = new RequestParameters();
+ parameters.setUserParams(request.getRequestDetails().getRequestParameters().getUserParams());
+ context.setRequestParameters(parameters);
+ context.setProductFamilyId("FamilyId");
+ context.setSource("source");
+ context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ cloudRegion.setTenantId("tenant-id");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("GlobalCustomerId");
+ customer.setSubscriberName("SubscriberName");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("owningEntityId");
+ owningEntity.setOwningEntityName("owningEntityName");
+ serviceInstance.setOwningEntity(owningEntity);
+
+ Project project = new Project();
+ project.setProjectName("projectName");
+ serviceInstance.setProject(project);
+
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setCustomer(customer);
+ gbb.setRequestContext(context);
+ gbb.setServiceInstance(serviceInstance);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ doReturn("CreateChildServiceBB").when(mockExecution).getFlowToBeCalled();
+ }
+
+ @Test
+ public void deleteChildServiceRequestBuilderTest() {
+ Service parent = new Service();
+ Service child = new Service();
+
+ ChildServiceRequestBuilder builder = ChildServiceRequestBuilder.getInstance(mockExecution, parent, child);
+ ServiceInstancesRequest sir = builder
+ .setParentRequestId(mockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).setChildSvcInstanceId("childInstanceId").build();
+
+ Assert.assertEquals("childInstanceId", sir.getServiceInstanceId());
+ Assert.assertEquals("serviceInstanceId",
+ sir.getRequestDetails().getRelatedInstanceList()[0].getRelatedInstance().getInstanceId());
+ }
+
+ @Test
+ public void createChildServiceRequestBuilderTest() {
+
+ ServiceInstancesRequest sir = ChildServiceRequestBuilder.getInstance(mockExecution, "service1-instanceName")
+ .setParentRequestId(mockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).setChildSvcInstanceId("childInstanceId").build();
+
+ Assert.assertEquals("childInstanceId", sir.getServiceInstanceId());
+
+ // modelInfo
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", modelInfo.getModelInvariantId());
+ Assert.assertEquals(ModelType.service, modelInfo.getModelType());
+ Assert.assertEquals("GuilinLcmSVC", modelInfo.getModelName());
+ Assert.assertEquals("2.0", modelInfo.getModelVersion());
+ Assert.assertEquals("cs1-svc-modelCustomizationId", modelInfo.getModelCustomizationId());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", modelInfo.getModelVersionId());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", modelInfo.getModelUuid());
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", modelInfo.getModelInvariantUuid());
+
+ // requestInfo
+ RequestInfo requestInfo = sir.getRequestDetails().getRequestInfo();
+ Assert.assertNotNull(requestInfo.getCorrelator());
+ Assert.assertEquals("FamilyId", requestInfo.getProductFamilyId());
+ Assert.assertEquals("source", requestInfo.getSource());
+ Assert.assertEquals("service1-instanceName", requestInfo.getInstanceName());
+ Assert.assertEquals(false, requestInfo.getSuppressRollback());
+ Assert.assertEquals("RequestOrId", requestInfo.getRequestorId());
+
+ RelatedInstanceList[] relatedInstanceList = sir.getRequestDetails().getRelatedInstanceList();
+ Assert.assertEquals(1, relatedInstanceList.length);
+ RelatedInstance relatedInstance = relatedInstanceList[0].getRelatedInstance();
+ Assert.assertEquals("serviceInstanceId", relatedInstance.getInstanceId());
+ Assert.assertEquals(InstanceDirection.source, relatedInstance.getInstanceDirection());
+
+ ModelInfo parentModel = relatedInstance.getModelInfo();
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", parentModel.getModelInvariantId());
+ Assert.assertEquals(ModelType.service, parentModel.getModelType());
+ Assert.assertEquals("GuilinLcmSVC", parentModel.getModelName());
+ Assert.assertEquals("2.0", parentModel.getModelVersion());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", parentModel.getModelVersionId());
+ Assert.assertEquals("5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52", parentModel.getModelUuid());
+ Assert.assertEquals("a316f8fa-c886-483f-801b-6663e35b836c", parentModel.getModelInvariantUuid());
+
+ SubscriberInfo subsciberInfo = sir.getRequestDetails().getSubscriberInfo();
+ Assert.assertEquals("GlobalCustomerId", subsciberInfo.getGlobalSubscriberId());
+ Assert.assertEquals("SubscriberName", subsciberInfo.getSubscriberName());
+
+ CloudConfiguration cloudConfiguration = sir.getRequestDetails().getCloudConfiguration();
+ Assert.assertEquals("tenant-id", cloudConfiguration.getTenantId());
+ Assert.assertEquals("CloudOwner", cloudConfiguration.getCloudOwner());
+ Assert.assertEquals("my-region-id", cloudConfiguration.getLcpCloudRegionId());
+
+ org.onap.so.serviceinstancebeans.RequestParameters requestParameters =
+ sir.getRequestDetails().getRequestParameters();
+ Assert.assertEquals(2, requestParameters.getUserParams().size());
+ Assert.assertEquals(userParamsExpected.get(0), requestParameters.getUserParams().get(0));
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ try {
+ String expectedChildService =
+ mapper.writeValueAsString(getChildService(userParamsExpected, "service1-instanceName"));
+ String actualChildService =
+ mapper.writeValueAsString(requestParameters.getUserParams().get(1).get("service"));
+ Assert.assertEquals(expectedChildService, actualChildService);
+ } catch (Exception e) {
+ Assert.fail();
+ }
+
+ org.onap.so.serviceinstancebeans.Project project = sir.getRequestDetails().getProject();
+ Assert.assertEquals("projectName", project.getProjectName());
+
+ org.onap.so.serviceinstancebeans.OwningEntity owningEntity = sir.getRequestDetails().getOwningEntity();
+ Assert.assertEquals("owningEntityId", owningEntity.getOwningEntityId());
+ Assert.assertEquals("owningEntityName", owningEntity.getOwningEntityName());
+ }
+
+ @Test
+ public void childServiceCloudConfigurationRequestBuilderTest() throws IOException {
+ String incomingRequest =
+ "{\"requestDetails\":{\"subscriberInfo\":{\"globalSubscriberId\":\"ubuntu-customer\"},\"requestInfo\":{\"suppressRollback\":false,\"instanceName\":\"onap-test-parent-child-service\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"requestorId\":\"portal\",\"source\":\"postman\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"215\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"iaas\"},\"requestParameters\":{\"subscriptionServiceType\":\"ubuntu\",\"userParams\":[{\"Homing_Solution\":\"none\"},{\"service\":{\"instanceParams\":[],\"resources\":{\"services\":[{\"instanceParams\":[],\"resources\":{},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service1-instanceName-child\",\"cloudConfiguration\":{\"lcpCloudRegionId\":\"test\",\"tenantId\":\"1234567890\",\"cloudOwner\":\"demo\"}},{\"instanceParams\":[],\"resources\":{},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service2-instanceName-child\"}]},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-UbuntuDemo\"},\"owningEntity\":{\"owningEntityId\":\"33a8b609-1cfe-4d19-8dc2-5b95b921de1e\",\"owningEntityName\":\"seb\"},\"modelInfo\":{\"modelVersion\":\"3.0\",\"modelVersionId\":\"872efe6d-c787-4caf-b6f8-3234a7bfc5cf\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+
+ RequestContext context = new RequestContext();
+ RequestParameters parameters = new RequestParameters();
+ parameters.setUserParams(request.getRequestDetails().getRequestParameters().getUserParams());
+ context.setRequestParameters(parameters);
+ context.setProductFamilyId("FamilyId");
+ context.setSource("source");
+ context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ cloudRegion.setTenantId("tenant-id");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("owningEntityId");
+ owningEntity.setOwningEntityName("owningEntityName");
+ serviceInstance.setOwningEntity(owningEntity);
+
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setRequestContext(context);
+ gbb.setServiceInstance(serviceInstance);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ doReturn("CreateChildServiceBB").when(mockExecution).getFlowToBeCalled();
+
+ ServiceInstancesRequest sir = ChildServiceRequestBuilder
+ .getInstance(mockExecution, "service1-instanceName-child")
+ .setParentRequestId(mockExecution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId())
+ .setCorrelationId(UUID.randomUUID().toString()).setChildSvcInstanceId("childInstanceId").build();
+
+ Assert.assertEquals("childInstanceId", sir.getServiceInstanceId());
+
+ CloudConfiguration cloudConfiguration = sir.getRequestDetails().getCloudConfiguration();
+ Assert.assertEquals("1234567890", cloudConfiguration.getTenantId());
+ Assert.assertEquals("demo", cloudConfiguration.getCloudOwner());
+ Assert.assertEquals("test", cloudConfiguration.getLcpCloudRegionId());
+ }
+
+ private Service getChildService(List<Map<String, Object>> userParams, String serviceInstanceName)
+ throws IOException {
+ String USERPARAMSERVICE = "service";
+ for (Map<String, Object> params : userParams) {
+ if (params.containsKey(USERPARAMSERVICE)) {
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get(USERPARAMSERVICE));
+ Service validate = obj.readValue(input, Service.class);
+ if (validate.getResources().getServices() != null) {
+ for (Service service : validate.getResources().getServices()) {
+ if (serviceInstanceName.equals(service.getInstanceName())) {
+ return service;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java
new file mode 100644
index 0000000000..6392d25998
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBBTest.java
@@ -0,0 +1,145 @@
+package org.onap.so.bpmn.infrastructure.service.composition;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.logging.filter.base.ONAPComponentsList;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.MockControllerBB;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.ApiHandlerClient;
+import org.onap.so.client.orchestration.ApiHandlerClientException;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_INSTANCE_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_PAYLOAD;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {CreateChildServiceBB.class, MockControllerBB.class, ExceptionBuilder.class})
+public class CreateChildServiceBBTest {
+
+ @Autowired
+ private CreateChildServiceBB createChildServiceBB;
+
+ @MockBean
+ private BuildingBlockExecution execution;
+
+ @MockBean
+ private ApiHandlerClient apiHandlerClient;
+
+ @MockBean
+ private ExceptionBuilder exceptionBuilder;
+
+ @Before
+ public void setUp() throws IOException, ApiHandlerClientException {
+ String incomingRequest =
+ "{\"requestDetails\":{\"subscriberInfo\":{\"globalSubscriberId\":\"ubuntu-customer\"},\"requestInfo\":{\"suppressRollback\":false,\"instanceName\":\"LcmDemo\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"requestorId\":\"portal\",\"source\":\"postman\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"requestParameters\":{\"subscriptionServiceType\":\"ubuntu\",\"userParams\":[{\"Homing_Solution\":\"none\"},{\"service\":{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}],\"services\":[{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service1-instanceName\"},{\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelName\":\"UbuntuSriovVF\",\"modelVersionId\":\"5b5d07f0-7449-4eec-95eb-531ddef18240\",\"modelInvariantUuid\":\"9ed17b82-11f3-44cc-a86f-32739360617e\",\"modelVersion\":\"1.0\",\"modelCustomizationId\":\"ae139d3d-b2ae-462c-b09d-c85bdc2e3073\",\"modelInstanceName\":\"UbuntuSriovVF0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"123\",\"tenantId\":\"e2710e84063b421fab08189818761d55\",\"cloudOwner\":\"cloudOwner\"},\"platform\":{\"platformName\":\"openstack\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"wireless\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceName\":\"vnf-instanceName\",\"instanceParams\":[{\"vnf-name\":\"vnf-vnf-name\",\"vnf_name\":\"UbuntuVNFName\"}],\"vfModules\":[{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..base..module-0\",\"modelVersionId\":\"f4ef24dd-7a4e-4eef-83b7-c58f2f3e36e4\",\"modelInvariantUuid\":\"719aab1e-c551-46e0-87e8-a78dcd7891da\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"dea421a8-c1b8-4044-8ca1-58c30de3b315\"},\"instanceName\":\"lcm-demo-network-1\",\"instanceParams\":[{\"name\":\"lcm-demo-network-1\",\"cidr\":\"10.10.10.0/24\"}]},{\"modelInfo\":{\"modelName\":\"Ubuntusriovvf..ubuntu-vf-module..module-1\",\"modelVersionId\":\"112f2de4-4f09-4567-9de1-2d271cb6e164\",\"modelInvariantUuid\":\"ba6d2e11-4e82-4bb8-9d52-a2962a263a09\",\"modelVersion\":\"1\",\"modelCustomizationId\":\"7bc2649e-b96b-44ec-adfe-4a6167f3034e\"},\"instanceName\":\"lcm-demo-ubuntu-1\",\"instanceParams\":[{\"name\":\"lcm-demo-ubuntu-1\",\"network_mgmt\":\"networkMgmt\",\"key_name\":\"demo\",\"network_name\":\"lcm-demo-network-1\",\"image_name\":\"imageName\",\"flavor_name\":\"m1.small\"}]}]}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelCustomizationId\":\"cs1-svc-modelCustomizationId\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"},\"instanceName\":\"service2-instanceName\"}]},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-UbuntuDemo\"},\"owningEntity\":{\"owningEntityId\":\"33a8b609-1cfe-4d19-8dc2-5b95b921de1e\",\"owningEntityName\":\"demo\"},\"modelInfo\":{\"modelVersion\":\"2.0\",\"modelVersionId\":\"5bc2b6b3-c9bb-49a1-89c8-4dac5b236d52\",\"modelInvariantId\":\"a316f8fa-c886-483f-801b-6663e35b836c\",\"modelName\":\"GuilinLcmSVC\",\"modelType\":\"service\"}}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ ServiceInstancesRequest request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ RequestContext context = new RequestContext();
+ RequestParameters parameters = new RequestParameters();
+ parameters.setUserParams(request.getRequestDetails().getRequestParameters().getUserParams());
+ context.setRequestParameters(parameters);
+ context.setProductFamilyId("FamilyId");
+ context.setSource("source");
+ context.setRequestorId("RequestOrId");
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ cloudRegion.setTenantId("tenant-id");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("GlobalCustomerId");
+ customer.setSubscriberName("SubscriberName");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("owningEntityId");
+ owningEntity.setOwningEntityName("owningEntityName");
+ serviceInstance.setOwningEntity(owningEntity);
+
+ Project project = new Project();
+ project.setProjectName("projectName");
+ serviceInstance.setProject(project);
+
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setCustomer(customer);
+ gbb.setRequestContext(context);
+ gbb.setServiceInstance(serviceInstance);
+
+ Map<ResourceKey, String> map = new HashMap<>();
+ map.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, "service1-instanceName");
+
+ when(execution.getGeneralBuildingBlock()).thenReturn(gbb);
+ when(execution.getLookupMap()).thenReturn(map);
+
+ ServiceInstancesResponse response = new ServiceInstancesResponse();
+ response.setRequestReferences(new RequestReferences());
+ response.getRequestReferences().setInstanceId("instanceId");
+ response.getRequestReferences().setRequestId("requestId");
+
+ when(apiHandlerClient.createServiceInstance(any())).thenReturn(response);
+ }
+
+ @Test
+ public void buildRequestTest() {
+ createChildServiceBB.buildRequest(execution);
+ }
+
+ @Test
+ public void sendRequestTest() throws Exception {
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails details = new RequestDetails();
+ details.setRequestInfo(new RequestInfo());
+ details.getRequestInfo().setCorrelator("correlator");
+ sir.setRequestDetails(details);
+
+ when(execution.getVariable(CHILD_SVC_REQ_PAYLOAD)).thenReturn(sir);
+ createChildServiceBB.sendRequest(execution);
+ verify(execution).setVariable(CHILD_SVC_REQ_ID, "requestId");
+ verify(execution).setVariable(CHILD_SVC_INSTANCE_ID, "instanceId");
+ verify(execution).setVariable(CHILD_SVC_REQ_CORRELATION_ID, "correlator");
+ }
+
+ @Test
+ public void handleFailureTest() {
+ createChildServiceBB.handleFailure(execution);
+ verify(exceptionBuilder).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), anyInt(),
+ anyString(), any(ONAPComponentsList.class));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index 7f44c97f59..aeef976fb4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -26,9 +26,19 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
import java.sql.Timestamp;
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Rule;
@@ -271,4 +281,125 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN");
Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class));
}
+
+ @Test
+ public void invokeSendMessageForChildServiceRollBackCompletedSuccessfully() {
+ String parentCorrelationId = "parentCorrelationId";
+ DelegateExecution mockExecution = Mockito.mock(DelegateExecution.class);
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ MessageCorrelationBuilder messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ when(runtimeService.createMessageCorrelation(anyString())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_STATUS, "FAILED"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_ERROR, "Rollback has been completed successfully."))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID, parentCorrelationId))
+ .thenReturn(messageCorrelationBuilder);
+
+ when(mockExecution.getVariable(PARENT_CORRELATION_ID)).thenReturn(parentCorrelationId);
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123");
+ when(mockExecution.getVariable("isRollbackComplete")).thenReturn(true);
+ when(mockExecution.getVariable("isRollback")).thenReturn(true);
+ when(mockExecution.getVariable(IS_CHILD_PROCESS)).thenReturn(true);
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(wfe);
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "Rollback has been completed successfully.");
+ verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
+ parentCorrelationId);
+ }
+
+ @Test
+ public void invokeSendMessageForChildServiceRollBackFailure() {
+ String parentCorrelationId = "parentCorrelationId";
+ DelegateExecution mockExecution = Mockito.mock(DelegateExecution.class);
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ MessageCorrelationBuilder messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ when(runtimeService.createMessageCorrelation(anyString())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_STATUS, "FAILED"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_ERROR, "error in rollback"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceVariableEquals(PARENT_CORRELATION_ID, parentCorrelationId))
+ .thenReturn(messageCorrelationBuilder);
+
+ when(mockExecution.getVariable(PARENT_CORRELATION_ID)).thenReturn(parentCorrelationId);
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123");
+ when(mockExecution.getVariable("isRollbackComplete")).thenReturn(false);
+ when(mockExecution.getVariable("isRollback")).thenReturn(true);
+ when(mockExecution.getVariable(IS_CHILD_PROCESS)).thenReturn(true);
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR,
+ "Failed to determine rollback error message.");
+
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(wfe);
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "error in rollback");
+ verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
+ parentCorrelationId);
+ }
+
+ @Test
+ public void invokeSendMessageForChildServiceNoRollBack() {
+ String parentCorrelationId = "parentCorrelationId";
+ DelegateExecution mockExecution = Mockito.mock(DelegateExecution.class);
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ MessageCorrelationBuilder messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ when(runtimeService.createMessageCorrelation(anyString())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_STATUS, "FAILED"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.setVariable(CHILD_SVC_REQ_ERROR, "error in rollback"))
+ .thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceVariableEquals(PARENT_CORRELATION_ID, parentCorrelationId))
+ .thenReturn(messageCorrelationBuilder);
+
+ when(mockExecution.getVariable(PARENT_CORRELATION_ID)).thenReturn(parentCorrelationId);
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("123");
+ when(mockExecution.getVariable("isRollbackComplete")).thenReturn(false);
+ when(mockExecution.getVariable("isRollback")).thenReturn(false);
+ when(mockExecution.getVariable(IS_CHILD_PROCESS)).thenReturn(true);
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+
+ InfraActiveRequests req = new InfraActiveRequests();
+ doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123");
+ doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class));
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "Failed to determine error message");
+
+ WorkflowException wfe = new WorkflowException("processKey123", 1, "error in rollback");
+ when(mockExecution.getVariable("WorkflowException")).thenReturn(wfe);
+ workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "error in rollback");
+ verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
+ parentCorrelationId);
+ }
+
+
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
index 76763e8ca8..2d41a24ac3 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
@@ -32,7 +32,11 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
+import org.onap.aai.domain.yang.ComposedResource;
+import org.onap.aai.domain.yang.ComposedResources;
+import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aaiclient.client.aai.entities.Relationships;
@@ -368,4 +372,56 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false, r2));
return resourceList;
}
+
+ @Test
+ public void traverseServiceInstanceChildServiceTest() {
+ List<Resource> resourceList = new ArrayList<>();
+ Resource parentResource = new Resource(WorkflowType.SERVICE, "parentId", false, null);
+ String resourceId = "siP";
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId(resourceId);
+
+ RelationshipData relationshipData = new RelationshipData();
+ relationshipData.setRelationshipKey("service-instance.service-instance-id");
+ relationshipData.setRelationshipValue("80ced9d5-666e-406b-88f0-a05d31328b70");
+ RelatedToProperty relatedToProperty = new RelatedToProperty();
+ relatedToProperty.setPropertyKey("service-instance.service-instance-name");
+ relatedToProperty.setPropertyValue("child_euler_002");
+
+ RelationshipData relationshipData1 = new RelationshipData();
+ relationshipData1.setRelationshipKey("service-instance.service-instance-id");
+ relationshipData1.setRelationshipValue("fa5640af-c827-4372-baae-7f1c50fdb5ed");
+ RelatedToProperty relatedToProperty1 = new RelatedToProperty();
+ relatedToProperty1.setPropertyKey("service-instance.service-instance-name");
+ relatedToProperty.setPropertyValue("child_euler_001");
+
+
+ Relationship relationship = new Relationship();
+ Relationship relationship1 = new Relationship();
+ relationship.setRelatedTo("service-instance");
+ relationship1.setRelatedTo("service-instance");
+ relationship.getRelationshipData().add(relationshipData);
+ relationship.getRelatedToProperty().add(relatedToProperty);
+ relationship1.getRelationshipData().add(relationshipData1);
+ relationship1.getRelatedToProperty().add(relatedToProperty1);
+
+ RelationshipList relationshipList = new RelationshipList();
+ RelationshipList relationshipList1 = new RelationshipList();
+ relationshipList.getRelationship().add(relationship);
+ relationshipList1.getRelationship().add(relationship1);
+
+ ComposedResource composedResource = new ComposedResource();
+ composedResource.setRelationshipList(relationshipList);
+ ComposedResource composedResource1 = new ComposedResource();
+ composedResource1.setRelationshipList(relationshipList);
+
+ ComposedResources composedResources = new ComposedResources();
+ composedResources.getComposedResource().add(composedResource);
+ composedResources.getComposedResource().add(composedResource1);
+
+ serviceInstanceAAI.setComposedResources(composedResources);
+
+ serviceEBBLoader.traverseServiceInstanceChildService(resourceList, parentResource, serviceInstanceAAI);
+ assertEquals(2, resourceList.size());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java
new file mode 100644
index 0000000000..f3a04e6f54
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/ApiHandlerClientTest.java
@@ -0,0 +1,121 @@
+package org.onap.so.client.orchestration;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.RestTemplate;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.instanceOf;
+
+
+@TestPropertySource(properties = {"mso.adapters.apihandler.endpoint=http://localhost:",
+ "mso.adapters.apihandler.auth=Basic dGVzdDp0ZXN0Cg=="})
+@RunWith(SpringJUnit4ClassRunner.class)
+public class ApiHandlerClientTest {
+
+ @InjectMocks
+ private ApiHandlerClient client;
+
+ @Mock
+ protected RestTemplate restTemplate;
+
+ private ServiceInstancesRequest buildRequest(String incomingRequest) {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ ServiceInstancesRequest request = null;
+ try {
+ request = mapper.readValue(incomingRequest, ServiceInstancesRequest.class);
+ System.out.println("Java Object: " + request);
+ } catch (Exception e) {
+ System.out.println("Caught Exception " + e.getMessage());
+ Assert.fail("Could not build ServiceInstancesRequest object");
+ }
+ return request;
+ }
+
+ @Test
+ public void createServiceInstanceTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ ResponseEntity<ServiceInstancesResponse> responseEntity =
+ new ResponseEntity<ServiceInstancesResponse>(new ServiceInstancesResponse(), HttpStatus.ACCEPTED);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenReturn(responseEntity);
+
+ try {
+ ServiceInstancesResponse response = client.createServiceInstance(request);
+ assertThat(response, instanceOf(ServiceInstancesResponse.class));
+ } catch (ApiHandlerClientException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void createServiceInstanceErrorTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
+ try {
+ client.createServiceInstance(request);
+ Assert.fail("ApiHandlerClientException exception was not thrown");
+ } catch (ApiHandlerClientException e) {
+ assertEquals("Failed sending service createInstance request to api-handler. Error: ", e.getMessage());
+ }
+ }
+
+ @Test
+ public void deleteServiceInstanceTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ ResponseEntity<ServiceInstancesResponse> responseEntity =
+ new ResponseEntity<ServiceInstancesResponse>(new ServiceInstancesResponse(), HttpStatus.ACCEPTED);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenReturn(responseEntity);
+
+ try {
+ ServiceInstancesResponse response = client.deleteServiceInstance(request);
+ assertThat(response, instanceOf(ServiceInstancesResponse.class));
+ } catch (ApiHandlerClientException e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void deleteServiceInstanceErrorTest() {
+ String incomingRequest =
+ "{\"requestDetails\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"owningEntity\":{\"owningEntityId\":\"038d99af-0427-42c2-9d15-971b99b9b489\",\"owningEntityName\":\"PACKETCORE\"},\"project\":{\"projectName\":\"{someprojectname}\"},\"subscriberInfo\":{\"globalSubscriberId\":\"{somesubscriberid}\"},\"requestInfo\":{\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"source\":\"VID\",\"suppressRollback\":true,\"requestorId\":\"xxxxxx\"},\"requestParameters\":{\"subscriptionServiceType\":\"VMX\",\"aLaCarte\":false,\"userParams\":[{\"service\":{\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantId\":\"5d48acb5-097d-4982-aeb2-f4a3bd87d31b\",\"modelVersionId\":\"3c40d244-808e-42ca-b09a-256d83d19d0a\",\"modelName\":\"MOWvMXBV1Service\",\"modelVersion\":\"10.0\"},\"instanceParams\":[],\"resources\":{\"vnfs\":[{\"modelInfo\":{\"modelType\":\"vnf\",\"modelName\":\"2016-73_MOW\",\"modelVersionId\":\"7f40c192-f63c-463e-ba94-286933b895f8\",\"modelCustomizationName\":\"2016-73_MOW\",\"modelCustomizationId\":\"ab153b6e-c364-44c0-bef6-1f2982117f04\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"88a6ca3ee0394ade9403f075db23167e\"},\"platform\":{\"platformName\":\"test\"},\"lineOfBusiness\":{\"lineOfBusinessName\":\"someValue\"},\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"instanceParams\":[],\"vfModules\":[{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"201673MowtestBvL\",\"modelVersionId\":\"4c75f813-fa91-45a4-89d0-790ff5f1ae79\",\"modelCustomizationId\":\"a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f\"},\"instanceName\":\"vfModule1\",\"instanceParams\":[{\"vmx_int_net_len\":\"24\"}]}]}]}}}]}}}";
+ ServiceInstancesRequest request = buildRequest(incomingRequest);
+ Mockito.when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.any(), ArgumentMatchers.<Class<ServiceInstancesResponse>>any()))
+ .thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));
+ try {
+ client.deleteServiceInstance(request);
+ Assert.fail("ApiHandlerClientException exception was not thrown");
+ } catch (ApiHandlerClientException e) {
+ assertEquals("Failed sending service deleteInstance request to api-handler. Error: ", e.getMessage());
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index b64fc3318b..d3f5696c16 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -84,7 +84,9 @@ mso:
workflow:
message:
endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50