aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap
diff options
context:
space:
mode:
authoreeginux <henry.xie@est.tech>2019-04-03 14:28:09 +0000
committereeginux <henry.xie@est.tech>2019-04-04 11:41:31 +0100
commit88c47a23b9428188ff5dd0b46941f8856465376b (patch)
tree3f1e028033ad56f398e8154f0be2272012b666b2 /bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap
parentb168125f237629b6dd7d73897548f2ee70139ed3 (diff)
PNF WF post instantiation configuration
Add PNF ipv4/v6 address for config Deploy Add Integration test for CreateVcpeResCustService_simplified.bpmn Modify the PnfEventReadyDmaapClient to avoid one more running thread Refactor the so-bpmn-infrastructure-flows test resources Modify the CreateVcpeResCustService_simplified.bpmn Add ConfigurePnfResource.bpmn Add Delegates Issue-ID: SO-1506 Change-Id: Iffb69d1441ef0b485ee8cd3fb5da5f1a35279a95 Signed-off-by: eeginux <henry.xie@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java148
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java136
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java188
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java2
4 files changed, 473 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java
new file mode 100644
index 0000000000..571f64335f
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java
@@ -0,0 +1,148 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
+import static org.mockito.BDDMockito.given;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SKIP_POST_INSTANTIATION_CONFIGURATION;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.camunda.bpm.engine.ProcessEngineConfiguration;
+import org.camunda.bpm.engine.delegate.BpmnError;
+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.bpmn.core.WorkflowException;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+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 = {CatalogDbClient.class, ExceptionBuilder.class, ConfigCheckerDelegate.class,
+ ProcessEngineConfiguration.class})
+public class ConfigCheckerDelegateTest {
+
+ private static String TEST_PROCESS_KEY = "processKey1";
+ private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ 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";
+
+ /**
+ * Service model info json.
+ */
+ private static String TEST_SERVICE_MODEL_INFO = "{\n"
+ + " \"modelType\":\"service\",\n"
+ + " \"modelInvariantUuid\":\"539b7a2f-9524-4dbf-9eee-f2e05521df3f\",\n"
+ + " \"modelInvariantId\":\"539b7a2f-9524-4dbf-9eee-f2e05521df3f\",\n"
+ + " \"modelUuid\":\"f2daaac6-5017-4e1e-96c8-6a27dfbe1421\",\n"
+ + " \"modelName\":\"PNF_demo_resource\",\n"
+ + " \"modelVersion\":\"1.0\"\n"
+ + " }";
+
+ /**
+ * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO.
+ */
+ private static String TEST_MODEL_UUID = "f2daaac6-5017-4e1e-96c8-6a27dfbe1421";
+
+ @MockBean
+ private CatalogDbClient catalogDbClient;
+
+ @MockBean
+ private ProcessEngineConfiguration processEngineConfiguration;
+
+ @Autowired
+ private ConfigCheckerDelegate configCheckerDelegate;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp() {
+ List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>();
+ pnfResourceCustomizations.add(buildPnfResourceCustomization());
+ given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID))
+ .willReturn(pnfResourceCustomizations);
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ execution.setVariable(SERVICE_MODEL_INFO, TEST_SERVICE_MODEL_INFO);
+ }
+
+ private PnfResourceCustomization buildPnfResourceCustomization() {
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ pnfResourceCustomization.setSkipPostInstConf(true);
+ pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME);
+ pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ return pnfResourceCustomization;
+ }
+
+ @Test
+ public void testExecution_validCatalogdb_skipVariableSet() {
+ try {
+ configCheckerDelegate.execute(execution);
+ assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID);
+ assertThat(execution.getVariable(SKIP_POST_INSTANTIATION_CONFIGURATION)).isEqualTo(Boolean.TRUE);
+ assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testExecution_EmptyPnfResourceCustomization_exceptionThrown() {
+ given(catalogDbClient.getPnfResourceCustomizationByModelUuid("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"))
+ .willReturn(Collections.EMPTY_LIST);
+
+ assertThatThrownBy(() -> configCheckerDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString()
+ .contains("Unable to find the PNF resource customizations of model service UUID")
+ .contains("f2daaac6-5017-4e1e-96c8-6a27dfbe1421");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+
+ @Test
+ public void testExecution_NonExistingServiceModelInfo_exceptionThrown() {
+ execution.removeVariable("serviceModelInfo");
+ assertThatThrownBy(() -> configCheckerDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString()
+ .contains("Unable to find parameter serviceModelInfo");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java
new file mode 100644
index 0000000000..8d817e5bca
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java
@@ -0,0 +1,136 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT;
+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.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import org.camunda.bpm.engine.delegate.BpmnError;
+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.bpmn.core.WorkflowException;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.cds.beans.ConfigAssignPropertiesForPnf;
+import org.onap.so.client.cds.beans.ConfigAssignRequestPnf;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ExceptionBuilder.class, PrepareConfigAssignDelegate.class})
+public class PrepareConfigAssignDelegateTest {
+
+ 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_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_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+
+ @Autowired
+ private PrepareConfigAssignDelegate prepareConfigAssignDelegate;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp(){
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ 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(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);
+ }
+
+ @Test
+ public void testExecution_validPnf_executionObjectCreated() {
+ try {
+ prepareConfigAssignDelegate.execute(execution);
+ Object executionObject = execution.getVariable(EXECUTION_OBJECT);
+ assertThat(executionObject).isNotNull();
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ checkCDSPropertiesBean((AbstractCDSPropertiesBean) executionObject);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ private void checkCDSPropertiesBean(AbstractCDSPropertiesBean executionObject) {
+ assertThat(executionObject.getBlueprintName()).matches(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(executionObject.getBlueprintVersion()).matches(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(executionObject.getRequestId()).matches(TEST_MSO_REQUEST_ID);
+ assertThat(executionObject.getSubRequestId()).matches(TEST_PNF_UUID);
+ assertThat(executionObject.getMode()).matches("sync");
+ assertThat(executionObject.getActionName()).matches("config-assign");
+ assertThat(executionObject.getOriginatorId()).matches("SO");
+
+ assertThat(executionObject.getRequestObject()).isNotNull();
+ String requestObject = executionObject.getRequestObject();
+
+ checkRequestJson(requestObject);
+ }
+
+ private void checkRequestJson(String requestObject) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode tree = mapper.readTree(requestObject);
+ ConfigAssignRequestPnf configAssignRequestPnf = mapper
+ .treeToValue(tree.at("/config-assign-request"), ConfigAssignRequestPnf.class);
+ assertThat(configAssignRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID);
+
+ ConfigAssignPropertiesForPnf properties = configAssignRequestPnf.getConfigAssignPropertiesForPnf();
+ assertThat(properties.getServiceInstanceId()).matches(TEST_SERVICE_INSTANCE_ID);
+ assertThat(properties.getPnfName()).matches(TEST_PNF_CORRELATION_ID);
+ assertThat(properties.getPnfId()).matches(TEST_PNF_UUID);
+ assertThat(properties.getPnfCustomizationUuid()).matches(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(properties.getServiceModelUuid()).matches(TEST_MODEL_UUID);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("Check request body is json message" + e.getMessage());
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java
new file mode 100644
index 0000000000..77b6d9ffdd
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java
@@ -0,0 +1,188 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * 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.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT;
+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.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.Optional;
+import org.camunda.bpm.engine.delegate.BpmnError;
+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.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf;
+import org.onap.so.client.cds.beans.ConfigDeployRequestPnf;
+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 = {ExceptionBuilder.class, PrepareConfigDeployDelegate.class})
+public class PrepareConfigDeployDelegateTest {
+
+ 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_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_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static String TEST_IPV4_ADDRESS = "1.1.1.1";
+ private static String TEST_IPV6_ADDRESS = "::1/128";
+
+ @Autowired
+ private PrepareConfigDeployDelegate prepareConfigDeployDelegate;
+
+ @MockBean
+ private PnfManagement pnfManagement;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp() throws IOException {
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ 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(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);
+ mockAai();
+ }
+
+ private void mockAai() throws IOException {
+ Pnf pnf = new Pnf();
+ pnf.setPnfIpv4Address(TEST_IPV4_ADDRESS);
+ pnf.setPnfIpv6Address(TEST_IPV6_ADDRESS);
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf));
+ }
+
+ @Test
+ public void testExecution_validPnf_executionObjectCreated() {
+ try {
+ prepareConfigDeployDelegate.execute(execution);
+ Object executionObject = execution.getVariable(EXECUTION_OBJECT);
+ assertThat(executionObject).isNotNull();
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ checkCDSPropertiesBean((AbstractCDSPropertiesBean) executionObject);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testExecution_failedAaiConnection_exceptionThrown(){
+ try {
+ /**
+ * Mock the IOException from AAI.
+ */
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenThrow(new IOException("Connection failed"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertThatThrownBy(()->prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString().contains("Unable to fetch from AAI");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+
+ @Test
+ public void testExecution_aaiEntryNotExist_exceptionThrown(){
+ try {
+ /**
+ * Mock the AAI without PNF.
+ */
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.empty());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertThatThrownBy(()->prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString().contains("AAI entry for PNF: " + TEST_PNF_CORRELATION_ID + " does not exist");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+
+ private void checkCDSPropertiesBean(AbstractCDSPropertiesBean executionObject) {
+ assertThat(executionObject.getBlueprintName()).matches(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(executionObject.getBlueprintVersion()).matches(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(executionObject.getRequestId()).matches(TEST_MSO_REQUEST_ID);
+ assertThat(executionObject.getSubRequestId()).matches(TEST_PNF_UUID);
+ assertThat(executionObject.getMode()).matches("async");
+ assertThat(executionObject.getActionName()).matches("config-deploy");
+ assertThat(executionObject.getOriginatorId()).matches("SO");
+
+ assertThat(executionObject.getRequestObject()).isNotNull();
+ String requestObject = executionObject.getRequestObject();
+
+ checkRequestJson(requestObject);
+ }
+
+ private void checkRequestJson(String requestObject) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode tree = mapper.readTree(requestObject);
+ ConfigDeployRequestPnf configDeployRequestPnf = mapper
+ .treeToValue(tree.at("/config-deploy-request"), ConfigDeployRequestPnf.class);
+ assertThat(configDeployRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID);
+
+ ConfigDeployPropertiesForPnf properties = configDeployRequestPnf
+ .getConfigDeployPropertiesForPnf();
+ assertThat(properties.getServiceInstanceId()).matches(TEST_SERVICE_INSTANCE_ID);
+ assertThat(properties.getPnfName()).matches(TEST_PNF_CORRELATION_ID);
+ assertThat(properties.getPnfId()).matches(TEST_PNF_UUID);
+ assertThat(properties.getPnfCustomizationUuid()).matches(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(properties.getServiceModelUuid()).matches(TEST_MODEL_UUID);
+ assertThat(properties.getPnfIpV4Address()).matches(TEST_IPV4_ADDRESS);
+ assertThat(properties.getPnfIpV6Address()).matches(TEST_IPV6_ADDRESS);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("Check request body is json message" + e.getMessage());
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
index 60f51ff783..cbfe6c1512 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -121,7 +121,7 @@ public class PnfEventReadyDmaapClientTest {
assertEquals(captor1.getValue().getURI().getScheme(),PROTOCOL);
assertEquals(captor1.getValue().getURI().getPath(),"/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
- verify(threadMockToNotifyCamundaFlow).run();
+ //verify(threadMockToNotifyCamundaFlow).run();
verify(executorMock).shutdown();
}