summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-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
28 files changed, 2368 insertions, 0 deletions
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