summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql34
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteChildServiceBB.bpmn98
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilder.java43
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/DeleteChildServiceBB.java95
-rwxr-xr-xbpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java53
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/service/composition/ChildServiceRequestBuilderTest.java23
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java56
8 files changed, 326 insertions, 89 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index 6b552b3fdd..9b21dcd2d2 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -91,21 +91,22 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, SC
('Service-Macro-Create', '21', 'ActivateVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Create', '22', 'ActivateNetworkCollectionBB', NULL, NULL,1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Create', '23', 'ActivateServiceInstanceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '1', 'DeactivateVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '2', 'DeleteVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '4', 'DeleteVolumeGroupBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '5', 'DeactivateVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '6', 'DeactivatePnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '7', 'DeactivateNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '8', 'DeleteNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '9', 'DeleteNetworkCollectionBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '10', 'DeactivateServiceInstanceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '11', 'UnassignVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '12', 'UnassignVolumeGroupBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '13', 'UnassignVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '14', 'UnassignNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Delete', '15', 'UnassignServiceInstanceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '1', 'DeleteChildServiceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '2', 'DeactivateVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '3', 'DeleteVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '4', 'DeactivateVolumeGroupBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '5', 'DeleteVolumeGroupBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '6', 'DeactivateVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '7', 'DeactivatePnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '8', 'DeactivateNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '9', 'DeleteNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '10', 'DeleteNetworkCollectionBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '11', 'DeactivateServiceInstanceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '12', 'UnassignVfModuleBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '13', 'UnassignVolumeGroupBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '14', 'UnassignVnfBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '15', 'UnassignNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Delete', '16', 'UnassignServiceInstanceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
('Service-Macro-Upgrade', '1', 'ChangeModelServiceInstanceBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Upgrade' and CLOUD_OWNER = 'DEFAULT')),
('Network-Create', '1', 'AssignNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')),
('Network-Create', '2', 'CreateNetworkBB', NULL, NULL, 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')),
@@ -322,6 +323,7 @@ VALUES
('VNFConfigModifyActivity','*','*','*','*','Manual','Abort','*', '*'),
('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*'),
+('DeleteChildServiceBB', '*', '*', '*', '*', 'Rollback', 'Abort', '*', '*'),
('CreateChildServiceBB', '*', '*', '*', '*', 'Rollback', 'Abort', '*', '*');
INSERT INTO building_block_detail (building_block_name, resource_type, target_action)
@@ -364,12 +366,12 @@ VALUES
('CreateNetworkBB', 'NETWORK', 'CREATE'),
('CreateNetworkCollectionBB', 'NETWORK_COLLECTION', 'CREATE'),
('CreateChildServiceBB', 'NO_VALIDATE', 'CUSTOM'),
-('DeleteChildServiceBB', 'NO_VALIDATE', 'CUSTOM'),
('DeleteVolumeGroupBB', 'VOLUME_GROUP', 'DELETE'),
('DeleteVfModuleBB', 'VF_MODULE', 'DELETE'),
('DeleteNetworkBB', 'NETWORK', 'DELETE'),
('DeleteNetworkCollectionBB', 'NETWORK_COLLECTION', 'DELETE'),
+('DeleteChildServiceBB', 'NO_VALIDATE', 'CUSTOM'),
('ConfigurationScaleOutBB', 'NO_VALIDATE', 'CUSTOM'),
('GenericVnfHealthCheckBB', 'NO_VALIDATE', 'CUSTOM'),
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
index cfa55d2101..3be6d32792 100644
--- 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
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns: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="3.6.0">
+<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>
@@ -27,18 +27,13 @@
<bpmn:outgoing>SequenceFlow_0v4loyx</bpmn:outgoing>
<bpmn:outgoing>SequenceFlow_12rysg7</bpmn:outgoing>
</bpmn:exclusiveGateway>
- <bpmn:task id="Task_1gohsu4" name="Update AAI">
- <bpmn:incoming>SequenceFlow_0v4loyx</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_096kfnj</bpmn:outgoing>
- </bpmn:task>
<bpmn:endEvent id="EndEvent_0fh7ikt">
- <bpmn:incoming>SequenceFlow_096kfnj</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0v4loyx</bpmn:incoming>
</bpmn:endEvent>
- <bpmn:sequenceFlow id="SequenceFlow_0v4loyx" name="Completed" sourceRef="ExclusiveGateway_1mxv8h6" targetRef="Task_1gohsu4">
+ <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_096kfnj" sourceRef="Task_1gohsu4" targetRef="EndEvent_0fh7ikt" />
<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>
@@ -56,71 +51,58 @@
<bpmn:message id="Message_0xg6jua" name="ChildServiceRequest" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteChildServiceBB">
- <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="BoundaryEvent_1f4g2g1_di" bpmnElement="BoundaryEvent_1f4g2g1">
- <dc:Bounds x="722" y="142" width="36" height="36" />
+ <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="760" y="173" width="40" height="14" />
+ <dc:Bounds x="925" y="173" width="30" height="14" />
</bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_01wirq3_di" bpmnElement="SequenceFlow_01wirq3">
- <di:waypoint x="188" y="120" />
- <di:waypoint x="290" 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 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_0o2ukb9_di" bpmnElement="SequenceFlow_0o2ukb9">
- <di:waypoint x="740" y="178" />
- <di:waypoint x="740" y="252" />
+ <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="Task_1gohsu4_di" bpmnElement="Task_1gohsu4">
- <dc:Bounds x="1050" y="80" width="100" height="80" />
- </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0fh7ikt_di" bpmnElement="EndEvent_0fh7ikt">
<dc:Bounds x="1242" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0v4loyx_di" bpmnElement="SequenceFlow_0v4loyx">
- <di:waypoint x="935" y="120" />
- <di:waypoint x="1050" y="120" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="966" y="102" width="54" height="14" />
- </bpmndi:BPMNLabel>
- </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_096kfnj_di" bpmnElement="SequenceFlow_096kfnj">
- <di:waypoint x="1150" y="120" />
- <di:waypoint x="1242" y="120" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_1ufwh0a_di" bpmnElement="SequenceFlow_1ufwh0a">
- <di:waypoint x="760" y="120" />
- <di:waypoint x="885" y="120" />
- </bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_0aqgcg6_di" bpmnElement="Task_01gqeuu">
<dc:Bounds x="290" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
@@ -130,6 +112,12 @@
<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-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
index 135b3d6ec4..2a008e3573 100644
--- 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
@@ -13,15 +13,14 @@ 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.RequestParameters;
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;
@@ -66,6 +65,17 @@ public class ChildServiceRequestBuilder {
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;
@@ -83,10 +93,28 @@ public class ChildServiceRequestBuilder {
public ServiceInstancesRequest build() {
RequestContext context = buildingBlockExecution.getGeneralBuildingBlock().getRequestContext();
- sir.setRequestDetails(createRequestDetails(context));
+
+ 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();
@@ -104,8 +132,13 @@ public class ChildServiceRequestBuilder {
private RequestParameters createRequestParameters(RequestContext context, Service childService) {
RequestParameters requestParameters = new RequestParameters();
- requestParameters.getUserParams().add(context.getRequestParameters().getUserParams().get(0));
- requestParameters.getUserParams().add(Map.of("service", childService));
+
+ 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());
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
index a3f70c8f5b..52d1b68ccd 100644
--- 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
@@ -16,27 +16,114 @@
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) {
- log.info("Sending Delete Service Request");
+ 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, final String responsePayload) {
- // log error
- // build workflowException with proper message
+ 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/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index ef0fbc850e..31a7caacda 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
@@ -692,11 +692,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) {
@@ -750,7 +750,8 @@ public class WorkflowAction {
}
if (resource.hasParent() && WorkflowType.SERVICE.equals(resourceType)
&& WorkflowType.SERVICE.equals(parent.getResourceType())) {
- workflowResourceIds.setChildServiceInstanceId(resourceId);
+ String childServiceInstanceId = resource.isGenerated() ? resourceId : resource.getResourceId();
+ workflowResourceIds.setChildServiceInstanceId(childServiceInstanceId);
workflowResourceIds.setChildServiceInstanceName(resource.getInstanceName());
} else {
WorkflowResourceIdsUtils.setInstanceNameByWorkflowType(workflowResourceIds, resourceType,
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 79e801b740..f16365b742 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;
@@ -204,6 +208,7 @@ public class ServiceEBBLoader {
new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false, null);
serviceResource.setModelInvariantId(serviceInstanceAAI.getModelInvariantId());
resourceList.add(serviceResource);
+ traverseServiceInstanceChildService(resourceList, serviceResource, serviceInstanceAAI);
traverseServiceInstanceMSOVnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
traverseServiceInstanceMSOPnfs(resourceList, serviceResource, aaiResourceIds, serviceInstanceMSO);
if (serviceInstanceMSO.getNetworks() != null) {
@@ -280,6 +285,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/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
index d1db3aadcd..e57232ebb7 100644
--- 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
@@ -53,6 +53,7 @@ public class ChildServiceRequestBuilderTest {
context.setProductFamilyId("FamilyId");
context.setSource("source");
context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setCloudOwner("CloudOwner");
@@ -82,10 +83,26 @@ public class ChildServiceRequestBuilderTest {
gbb.setServiceInstance(serviceInstance);
mockExecution = mock(BuildingBlockExecution.class);
doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ doReturn("CreateChildServiceBB").when(mockExecution).getFlowToBeCalled();
}
@Test
- public void childServiceRequestBuilderTest() {
+ 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())
@@ -180,6 +197,7 @@ public class ChildServiceRequestBuilderTest {
context.setProductFamilyId("FamilyId");
context.setSource("source");
context.setRequestorId("RequestOrId");
+ context.setAction("createInstance");
CloudRegion cloudRegion = new CloudRegion();
cloudRegion.setCloudOwner("CloudOwner");
@@ -198,6 +216,7 @@ public class ChildServiceRequestBuilderTest {
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")
@@ -231,6 +250,4 @@ public class ChildServiceRequestBuilderTest {
}
return null;
}
-
-
}
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 2725626c1a..9377daea5e 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;
@@ -364,4 +368,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());
+ }
}