summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn102
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn156
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEvent.java99
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java45
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java34
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java29
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEventTest.java125
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java50
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java17
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java52
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java18
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java86
16 files changed, 588 insertions, 384 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
index 930f666bf0..c8600586ce 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn
@@ -1,68 +1,40 @@
<?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_1a52v2f" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.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_1a52v2f" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
<bpmn:collaboration id="Collaboration_0go8wi3">
<bpmn:participant id="Participant_1dwc5st" name="SO&#10;Assign PNF" processRef="AssignPnfBB" />
<bpmn:participant id="Participant_0gycee4" name="AAI" />
<bpmn:messageFlow id="MessageFlow_0xh6bkn" sourceRef="CreatePnfEntryInAai" targetRef="Participant_0gycee4" />
- <bpmn:messageFlow id="MessageFlow_0cnehf5" sourceRef="Participant_0gycee4" targetRef="CheckAaiForPnfCorrelationId" />
- <bpmn:messageFlow id="MessageFlow_1e1pjve" sourceRef="CheckAaiForPnfCorrelationId" targetRef="Participant_0gycee4" />
</bpmn:collaboration>
<bpmn:process id="AssignPnfBB" name="AssignPnfBB" isExecutable="true">
- <bpmn:startEvent id="AssignPnf_StartEvent">
- <bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing>
- </bpmn:startEvent>
- <bpmn:serviceTask id="CheckAaiForPnfCorrelationId" name="Check AAI for pnf_correlation_id" camunda:expression="${CheckAaiForPnfCorrelationId.execute(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_081rs5d</bpmn:outgoing>
- </bpmn:serviceTask>
- <bpmn:exclusiveGateway id="DoesAaiContainInfoAboutPnf" name="Does AAI contain info about pnf?">
- <bpmn:incoming>SequenceFlow_081rs5d</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0fn5kgz</bpmn:outgoing>
- <bpmn:outgoing>SequenceFlow_1ewfz8r</bpmn:outgoing>
- </bpmn:exclusiveGateway>
- <bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:expression="${CreatePnfEntryInAai.execute(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_0fn5kgz</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing>
- </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" />
+ <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CreatePnfEntryInAai" />
<bpmn:endEvent id="AaiEntryExists" name="AAI entry exists">
- <bpmn:incoming>SequenceFlow_1ewfz8r</bpmn:incoming>
<bpmn:incoming>SequenceFlow_0l6rtzy</bpmn:incoming>
</bpmn:endEvent>
- <bpmn:sequenceFlow id="SequenceFlow_081rs5d" sourceRef="CheckAaiForPnfCorrelationId" targetRef="DoesAaiContainInfoAboutPnf" />
- <bpmn:sequenceFlow id="SequenceFlow_0fn5kgz" name="No" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="CreatePnfEntryInAai">
- <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!aaiContainsInfoAboutPnf}</bpmn:conditionExpression>
- </bpmn:sequenceFlow>
- <bpmn:sequenceFlow id="SequenceFlow_1ewfz8r" name="Yes&#10;&#10;" sourceRef="DoesAaiContainInfoAboutPnf" targetRef="AaiEntryExists">
- <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{aaiContainsInfoAboutPnf}</bpmn:conditionExpression>
- </bpmn:sequenceFlow>
- <bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" />
- <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CheckAaiForPnfCorrelationId" />
+ <bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:expression="${AAICreateTasks.createPnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:startEvent id="AssignPnf_StartEvent">
+ <bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:association id="Association_1le3nwi" sourceRef="AssignPnf_StartEvent" targetRef="TextAnnotation_184cxp4" />
<bpmn:textAnnotation id="TextAnnotation_184cxp4">
<bpmn:text>Inputs:
- - pnfCorrelationId - String
- - uuid - String</bpmn:text>
+ - pnfName - String
+</bpmn:text>
</bpmn:textAnnotation>
- <bpmn:association id="Association_1le3nwi" sourceRef="AssignPnf_StartEvent" targetRef="TextAnnotation_184cxp4" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0go8wi3">
<bpmndi:BPMNShape id="Participant_1dwc5st_di" bpmnElement="Participant_1dwc5st" isHorizontal="true">
- <dc:Bounds x="160" y="80" width="1100" height="390" />
+ <dc:Bounds x="160" y="80" width="646" height="391" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0gycee4_di" bpmnElement="Participant_0gycee4" isHorizontal="true">
- <dc:Bounds x="590" y="570" width="502" height="60" />
+ <dc:Bounds x="260" y="567" width="502" height="60" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_1ix8822_di" bpmnElement="CreatePnfEntryInAai">
- <dc:Bounds x="920" y="247" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="ExclusiveGateway_1l92fkt_di" bpmnElement="DoesAaiContainInfoAboutPnf" isMarkerVisible="true">
- <dc:Bounds x="795" y="262" width="50" height="50" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="777" y="322" width="85" height="27" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="ServiceTask_0ebur3y_di" bpmnElement="CheckAaiForPnfCorrelationId">
- <dc:Bounds x="640" y="247" width="100" height="80" />
+ <dc:Bounds x="461" y="247" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_1g3euow_di" bpmnElement="AssignPnf_StartEvent">
<dc:Bounds x="219" y="269" width="36" height="36" />
@@ -70,55 +42,27 @@
<bpmndi:BPMNShape id="TextAnnotation_184cxp4_di" bpmnElement="TextAnnotation_184cxp4">
<dc:Bounds x="236" y="150" width="243" height="53" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_081rs5d_di" bpmnElement="SequenceFlow_081rs5d">
- <di:waypoint x="740" y="287" />
- <di:waypoint x="795" y="287" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_0fn5kgz_di" bpmnElement="SequenceFlow_0fn5kgz">
- <di:waypoint x="845" y="287" />
- <di:waypoint x="920" y="287" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="854" y="290" width="15" height="14" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="MessageFlow_0xh6bkn_di" bpmnElement="MessageFlow_0xh6bkn">
- <di:waypoint x="970" y="327" />
- <di:waypoint x="970" y="570" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="MessageFlow_0cnehf5_di" bpmnElement="MessageFlow_0cnehf5">
- <di:waypoint x="710" y="570" />
- <di:waypoint x="710" y="327" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="MessageFlow_1e1pjve_di" bpmnElement="MessageFlow_1e1pjve">
- <di:waypoint x="671" y="327" />
- <di:waypoint x="671" y="570" />
+ <di:waypoint x="511" y="327" />
+ <di:waypoint x="511" y="567" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_1le3nwi_di" bpmnElement="Association_1le3nwi">
<di:waypoint x="237" y="269" />
<di:waypoint x="237" y="203" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_1wfgsdz_di" bpmnElement="AaiEntryExists">
- <dc:Bounds x="1152" y="269" width="36" height="36" />
+ <dc:Bounds x="722" y="269" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1133" y="312" width="77" height="14" />
+ <dc:Bounds x="703" y="312" width="77" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_1ewfz8r_di" bpmnElement="SequenceFlow_1ewfz8r">
- <di:waypoint x="820" y="262" />
- <di:waypoint x="820" y="170" />
- <di:waypoint x="1170" y="170" />
- <di:waypoint x="1170" y="269" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="822" y="240" width="19" height="40" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0l6rtzy_di" bpmnElement="SequenceFlow_0l6rtzy">
- <di:waypoint x="1020" y="287" />
- <di:waypoint x="1152" y="287" />
+ <di:waypoint x="561" y="287" />
+ <di:waypoint x="722" y="287" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1fu9o4x_di" bpmnElement="SequenceFlow_1fu9o4x">
<di:waypoint x="255" y="287" />
- <di:waypoint x="640" y="287" />
+ <di:waypoint x="461" y="287" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn
new file mode 100644
index 0000000000..b38ec69ba5
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WaitForPnfReadyBB.bpmn
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
+ <bpmn:collaboration id="Collaboration_1d0w8lf">
+ <bpmn:participant id="WaitForPnfReadyBB_ID" name="SO&#10;Wait For Pnf Ready" processRef="WaitForPnfReadyBB" />
+ <bpmn:participant id="WorkflowMessageServiceForDmaap" name="Workflow Message Service&#10;(communication with DMAAP)&#10;" />
+ <bpmn:messageFlow id="MessageFlow_1vrcp2d" sourceRef="WorkflowMessageServiceForDmaap" targetRef="WaitForDmaapPnfReadyNotification" />
+ <bpmn:messageFlow id="MessageFlow_0tg4hw9" sourceRef="RegisterForPnfReadyEvent" targetRef="WorkflowMessageServiceForDmaap" />
+ <bpmn:messageFlow id="MessageFlow_1py54jr" sourceRef="UnregisterfromPnfReadyEvent" targetRef="WorkflowMessageServiceForDmaap" />
+ </bpmn:collaboration>
+ <bpmn:process id="WaitForPnfReadyBB" name="WaitForPnfReadyBB" isExecutable="true">
+ <bpmn:startEvent id="WaitForPnfReady_StartEvent">
+ <bpmn:outgoing>SequenceFlow_1jzs6dp</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:serviceTask id="RegisterForPnfReadyEvent" name="Register for Pnf Ready Event" camunda:delegateExpression="${RegisterForPnfReadyEvent}">
+ <bpmn:incoming>SequenceFlow_1jzs6dp</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1o8od8e</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_1miyzfe" sourceRef="UnregisterfromPnfReadyEvent" targetRef="ThrowTimeoutException" />
+ <bpmn:sequenceFlow id="SequenceFlow_0p09qgm" sourceRef="WaitForDmaapPnfReadyNotification" targetRef="AaiEntryUpdated" />
+ <bpmn:sequenceFlow id="SequenceFlow_1o8od8e" sourceRef="RegisterForPnfReadyEvent" targetRef="WaitForDmaapPnfReadyNotification" />
+ <bpmn:sequenceFlow id="SequenceFlow_1kc34bc" sourceRef="WaitForDmaapTimeout" targetRef="UnregisterfromPnfReadyEvent" />
+ <bpmn:sequenceFlow id="SequenceFlow_1jzs6dp" sourceRef="WaitForPnfReady_StartEvent" targetRef="RegisterForPnfReadyEvent" />
+ <bpmn:receiveTask id="WaitForDmaapPnfReadyNotification" name="Wait for DMAAP pnf-ready notification" messageRef="Message_13h1tlo">
+ <bpmn:incoming>SequenceFlow_1o8od8e</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0p09qgm</bpmn:outgoing>
+ </bpmn:receiveTask>
+ <bpmn:boundaryEvent id="WaitForDmaapTimeout" name="Timeout" attachedToRef="WaitForDmaapPnfReadyNotification">
+ <bpmn:outgoing>SequenceFlow_1kc34bc</bpmn:outgoing>
+ <bpmn:timerEventDefinition>
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">#{timeoutForPnfEntryNotification}</bpmn:timeDuration>
+ </bpmn:timerEventDefinition>
+ </bpmn:boundaryEvent>
+ <bpmn:serviceTask id="UnregisterfromPnfReadyEvent" name="Unregister from Pnf Ready Event" camunda:delegateExpression="${CancelDmaapSubscription}">
+ <bpmn:incoming>SequenceFlow_1kc34bc</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1miyzfe</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="ThrowTimeoutException" name="Throw timeout exception">
+ <bpmn:incoming>SequenceFlow_1miyzfe</bpmn:incoming>
+ <bpmn:errorEventDefinition errorRef="Error_1" />
+ </bpmn:endEvent>
+ <bpmn:endEvent id="AaiEntryUpdated" name="AAI entry updated">
+ <bpmn:incoming>SequenceFlow_0p09qgm</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:textAnnotation id="TextAnnotation_1eyzes8">
+ <bpmn:text>Inputs:
+ - pnf name - String</bpmn:text>
+ </bpmn:textAnnotation>
+ <bpmn:association id="Association_0d7oxnz" sourceRef="WaitForPnfReady_StartEvent" targetRef="TextAnnotation_1eyzes8" />
+ </bpmn:process>
+ <bpmn:error id="Error_1" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
+ <bpmn:message id="Message_13h1tlo" name="WorkflowMessage" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1d0w8lf">
+ <bpmndi:BPMNShape id="Participant_1egg397_di" bpmnElement="WaitForPnfReadyBB_ID" isHorizontal="true">
+ <dc:Bounds x="160" y="50" width="810" height="400" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0k52gr7_di" bpmnElement="AaiEntryUpdated">
+ <dc:Bounds x="882" y="189" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="858" y="230" width="88" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="StartEvent_0j5ok9h_di" bpmnElement="WaitForPnfReady_StartEvent">
+ <dc:Bounds x="219" y="189" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-80" y="228" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Participant_0vmrrhf_di" bpmnElement="WorkflowMessageServiceForDmaap" isHorizontal="true">
+ <dc:Bounds x="340" y="490" width="463" height="60" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_0wbx6tt_di" bpmnElement="ThrowTimeoutException">
+ <dc:Bounds x="882" y="322" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="875" y="359" width="70" height="27" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="TextAnnotation_1eyzes8_di" bpmnElement="TextAnnotation_1eyzes8">
+ <dc:Bounds x="236" y="70" width="243" height="39" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="Association_0d7oxnz_di" bpmnElement="Association_0d7oxnz">
+ <di:waypoint x="237" y="189" />
+ <di:waypoint x="237" y="109" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="MessageFlow_1vrcp2d_di" bpmnElement="MessageFlow_1vrcp2d">
+ <di:waypoint x="582" y="490" />
+ <di:waypoint x="582" y="247" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="996" y="380" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="BoundaryEvent_15eo1k9_di" bpmnElement="WaitForDmaapTimeout">
+ <dc:Bounds x="596" y="229" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="639" y="240" width="40" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1kc34bc_di" bpmnElement="SequenceFlow_1kc34bc">
+ <di:waypoint x="614" y="265" />
+ <di:waypoint x="614" y="340" />
+ <di:waypoint x="710" y="340" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1028" y="309" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ReceiveTask_1sfysua_di" bpmnElement="WaitForDmaapPnfReadyNotification">
+ <dc:Bounds x="530" y="167" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0p09qgm_di" bpmnElement="SequenceFlow_0p09qgm">
+ <di:waypoint x="630" y="207" />
+ <di:waypoint x="882" y="207" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1106.5" y="187" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_1o8od8e_di" bpmnElement="SequenceFlow_1o8od8e">
+ <di:waypoint x="440" y="207" />
+ <di:waypoint x="530" y="207" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="893.5" y="187" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="MessageFlow_0tg4hw9_di" bpmnElement="MessageFlow_0tg4hw9">
+ <di:waypoint x="390" y="247" />
+ <di:waypoint x="390" y="490" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="823" y="380" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1iax11n_di" bpmnElement="RegisterForPnfReadyEvent">
+ <dc:Bounds x="340" y="167" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1miyzfe_di" bpmnElement="SequenceFlow_1miyzfe">
+ <di:waypoint x="810" y="340" />
+ <di:waypoint x="882" y="340" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1233.5" y="343" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="MessageFlow_1py54jr_di" bpmnElement="MessageFlow_1py54jr">
+ <di:waypoint x="760" y="380" />
+ <di:waypoint x="760" y="490" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1165" y="458" width="90" height="10" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_12j7hox_di" bpmnElement="UnregisterfromPnfReadyEvent">
+ <dc:Bounds x="710" y="300" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1jzs6dp_di" bpmnElement="SequenceFlow_1jzs6dp">
+ <di:waypoint x="255" y="207" />
+ <di:waypoint x="340" y="207" />
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEvent.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEvent.java
new file mode 100644
index 0000000000..f0eadbbf78
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEvent.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
+import com.google.common.base.Strings;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is designed to be used within WaitForPnfReadyBB
+ */
+@Component
+public class RegisterForPnfReadyEvent implements JavaDelegate {
+
+ private static final String ERROR_MESSAGE_PNF_NOT_FOUND =
+ "pnf resource not found in buildingBlockExecution while registering to dmaap listener";
+ private static final Logger LOGGER = LoggerFactory.getLogger(RegisterForPnfReadyEvent.class);
+
+ private DmaapClient dmaapClient;
+ private ExtractPojosForBB extractPojosForBB;
+ private ExceptionBuilder exceptionBuilder;
+ private String pnfEntryNotificationTimeout;
+
+ @Autowired
+ public RegisterForPnfReadyEvent(DmaapClient dmaapClient, ExtractPojosForBB extractPojosForBB,
+ ExceptionBuilder exceptionBuilder,
+ @Value("${aai.pnfEntryNotificationTimeout}") String pnfEntryNotificationTimeout) {
+ this.dmaapClient = dmaapClient;
+ this.extractPojosForBB = extractPojosForBB;
+ this.exceptionBuilder = exceptionBuilder;
+ this.pnfEntryNotificationTimeout = pnfEntryNotificationTimeout;
+ }
+
+ @Override
+ public void execute(DelegateExecution execution) {
+ try {
+ String pnfName = getPnfName(execution);
+ fillExecution(execution, pnfName);
+ RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
+ dmaapClient.registerForUpdate(pnfName, () -> runtimeService.createMessageCorrelation("WorkflowMessage")
+ .processInstanceBusinessKey(execution.getProcessBusinessKey()).correlateWithResult());
+ } catch (BBObjectNotFoundException e) {
+ LOGGER.error(ERROR_MESSAGE_PNF_NOT_FOUND);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ERROR_MESSAGE_PNF_NOT_FOUND);
+ }
+ }
+
+ private void fillExecution(DelegateExecution execution, String pnfName) {
+ execution.setVariable(ExecutionVariableNames.PNF_CORRELATION_ID, pnfName);
+ if (Strings.isNullOrEmpty(pnfEntryNotificationTimeout)) {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ "pnfEntryNotificationTimeout value not defined");
+ }
+ execution.setVariable(TIMEOUT_FOR_NOTIFICATION, pnfEntryNotificationTimeout);
+ }
+
+ private String getPnfName(DelegateExecution execution) throws BBObjectNotFoundException {
+ BuildingBlockExecution buildingBlockExecution =
+ (BuildingBlockExecution) execution.getVariable("gBuildingBlockExecution");
+ Pnf pnf = extractPojosForBB.extractByKey(buildingBlockExecution, ResourceKey.PNF);
+ String pnfName = pnf.getPnfName();
+ if (Strings.isNullOrEmpty(pnfName)) {
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "pnf name is not set");
+ }
+ return pnfName;
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java
deleted file mode 100644
index 29914252d8..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.tasks;
-
-import joptsimple.internal.Strings;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.client.exception.BBObjectNotFoundException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-import java.io.IOException;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
-
-@Component
-public class CheckAaiForPnfCorrelationId extends PnfBaseTasks {
- private static final Logger logger = LoggerFactory.getLogger(CheckAaiForPnfCorrelationId.class);
-
- @Override
- public void execute(BuildingBlockExecution execution) {
- try {
- String pnfCorrelationId = extractPnf(execution).getPnfName();
- checkIfPnfCorrelationIdPresent(execution, pnfCorrelationId);
- checkIfPnfExistsInAai(execution, pnfCorrelationId);
- } catch (BBObjectNotFoundException e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
- }
-
- }
-
- private void checkIfPnfCorrelationIdPresent(BuildingBlockExecution execution, String pnfCorrelationId) {
- if (Strings.isNullOrEmpty(pnfCorrelationId)) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, PNF_CORRELATION_ID + " is not set");
- }
- }
-
- private void checkIfPnfExistsInAai(BuildingBlockExecution execution, String pnfCorrelationId) {
- try {
- boolean isEntry = pnfManagement.getEntryFor(pnfCorrelationId).isPresent();
- logger.debug("AAI entry is found for pnf correlation id {}: {}", PNF_CORRELATION_ID, isEntry);
- execution.setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry);
- } catch (IOException e) {
- logger.error("Exception in check AAI for pnf_correlation_id execution", e);
- exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e);
- }
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java
deleted file mode 100644
index 6e86ad619e..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.tasks;
-
-import org.onap.aai.domain.yang.Pnf;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.client.exception.BBObjectNotFoundException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-@Component
-public class CreatePnfEntryInAai extends PnfBaseTasks {
- private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAai.class);
-
- @Override
- public void execute(BuildingBlockExecution execution) throws Exception {
- try {
- org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = extractPnf(execution);
- String pnfCorrelationId = pnf.getPnfName();
- pnfManagement.createEntry(pnfCorrelationId, preparePnfForAai(pnf));
- logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", pnfCorrelationId,
- pnf.getPnfId());
- } catch (BBObjectNotFoundException e) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
- }
- }
-
- private Pnf preparePnfForAai(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf) {
- Pnf pnfAai = new Pnf();
- pnfAai.setPnfId(pnf.getPnfId());
- pnfAai.setPnfName(pnf.getPnfName());
- return pnfAai;
- }
-
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java
deleted file mode 100644
index d8e3379afb..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.tasks;
-
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
-import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.client.exception.BBObjectNotFoundException;
-import org.onap.so.client.exception.ExceptionBuilder;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public abstract class PnfBaseTasks {
- protected PnfManagement pnfManagement;
- @Autowired
- protected ExceptionBuilder exceptionUtil;
- @Autowired
- protected ExtractPojosForBB extractPojosForBB;
-
- @Autowired
- public void setPnfManagement(PnfManagement pnfManagement) {
- this.pnfManagement = pnfManagement;
- }
-
- public abstract void execute(BuildingBlockExecution execution) throws Exception;
-
- protected Pnf extractPnf(BuildingBlockExecution execution) throws BBObjectNotFoundException {
- return extractPojosForBB.extractByKey(execution, ResourceKey.PNF);
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEventTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEventTest.java
new file mode 100644
index 0000000000..a82fb5d823
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/RegisterForPnfReadyEventTest.java
@@ -0,0 +1,125 @@
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.HashMap;
+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.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
+
+public class RegisterForPnfReadyEventTest {
+
+ private static final String PNF_NAME = "pnfNameTest";
+
+ private DelegateExecution delegateExecution;
+ private ExtractPojosForBB extractPojosForBBMock;
+ private DmaapClientTestImpl dmaapClientTest;
+ private MessageCorrelationBuilder messageCorrelationBuilder;
+ private ExceptionBuilder exceptionBuilderMock;
+ private BuildingBlockExecution buildingBlockExecution;
+ private static final String PNF_ENTRY_NOTIFICATION_TIMEOUT = "P14D";
+
+ private RegisterForPnfReadyEvent testedObject;
+
+ @Before
+ public void init() {
+ delegateExecution = prepareExecution();
+ dmaapClientTest = new DmaapClientTestImpl();
+ exceptionBuilderMock = mock(ExceptionBuilder.class);
+ extractPojosForBBMock = mock(ExtractPojosForBB.class);
+ buildingBlockExecution = new DelegateExecutionImpl(new HashMap<>());
+ when(delegateExecution.getVariable("gBuildingBlockExecution")).thenReturn(buildingBlockExecution);
+ }
+
+ @Test
+ public void shouldRegisterForDmaapClient() throws BBObjectNotFoundException {
+ // given
+ testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock,
+ PNF_ENTRY_NOTIFICATION_TIMEOUT);
+ Pnf pnf = new Pnf();
+ pnf.setPnfName(PNF_NAME);
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(pnf);
+ // when
+ testedObject.execute(delegateExecution);
+ // then
+ verify(delegateExecution).setVariable(ExecutionVariableNames.PNF_CORRELATION_ID, PNF_NAME);
+ verify(delegateExecution).setVariable(ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION,
+ PNF_ENTRY_NOTIFICATION_TIMEOUT);
+ checkIfInformConsumerThreadIsRunProperly(dmaapClientTest);
+ }
+
+ @Test
+ public void pnfNotFoundInBBexecution_WorkflowExIsThrown() throws BBObjectNotFoundException {
+ // given
+ testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock,
+ PNF_ENTRY_NOTIFICATION_TIMEOUT);
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF))
+ .thenThrow(BBObjectNotFoundException.class);
+ // when
+ testedObject.execute(delegateExecution);
+ // then
+ verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000,
+ "pnf resource not found in buildingBlockExecution while registering to dmaap listener");
+ }
+
+ @Test
+ public void pnfNameIsNull_WorkflowExIsThrown() throws BBObjectNotFoundException {
+ // given
+ testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock,
+ PNF_ENTRY_NOTIFICATION_TIMEOUT);
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(new Pnf());
+ // when
+ testedObject.execute(delegateExecution);
+ // then
+ verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000, "pnf name is not set");
+ }
+
+ @Test
+ public void pnfEventNotificationTimeoutNotSet_WorkflowExIsThrown() throws BBObjectNotFoundException {
+ // given
+ testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock, null);
+ when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(new Pnf());
+ // when
+ testedObject.execute(delegateExecution);
+ // then
+ verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000,
+ "pnfEntryNotificationTimeout value not defined");
+ }
+
+ private void checkIfInformConsumerThreadIsRunProperly(DmaapClientTestImpl dmaapClientTest) {
+ dmaapClientTest.getInformConsumer().run();
+ InOrder inOrder = inOrder(messageCorrelationBuilder);
+ inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey");
+ inOrder.verify(messageCorrelationBuilder).correlateWithResult();
+ }
+
+ private DelegateExecution prepareExecution() {
+ DelegateExecution delegateExecution = mock(DelegateExecution.class);
+ when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+
+ messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder);
+
+ return delegateExecution;
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java
deleted file mode 100644
index 3fa9fbf3b5..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.tasks;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.runners.Enclosed;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl;
-import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementThrowingException;
-import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
-import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.client.exception.ExceptionBuilder;
-import java.io.IOException;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.anyInt;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.doThrow;
-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.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITHOUT_ENTRY;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY;
-import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf;
-
-@RunWith(Enclosed.class)
-public class CheckAaiForPnfCorrelationIdTest {
-
- @RunWith(MockitoJUnitRunner.class)
- public static class ConnectionOkTests {
-
- @Mock
- private ExtractPojosForBB extractPojosForBB;
- @Mock
- private ExceptionBuilder exceptionUtil;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @InjectMocks
- private CheckAaiForPnfCorrelationId task = new CheckAaiForPnfCorrelationId();
- private PnfManagement pnfManagementTest = new PnfManagementTestImpl();
-
- @Before
- public void setUp() {
- task.setPnfManagement(pnfManagementTest);
- }
-
- @Test
- public void shouldThrowExceptionWhenPnfCorrelationIdIsNotSet() throws Exception {
- // given
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))).thenReturn(preparePnf(null, PNF_UUID));
- BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(eq(execution),
- anyInt(), anyString());
- // when, then
- expectedException.expect(BpmnError.class);
- task.execute(execution);
- verify(exceptionUtil).buildAndThrowWorkflowException(eq(execution), anyInt(), anyString());
- }
-
- @Test
- public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception {
- // given
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
- .thenReturn(preparePnf(ID_WITHOUT_ENTRY, PNF_UUID));
- BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
- // when
- task.execute(execution);
- // then
- verify(execution).setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, false);
- }
-
- @Test
- public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception {
- // given
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
- .thenReturn(preparePnf(ID_WITH_ENTRY, PNF_UUID));
- BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
- // when
- task.execute(execution);
- // then
- verify(execution).setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, true);
- }
- }
-
- @RunWith(MockitoJUnitRunner.class)
- public static class NoConnectionTests {
-
- @Mock
- private ExtractPojosForBB extractPojosForBB;
- @Mock
- private ExceptionBuilder exceptionUtil;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @InjectMocks
- private CheckAaiForPnfCorrelationId task = new CheckAaiForPnfCorrelationId();
- private PnfManagement pnfManagementTest = new PnfManagementThrowingException();
-
- @Before
- public void setUp() throws Exception {
- task.setPnfManagement(pnfManagementTest);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
- .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID));
- }
-
- @Test
- public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
- // given
- BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
- doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(eq(execution),
- anyInt(), any(IOException.class));
- // when, then
- expectedException.expect(BpmnError.class);
- task.execute(execution);
- verify(exceptionUtil).buildAndThrowWorkflowException(eq(execution), anyInt(), any(IOException.class));
- }
- }
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java
deleted file mode 100644
index ed8dd82efb..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.tasks;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.aai.domain.yang.Pnf;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl;
-import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf;
-
-@RunWith(MockitoJUnitRunner.class)
-public class CreatePnfEntryInAaiTest {
-
- @Mock
- private ExtractPojosForBB extractPojosForBB;
- @InjectMocks
- private CreatePnfEntryInAai task = new CreatePnfEntryInAai();
- private PnfManagementTestImpl pnfManagementTest = new PnfManagementTestImpl();
-
- @Before
- public void setUp() throws Exception {
- task.setPnfManagement(pnfManagementTest);
- when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF)))
- .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID));
- }
-
- @Test
- public void shouldSetPnfIdAndPnfName() throws Exception {
- // when
- task.execute(mock(BuildingBlockExecution.class));
- // then
- Pnf createdEntry = pnfManagementTest.getCreated().get(PNF_CORRELATION_ID);
- assertThat(createdEntry.getPnfId()).isEqualTo(PNF_UUID);
- assertThat(createdEntry.getPnfName()).isEqualTo(PNF_CORRELATION_ID);
- assertThat(createdEntry.isInMaint()).isNull();
- }
-
-}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java
deleted file mode 100644
index 49fe96c3d9..0000000000
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.onap.so.bpmn.infrastructure.pnf.tasks;
-
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
-import java.util.UUID;
-
-public class PnfTasksUtils {
- static final String PNF_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
- static final String PNF_CORRELATION_ID = "testPnfCorrelationId";
-
- public static Pnf preparePnf(String pnfName, String pnfUuid) {
- Pnf pnf = new Pnf();
- pnf.setPnfName(pnfName);
- pnf.setPnfId(pnfUuid);
- return pnf;
- }
-
-}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index b9f73f3f0e..22089dae1f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -29,6 +31,7 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.onap.so.client.orchestration.AAIPnfResources;
import org.onap.so.logger.LoggingAnchor;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -43,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
@@ -50,7 +54,6 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -87,6 +90,8 @@ public class AAICreateTasks {
@Autowired
private AAIVnfResources aaiVnfResources;
@Autowired
+ private AAIPnfResources aaiPnfResources;
+ @Autowired
private ExceptionBuilder exceptionUtil;
@Autowired
private ExtractPojosForBB extractPojosForBB;
@@ -252,6 +257,17 @@ public class AAICreateTasks {
}
}
+ public void createPnf(BuildingBlockExecution execution) {
+ try {
+ Pnf pnf = extractPojosForBB.extractByKey(execution, ResourceKey.PNF);
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ aaiPnfResources.createPnfAndConnectServiceInstance(pnf, serviceInstance);
+ } catch (BBObjectNotFoundException e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
+
/**
* This method is used for separating (,) from the string.
*
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
index 06f6550d51..11a7b83259 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -87,6 +89,10 @@ public class AAIObjectMapper {
return modelMapper.map(vnf, org.onap.aai.domain.yang.GenericVnf.class);
}
+ public org.onap.aai.domain.yang.Pnf mapPnf(Pnf pnf) {
+ return modelMapper.map(pnf, org.onap.aai.domain.yang.Pnf.class);
+ }
+
public org.onap.aai.domain.yang.VfModule mapVfModule(VfModule vfModule) {
if (modelMapper.getTypeMap(VfModule.class, org.onap.aai.domain.yang.VfModule.class) == null) {
modelMapper.addMappings(new PropertyMap<VfModule, org.onap.aai.domain.yang.VfModule>() {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
new file mode 100644
index 0000000000..9dd44c43e9
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.orchestration;
+
+import java.util.Optional;
+import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.aai.mapper.AAIObjectMapper;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AAIPnfResources {
+
+ @Autowired
+ private InjectionHelper injectionHelper;
+
+ @Autowired
+ private AAIObjectMapper aaiObjectMapper;
+
+ public void createPnfAndConnectServiceInstance(Pnf pnf, ServiceInstance serviceInstance) {
+ AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName());
+ pnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ AAIResourceUri serviceInstanceURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId());
+ injectionHelper.getAaiClient().createIfNotExists(pnfURI, Optional.of(aaiObjectMapper.mapPnf(pnf)))
+ .connect(pnfURI, serviceInstanceURI);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index 39efa6dc76..73896d7d6d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -40,6 +42,7 @@ import org.onap.so.client.orchestration.AAICollectionResources;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.client.orchestration.AAIInstanceGroupResources;
import org.onap.so.client.orchestration.AAINetworkResources;
+import org.onap.so.client.orchestration.AAIPnfResources;
import org.onap.so.client.orchestration.AAIServiceInstanceResources;
import org.onap.so.client.orchestration.AAIVfModuleResources;
import org.onap.so.client.orchestration.AAIVnfResources;
@@ -69,6 +72,9 @@ public abstract class BaseTaskTest extends TestDataSetup {
protected AAIVnfResources aaiVnfResources;
@Mock
+ protected AAIPnfResources aaiPnfResources;
+
+ @Mock
protected AAIVfModuleResources aaiVfModuleResources;
@Mock
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index a8550d8df9..a8f47fc763 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -55,6 +57,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
@@ -74,6 +77,7 @@ public class AAICreateTasksTest extends BaseTaskTest {
private ServiceInstance serviceInstance;
private L3Network network;
private GenericVnf genericVnf;
+ private Pnf pnf;
private VolumeGroup volumeGroup;
private CloudRegion cloudRegion;
private VfModule vfModule;
@@ -93,6 +97,7 @@ public class AAICreateTasksTest extends BaseTaskTest {
serviceInstance = setServiceInstance();
network = setL3Network();
genericVnf = setGenericVnf();
+ pnf = buildPnf();
volumeGroup = setVolumeGroup();
cloudRegion = setCloudRegion();
vfModule = setVfModule();
@@ -324,6 +329,19 @@ public class AAICreateTasksTest extends BaseTaskTest {
verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
}
+ @Test
+ public void createPnfShouldCallCreatePnfAndConnectServiceInstance() throws BBObjectNotFoundException {
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf);
+ aaiCreateTasks.createPnf(execution);
+ verify(aaiPnfResources, times(1)).createPnfAndConnectServiceInstance(pnf, serviceInstance);
+ }
+
+ @Test
+ public void createPnfShouldThrowBpmnErrorWhenPnfIsNotFound() throws BBObjectNotFoundException {
+ expectedException.expect(BpmnError.class);
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(execution, ResourceKey.PNF);
+ aaiCreateTasks.createPnf(execution);
+ }
@Test
public void createVfModuleTest() throws Exception {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
new file mode 100644
index 0000000000..a929f256ac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.orchestration;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.common.data.TestDataSetup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.mapper.AAIObjectMapper;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AAIPnfResourcesTest extends TestDataSetup {
+
+ private Pnf pnf;
+ private ServiceInstance serviceInstance;
+
+ @Mock
+ protected AAIObjectMapper aaiObjectMapperMock;
+
+ @Mock
+ protected InjectionHelper injectionHelperMock;
+
+ @Mock
+ protected AAIResourcesClient aaiResourcesClientMock;
+
+ @InjectMocks
+ AAIPnfResources aaiPnfResources = new AAIPnfResources();
+
+ @Before
+ public void setUp() {
+ pnf = buildPnf();
+ pnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ serviceInstance = buildServiceInstance();
+
+ doReturn(aaiResourcesClientMock).when(injectionHelperMock).getAaiClient();
+ }
+
+ @Test
+ public void createPnfAndConnectServiceInstanceShouldSetInventoriedStatusAndCallConnectMethod() {
+ org.onap.aai.domain.yang.Pnf pnfYang = new org.onap.aai.domain.yang.Pnf();
+
+ doReturn(pnfYang).when(aaiObjectMapperMock).mapPnf(pnf);
+ doReturn(aaiResourcesClientMock).when(aaiResourcesClientMock).createIfNotExists(any(AAIResourceUri.class),
+ eq(Optional.of(pnfYang)));
+
+ aaiPnfResources.createPnfAndConnectServiceInstance(pnf, serviceInstance);
+
+ assertEquals(OrchestrationStatus.INVENTORIED, pnf.getOrchestrationStatus());
+ verify(aaiResourcesClientMock, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
+ }
+
+}