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