summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreeginux <henry.xie@est.tech>2019-11-20 13:23:49 +0000
committerXuefeng Xie <henry.xie@est.tech>2020-01-24 10:12:25 +0000
commit8c9f2c73f4366ae42ad7e2c1742885b5ad793360 (patch)
tree7664c0f06c29b67bba254b14873c4d18f20d6b45
parent8d77d8544d88dfb91e9287b1620212cc9821bd54 (diff)
decision point API
ControllerRunnable interface: implemented by controller ControllerContext: Controller Context for controller execution ControllerPreparable interface:used to setup execution context ControllerExecutionBB:controller execution for building block ControllerExecutionDE:controller execution for camunda Skeleton implementation for APPC controller Skeleton implementation for SDNC controller Use ControllerExecutionDE for existing PNF configuration. Add integration tests for controllerExecutionBB/DE Add GenericControllerExecution activity for BuildingBlockExecution based Add GenericControllerExecutionDE activity for DelegateExecution based. CDS controller to be implemented by SO-CDS generic buildingBlock Actor seletion based on ingested metadata Issue-ID: SO-2070 Change-Id: I4020c2ce21468939690e2cef78bbadbfff4bd3e4 Signed-off-by: eeginux<henry.xie@est.tech>
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java2
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecution.json15
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecutionDE.json15
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecution.bpmn44
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecutionDE.bpmn44
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java8
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionDETest.java54
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionTest.java54
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java95
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java56
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java48
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java27
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn104
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java1
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json3
-rw-r--r--bpmn/so-bpmn-tasks/pom.xml7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java174
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java152
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/LcmControllerBB.java68
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBB.java66
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBB.java73
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncBB.java47
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBB.java60
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDE.java148
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDE.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java61
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigAssignDE.java50
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigDeployDE.java50
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java62
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java113
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java160
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTestIT.java194
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/MockControllerBB.java54
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBBTest.java65
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBBTest.java64
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETest.java160
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java144
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/MockControllerDE.java55
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDETest.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java66
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml6
44 files changed, 2865 insertions, 76 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
index 9741d4b6c2..424a4f3ecc 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
@@ -68,7 +68,7 @@ public class AbstractCDSProcessingBBUtils {
private static final String EXCEPTION = "Exception";
@Autowired
- private ExceptionBuilder exceptionUtil;
+ protected ExceptionBuilder exceptionUtil;
/**
* Extracting data from execution object and building the ExecutionServiceInput Object
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecution.json b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecution.json
new file mode 100644
index 0000000000..d4a0e83546
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecution.json
@@ -0,0 +1,15 @@
+{
+ "name": "GenericControllerExecution",
+ "description": "Generic controller execution with BuildingBlockExecution context against controller northbound interface",
+ "categoryList": [
+ "VNF",
+ "PNF"
+ ],
+ "inputParameters": [],
+ "outputParameters": [
+ {
+ "name": "WorkflowException",
+ "type": "WorkflowException"
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecutionDE.json b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecutionDE.json
new file mode 100644
index 0000000000..cd1fa865ee
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/ActivitySpec/GenericControllerExecutionDE.json
@@ -0,0 +1,15 @@
+{
+ "name": "GenericControllerExecutionDE",
+ "description": "Generic controller execution with DelegateExecution context against controller northbound interface",
+ "categoryList": [
+ "VNF",
+ "PNF"
+ ],
+ "inputParameters": [],
+ "outputParameters": [
+ {
+ "name": "WorkflowException",
+ "type": "WorkflowException"
+ }
+ ]
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecution.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecution.bpmn
new file mode 100644
index 0000000000..bd606738e2
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecution.bpmn
@@ -0,0 +1,44 @@
+<?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" id="Definitions_0ky0lyw" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+ <bpmn:process id="GenericControllerExecution" name="GenericControllerExecution" isExecutable="true">
+ <bpmn:startEvent id="Start_ControllerExecutionBB" name="Start">
+ <bpmn:outgoing>SequenceFlow_06ab7wm</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_06ab7wm" sourceRef="Start_ControllerExecutionBB" targetRef="Call_ControllerExecutionBB" />
+ <bpmn:endEvent id="End_ControllerExecutionBB" name="End">
+ <bpmn:incoming>SequenceFlow_12srn62</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_12srn62" sourceRef="Call_ControllerExecutionBB" targetRef="End_ControllerExecutionBB" />
+ <bpmn:serviceTask id="Call_ControllerExecutionBB" name="Call ControllerExecutionBB&#10;" camunda:expression="${ControllerExecutionBB.execute(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_06ab7wm</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_12srn62</bpmn:outgoing>
+ </bpmn:serviceTask>
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericControllerExecution">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_ControllerExecutionBB">
+ <dc:Bounds x="173" y="102" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="180" y="145" width="24" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_06ab7wm_di" bpmnElement="SequenceFlow_06ab7wm">
+ <di:waypoint x="209" y="120" />
+ <di:waypoint x="291" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="EndEvent_07e01q3_di" bpmnElement="End_ControllerExecutionBB">
+ <dc:Bounds x="554" y="102" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="562" y="145" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_12srn62_di" bpmnElement="SequenceFlow_12srn62">
+ <di:waypoint x="391" y="120" />
+ <di:waypoint x="554" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0d1v1dn_di" bpmnElement="Call_ControllerExecutionBB">
+ <dc:Bounds x="291" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions> \ No newline at end of file
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecutionDE.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecutionDE.bpmn
new file mode 100644
index 0000000000..b5dcec00cd
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/GenericControllerExecutionDE.bpmn
@@ -0,0 +1,44 @@
+<?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" id="Definitions_0ky0lyw" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+ <bpmn:process id="GenericControllerExecutionDE" name="GenericControllerExecutionDE" isExecutable="true">
+ <bpmn:startEvent id="Start_ControllerExecutionDE" name="Start">
+ <bpmn:outgoing>SequenceFlow_06ab7wm</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_06ab7wm" sourceRef="Start_ControllerExecutionDE" targetRef="Call_ControllerExecutionDE" />
+ <bpmn:endEvent id="End_ControllerExecutionDE" name="End">
+ <bpmn:incoming>SequenceFlow_12srn62</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_12srn62" sourceRef="Call_ControllerExecutionDE" targetRef="End_ControllerExecutionDE" />
+ <bpmn:serviceTask id="Call_ControllerExecutionDE" name="Call ControllerExecutionDE&#10;" camunda:delegateExpression="${ControllerExecutionDE}">
+ <bpmn:incoming>SequenceFlow_06ab7wm</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_12srn62</bpmn:outgoing>
+ </bpmn:serviceTask>
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="GenericControllerExecutionDE">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_ControllerExecutionDE">
+ <dc:Bounds x="173" y="102" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="180" y="145" width="24" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_06ab7wm_di" bpmnElement="SequenceFlow_06ab7wm">
+ <di:waypoint x="209" y="120" />
+ <di:waypoint x="291" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="EndEvent_07e01q3_di" bpmnElement="End_ControllerExecutionDE">
+ <dc:Bounds x="554" y="102" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="562" y="145" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_12srn62_di" bpmnElement="SequenceFlow_12srn62">
+ <di:waypoint x="391" y="120" />
+ <di:waypoint x="554" y="120" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0d1v1dn_di" bpmnElement="Call_ControllerExecutionDE">
+ <dc:Bounds x="291" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
index 5b7fe66f54..874e3415b2 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java
@@ -55,6 +55,8 @@ import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterImpl;
import org.onap.so.bpmn.infrastructure.appc.tasks.AppcOrchestratorPreProcessor;
import org.onap.so.bpmn.infrastructure.appc.tasks.AppcRunTasks;
import org.onap.so.bpmn.infrastructure.audit.AuditTasks;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.ControllerExecutionBB;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.ControllerExecutionDE;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.ActivateVfModule;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetwork;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
@@ -254,6 +256,12 @@ public abstract class BaseBPMNTest {
@MockBean
protected ManualHandlingTasks manualHandlingTasks;
+ @MockBean
+ protected ControllerExecutionBB controllerExecutionBB;
+
+ @MockBean
+ protected ControllerExecutionDE controllerExecutionDE;
+
@LocalServerPort
protected int port;
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionDETest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionDETest.java
new file mode 100644
index 0000000000..83cf98ec0c
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionDETest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.bpmn.subprocess;
+
+import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Test;
+import org.onap.so.bpmn.BaseBPMNTest;
+
+
+public class GenericControllerExecutionDETest extends BaseBPMNTest {
+
+ @Test
+ public void testExecution_validInput_expectedExecution() {
+
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("GenericControllerExecutionDE", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("Start_ControllerExecutionDE", "Call_ControllerExecutionDE",
+ "End_ControllerExecutionDE");
+ assertThat(pi).isEnded();
+ }
+
+ @Test
+ public void testExecution_failedExecution_exceptionThrown() {
+ doThrow(new BpmnError("7000", "TESTING ERRORS")).when(controllerExecutionDE)
+ .execute(any(DelegateExecution.class));
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("GenericControllerExecutionDE", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("Start_ControllerExecutionDE", "Call_ControllerExecutionDE")
+ .hasNotPassed("End_ControllerExecutionDE");
+ assertThat(pi).isEnded();
+ }
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionTest.java
new file mode 100644
index 0000000000..c2aa3af721
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/GenericControllerExecutionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.bpmn.subprocess;
+
+import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Test;
+import org.onap.so.bpmn.BaseBPMNTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+
+
+public class GenericControllerExecutionTest extends BaseBPMNTest {
+
+ @Test
+ public void testExecution_validInput_expectedExecution() {
+
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("GenericControllerExecution", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("Start_ControllerExecutionBB", "Call_ControllerExecutionBB",
+ "End_ControllerExecutionBB");
+ assertThat(pi).isEnded();
+ }
+
+ @Test
+ public void testExecution_failedExecution_exceptionThrown() {
+ doThrow(new BpmnError("7000", "TESTING ERRORS")).when(controllerExecutionBB)
+ .execute(any(BuildingBlockExecution.class));
+ ProcessInstance pi = runtimeService.startProcessInstanceByKey("GenericControllerExecution", variables);
+ assertThat(pi).isNotNull();
+ assertThat(pi).isStarted().hasPassedInOrder("Start_ControllerExecutionBB", "Call_ControllerExecutionBB")
+ .hasNotPassed("End_ControllerExecutionBB");
+ assertThat(pi).isEnded();
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java
new file mode 100644
index 0000000000..0de211bd7d
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.decisionpoint.api;
+
+import java.util.Map;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+
+/**
+ * This class is used to represent the Context used by {@ref ControllerRunnable}.
+ */
+public class ControllerContext<T> {
+
+ /**
+ * Action to be executed against controller.
+ *
+ * e.g, healthcheck, scaleout, config-assign
+ *
+ * Action is case insensitive.
+ */
+ private String controllerAction;
+
+ /**
+ * Controller actor.
+ *
+ * e.g., CDS, SDNC, APPC.
+ *
+ * actor name is case insensitive.
+ */
+ private String controllerActor;
+
+ /**
+ * scope: PNF, VNF, VF.
+ */
+ private String controllerScope;
+
+ /**
+ * Execution context, buildingblockExecution or DelegateExecution.
+ */
+ private T execution;
+
+ public ControllerContext() {}
+
+ public void setExecution(T execution) {
+ this.execution = execution;
+ }
+
+ public T getExecution() {
+ return execution;
+ }
+
+ public String getControllerAction() {
+ return controllerAction;
+ }
+
+ public void setControllerAction(String controllerAction) {
+ this.controllerAction = controllerAction;
+ }
+
+ public String getControllerActor() {
+ return controllerActor;
+ }
+
+ public void setControllerActor(String controllerActor) {
+ this.controllerActor = controllerActor;
+ }
+
+ public String getControllerScope() {
+ return controllerScope;
+ }
+
+ public void setControllerScope(String controllerScope) {
+ this.controllerScope = controllerScope;
+ }
+
+ public String toString() {
+ return "Controller context for actor: " + controllerActor + ", action: " + controllerAction + ",scope: "
+ + controllerScope;
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java
new file mode 100644
index 0000000000..670f4d399e
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.decisionpoint.api;
+
+/**
+ * the ControllerRunnable interface should be implemented by any class intended to execute against controller northbound
+ * interface.
+ *
+ */
+public interface ControllerRunnable<T> {
+
+ /**
+ * This method is used to decide whether the implementation is to serve the controller northbound interface.
+ *
+ * @param context {@link ControllerContext} is used as the input to the execution.
+ * @return
+ */
+ Boolean understand(final ControllerContext<T> context);
+
+ /**
+ * this method is used to check whether the controller Northbound interface is ready to use.
+ *
+ * @param context {@link ControllerContext} is used as the input to the execution.
+ * @return True if the controller is ready to use or return false.
+ */
+ Boolean ready(final ControllerContext<T> context);
+
+ /**
+ * This method is used to set up the context so it can be used to run against the controller NB.
+ */
+ void prepare(final ControllerContext<T> context);
+
+ /**
+ * This method is used to run against the controller northbound interface.
+ *
+ * @param context {@link ControllerContext} is used as the input to the execution.
+ */
+ void run(final ControllerContext<T> context);
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java
new file mode 100644
index 0000000000..98bab2c1ed
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.api.controller;
+
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+
+/**
+ * This interface is used by {@link ControllerRunnable} to prepare the Context.
+ *
+ * The interface should be implementation by controller preparation instance to configure the context required for
+ * execution.
+ */
+public interface ControllerPreparable<T> {
+
+ /**
+ * This method is used to decide whether the implementation is used to configure the {@link ControllerContext}.
+ *
+ * @param controllerContext
+ * @return
+ */
+ boolean understand(final ControllerContext<T> controllerContext);
+
+ /**
+ * This method is used to prepare the {@link ControllerContext}.
+ *
+ * @param controllerContext
+ */
+ void prepare(final ControllerContext<T> controllerContext);
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java
index ee86ca4292..37b9376e14 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java
@@ -1,15 +1,20 @@
-/*
- * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
- * Foundation. ================================================================================ 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
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ * 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.
*
- * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
package org.onap.so.bpmn.infrastructure.pnf.delegate;
@@ -17,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CONTROLLER_ACTOR;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO;
@@ -75,6 +81,7 @@ public class ConfigCheckerDelegate implements JavaDelegate {
delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID,
pnfResourceCustomization.getModelCustomizationUUID());
delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName());
+ delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor());
} else {
logger.warn("Unable to find the PNF resource customizations of model service UUID: {}",
serviceModelUuid);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
index c16175b8e2..fab3496559 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
@@ -5,6 +5,7 @@
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Modifications Copyright 2018 Nokia
+ * Modifications Copyright 2019 Nordix
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,6 +52,8 @@ public class ExecutionVariableNames {
public static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
public static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
public static final String PRC_INSTANCE_NAME = "PRC_instanceName";
+ public static final String PRC_CONTROLLER_ACTOR = "actor";
+
/**
* Variable used to contain skipPostInstantiationConfiguration flag.
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
index 9a1a7ed628..6d5b2a2f28 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
@@ -16,45 +16,19 @@
<bpmn:sequenceFlow id="SequenceFlow_157of54" name="true" sourceRef="ExclusiveGateway_079gavg" targetRef="EndEvent_0xky46v">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{SkipPostInstantiationConfiguration}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
- <bpmn:serviceTask id="Task_0k2q5vd" name="Prepare Config Assign" camunda:delegateExpression="${PrepareConfigAssignDelegate}">
- <bpmn:incoming>SequenceFlow_0j3pm2g</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_17llfxw</bpmn:outgoing>
- </bpmn:serviceTask>
- <bpmn:sequenceFlow id="SequenceFlow_17llfxw" sourceRef="Task_0k2q5vd" targetRef="Task_1u5pka9" />
- <bpmn:callActivity id="Task_1u5pka9" name="Config Assign&#10;CDS call&#10;" calledElement="AbstractCDSProcessingBB">
- <bpmn:extensionElements>
- <camunda:in source="executionObject" target="executionObject" />
- <camunda:in businessKey="#{execution.processBusinessKey}" />
- <camunda:out source="CDSStatus" target="CDSStatus" />
- </bpmn:extensionElements>
- <bpmn:incoming>SequenceFlow_17llfxw</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0p0aqtx</bpmn:outgoing>
- </bpmn:callActivity>
<bpmn:exclusiveGateway id="ExclusiveGateway_0vtv1wi" default="SequenceFlow_1w4p9f7">
- <bpmn:incoming>SequenceFlow_0p0aqtx</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_07bmtu7</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1owbpsy</bpmn:outgoing>
<bpmn:outgoing>SequenceFlow_1w4p9f7</bpmn:outgoing>
</bpmn:exclusiveGateway>
- <bpmn:sequenceFlow id="SequenceFlow_0p0aqtx" sourceRef="Task_1u5pka9" targetRef="ExclusiveGateway_0vtv1wi" />
- <bpmn:sequenceFlow id="SequenceFlow_1owbpsy" name="Success" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="Task_1uvsz0c">
+ <bpmn:sequenceFlow id="SequenceFlow_1owbpsy" name="Success" sourceRef="ExclusiveGateway_0vtv1wi" targetRef="Task_14cwhgk">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
- <bpmn:sequenceFlow id="SequenceFlow_0jfgn7n" sourceRef="Task_1uvsz0c" targetRef="Task_1a5w1si" />
- <bpmn:callActivity id="Task_1a5w1si" name="Config Deploy&#10;CDS call&#10;" calledElement="AbstractCDSProcessingBB">
- <bpmn:extensionElements>
- <camunda:in businessKey="#{execution.processBusinessKey}" />
- <camunda:in source="executionObject" target="executionObject" />
- <camunda:out source="CDSStatus" target="CDSStatus" />
- </bpmn:extensionElements>
- <bpmn:incoming>SequenceFlow_0jfgn7n</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_08voj55</bpmn:outgoing>
- </bpmn:callActivity>
<bpmn:exclusiveGateway id="ExclusiveGateway_01jwwmc" default="SequenceFlow_0d24h26">
- <bpmn:incoming>SequenceFlow_08voj55</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_02919fh</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1n080up</bpmn:outgoing>
<bpmn:outgoing>SequenceFlow_0d24h26</bpmn:outgoing>
</bpmn:exclusiveGateway>
- <bpmn:sequenceFlow id="SequenceFlow_08voj55" sourceRef="Task_1a5w1si" targetRef="ExclusiveGateway_01jwwmc" />
<bpmn:sequenceFlow id="SequenceFlow_1n080up" name="Success" sourceRef="ExclusiveGateway_01jwwmc" targetRef="EndEvent_0xky46v">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
@@ -74,12 +48,30 @@
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_069mxkg" sourceRef="ConfigurePnfResource_StartEvent" targetRef="Task_1nhh7ob" />
<bpmn:sequenceFlow id="SequenceFlow_1u89rk8" sourceRef="Task_1nhh7ob" targetRef="ExclusiveGateway_079gavg" />
- <bpmn:sequenceFlow id="SequenceFlow_0j3pm2g" name="false" sourceRef="ExclusiveGateway_079gavg" targetRef="Task_0k2q5vd">
+ <bpmn:sequenceFlow id="SequenceFlow_0j3pm2g" name="false" sourceRef="ExclusiveGateway_079gavg" targetRef="Task_0zivzd5">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{!SkipPostInstantiationConfiguration}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
- <bpmn:serviceTask id="Task_1uvsz0c" name="Prepare Config Deploy" camunda:delegateExpression="${PrepareConfigDeployDelegate}">
+ <bpmn:sequenceFlow id="SequenceFlow_07bmtu7" sourceRef="Task_0zivzd5" targetRef="ExclusiveGateway_0vtv1wi" />
+ <bpmn:serviceTask id="Task_0zivzd5" name="ControllerExecutionDE" camunda:delegateExpression="${ControllerExecutionDE}">
+ <bpmn:extensionElements>
+ <camunda:inputOutput>
+ <camunda:inputParameter name="action">config-assign</camunda:inputParameter>
+ <camunda:inputParameter name="scope">pnf</camunda:inputParameter>
+ </camunda:inputOutput>
+ </bpmn:extensionElements>
+ <bpmn:incoming>SequenceFlow_0j3pm2g</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_07bmtu7</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_02919fh" sourceRef="Task_14cwhgk" targetRef="ExclusiveGateway_01jwwmc" />
+ <bpmn:serviceTask id="Task_14cwhgk" name="ControllerExecutionDE" camunda:delegateExpression="${ControllerExecutionDE}">
+ <bpmn:extensionElements>
+ <camunda:inputOutput>
+ <camunda:inputParameter name="action">config-deploy</camunda:inputParameter>
+ <camunda:inputParameter name="scope">pnf</camunda:inputParameter>
+ </camunda:inputOutput>
+ </bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1owbpsy</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_0jfgn7n</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_02919fh</bpmn:outgoing>
</bpmn:serviceTask>
</bpmn:process>
<bpmn:error id="Error_11v8tez" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
@@ -105,44 +97,19 @@
<dc:Bounds x="918" y="158" width="19" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_0h627qv_di" bpmnElement="Task_0k2q5vd">
- <dc:Bounds x="486" y="286" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_17llfxw_di" bpmnElement="SequenceFlow_17llfxw">
- <di:waypoint x="586" y="326" />
- <di:waypoint x="621" y="326" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="CallActivity_0y8mxy4_di" bpmnElement="Task_1u5pka9">
- <dc:Bounds x="621" y="286" width="100" height="80" />
- </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ExclusiveGateway_0vtv1wi_di" bpmnElement="ExclusiveGateway_0vtv1wi" isMarkerVisible="true">
<dc:Bounds x="786" y="301" width="50" height="50" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_0p0aqtx_di" bpmnElement="SequenceFlow_0p0aqtx">
- <di:waypoint x="721" y="326" />
- <di:waypoint x="786" y="326" />
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1owbpsy_di" bpmnElement="SequenceFlow_1owbpsy">
<di:waypoint x="836" y="326" />
- <di:waypoint x="901" y="326" />
+ <di:waypoint x="987" y="326" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="847" y="308" width="43" height="14" />
+ <dc:Bounds x="890" y="308" width="43" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_0jfgn7n_di" bpmnElement="SequenceFlow_0jfgn7n">
- <di:waypoint x="1001" y="326" />
- <di:waypoint x="1066" y="326" />
- </bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="CallActivity_1viph1b_di" bpmnElement="Task_1a5w1si">
- <dc:Bounds x="1066" y="286" width="100" height="80" />
- </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ExclusiveGateway_01jwwmc_di" bpmnElement="ExclusiveGateway_01jwwmc" isMarkerVisible="true">
<dc:Bounds x="1231" y="301" width="50" height="50" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_08voj55_di" bpmnElement="SequenceFlow_08voj55">
- <di:waypoint x="1166" y="326" />
- <di:waypoint x="1231" y="326" />
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1n080up_di" bpmnElement="SequenceFlow_1n080up">
<di:waypoint x="1256" y="301" />
<di:waypoint x="1256" y="176" />
@@ -185,13 +152,24 @@
<bpmndi:BPMNEdge id="SequenceFlow_0j3pm2g_di" bpmnElement="SequenceFlow_0j3pm2g">
<di:waypoint x="426" y="201" />
<di:waypoint x="426" y="326" />
- <di:waypoint x="486" y="326" />
+ <di:waypoint x="551" y="326" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="429" y="261" width="24" height="14" />
+ <dc:Bounds x="471" y="308" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ServiceTask_0vmu4wk_di" bpmnElement="Task_1uvsz0c">
- <dc:Bounds x="901" y="286" width="100" height="80" />
+ <bpmndi:BPMNEdge id="SequenceFlow_07bmtu7_di" bpmnElement="SequenceFlow_07bmtu7">
+ <di:waypoint x="651" y="326" />
+ <di:waypoint x="786" y="326" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_1rqxeyq_di" bpmnElement="Task_0zivzd5">
+ <dc:Bounds x="551" y="286" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_02919fh_di" bpmnElement="SequenceFlow_02919fh">
+ <di:waypoint x="1087" y="326" />
+ <di:waypoint x="1231" y="326" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0lyl5n4_di" bpmnElement="Task_14cwhgk">
+ <dc:Bounds x="987" y="286" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
index 1cd8295fa2..aea06b5fc9 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java
@@ -105,7 +105,6 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest {
}
- @Ignore
@Test
public void workflow_validInput_expectedOuput() throws InterruptedException {
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json
index 66d1a88ee8..422fb41de7 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json
@@ -15,6 +15,7 @@
"blueprintVersion": "1.0.0",
"skipPostInstConf": false,
"creationTimestamp": "2019-03-08T12:00:29.000+0000",
+ "controllerActor": "cds",
"_links": {
"self": {
"href": "http://localhost:41023/pnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002680"
@@ -34,4 +35,4 @@
"href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=5df8b6de-2083-11e7-93ae-92361f002676"
}
}
-} \ No newline at end of file
+}
diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml
index bf129dfc56..d37120b452 100644
--- a/bpmn/so-bpmn-tasks/pom.xml
+++ b/bpmn/so-bpmn-tasks/pom.xml
@@ -13,6 +13,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
+ <grpc.version>1.17.1</grpc.version>
</properties>
<build>
<plugins>
@@ -165,5 +166,11 @@
<version>2.5.1</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-testing</artifactId>
+ <version>${grpc.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java
new file mode 100644
index 0000000000..f3b767a8f1
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/AbstractControllerExecution.java
@@ -0,0 +1,174 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl;
+
+import com.google.common.base.Strings;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Abstract class of the controller execution, it should be extended for the controller execution task.
+ *
+ * @param <T> execution context type, e.g., BuildingBlockExecution or DelegateExecution
+ */
+public abstract class AbstractControllerExecution<T> {
+
+ /**
+ * parameters from the execution context.
+ */
+ protected static final String CONTROLLER_ACTOR_PARAM = "actor";
+ protected static final String CONTROLLER_ACTION_PARAM = "action";
+ protected static final String CONTROLLER_SCOPE_PARAM = "scope";
+ protected static final String RESOURCE_CUSTOMIZATION_UUID_PARAM = "resource_customization_uuid";
+ protected static final String RESOURCE_TYPE_PARAM = "resource_type";
+
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ protected List<ControllerRunnable<T>> availableControllerRunnables;
+
+ @Autowired
+ protected ExceptionBuilder exceptionBuilder;
+
+ /**
+ * Find the {@ref ControllerRunnable} instances understanding the {@ref ControllerContext}.
+ *
+ * Only one instance should be able to understand the context. if more than one or none instances found, return
+ * null.
+ *
+ * @param context controller context
+ * @return Optional of ControllerRunnable instance
+ */
+ protected Optional<ControllerRunnable> getController(ControllerContext<T> context) {
+ List<ControllerRunnable<T>> satisfiedControllers = availableControllerRunnables.stream()
+ .filter(controllerRunnable -> controllerRunnable.understand(context)).collect(Collectors.toList());
+
+ if (logger.isDebugEnabled()) {
+ for (ControllerRunnable<T> satisfiedController : satisfiedControllers) {
+ logger.debug("{} controllerRunnable understands the context", satisfiedController.getClass().getName());
+ }
+ }
+
+ /**
+ * Make sure only one {@ref ControllerRunnable} instance understands the context or else return Null.
+ */
+ if (satisfiedControllers.size() == 1) {
+ return Optional.of(satisfiedControllers.get(0));
+ } else if (satisfiedControllers.isEmpty()) {
+ logger.warn("Can NOT find any ControllerRunnable for context: {}", context);
+ } else if (satisfiedControllers.size() > 1) {
+ logger.warn(
+ "Found {} instances understanding the context: {}, please make sure only 1 instance understands it",
+ satisfiedControllers.size(), context);
+ }
+
+ return Optional.empty();
+ }
+
+ /**
+ * Build the {@ref ControllerContext} context based on execution context.
+ *
+ * @param t execution context instance, e.g., BuildingBlockExecution or DelegateExecution instance
+ * @return controller context instance of the execution context type
+ */
+ protected ControllerContext<T> buildControllerContext(final T t) {
+ String controllerAction = getParameterFromExecution(t, CONTROLLER_ACTION_PARAM);
+ String controllerScope = getParameterFromExecution(t, CONTROLLER_SCOPE_PARAM);
+ String resourceCustomizationUuid = getParameterFromExecution(t, RESOURCE_CUSTOMIZATION_UUID_PARAM);
+ String controllerActor = getControllerActor(t, controllerScope, resourceCustomizationUuid, controllerAction);
+ ControllerContext<T> controllerContext = new ControllerContext<>();
+ controllerContext.setExecution(t);
+ controllerContext.setControllerAction(controllerAction);
+ controllerContext.setControllerActor(controllerActor);
+ controllerContext.setControllerScope(controllerScope);
+ return controllerContext;
+ }
+
+ /**
+ * Retrieve the controller actor.
+ *
+ * @param t execution context instance, e.g., BuildingBlockExecution or DelegateExecution instance
+ * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
+ * @param resourceCustomizationUuid resource customization UUID, e.g, pnfCustomizationUuid, vnfCustomizationUuid
+ * @param controllerAction controller action, e.g, configAssign, configDeploy
+ * @return controller actor
+ */
+ protected abstract String getControllerActor(T t, String controllerScope, String resourceCustomizationUuid,
+ String controllerAction);
+
+ /**
+ * Controller execution based on the Controller Context.
+ *
+ * @param controllerContext ControllerContext object
+ */
+ public abstract void controllerExecute(final ControllerContext<T> controllerContext);
+
+ /**
+ * Retrieve the parameter value as String from the execution context.
+ *
+ * @param t execution context instance, e.g., BuildingBlockExecution or DelegateExecution instance
+ * @param parameterName parameter name to be retrieved
+ * @return String value of the parameter
+ */
+ protected abstract String getParameterFromExecution(final T t, String parameterName);
+
+ /**
+ * Check whether the controller actor value is SO ref value, i.e, equals to SO-REF-DATA.
+ *
+ * @param controllerActor controller actor, e.g, SO-REF-DATA, SDNC, CDS
+ * @return true if the controller actor is SO-REF-DATA, else return false
+ */
+ protected boolean isSoRefControllerActor(final String controllerActor) {
+ return !Strings.isNullOrEmpty(controllerActor) && controllerActor.equalsIgnoreCase("SO-REF-DATA");
+ }
+
+ /**
+ * Check whether the controller scope is PNF resource related.
+ *
+ * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
+ * @return true if the controller scope is pnf, else return false
+ */
+ protected boolean isPnfResourceScope(final String controllerScope) {
+ return ("pnf").equalsIgnoreCase(controllerScope);
+ }
+
+ /**
+ * Check whether the controller scope is VNF resource related.
+ *
+ * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
+ * @return true if the controller scope is vnf or vfModule, else return false
+ */
+ protected boolean isVnfResourceScope(final String controllerScope) {
+ if (Strings.isNullOrEmpty(controllerScope)) {
+ return false;
+ }
+ if (controllerScope.toLowerCase().startsWith("vnf") || controllerScope.equalsIgnoreCase("vfmodule")) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java
new file mode 100644
index 0000000000..39a695b0b6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBB.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock;
+
+import com.google.common.base.Strings;
+import java.util.Optional;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.AbstractControllerExecution;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is used for {@ref BuildingBlockExecution} API based execution.
+ *
+ * it decides which controller implementation to use based on the parameters, like actor, scope, action.
+ *
+ * The following parameters are expected in the {@ref BuildingBlockExecution} context,
+ * <ul>
+ * <li>action: action to be executed</li>
+ * <li>scope: type of the resource, i.e, pnf, vnf, vf</li>
+ * <li>resource_customization_uuid: resource customization UUID</li>
+ * <li>resource_type: resource type, optional. It's used to find the controller from controller_selection_reference
+ * table. Same as VNF_TYPE in the table</li>
+ * </ul>
+ */
+@Component
+public class ControllerExecutionBB extends AbstractControllerExecution<BuildingBlockExecution> {
+
+ @Autowired
+ protected CatalogDbClient catalogDbClient;
+
+ public void execute(final BuildingBlockExecution execution) {
+ ControllerContext<BuildingBlockExecution> controllerContext = buildControllerContext(execution);
+ controllerExecute(controllerContext);
+ }
+
+ @Override
+ protected String getParameterFromExecution(BuildingBlockExecution execution, String parameterName) {
+ Object object = execution.getVariable(parameterName);
+ if (object != null) {
+ String paramValue = String.valueOf(object);
+ logger.debug("parameterName: {}, parameterValue: {}", parameterName, paramValue);
+ return paramValue;
+ }
+ return "";
+ }
+
+ /**
+ * this method is used to get the controller actor, there could be few places to get the actor(ordered by priority),
+ *
+ * <ol>
+ * <li>Execution Context, i.e, BuildingBlockExecution</li>
+ * <li>Resource customization table, pnf_resource_customization for PNF or vnf_resource_customization for VNF</li>
+ * <li>controller_selection_reference, resource_type and action will be used to fetch from this table</li>
+ * </ol>
+ *
+ * @param execution BuildingBlockExecution instance
+ * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
+ * @param resourceCustomizationUuid resource customization UUID, e.g, pnfCustomizationUuid, vnfCustomizationUuid
+ * @param controllerAction controller action, e.g, configAssign, configDeploy
+ * @return controller actor name
+ */
+ @Override
+ protected String getControllerActor(BuildingBlockExecution execution, String controllerScope,
+ String resourceCustomizationUuid, String controllerAction) {
+
+ /**
+ * Firstly, check the execution context for actor parameter.
+ */
+ String controllerActor = getParameterFromExecution(execution, CONTROLLER_ACTOR_PARAM);
+
+ /**
+ * If no meaningful controller actor value found in the execution context and the value is not SO-REF-DATA.
+ */
+ if (Strings.isNullOrEmpty(controllerActor) && !isSoRefControllerActor(controllerActor)) {
+
+ /**
+ * For BuildingBlockExecution, we should try to get the resource information from Cached metadata.
+ *
+ * As the current cached metadata doesn't support controller actor, we use the
+ * {@link org.onap.so.db.catalog.client.CatalogDbClient} to fetch information. Once the change is done in
+ * cached metadata, this part should be refactored as well.
+ */
+ if (isPnfResourceScope(controllerScope)) {
+ PnfResourceCustomization pnfResourceCustomization =
+ catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
+ controllerActor = pnfResourceCustomization.getControllerActor();
+ } else if (isVnfResourceScope(controllerScope)) {
+ VnfResourceCustomization vnfResourceCustomization =
+ catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
+ controllerActor = vnfResourceCustomization.getControllerActor();
+ } else {
+ logger.warn("Unrecognized scope: {}", controllerScope);
+ }
+ }
+
+ /**
+ * Lastly, can NOT find the controller actor information from resource customization table or the return value
+ * is SO-REF-DATA.
+ */
+ if (Strings.isNullOrEmpty(controllerActor) || isSoRefControllerActor(controllerActor)) {
+ String resourceType = getParameterFromExecution(execution, RESOURCE_TYPE_PARAM);
+ ControllerSelectionReference reference = catalogDbClient
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(resourceType, controllerAction);
+
+ controllerActor = reference.getControllerName();
+ }
+ return controllerActor;
+ }
+
+ @Override
+ public void controllerExecute(ControllerContext<BuildingBlockExecution> controllerContext) {
+ Optional<ControllerRunnable> optional = getController(controllerContext);
+ if (optional.isPresent()) {
+ ControllerRunnable controller = optional.get();
+ if (controller.ready(controllerContext)) {
+ controller.prepare(controllerContext);
+ controller.run(controllerContext);
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(controllerContext.getExecution(), 9001,
+ "Controller is NOT Ready for the action", ONAPComponents.SO);
+ }
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(controllerContext.getExecution(), 9000,
+ "Unable to find the controller implementation", ONAPComponents.SO);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/LcmControllerBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/LcmControllerBB.java
new file mode 100644
index 0000000000..d7f6808b75
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/LcmControllerBB.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller;
+
+import java.util.List;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * This class should be extended by LCM api based controllers.
+ */
+public abstract class LcmControllerBB implements ControllerRunnable<BuildingBlockExecution> {
+
+ protected Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ protected ExceptionBuilder exceptionUtil;
+
+ @Autowired(required = false)
+ protected List<ControllerPreparable<BuildingBlockExecution>> prepareList;
+
+ @Autowired
+ protected ApplicationControllerAction client;
+
+ @Override
+ public void prepare(ControllerContext<BuildingBlockExecution> context) {
+ prepareList.stream().filter(prepare -> prepare.understand(context))
+ .forEach(prepare -> prepare.prepare(context));
+ }
+
+ @Override
+ public void run(ControllerContext<BuildingBlockExecution> context) {
+ callLcmClient(context);
+ }
+
+ /**
+ * This method is used to execute the LCM action by calling LCM client, appc Client or SDNC client.
+ *
+ * @return error code
+ */
+ protected abstract int callLcmClient(ControllerContext<BuildingBlockExecution> context);
+
+ protected abstract int getErrorCode();
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBB.java
new file mode 100644
index 0000000000..8650994da6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBB.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.appc;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.LcmControllerBB;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This implementation of {@link ControllerRunnable} is created to demonstrate how to support Appc based controller.
+ */
+@Component
+public class AppcControllerBB extends LcmControllerBB {
+
+ private static final int APPC_ERROR_CODE = 1002;
+
+ @Autowired
+ private ApplicationControllerAction client;
+
+ @Override
+ public Boolean understand(ControllerContext<BuildingBlockExecution> context) {
+ return context.getControllerActor().equalsIgnoreCase("appc");
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<BuildingBlockExecution> context) {
+ return true;
+ }
+
+ /**
+ * This method is left empty intentionally. If you are planning to use the Appc Controller, please implement here.
+ *
+ * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator},
+ * {@ref ApplicationControllerClient} or create your own Appc Client proxy.
+ */
+ @Override
+ protected int callLcmClient(ControllerContext<BuildingBlockExecution> context) {
+ return 0;
+ }
+
+ @Override
+ protected int getErrorCode() {
+ return APPC_ERROR_CODE;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBB.java
new file mode 100644
index 0000000000..6baf881be8
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBB.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc;
+
+import java.util.Arrays;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.LcmControllerBB;
+import org.springframework.stereotype.Component;
+
+/**
+ * This implementation of {@link ControllerRunnable} is created to demonstrate how to support SDNC based controller.
+ *
+ * For demo purpose, the following actions are supported, UpgradePreCheck UpgradeSoftware UpgradePostCheck, all of these
+ * actions are appc based actions and they need to be refactored to proper SDNC LCM actions.
+ */
+@Component
+public class SdncControllerBB extends LcmControllerBB {
+
+ private static final String[] supportedActions = new String[] {};
+
+ private static final int SDNC_ERROR_CODE = 1002;
+
+ @Override
+ public Boolean understand(ControllerContext<BuildingBlockExecution> context) {
+ return context.getControllerActor().equalsIgnoreCase("sdnc");
+ }
+
+ private boolean isActionSupported(ControllerContext<BuildingBlockExecution> context) {
+ return Arrays.stream(supportedActions).anyMatch(action -> action.equals(context.getControllerAction()));
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<BuildingBlockExecution> context) {
+ return true;
+ }
+
+ /**
+ * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here.
+ *
+ * You can use the Appc Client proxy, like, {@ref ApplicationControllerAction}
+ * {@ref ApplicationControllerOrchestrator} {@ref ApplicationControllerClient}
+ *
+ * Or create your own SDNC Client proxy.
+ */
+ @Override
+ protected int callLcmClient(ControllerContext<BuildingBlockExecution> context) {
+ return 0;
+ }
+
+ @Override
+ protected int getErrorCode() {
+ return SDNC_ERROR_CODE;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncBB.java
new file mode 100644
index 0000000000..dd75107b73
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncBB.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc.prepare;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * This abstract class should be extended by all the SDNC based {@ControllerPreparable}. It defines some common
+ * behavior.
+ */
+public abstract class PrepareSdncBB implements ControllerPreparable<BuildingBlockExecution> {
+
+ protected Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ protected ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ protected ExtractPojosForBB extractPojosForBB;
+
+ public boolean understand(final ControllerContext<BuildingBlockExecution> controllerContext) {
+ return controllerContext.getControllerActor().equalsIgnoreCase("sdnc");
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBB.java
new file mode 100644
index 0000000000..c659290f28
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/prepare/PrepareSdncUpgradePreCheckPnfBB.java
@@ -0,0 +1,60 @@
+/*
+ * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
+ * ================================================================================ 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc.prepare;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is used to prepare the {@ref ControllerContext} for SDNC UpgradePreCheck action.
+ */
+@Component
+public class PrepareSdncUpgradePreCheckPnfBB extends PrepareSdncBB {
+
+ @Override
+ public boolean understand(ControllerContext<BuildingBlockExecution> controllerContext) {
+ return super.understand(controllerContext) && controllerContext.getControllerAction().equals("UpgradePreCheck")
+ && controllerContext.getControllerScope().equalsIgnoreCase("pnf");
+ }
+
+ @Override
+ public void prepare(ControllerContext<BuildingBlockExecution> controllerContext) {
+
+ String payload = controllerContext.getExecution().getVariable("payload");
+ String actualPayLoad = constructPayload(payload, controllerContext.getControllerAction());
+
+ controllerContext.getExecution().setVariable("payload", actualPayLoad);
+ }
+
+ private String constructPayload(String payload, String action) {
+
+ JSONObject jsonObject = new JSONObject(payload);
+ if (jsonObject.has("action")) {
+ JSONArray jsonArray = jsonObject.getJSONArray("action");
+
+ for (int i = 0; i < jsonArray.length(); i++) {
+ JSONObject jsonObject1 = jsonArray.getJSONObject(i);
+ if (jsonObject1.has(action)) {
+ return jsonObject1.toString();
+ }
+ }
+ }
+ return payload;
+ }
+}
+
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDE.java
new file mode 100644
index 0000000000..0458d3c103
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDE.java
@@ -0,0 +1,148 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
+
+import com.google.common.base.Strings;
+import java.util.Optional;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.AbstractControllerExecution;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is used for camunda {@ref DelegateExecution} API based controller execution.
+ *
+ * The following parameters are expected in the {@ref DelegateExecution} context,
+ *
+ * <ul>
+ * <li>action: action to be executed</li>
+ * <li>scope: type of the resource, i.e, pnf, vnf, vf</li>
+ * <li>resource_customization_uuid: resource customization UUID</li>
+ * <li>resource_type: resource type, optional. It's used to find the controller from controller_selection_reference
+ * table. Same as VNF_TYPE in the table</li>
+ * </ul>
+ */
+@Component
+public class ControllerExecutionDE extends AbstractControllerExecution<DelegateExecution> implements JavaDelegate {
+
+ @Autowired
+ protected CatalogDbClient catalogDbClient;
+
+ @Override
+ public void execute(final DelegateExecution execution) {
+ ControllerContext<DelegateExecution> controllerContext = buildControllerContext(execution);
+ controllerExecute(controllerContext);
+ }
+
+ /**
+ * this method is used to get the controller actor, there could be few places to get the actor(ordered by priority),
+ *
+ * <ol>
+ * <li>Execution Context, i.e, DelegateExecution</li>
+ * <li>Resource customization table, pnf_resource_customization for PNF or vnf_resource_customization for VNF</li>
+ * <li>controller_selection_reference, resource_type and action will be used to fetch from this table</li>
+ * </ol>
+ *
+ * @param execution DelegateExecution instance
+ * @param controllerScope controller scope, e.g, pnf, vnf, vfModule
+ * @param resourceCustomizationUuid resource customization UUID, e.g, pnfCustomizationUuid, vnfCustomizationUuid
+ * @param controllerAction controller action, e.g, configAssign, configDeploy
+ * @return controller actor
+ */
+ protected String getControllerActor(DelegateExecution execution, String controllerScope,
+ String resourceCustomizationUuid, String controllerAction) {
+
+ /**
+ * Firstly, check the execution context for actor parameter.
+ */
+ String controllerActor = getParameterFromExecution(execution, CONTROLLER_ACTOR_PARAM);
+
+ /**
+ * If no meaningful controller actor value found in the execution context and the value is not SO-REF-DATA.
+ */
+ if (Strings.isNullOrEmpty(controllerActor) && !isSoRefControllerActor(controllerActor)) {
+
+ /**
+ * secondly, if no meaningful actor from execution context, getting from resource table in database.
+ */
+ if (isPnfResourceScope(controllerScope)) {
+ PnfResourceCustomization pnfResourceCustomization =
+ catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
+ controllerActor = pnfResourceCustomization.getControllerActor();
+ } else if (isVnfResourceScope(controllerScope)) {
+ VnfResourceCustomization vnfResourceCustomization =
+ catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(resourceCustomizationUuid);
+ controllerActor = vnfResourceCustomization.getControllerActor();
+ } else {
+ logger.warn("Unrecognized scope: {}", controllerScope);
+ }
+ }
+
+ /**
+ * Lastly, can NOT find the controller actor information from resource customization table or value is
+ * SO-REF-DATA
+ */
+ if (Strings.isNullOrEmpty(controllerActor) || isSoRefControllerActor(controllerActor)) {
+ String resourceType = getParameterFromExecution(execution, RESOURCE_TYPE_PARAM);
+ ControllerSelectionReference reference = catalogDbClient
+ .getControllerSelectionReferenceByVnfTypeAndActionCategory(resourceType, controllerAction);
+ controllerActor = reference.getControllerName();
+ }
+
+ return controllerActor;
+ }
+
+ @Override
+ public void controllerExecute(ControllerContext<DelegateExecution> controllerContext) {
+ Optional<ControllerRunnable> optional = getController(controllerContext);
+
+ if (optional.isPresent()) {
+ ControllerRunnable controller = optional.get();
+ if (controller.ready(controllerContext)) {
+ controller.prepare(controllerContext);
+ controller.run(controllerContext);
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(controllerContext.getExecution(), 9001,
+ "Controller is NOT Ready for the action", ONAPComponents.SO);
+ }
+ } else {
+ exceptionBuilder.buildAndThrowWorkflowException(controllerContext.getExecution(), 9000,
+ "Unable to find the controller implementation", ONAPComponents.SO);
+ }
+ }
+
+ @Override
+ protected String getParameterFromExecution(DelegateExecution execution, String parameterName) {
+ if (execution.hasVariable(parameterName)) {
+ String paramValue = String.valueOf(execution.getVariable(parameterName));
+ logger.debug("parameterName: {}, parameterValue: {}", parameterName, paramValue);
+ return paramValue;
+ } else {
+ return "";
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
new file mode 100644
index 0000000000..95e270a071
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller;
+
+import java.util.List;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * This abstract class implements {@link ControllerRunnable} used for {@link DelegateExecution} API based LCM
+ * controller.
+ */
+public abstract class LcmControllerDE implements ControllerRunnable<DelegateExecution> {
+
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ protected ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ protected List<ControllerPreparable<DelegateExecution>> prepareList;
+
+ @Autowired
+ protected ApplicationControllerAction client;
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> context) {
+ prepareList.stream().filter(prepare -> prepare.understand(context))
+ .forEach(prepare -> prepare.prepare(context));
+ }
+
+ @Override
+ public void run(ControllerContext<DelegateExecution> context) {
+ callLcmClient(context);
+ }
+
+ /**
+ * This method is used to execute the LCM action by calling LCM client, appc Client or SDNC client.
+ *
+ * @return error code
+ */
+ protected abstract int callLcmClient(ControllerContext<DelegateExecution> context);
+
+ protected abstract int getErrorCode();
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDE.java
new file mode 100644
index 0000000000..7ebd16e561
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDE.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.appc;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is created to demonstrate how to support {@link DelegateExecution} API based APPC controller.
+ *
+ * Function wise, it's similar as {@ref AppcClient} groovy code.
+ */
+@Component
+public class AppcControllerDE extends LcmControllerDE {
+
+ private static final int APPC_DELEGATE_EXECUTION_ERROR_CODE = 1102;
+
+ @Override
+ public Boolean understand(ControllerContext<DelegateExecution> context) {
+ return context.getControllerActor().equalsIgnoreCase("appc");
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<DelegateExecution> context) {
+ return true;
+ }
+
+ /**
+ * This method is left empty intentionally. If you are planning to use the Appc Controller, please implement here.
+ *
+ * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator},
+ * {@ref ApplicationControllerClient} or create your own Appc Client proxy.
+ */
+ @Override
+ protected int callLcmClient(ControllerContext<DelegateExecution> context) {
+ return 0;
+ }
+
+ @Override
+ protected int getErrorCode() {
+ return APPC_DELEGATE_EXECUTION_ERROR_CODE;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java
new file mode 100644
index 0000000000..6b0cbc0396
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.cds;
+
+import java.util.List;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This implementation of {@ref ControllerRunnable} is used for Self service, i.e, blueprint based Controller.
+ */
+@Component
+public class CdsControllerDE extends AbstractCDSProcessingBBUtils implements ControllerRunnable<DelegateExecution> {
+
+ @Autowired(required = false)
+ private List<ControllerPreparable<DelegateExecution>> prepareList;
+
+ @Override
+ public Boolean understand(ControllerContext<DelegateExecution> context) {
+ return context.getControllerActor().equalsIgnoreCase("cds");
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<DelegateExecution> context) {
+ return true;
+ }
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> context) {
+ prepareList.stream().filter(prepare -> prepare.understand(context))
+ .forEach(prepare -> prepare.prepare(context));
+ }
+
+ @Override
+ public void run(ControllerContext<DelegateExecution> context) {
+ DelegateExecution execution = context.getExecution();
+ constructExecutionServiceInputObject(execution);
+ sendRequestToCDSClient(execution);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigAssignDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigAssignDE.java
new file mode 100644
index 0000000000..b0da075e7e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigAssignDE.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.cds.prepare;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.PrepareConfigAssignDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class implements {@link ControllerPreparable} interface and is used to set up the context for PNF config-assign
+ * action.
+ */
+@Component
+public class PreparePnfConfigAssignDE implements ControllerPreparable<DelegateExecution> {
+
+ @Autowired
+ private PrepareConfigAssignDelegate prepareConfigAssignDelegate;
+
+ @Override
+ public boolean understand(ControllerContext<DelegateExecution> controllerContext) {
+ return controllerContext.getControllerActor().equalsIgnoreCase("cds")
+ && controllerContext.getControllerAction().equalsIgnoreCase("config-assign")
+ && controllerContext.getControllerScope().equalsIgnoreCase("pnf");
+ }
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> controllerContext) {
+ prepareConfigAssignDelegate.execute(controllerContext.getExecution());
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigDeployDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigDeployDE.java
new file mode 100644
index 0000000000..b88da2ed39
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/prepare/PreparePnfConfigDeployDE.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.cds.prepare;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.bpmn.infrastructure.pnf.delegate.PrepareConfigDeployDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class implements {@link ControllerPreparable} interface and is used to set up the context for PNF config-deploy
+ * action.
+ */
+@Component
+public class PreparePnfConfigDeployDE implements ControllerPreparable<DelegateExecution> {
+
+ @Autowired
+ private PrepareConfigDeployDelegate prepareConfigDeployDelegate;
+
+ @Override
+ public boolean understand(ControllerContext<DelegateExecution> controllerContext) {
+ return controllerContext.getControllerActor().equalsIgnoreCase("cds")
+ && controllerContext.getControllerAction().equalsIgnoreCase("config-deploy")
+ && controllerContext.getControllerScope().equalsIgnoreCase("pnf");
+ }
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> controllerContext) {
+ prepareConfigDeployDelegate.execute(controllerContext.getExecution());
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
new file mode 100644
index 0000000000..db0d402f6e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class is created to demonstrate how to support {@link DelegateExecution} API based SDNC controller.
+ *
+ * Function wise, it's similar to the Appc Controller, like in the AppcClient groovy code.
+ */
+@Component
+public class SdncControllerDE extends LcmControllerDE {
+
+ private static final int SDNC_DELEGATE_EXECUTION_ERROR_CODE = 1103;
+
+ @Override
+ public Boolean understand(ControllerContext<DelegateExecution> context) {
+ return context.getControllerActor().equalsIgnoreCase("sdnc");
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<DelegateExecution> context) {
+ return true;
+ }
+
+ /**
+ * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here.
+ *
+ * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator},
+ * {@ref ApplicationControllerClient} or create your own SDNC Client proxy.
+ */
+ @Override
+ protected int callLcmClient(ControllerContext<DelegateExecution> context) {
+ return 0;
+ }
+
+ @Override
+ protected int getErrorCode() {
+ return SDNC_DELEGATE_EXECUTION_ERROR_CODE;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java
new file mode 100644
index 0000000000..e089da6ac7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/GrpcNettyServer.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so;
+
+import io.grpc.ServerBuilder;
+import io.grpc.stub.StreamObserver;
+import io.grpc.testing.GrpcCleanupRule;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.annotation.PostConstruct;
+import org.junit.Rule;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class GrpcNettyServer extends BluePrintProcessingServiceImplBase {
+
+ private static final Logger logger = LoggerFactory.getLogger(GrpcNettyServer.class);
+
+ @Value("${cds.endpoint}")
+ private String host;
+
+ @Value("${cds.port}")
+ private String port;
+
+ @Rule
+ public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
+
+ private final CountDownLatch allRequestsDelivered = new CountDownLatch(1);
+ private final AtomicReference<StreamObserver<ExecutionServiceOutput>> responseObserverRef = new AtomicReference<>();
+ private final List<ExecutionServiceInput> detailedMessages = new ArrayList<>();
+
+ @PostConstruct
+ public void start() throws IOException {
+
+ final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = new BluePrintProcessingServiceImplBase() {
+ @Override
+ public StreamObserver<ExecutionServiceInput> process(
+ StreamObserver<ExecutionServiceOutput> responseObserver) {
+
+ responseObserverRef.set(responseObserver);
+
+ StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {
+ @Override
+ public void onNext(ExecutionServiceInput message) {
+ detailedMessages.add(message);
+ logger.info("Message received: {}", message);
+ ExecutionServiceOutput executionServiceOutput = ExecutionServiceOutput.newBuilder()
+ .setActionIdentifiers(message.getActionIdentifiers())
+ .setStatus(Status.newBuilder().setEventType(EventType.EVENT_COMPONENT_EXECUTED).build())
+ .build();
+
+ responseObserverRef.get().onNext(executionServiceOutput);
+ logger.info("Message sent: {}", executionServiceOutput);
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ responseObserverRef.get().onError(t);
+ }
+
+ @Override
+ public void onCompleted() {
+ allRequestsDelivered.countDown();
+ responseObserverRef.get().onCompleted();
+ }
+ };
+
+ return requestObserver;
+ }
+ };
+ grpcCleanup.register(ServerBuilder.forPort(Integer.valueOf(port)).directExecutor()
+ .addService(blueprintPrcessorImpl).build().start());
+
+ }
+
+ public List<ExecutionServiceInput> getDetailedMessages() {
+ return this.detailedMessages;
+ }
+
+ public void cleanMessage() {
+ this.detailedMessages.clear();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java
new file mode 100644
index 0000000000..0f9b4d9012
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTest.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.MockControllerBB.TEST_ACTION;
+import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.MockControllerBB.TEST_ACTOR;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ControllerExecutionBB.class, MockControllerBB.class, ExceptionBuilder.class})
+public class ControllerExecutionBBTest {
+
+ private static final String ACTOR_PARAM = "actor";
+ private static final String ACTION_PARAM = "action";
+ private static final String RESOURCE_TYPE_PARAM = "resource_type";
+
+ private static final String TEST_RESOURCE_CUSTOMIZATION_UUID = "68dc9a92-214c-11e7-93ae-92361f002680";
+ private static final String TEST_CATALOGDB_CONTROLLER_ACTOR = "cds";
+ private static final String TEST_RESOURCE_TYPE = "Firewall";
+ private static final String TEST_CONTROLLER_REFERENCE_ACTOR = "sdnc";
+ private static final String TEST_SCOPE = "pnf";
+
+ @Autowired
+ private ControllerExecutionBB controllerExecutionBB;
+
+ @MockBean
+ private BuildingBlockExecution execution;
+
+ @MockBean
+ private CatalogDbClient client;
+
+ @MockBean
+ private PnfResourceCustomization pnfResourceCustomization;
+
+ @MockBean
+ private VnfResourceCustomization vnfResourceCustomization;
+
+ @MockBean
+ private ControllerSelectionReference controllerSelectionReference;
+
+ @Before
+ public void setUp() {
+ when(execution.getVariable(ACTOR_PARAM)).thenReturn(TEST_ACTOR);
+ when(execution.getVariable(ACTION_PARAM)).thenReturn(MockControllerBB.TEST_ACTION);
+
+ when(pnfResourceCustomization.getControllerActor()).thenReturn(TEST_CATALOGDB_CONTROLLER_ACTOR);
+ when(client.getPnfResourceCustomizationByModelCustomizationUUID(TEST_RESOURCE_CUSTOMIZATION_UUID))
+ .thenReturn(pnfResourceCustomization);
+
+ when(execution.getVariable(RESOURCE_TYPE_PARAM)).thenReturn(TEST_RESOURCE_TYPE);
+ when(controllerSelectionReference.getControllerName()).thenReturn(TEST_CONTROLLER_REFERENCE_ACTOR);
+ when(client.getControllerSelectionReferenceByVnfTypeAndActionCategory(TEST_RESOURCE_TYPE, TEST_ACTION))
+ .thenReturn(controllerSelectionReference);
+ }
+
+ @Test
+ public void testExecution_validInput_expectedOutput() {
+ controllerExecutionBB.execute(execution);
+ verify(execution).setVariable("stage", "ready");
+ verify(execution).setVariable("stage", "prepare");
+ verify(execution).setVariable("stage", "run");
+ }
+
+ @Test
+ public void testGetController_availableInExecutionContext_returnFromExecutionContext() {
+ String controllerActor = controllerExecutionBB.getControllerActor(execution, TEST_SCOPE, "", TEST_ACTION);
+ assertEquals(TEST_ACTOR, controllerActor);
+ }
+
+ @Test
+ public void testGetController_soRefDataInExecutionContext_returnFromControllerReference() {
+ when(execution.getVariable(ACTOR_PARAM)).thenReturn("so-ref-data");
+ String controllerActor = controllerExecutionBB.getControllerActor(execution, TEST_SCOPE, "", TEST_ACTION);
+ assertEquals(TEST_CONTROLLER_REFERENCE_ACTOR, controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContext_returnFromCatalogdb() {
+ when(execution.getVariable(ACTOR_PARAM)).thenReturn("");
+ String controllerActor = controllerExecutionBB.getControllerActor(execution, TEST_SCOPE,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+ assertEquals("The controller actor should be the same as in the catalogdb", TEST_CATALOGDB_CONTROLLER_ACTOR,
+ controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContextAndSoRefDataInCatalogdb_returnFromControllerReference() {
+ when(execution.getVariable(ACTOR_PARAM)).thenReturn("");
+ when(pnfResourceCustomization.getControllerActor()).thenReturn("SO-REF-DATA");
+ String controllerActor = controllerExecutionBB.getControllerActor(execution, TEST_SCOPE,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+ assertEquals("The controller actor should be the same as in the catalogdb", TEST_CONTROLLER_REFERENCE_ACTOR,
+ controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContextAndCatalogdb_returnFromControllerReference() {
+ when(execution.getVariable(ACTOR_PARAM)).thenReturn("");
+ when(pnfResourceCustomization.getControllerActor()).thenReturn("");
+
+ String controllerActor = controllerExecutionBB.getControllerActor(execution, TEST_SCOPE,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+ assertEquals("The controller actor should be the same as in the controller reference table",
+ TEST_CONTROLLER_REFERENCE_ACTOR, controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContextVnfType_returnFromCatalogdb() {
+ when(execution.getVariable(ACTOR_PARAM)).thenReturn("");
+
+ String expectedVnfControllerActor = "appc";
+
+ String[] controllerScopeArray = new String[] {"vnf", "vfModule"};
+
+ for (String controllerScope : controllerScopeArray) {
+
+ when(vnfResourceCustomization.getControllerActor()).thenReturn(expectedVnfControllerActor);
+ when(client.getVnfResourceCustomizationByModelCustomizationUUID(TEST_RESOURCE_CUSTOMIZATION_UUID))
+ .thenReturn(vnfResourceCustomization);
+
+ String controllerActor = controllerExecutionBB.getControllerActor(execution, controllerScope,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+
+ assertEquals("The controller actor should be the same as in the catalogdb for scope: " + controllerScope,
+ expectedVnfControllerActor, controllerActor);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTestIT.java
new file mode 100644
index 0000000000..5eef671106
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/ControllerExecutionBBTestIT.java
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
+import com.google.protobuf.Struct;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.appc.client.lcm.model.Action;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.so.BaseIntegrationTest;
+import org.onap.so.GrpcNettyServer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ControllerExecutionBBTestIT extends BaseIntegrationTest {
+
+ private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ private ControllerExecutionBB controllerExecutionBB;
+
+ @Autowired
+ private GrpcNettyServer grpcNettyServer;
+
+ private GenericVnf genericVnf;
+
+ private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static String TEST_PROCESS_KEY = "processKey1";
+ private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+
+ private static String TEST_CDS_ACTION = "config-assign";
+ private static String TEST_APPC_ACTION = "HealthCheck";
+
+ private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+ private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+
+ @Before
+ public void setUp() {
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+
+ grpcNettyServer.cleanMessage();
+ }
+
+ @Test
+ @Ignore
+ // TODO: re-activate this test case after the SO-CDS generic buildingblock implementation in place
+ public void testExecution_cdsConfigAssign_actionExecuted() {
+
+ configureCdsConfigAssign();
+
+ controllerExecutionBB.execute(execution);
+ List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
+ assertThat(detailedMessages).hasSize(1);
+ try {
+ checkConfigAssign(detailedMessages.get(0));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("ConfigAssign request exception", e);
+ }
+ }
+
+ @Test
+ @Ignore
+ // TODO: re-activate this test case after the SDNC controller is fully implemented.
+ public void testExecution_sdncUpgradeHealthCheck_actionExecuted() {
+ configureSdncUpgrade();
+ controllerExecutionBB.execute(execution);
+
+ verify(appCClient, times(1)).runAppCCommand(eq(Action.UpgradePreCheck), eq(TEST_MSO_REQUEST_ID), eq(null),
+ any(Optional.class), any(HashMap.class), eq("sdnc"));
+ }
+
+ private void configureSdncUpgrade() {
+ execution.setVariable("actor", "sdnc");
+ execution.setVariable("action", "UpgradePreCheck");
+ execution.setVariable("payload", "{ \n" + " \"action\":[ \n" + " { \n"
+ + " \"UpgradePreCheck\":{ \n" + " \"payload\":{ \n"
+ + " \"pnf-flag\":\"true\",\n" + " \"pnf-name\":\"5gDU0001\",\n"
+ + " \"pnfId\":\"5gDU0001\",\n"
+ + " \"ipaddress-v4-oam\":\"192.168.35.83\",\n"
+ + " \"oldSwVersion\":\"v1\",\n" + " \"targetSwVersion\":\"v2\",\n"
+ + " \"ruleName\":\"r001\",\n" + " \"Id\":\"10\",\n"
+ + " \"additionalData\":\"{}\"\n" + " }\n" + " }\n" + " },\n"
+ + " { \n" + " \"UpgradeSoftware\":{ \n" + " \"payload\":{ \n"
+ + " \"pnf-flag\":\"true\",\n" + " \"pnfId\":\"5gDU0001\",\n"
+ + " \"ipaddress-v4-oam\":\"192.168.35.83\",\n"
+ + " \"swToBeDownloaded\":[ \n" + " { \n"
+ + " \"swLocation\":\"http://192.168.35.96:10080/ran_du_pkg1-v2.zip\",\n"
+ + " \"swFileSize\":353,\n" + " \"swFileCompression\":\"ZIP\",\n"
+ + " \"swFileFormat\":\"zip\"\n" + " }\n" + " ]\n"
+ + " }\n" + " }\n" + " }\n" + " ]\n" + "}");
+
+ setServiceInstance();
+ genericVnf = setGenericVnf();
+
+ RequestContext requestContext = setRequestContext();
+ requestContext.setMsoRequestId(TEST_MSO_REQUEST_ID);
+ gBBInput.setRequestContext(requestContext);
+ }
+
+ private void configureCdsConfigAssign() {
+ execution.setVariable("actor", "cds");
+ execution.setVariable("scope", "pnf");
+ execution.setVariable("action", TEST_CDS_ACTION);
+
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ }
+
+ private void checkConfigAssign(ExecutionServiceInput executionServiceInput) {
+
+ logger.info("Checking the configAssign request");
+ ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+
+ /**
+ * the fields of actionIdentifiers should match the one in the
+ * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json.
+ */
+ assertThat(actionIdentifiers.getBlueprintName()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(actionIdentifiers.getActionName()).isEqualTo(TEST_CDS_ACTION);
+ assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+
+ CommonHeader commonHeader = executionServiceInput.getCommonHeader();
+ assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
+ assertThat(commonHeader.getRequestId()).isEqualTo(TEST_MSO_REQUEST_ID);
+
+ Struct payload = executionServiceInput.getPayload();
+ Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue();
+
+ assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue())
+ .isEqualTo(TEST_PNF_CORRELATION_ID);
+ Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue();
+
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo(TEST_PNF_CORRELATION_ID);
+ assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).isEqualTo(TEST_MODEL_UUID);
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
+ .isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/MockControllerBB.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/MockControllerBB.java
new file mode 100644
index 0000000000..06fd01dce1
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/MockControllerBB.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MockControllerBB implements ControllerRunnable<BuildingBlockExecution> {
+
+ public static final String TEST_ACTOR = "test-controller";
+ public static final String TEST_ACTION = "configuration";
+
+ @Override
+ public Boolean understand(ControllerContext<BuildingBlockExecution> context) {
+ return context.getControllerAction().equalsIgnoreCase(TEST_ACTION)
+ && context.getControllerActor().equalsIgnoreCase(TEST_ACTOR);
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<BuildingBlockExecution> context) {
+ context.getExecution().setVariable("stage", "ready");
+ return true;
+ }
+
+ @Override
+ public void prepare(ControllerContext<BuildingBlockExecution> context) {
+ context.getExecution().setVariable("stage", "prepare");
+ }
+
+ @Override
+ public void run(ControllerContext<BuildingBlockExecution> context) {
+ context.getExecution().setVariable("stage", "run");
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBBTest.java
new file mode 100644
index 0000000000..46cb8189cc
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/appc/AppcControllerBBTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.appc;
+
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.when;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {AppcControllerBB.class, ExceptionBuilder.class})
+public class AppcControllerBBTest {
+
+ @Autowired
+ private AppcControllerBB appcControllerBB;
+
+ @MockBean
+ private ControllerContext controllerContext;
+
+ @MockBean
+ protected ApplicationControllerAction client;
+
+ @Before
+ public void setUp() {
+ when(controllerContext.getControllerActor()).thenReturn("appc");
+ }
+
+ @Test
+ public void testUnderstand_validContext_TrueReturned() {
+ assertTrue(appcControllerBB.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_invalidContext_FalseReturned() {
+ when(controllerContext.getControllerActor()).thenReturn("sdnc");
+ assertFalse(appcControllerBB.understand(controllerContext));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBBTest.java
new file mode 100644
index 0000000000..5c3b439819
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/buildingblock/controller/sdnc/SdncControllerBBTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.buildingblock.controller.sdnc;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.when;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SdncControllerBB.class, ExceptionBuilder.class})
+public class SdncControllerBBTest {
+
+ @Autowired
+ private SdncControllerBB sSdncControllerBB;
+
+ @MockBean
+ private ControllerContext controllerContext;
+
+ @MockBean
+ protected ApplicationControllerAction client;
+
+ @Before
+ public void setUp() {
+ when(controllerContext.getControllerActor()).thenReturn("sdnc");
+ }
+
+ @Test
+ public void testUnderstand_validContext_TrueReturned() {
+ assertTrue(sSdncControllerBB.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_invalidContext_FalseReturned() {
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ assertFalse(sSdncControllerBB.understand(controllerContext));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETest.java
new file mode 100644
index 0000000000..15a1a1e52d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETest.java
@@ -0,0 +1,160 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.MockControllerDE.TEST_ACTION;
+import static org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.MockControllerDE.TEST_ACTOR;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ControllerExecutionDE.class, MockControllerDE.class, ExceptionBuilder.class})
+public class ControllerExecutionDETest {
+
+ private static final String ACTOR_PARAM = "actor";
+ private static final String ACTION_PARAM = "action";
+ private static final String RESOURCE_TYPE_PARAM = "resource_type";
+
+ private static final String TEST_RESOURCE_CUSTOMIZATION_UUID = "68dc9a92-214c-11e7-93ae-92361f002680";
+ private static final String TEST_CATALOGDB_CONTROLLER_ACTOR = "cds";
+ private static final String TEST_RESOURCE_TYPE = "Firewall";
+ private static final String TEST_CONTROLLER_REFERENCE_ACTOR = "sdnc";
+ private static final String TEST_SCOPE = "pnf";
+
+ @Autowired
+ private ControllerExecutionDE controllerExecutionDE;
+
+ @MockBean
+ private CatalogDbClient client;
+
+ @MockBean
+ private PnfResourceCustomization pnfResourceCustomization;
+
+ @MockBean
+ private VnfResourceCustomization vnfResourceCustomization;
+
+ @MockBean
+ private ControllerSelectionReference controllerSelectionReference;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp() {
+ execution.setVariable(ACTION_PARAM, TEST_ACTION);
+ execution.setVariable(ACTOR_PARAM, TEST_ACTOR);
+
+ when(pnfResourceCustomization.getControllerActor()).thenReturn(TEST_CATALOGDB_CONTROLLER_ACTOR);
+ when(client.getPnfResourceCustomizationByModelCustomizationUUID(TEST_RESOURCE_CUSTOMIZATION_UUID))
+ .thenReturn(pnfResourceCustomization);
+
+ execution.setVariable(RESOURCE_TYPE_PARAM, TEST_RESOURCE_TYPE);
+ when(controllerSelectionReference.getControllerName()).thenReturn(TEST_CONTROLLER_REFERENCE_ACTOR);
+ when(client.getControllerSelectionReferenceByVnfTypeAndActionCategory(TEST_RESOURCE_TYPE, TEST_ACTION))
+ .thenReturn(controllerSelectionReference);
+ }
+
+ @Test
+ public void testExecution_validInput_expectedOutput() {
+ controllerExecutionDE.execute(execution);
+ assertTrue((Boolean) execution.getVariable("ready"));
+ assertTrue((Boolean) execution.getVariable("prepare"));
+ assertTrue((Boolean) execution.getVariable("run"));
+ }
+
+ @Test
+ public void testGetController_availableInExecutionContext_returnFromExecutionContext() {
+ String controllerActor = controllerExecutionDE.getControllerActor(execution, TEST_SCOPE, "", TEST_ACTION);
+ assertEquals(TEST_ACTOR, controllerActor);
+ }
+
+ @Test
+ public void testGetController_soRefDataInExecutionContext_returnFromExecutionContext() {
+ execution.setVariable(ACTOR_PARAM, "so-ref-data");
+ String controllerActor = controllerExecutionDE.getControllerActor(execution, TEST_SCOPE, "", TEST_ACTION);
+ assertEquals(TEST_CONTROLLER_REFERENCE_ACTOR, controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContext_returnFromCatalogdb() {
+ execution.setVariable(ACTOR_PARAM, "");
+ String controllerActor = controllerExecutionDE.getControllerActor(execution, TEST_SCOPE,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+ assertEquals("The controller actor should be the same as in the catalogdb", TEST_CATALOGDB_CONTROLLER_ACTOR,
+ controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContextAndSoRefDataInCatalogdb_returnFromControllerReference() {
+ execution.setVariable(ACTOR_PARAM, "");
+ when(pnfResourceCustomization.getControllerActor()).thenReturn("SO-REF-DATA");
+ String controllerActor = controllerExecutionDE.getControllerActor(execution, TEST_SCOPE,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+ assertEquals("The controller actor should be the same as in the catalogdb", TEST_CONTROLLER_REFERENCE_ACTOR,
+ controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContextAndCatalogdb_returnFromControllerReference() {
+ execution.setVariable(ACTOR_PARAM, "");
+ when(pnfResourceCustomization.getControllerActor()).thenReturn("");
+
+ String controllerActor = controllerExecutionDE.getControllerActor(execution, TEST_SCOPE,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+ assertEquals("The controller actor should be the same as in the controller reference table",
+ TEST_CONTROLLER_REFERENCE_ACTOR, controllerActor);
+ }
+
+ @Test
+ public void testGetController_notAvailableInExecutionContextVnfType_returnFromCatalogdb() {
+ execution.setVariable(ACTOR_PARAM, "");
+
+ String expectedVnfControllerActor = "appc";
+
+ String[] controllerScopeArray = new String[] {"vnf", "vfModule"};
+
+ for (String controllerScope : controllerScopeArray) {
+
+ when(vnfResourceCustomization.getControllerActor()).thenReturn(expectedVnfControllerActor);
+ when(client.getVnfResourceCustomizationByModelCustomizationUUID(TEST_RESOURCE_CUSTOMIZATION_UUID))
+ .thenReturn(vnfResourceCustomization);
+
+ String controllerActor = controllerExecutionDE.getControllerActor(execution, controllerScope,
+ TEST_RESOURCE_CUSTOMIZATION_UUID, TEST_ACTION);
+
+ assertEquals("The controller actor should be the same as in the catalogdb for scope: " + controllerScope,
+ expectedVnfControllerActor, controllerActor);
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
new file mode 100644
index 0000000000..860780a2fc
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.fail;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
+import com.google.protobuf.Struct;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
+import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.so.BaseIntegrationTest;
+import org.onap.so.GrpcNettyServer;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ControllerExecutionDETestIT extends BaseIntegrationTest {
+
+ private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+ @Autowired
+ private ControllerExecutionDE controllerExecutionDE;
+
+ @Autowired
+ private GrpcNettyServer grpcNettyServer;
+
+ private GenericVnf genericVnf;
+
+ private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static String TEST_PROCESS_KEY = "processKey1";
+ private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+
+ private static String TEST_CDS_ACTION = "config-assign";
+ private static String TEST_APPC_ACTION = "HealthCheck";
+
+ private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+ private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+
+ @Before
+ public void setUp() {
+ delegateExecution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ delegateExecution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ delegateExecution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ delegateExecution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+
+ grpcNettyServer.cleanMessage();
+ }
+
+ @Test
+ public void testExecution_cdsConfigAssign_actionExecuted() {
+
+ configureCdsConfigAssign();
+
+ controllerExecutionDE.execute(delegateExecution);
+ List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
+ assertThat(detailedMessages).hasSize(1);
+ try {
+ checkConfigAssign(detailedMessages.get(0));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("ConfigAssign request exception", e);
+ }
+ }
+
+ private void configureCdsConfigAssign() {
+ delegateExecution.setVariable("actor", "cds");
+ delegateExecution.setVariable("action", TEST_CDS_ACTION);
+ delegateExecution.setVariable("scope", "pnf");
+
+ delegateExecution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ delegateExecution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ delegateExecution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ delegateExecution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ }
+
+ private void checkConfigAssign(ExecutionServiceInput executionServiceInput) {
+
+ logger.info("Checking the configAssign request");
+ ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
+
+ /**
+ * the fields of actionIdentifiers should match the one in the
+ * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json.
+ */
+ assertThat(actionIdentifiers.getBlueprintName()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(actionIdentifiers.getActionName()).isEqualTo(TEST_CDS_ACTION);
+ assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+
+ CommonHeader commonHeader = executionServiceInput.getCommonHeader();
+ assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
+ assertThat(commonHeader.getRequestId()).isEqualTo(TEST_MSO_REQUEST_ID);
+
+ Struct payload = executionServiceInput.getPayload();
+ Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue();
+
+ assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue())
+ .isEqualTo(TEST_PNF_CORRELATION_ID);
+ Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue();
+
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo(TEST_PNF_CORRELATION_ID);
+ assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).isEqualTo(TEST_MODEL_UUID);
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
+ .isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/MockControllerDE.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/MockControllerDE.java
new file mode 100644
index 0000000000..c66fefdffe
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/MockControllerDE.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MockControllerDE implements ControllerRunnable<DelegateExecution> {
+
+ public static final String TEST_ACTOR = "test-controller";
+ public static final String TEST_ACTION = "configuration";
+
+ @Override
+ public Boolean understand(ControllerContext<DelegateExecution> context) {
+ return context.getControllerAction().equalsIgnoreCase(TEST_ACTION)
+ && context.getControllerActor().equalsIgnoreCase(TEST_ACTOR);
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<DelegateExecution> context) {
+ context.getExecution().setVariable("ready", true);
+ return true;
+ }
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> context) {
+ context.getExecution().setVariable("prepare", true);
+ }
+
+ @Override
+ public void run(ControllerContext<DelegateExecution> context) {
+ context.getExecution().setVariable("run", true);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDETest.java
new file mode 100644
index 0000000000..3b7a863cd3
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/appc/AppcControllerDETest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.appc;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.when;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {AppcControllerDE.class, ExceptionBuilder.class})
+public class AppcControllerDETest {
+
+ @Autowired
+ private AppcControllerDE appcControllerDE;
+
+ @MockBean
+ private ControllerContext controllerContext;
+
+ @MockBean
+ private ControllerPreparable<DelegateExecution> preparable;
+
+ @MockBean
+ protected ApplicationControllerAction client;
+
+ @Before
+ public void setUp() {
+ when(controllerContext.getControllerActor()).thenReturn("appc");
+ }
+
+ @Test
+ public void testUnderstand_validContext_TrueReturned() {
+ assertTrue(appcControllerDE.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_invalidContext_FalseReturned() {
+ when(controllerContext.getControllerActor()).thenReturn("sdnc");
+ assertFalse(appcControllerDE.understand(controllerContext));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java
new file mode 100644
index 0000000000..79bce8a1f4
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.cds;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.when;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {CdsControllerDE.class, ExceptionBuilder.class})
+public class CdsControllerDETest {
+
+ @Autowired
+ private CdsControllerDE cdsControllerDE;
+
+ @MockBean
+ private ControllerContext controllerContext;
+
+ @MockBean
+ private ControllerPreparable<DelegateExecution> preparable;
+
+ @Before
+ public void setUp() {
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ }
+
+ @Test
+ public void testUnderstand_validContext_TrueReturned() {
+ assertTrue(cdsControllerDE.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_invalidContext_FalseReturned() {
+ when(controllerContext.getControllerActor()).thenReturn("appc");
+ assertFalse(cdsControllerDE.understand(controllerContext));
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
new file mode 100644
index 0000000000..674167624e
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.when;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SdncControllerDE.class, ExceptionBuilder.class})
+public class SdncControllerDETest {
+
+ @Autowired
+ private SdncControllerDE sdncControllerDE;
+
+ @MockBean
+ private ControllerContext controllerContext;
+
+ @MockBean
+ private ControllerPreparable<DelegateExecution> preparable;
+
+ @MockBean
+ protected ApplicationControllerAction client;
+
+ @Before
+ public void setUp() {
+ when(controllerContext.getControllerActor()).thenReturn("sdnc");
+ }
+
+ @Test
+ public void testUnderstand_validContext_TrueReturned() {
+ assertTrue(sdncControllerDE.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_invalidContext_FalseReturned() {
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ assertFalse(sdncControllerDE.understand(controllerContext));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index fed2aa69c7..199274e94c 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -215,3 +215,9 @@ camunda:
metrics:
enabled: false
db-reporter-activate: false
+# CDSProcessingClient
+cds:
+ endpoint: localhost
+ port: 11012
+ auth: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
+ timeout: 60