From 88c47a23b9428188ff5dd0b46941f8856465376b Mon Sep 17 00:00:00 2001 From: eeginux Date: Wed, 3 Apr 2019 14:28:09 +0000 Subject: 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 --- .../client/cds/AbstractCDSProcessingBBUtils.java | 4 +- .../cds/beans/ConfigDeployPropertiesForPnf.java | 30 ++ .../beans/ConfigDeployPropertiesForPnfTest.java | 54 ++-- bpmn/pom.xml | 1 + .../pnf/delegate/ConfigCheckerDelegate.java | 97 +++++++ .../pnf/delegate/ExecutionVariableNames.java | 22 ++ .../pnf/delegate/PrepareCdsCallDelegate.java | 84 ++++++ .../pnf/delegate/PrepareConfigAssignDelegate.java | 79 ++++++ .../pnf/delegate/PrepareConfigDeployDelegate.java | 108 ++++++++ .../pnf/dmaap/PnfEventReadyDmaapClient.java | 3 +- .../pnf/delegate/ConfigCheckerDelegateTest.java | 148 ++++++++++ .../delegate/PrepareConfigAssignDelegateTest.java | 136 +++++++++ .../delegate/PrepareConfigDeployDelegateTest.java | 188 +++++++++++++ .../pnf/dmaap/PnfEventReadyDmaapClientTest.java | 2 +- bpmn/so-bpmn-infrastructure-flows/pom.xml | 48 +++- .../resources/process/ConfigurePnfResource.bpmn | 198 ++++++++++++++ .../CreateVcpeResCustService_simplified.bpmn | 105 ++++--- .../test/java/org/onap/so/AllBPMNTestSuites.java | 32 +++ .../src/test/java/org/onap/so/BaseBPMNTest.java | 69 +++++ .../java/org/onap/so/EmbeddedMariaDbConfig.java | 65 +++++ .../src/test/java/org/onap/so/GrpcNettyServer.java | 110 ++++++++ .../org/onap/so/InfraEmbeddedMariaDbConfig.java | 72 ----- .../src/test/java/org/onap/so/TestApplication.java | 4 +- .../src/test/java/org/onap/so/ValidBPMNTest.java | 43 --- .../CreateVcpeResCustServiceSimplifiedTest.java | 261 ++++++++++++++++++ .../stubprocess/DoCreateAllottedResourceBRG.bpmn | 54 ---- .../DoCreateAllottedResourceBRGRollback.bpmn | 55 ---- .../stubprocess/DoCreateAllottedResourceTXC.bpmn | 38 --- .../DoCreateServiceInstanceRollback.bpmn | 53 ---- .../VCPE/stubprocess/DoCreateVnfAndModules.bpmn | 53 ---- .../stubprocess/DoCreateVnfAndModulesRollback.bpmn | 53 ---- .../VCPE/stubprocess/DoDeleteVnfAndModules.bpmn | 37 --- .../test/resources/VCPE/stubprocess/Homing.bpmn | 35 --- .../src/test/resources/application-test.yaml | 36 ++- .../src/test/resources/application-test.yml | 303 --------------------- .../src/test/resources/logback-test.xml | 85 ++++-- .../CreateVcpeResCustServiceSimplifiedTest.json | 47 ++++ .../CreateVcpeResCustServiceSimplifiedTest.json | 26 ++ ...VcpeResCustServiceSimplifiedTest_catalogdb.json | 37 +++ .../test/resources/stubprocess/GenericStub.bpmn | 35 --- bpmn/so-bpmn-tasks/pom.xml | 2 +- 41 files changed, 1976 insertions(+), 936 deletions(-) create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/CreateVcpeResCustServiceSimplifiedTest.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 0b2ef928ad..7a967d3159 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -128,9 +128,9 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution .getVariable("executionServiceInput"); - CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils(); + //CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils(); - CDSProcessingClient cdsClient = new CDSProcessingClient(cdsProcessingListener); + CDSProcessingClient cdsClient = new CDSProcessingClient(this); CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput); try { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java index b8fb5b96bd..6fadc7b55c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; "service-instance-id", "pnf-id", "pnf-name", +"pnf-ipv4-address", +"pnf-ipv6-address", "service-model-uuid", "pnf-customization-uuid" }) @@ -24,6 +26,15 @@ public class ConfigDeployPropertiesForPnf { @JsonProperty("pnf-name") private String pnfName; + /** + * Config Deploy require IP address of PNF. + */ + @JsonProperty("pnf-ipv4-address") + private String pnfIpV4Address; + + @JsonProperty("pnf-ipv6-address") + private String pnfIpV6Address; + @JsonProperty("service-model-uuid") private String serviceModelUuid; @@ -70,6 +81,23 @@ public class ConfigDeployPropertiesForPnf { this.pnfCustomizationUuid = pnfCustomizationUuid; } + public String getPnfIpV4Address() { + return pnfIpV4Address; + } + + public void setPnfIpV4Address(String pnfIpV4Address) { + this.pnfIpV4Address = pnfIpV4Address; + } + + public String getPnfIpV6Address() { + return pnfIpV6Address; + } + + public void setPnfIpV6Address(String pnfIpV6Address) { + this.pnfIpV6Address = pnfIpV6Address; + } + + @Override public String toString() { @@ -77,6 +105,8 @@ public class ConfigDeployPropertiesForPnf { sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"pnf-ipv4-address\":").append("\"").append(pnfIpV4Address).append("\""); + sb.append(", \"pnf-ipv6-address\":").append("\"").append(pnfIpV6Address).append("\""); sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java index 1d771c86d5..8e16ce6337 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java @@ -3,45 +3,59 @@ package org.onap.so.client.cds.beans; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import org.junit.Before; import org.junit.Test; public class ConfigDeployPropertiesForPnfTest { + ConfigDeployPropertiesForPnf configDeployPropertiesForPnf = new ConfigDeployPropertiesForPnf(); - private String serviceInstanceId; - private String pnfId; - private String pnfName; - private String serviceModelUuid; - private String pnfCustomizationUuid; + private static final String TEST_SERVICE_MODEL_UUID = "service-model-uuid"; + private static final String TEST_PNF_CUSTOMIZATION_UUID = "pnf-customization-uuid"; + private static final String TEST_PNF_ID = "pnf-id"; + private static final String TEST_PNF_NAME = "pnf-name"; + private static final String TEST_PNF_IP_V4_ADDRESS = "1.1.1.1"; + private static final String TEST_PNF_IP_V6_ADDRESS = "::/128"; + private static final String TEST_SERVICE_INSTANCE_ID = "service-instance-id"; + + @Before + public void setUp(){ + configDeployPropertiesForPnf.setServiceInstanceId(TEST_SERVICE_INSTANCE_ID); + configDeployPropertiesForPnf.setServiceModelUuid(TEST_SERVICE_MODEL_UUID); + configDeployPropertiesForPnf.setPnfCustomizationUuid(TEST_PNF_CUSTOMIZATION_UUID); + configDeployPropertiesForPnf.setPnfId(TEST_PNF_ID); + configDeployPropertiesForPnf.setPnfName(TEST_PNF_NAME); + configDeployPropertiesForPnf.setPnfIpV4Address(TEST_PNF_IP_V4_ADDRESS); + configDeployPropertiesForPnf.setPnfIpV6Address(TEST_PNF_IP_V6_ADDRESS); + } @Test public final void testConfigDeployPropertiesForPnfTest() { - configDeployPropertiesForPnf.setServiceInstanceId("service-instance-id"); - configDeployPropertiesForPnf.setServiceModelUuid("service-model-uuid"); - configDeployPropertiesForPnf.setPnfCustomizationUuid("pnf-customization-uuid"); - configDeployPropertiesForPnf.setPnfId("pnf-id"); - configDeployPropertiesForPnf.setPnfName("pnf-name"); assertNotNull(configDeployPropertiesForPnf.getServiceInstanceId()); assertNotNull(configDeployPropertiesForPnf.getServiceModelUuid()); assertNotNull(configDeployPropertiesForPnf.getPnfCustomizationUuid()); assertNotNull(configDeployPropertiesForPnf.getPnfId()); assertNotNull(configDeployPropertiesForPnf.getPnfName()); - assertEquals("service-instance-id", configDeployPropertiesForPnf.getServiceInstanceId()); - assertEquals("service-model-uuid", configDeployPropertiesForPnf.getServiceModelUuid()); - assertEquals("pnf-customization-uuid", configDeployPropertiesForPnf.getPnfCustomizationUuid()); - assertEquals("pnf-id", configDeployPropertiesForPnf.getPnfId()); - assertEquals("pnf-name", configDeployPropertiesForPnf.getPnfName()); + assertEquals(TEST_SERVICE_INSTANCE_ID, configDeployPropertiesForPnf.getServiceInstanceId()); + assertEquals(TEST_SERVICE_MODEL_UUID, configDeployPropertiesForPnf.getServiceModelUuid()); + assertEquals(TEST_PNF_CUSTOMIZATION_UUID, configDeployPropertiesForPnf.getPnfCustomizationUuid()); + assertEquals(TEST_PNF_ID, configDeployPropertiesForPnf.getPnfId()); + assertEquals(TEST_PNF_NAME, configDeployPropertiesForPnf.getPnfName()); + assertEquals(TEST_PNF_IP_V4_ADDRESS, configDeployPropertiesForPnf.getPnfIpV4Address()); + assertEquals(TEST_PNF_IP_V6_ADDRESS, configDeployPropertiesForPnf.getPnfIpV6Address()); } @Test public void testtoString() { final StringBuilder sb = new StringBuilder("{"); - sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); - sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); - sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); - sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); - sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + sb.append("\"service-instance-id\":").append("\"").append(TEST_SERVICE_INSTANCE_ID).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(TEST_PNF_ID).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(TEST_PNF_NAME).append("\""); + sb.append(", \"pnf-ipv4-address\":").append("\"").append(TEST_PNF_IP_V4_ADDRESS).append("\""); + sb.append(", \"pnf-ipv6-address\":").append("\"").append(TEST_PNF_IP_V6_ADDRESS).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(TEST_SERVICE_MODEL_UUID).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(TEST_PNF_CUSTOMIZATION_UUID).append("\""); sb.append('}'); String Expexted = sb.toString(); assertEquals(Expexted, configDeployPropertiesForPnf.toString()); diff --git a/bpmn/pom.xml b/bpmn/pom.xml index df68017f5c..dc309253d4 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -24,6 +24,7 @@ 2.4.0 UTF-8 UTF-8 + 1.5.1-SNAPSHOT diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java new file mode 100644 index 0000000000..9b60a05e98 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java @@ -0,0 +1,97 @@ +/* + * ============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.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.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.core.json.JsonUtils; +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.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This implementation of {@link JavaDelegate} is used to check the SO catalogdb for PNF config flag. + * + * It queries the PNF resource customization table for the skip_post_instantiation_configuration for required PNF model + * UUID. + */ +@Component +public class ConfigCheckerDelegate implements JavaDelegate { + + private Logger logger = LoggerFactory.getLogger(ConfigCheckerDelegate.class); + + //ERROR CODE for variable not found in the delegation Context + private static int ERROR_CODE = 601; + + @Autowired + protected ExceptionBuilder exceptionUtil; + + @Autowired + protected CatalogDbClient catalogDbClient; + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + + logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + delegateExecution.getCurrentActivityName()); + + if (delegateExecution.hasVariable(SERVICE_MODEL_INFO)) { + String serviceModelInfo = (String) delegateExecution.getVariable(SERVICE_MODEL_INFO); + String serviceModelUuid = JsonUtils.getJsonValue(serviceModelInfo, MODEL_UUID); + delegateExecution.setVariable(MODEL_UUID, serviceModelUuid); + List pnfCustomizations = catalogDbClient + .getPnfResourceCustomizationByModelUuid(serviceModelUuid); + if (pnfCustomizations != null && pnfCustomizations.size() >= 1) { + PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + boolean skipPostInstantiationConfiguration = pnfResourceCustomization.isSkipPostInstConf(); + delegateExecution + .setVariable(SKIP_POST_INSTANTIATION_CONFIGURATION, skipPostInstantiationConfiguration); + delegateExecution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName()); + delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion()); + delegateExecution + .setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID()); + delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + } else { + logger + .warn("Unable to find the PNF resource customizations of model service UUID: {}", serviceModelUuid); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find the PNF resource customizations of model service UUID: " + serviceModelUuid); + } + } else { + logger.warn("Unable to find the parameter: {} in the execution context", SERVICE_MODEL_INFO); + exceptionUtil + .buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, + "Unable to find parameter " + SERVICE_MODEL_INFO); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index 7d449e72a8..c16175b8e2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -34,4 +34,26 @@ public class ExecutionVariableNames { public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification"; public final static String PNF_UUID = "pnfUuid"; public final static String SERVICE_INSTANCE_ID = "serviceInstanceId"; + public final static String MSO_REQUEST_ID = "msoRequestId"; + public final static String MODEL_UUID = "modelUuid"; + + public final static String SERVICE_MODEL_INFO = "serviceModelInfo"; + + /** + * Variable used to contain the {@link org.onap.so.client.cds.beans.AbstractCDSPropertiesBean} json value. + */ + public static final String EXECUTION_OBJECT = "executionObject"; + + /** + * Variables used to contain the {@link org.onap.so.db.catalog.beans.PnfResourceCustomization} fields. + */ + public static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName"; + public static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion"; + public static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid"; + public static final String PRC_INSTANCE_NAME = "PRC_instanceName"; + + /** + * Variable used to contain skipPostInstantiationConfiguration flag. + */ + public static final String SKIP_POST_INSTANTIATION_CONFIGURATION = "SkipPostInstantiationConfiguration"; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java new file mode 100644 index 0000000000..49887af4be --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java @@ -0,0 +1,84 @@ +/* + * ============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.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_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 org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Abstract class for preparing CDS call. + */ +public abstract class PrepareCdsCallDelegate implements JavaDelegate { + + protected Logger logger = LoggerFactory.getLogger(this.getClass()); + + protected static final String ORIGINATOR_ID = "SO"; + protected static final int ERROR_CODE = 7010; + + protected String actionName; + protected String mode; + + @Autowired + protected ExceptionBuilder exceptionUtil; + + @Override + public void execute(DelegateExecution delegateExecution){ + + logger.debug("Running execute block for activity:{}", delegateExecution.getCurrentActivityId()); + AbstractCDSPropertiesBean cdsPropertiesBean = new AbstractCDSPropertiesBean(); + cdsPropertiesBean.setBlueprintName((String) delegateExecution.getVariable(PRC_BLUEPRINT_NAME)); + cdsPropertiesBean.setBlueprintVersion((String) delegateExecution.getVariable(PRC_BLUEPRINT_VERSION)); + cdsPropertiesBean.setOriginatorId(ORIGINATOR_ID); + cdsPropertiesBean.setActionName(getActionName()); + cdsPropertiesBean.setMode(getMode()); + cdsPropertiesBean.setRequestId((String) delegateExecution.getVariable(MSO_REQUEST_ID)); + cdsPropertiesBean.setSubRequestId((String) delegateExecution.getVariable(PNF_UUID)); + cdsPropertiesBean.setRequestObject(getRequestObject(delegateExecution)); + delegateExecution.setVariable(EXECUTION_OBJECT, cdsPropertiesBean); + } + + /** + * Return the request object sent to CDS call. + * + * @param delegateExecution BPMN delegateExecution context + * @return string value of the request object + */ + protected abstract String getRequestObject(final DelegateExecution delegateExecution); + + public String getActionName() { + return actionName; + } + + public String getMode() { + return mode; + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java new file mode 100644 index 0000000000..5bf167ea7a --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java @@ -0,0 +1,79 @@ +/* + * ============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.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID; +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_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 org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +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.springframework.stereotype.Component; + +/** + * This implementation of {@link JavaDelegate} is used to prepare for config Assign. + * + * It queries the PNF resource customization table and construct the {@link AbstractCDSPropertiesBean} as + * executionObject. + */ +@Component +public class PrepareConfigAssignDelegate extends PrepareCdsCallDelegate { + + public PrepareConfigAssignDelegate() { + this.actionName = "config-assign"; + this.mode = "sync"; + } + + @Override + protected String getRequestObject(final DelegateExecution delegateExecution){ + + ConfigAssignPropertiesForPnf configAssignProperties = new ConfigAssignPropertiesForPnf(); + configAssignProperties.setServiceInstanceId((String) delegateExecution.getVariable(SERVICE_INSTANCE_ID)); + + /** + * PNF Name matches the name in AAI, i.e., correlationID as in customized workflow. + */ + configAssignProperties.setPnfName((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + /** + * PNF id match AAI entry, i.e, PNF UUID. + */ + configAssignProperties.setPnfId((String) delegateExecution.getVariable(PNF_UUID)); + configAssignProperties.setPnfCustomizationUuid((String) delegateExecution.getVariable(PRC_CUSTOMIZATION_UUID)); + configAssignProperties.setServiceModelUuid((String) delegateExecution.getVariable(MODEL_UUID)); + + ConfigAssignRequestPnf configAssignRequest = new ConfigAssignRequestPnf(); + configAssignRequest.setConfigAssignPropertiesForPnf(configAssignProperties); + + /** + * resolution key is the same as PNF name. + */ + configAssignRequest.setResolutionKey((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + return configAssignRequest.toString(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java new file mode 100644 index 0000000000..9b13be8e52 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java @@ -0,0 +1,108 @@ +/* + * ============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.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID; +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_CUSTOMIZATION_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; + +import java.io.IOException; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.aai.domain.yang.Pnf; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This implementation of {@link JavaDelegate} is used to prepare for config Deploy. + * + * It queries the PNF resource customization table and construct the {@link AbstractCDSPropertiesBean} as + * executionObject. + */ +@Component +public class PrepareConfigDeployDelegate extends PrepareCdsCallDelegate { + + @Autowired + private PnfManagement pnfManagement; + + public PrepareConfigDeployDelegate() { + this.actionName = "config-deploy"; + this.mode = "async"; + } + + @Override + protected String getRequestObject(DelegateExecution delegateExecution){ + + ConfigDeployPropertiesForPnf configDeployProperties = new ConfigDeployPropertiesForPnf(); + + configDeployProperties.setServiceInstanceId((String) delegateExecution.getVariable(SERVICE_INSTANCE_ID)); + + /** + * PNF Name matches the name in AAI, i.e., correlationID as in customized workflow. + */ + configDeployProperties.setPnfName((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + /** + * PNF id match AAI entry, i.e, PNF UUID. + */ + configDeployProperties.setPnfId((String) delegateExecution.getVariable(PNF_UUID)); + configDeployProperties.setPnfCustomizationUuid((String) delegateExecution.getVariable(PRC_CUSTOMIZATION_UUID)); + configDeployProperties.setServiceModelUuid((String) delegateExecution.getVariable(MODEL_UUID)); + setIpAddress(configDeployProperties, delegateExecution); + + ConfigDeployRequestPnf configDeployRequest = new ConfigDeployRequestPnf(); + configDeployRequest.setConfigDeployPropertiesForPnf(configDeployProperties); + + /** + * Resolution key is the same as PNF name. + */ + configDeployRequest.setResolutionKey((String) delegateExecution.getVariable(PNF_CORRELATION_ID)); + + return configDeployRequest.toString(); + } + + private void setIpAddress(ConfigDeployPropertiesForPnf configDeployProperties, DelegateExecution delegateExecution) { + + /** + * Retrieve PNF entry from AAI. + */ + try { + String pnfName = (String) delegateExecution.getVariable(PNF_CORRELATION_ID); + Optional pnfOptional = pnfManagement.getEntryFor(pnfName); + if ( pnfOptional.isPresent()){ + Pnf pnf = pnfOptional.get(); + configDeployProperties.setPnfIpV4Address(pnf.getPnfIpv4Address()); + configDeployProperties.setPnfIpV6Address(pnf.getPnfIpv6Address()); + } else { + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, "AAI entry for PNF: " + pnfName + " does not exist"); + } + } catch (IOException e) { + logger.warn(e.getMessage(), e); + exceptionUtil.buildAndThrowWorkflowException(delegateExecution, ERROR_CODE, "Unable to fetch from AAI" + e.getMessage()); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 1b7a69eec8..6f828f6cb0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -136,7 +136,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient { Runnable runnable = unregister(pnfCorrelationId); if (runnable != null) { logger.debug("dmaap listener gets pnf ready event for pnfCorrelationId: {}", pnfCorrelationId); - runnable.run(); + //runnable.run(); + runnable = null; } } } 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 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(); } diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index 59b9027000..ce7f0d9148 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -8,6 +8,14 @@ 4.0.0 so-bpmn-infrastructure-flows jar + + + 2.0-alpha2 + 1.7.0 + 1.17.1 + 3.2.1 + + @@ -138,6 +146,12 @@ ${camunda.springboot.version} test + + org.camunda.bpm.extension.mockito + camunda-bpm-mockito + ${camunda.mockito.version} + test + org.springframework.boot spring-boot-starter-test @@ -197,6 +211,13 @@ MSOCoreBPMN ${project.version} + + org.onap.so + MSOCoreBPMN + ${project.version} + tests + test + org.onap.so MSOCommonBPMN @@ -204,11 +225,17 @@ org.onap.so - MSOCoreBPMN + MSOCommonBPMN ${project.version} tests test + + org.onap.so + so-bpmn-building-blocks + ${project.version} + test + javax.ws.rs javax.ws.rs-api @@ -239,6 +266,18 @@ camunda-engine-plugin-connect test + + org.camunda.bpm.extension + camunda-bpm-assert + ${camunda.bpm.assert.version} + test + + + org.assertj + assertj-core + ${assertj.core.version} + test + javax.annotation javax.annotation-api @@ -271,5 +310,12 @@ 2.2.3 test + + io.grpc + grpc-testing + ${grpc.version} + test + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn new file mode 100644 index 0000000000..f489a27052 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn @@ -0,0 +1,198 @@ + + + + + SequenceFlow_069mxkg + + + SequenceFlow_1u89rk8 + SequenceFlow_157of54 + SequenceFlow_0j3pm2g + + + SequenceFlow_157of54 + SequenceFlow_1n080up + + + #{SkipPostInstantiationConfiguration} + + + SequenceFlow_0j3pm2g + SequenceFlow_17llfxw + + + + + + + + + SequenceFlow_17llfxw + SequenceFlow_0p0aqtx + + + SequenceFlow_0p0aqtx + SequenceFlow_1owbpsy + SequenceFlow_1w4p9f7 + + + + #{execution.getVariable("CDSStatus").equals("Success")} + + + + + + + + + SequenceFlow_0jfgn7n + SequenceFlow_08voj55 + + + SequenceFlow_08voj55 + SequenceFlow_1n080up + SequenceFlow_0d24h26 + + + + #{execution.getVariable("CDSStatus").equals("Success")} + + + + SequenceFlow_1w4p9f7 + + + + + SequenceFlow_0d24h26 + + + + SequenceFlow_069mxkg + SequenceFlow_1u89rk8 + + + + + #{!SkipPostInstantiationConfiguration} + + + SequenceFlow_1owbpsy + SequenceFlow_0jfgn7n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn index 9579f770fc..9e33cbc68d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_7 @@ -343,7 +343,7 @@ CreateVcpeResCustService.prepareDecomposeService(execution) - SequenceFlow_0clhseq + SequenceFlow_0ti37h1 @@ -355,7 +355,6 @@ CreateVcpeResCustService.processDecomposition(execution) - @@ -365,7 +364,7 @@ CreateVcpeResCustService.processDecomposition(execution) SequenceFlow_1yojilk - SequenceFlow_0clhseq + SequenceFlow_050kuu1 @@ -422,6 +421,20 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution)SequenceFlow_0gj4vud SequenceFlow_1yojilk + + + + + + + + + + + + SequenceFlow_050kuu1 + SequenceFlow_0ti37h1 + @@ -554,25 +567,25 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + - + - + @@ -591,7 +604,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -599,7 +612,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -608,14 +621,14 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + @@ -624,7 +637,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -692,7 +705,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -700,7 +713,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -754,7 +767,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -771,7 +784,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -787,13 +800,13 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + @@ -806,20 +819,20 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + - + @@ -827,27 +840,27 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + - + - + @@ -860,7 +873,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -874,7 +887,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -904,7 +917,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -929,9 +942,9 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + @@ -943,13 +956,13 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + @@ -963,7 +976,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -971,14 +984,14 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + - + @@ -996,7 +1009,7 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - + @@ -1016,13 +1029,6 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) - - - - - - - @@ -1082,6 +1088,17 @@ CreateVcpeResCustService.postProcessServiceInstanceCreate(execution) + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java new file mode 100644 index 0000000000..4f98ee4f1b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/AllBPMNTestSuites.java @@ -0,0 +1,32 @@ +/* + * + * ============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; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; +import org.junit.runner.RunWith; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({"**/service/*Test.class", "**/process/*Test.class", "**/subprocess/*Test.class"}) +public class AllBPMNTestSuites { + // the class remains empty, + // used only as a holder for the above annotations +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java new file mode 100644 index 0000000000..648c9887c2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/BaseBPMNTest.java @@ -0,0 +1,69 @@ +/* + * ============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; + +import com.github.tomakehurst.wiremock.WireMockServer; +import java.util.HashMap; +import java.util.Map; +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.junit.After; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public abstract class BaseBPMNTest { + + @Autowired + protected RuntimeService runtimeService; + + @Autowired + protected RepositoryService repositoryService; + + @Autowired + protected HistoryService historyService; + + protected Map variables = new HashMap<>(); + + @LocalServerPort + protected int port; + + @Autowired + protected WireMockServer wireMockServer; + + @Value("${wiremock.server.port}") + protected int wireMockPort; + + @After + public void shutDown(){ + wireMockServer.resetAll(); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..963d989eb7 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import javax.sql.DataSource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration +@Profile({"test"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + MariaDB4jSpringService service = new MariaDB4jSpringService(); + + + service.getConfiguration().addArg("--lower_case_table_names=1"); + return service; + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java new file mode 100644 index 0000000000..a4de95e4fa --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/GrpcNettyServer.java @@ -0,0 +1,110 @@ +/* + * ============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; + +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.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 List messagesDelivered = new ArrayList<>(); + private final CountDownLatch allRequestsDelivered = new CountDownLatch(1); + private final AtomicReference> responseObserverRef = new AtomicReference<>(); + + @PostConstruct + public void start() throws IOException { + + final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = + new BluePrintProcessingServiceImplBase() { + @Override + public StreamObserver process( + StreamObserver responseObserver) { + + responseObserverRef.set(responseObserver); + + StreamObserver requestObserver = new StreamObserver() { + @Override + public void onNext(ExecutionServiceInput message) { + messagesDelivered.add(message.getActionIdentifiers().getActionName()); + 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 getMessagesDelivered() { + return this.messagesDelivered; + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java deleted file mode 100644 index 3f0a2145df..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/InfraEmbeddedMariaDbConfig.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so; -import ch.vorburger.exec.ManagedProcessException; -import ch.vorburger.mariadb4j.DBConfigurationBuilder; -import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", - basePackages = { "org.onap.so.db.request.data.repository"} -) -@Profile({"test"}) -public class InfraEmbeddedMariaDbConfig { - - @Primary - @Bean(name = "requestEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean - entityManagerFactory( - EntityManagerFactoryBuilder builder, - DataSource dataSource - ) { - return builder - .dataSource(dataSource) - .packages("org.onap.so.db.request.beans") - .persistenceUnit("requestDB") - .build(); - } - - @Bean(name = "requestTransactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("requestEntityManagerFactory") EntityManagerFactory - entityManagerFactory - ) { - return new JpaTransactionManager(entityManagerFactory); - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java index f1b69c653f..64311d85da 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/TestApplication.java @@ -31,13 +31,11 @@ import org.springframework.context.annotation.Profile; @SpringBootApplication @Profile("test") @ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = { - @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class) }) + @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) public class TestApplication { public static void main(String... args) { SpringApplication.run(TestApplication.class, args); System.getProperties().setProperty("mso.db", "MARIADB"); System.getProperties().setProperty("server.name", "Springboot"); - - } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java deleted file mode 100644 index 0521fa737d..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/ValidBPMNTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -@ContextConfiguration -@AutoConfigureWireMock(port = 0) -public class ValidBPMNTest { - - @Test - public void verifyApplicationStartup(){ - //Verifys Springboot app can start up and all BPMN's are in fact parsable - assert(true); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java new file mode 100644 index 0000000000..897ab037f2 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -0,0 +1,261 @@ +/* + * + * ============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.process; + +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +import java.io.IOException; +import java.util.List; +import java.util.UUID; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.mock.FileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + + +/** + * Basic Integration test for createVcpeResCustService_Simplified.bpmn workflow. + */ +public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private static final String TEST_PROCESSINSTANCE_KEY = "CreateVcpeResCustService_simplified"; + + private String testBusinessKey; + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + + requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); + responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); + + variables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. + * It's injected by {@link WorkflowProcessor}. + */ + variables.put("isAsyncProcess", "true"); + + /** + * Temporary solution to add pnfCorrelationId to context. + * this value is getting from the request to SO api handler and then convert to CamudaInput + */ + variables.put("pnfCorrelationId", "PNFDemo"); + + /** + * Create mso-request-id. + */ + String msoRequestId = UUID.randomUUID().toString(); + + variables.put("mso-request-id", msoRequestId); + + /** + * Create Business key for the process instance + */ + testBusinessKey = UUID.randomUUID().toString(); + + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + } + + @Test + public void workflow_validInput_expectedOuput() { + + mockCatalogDb(); + mockAai(); + mockDmaapForPnf(); + + ProcessInstance pi = runtimeService + .startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, variables); + assertThat(pi).isNotNull(); + + Execution execution = runtimeService.createExecutionQuery().processDefinitionKey("CreateAndActivatePnfResource") + .activityId("WaitForDmaapPnfReadyNotification").singleResult(); + + if (!execution.isSuspended() && !execution.isEnded()) { + try { + + runtimeService.signal(execution.getId()); + } catch (Exception e) { + logger.info(e.getMessage(), e); + } + } + + assertThat(pi).isStarted().hasPassedInOrder( + "createVCPE_startEvent", + "preProcessRequest_ScriptTask", + "sendSyncAckResponse_ScriptTask", + "ScriptTask_0cdtchu", + "DecomposeService", + "ScriptTask_0lpv2da", + "ScriptTask_1y241p8", + "CallActivity_1vc4jeh", + "ScriptTask_1y5lvl7", + "GeneratePnfUuid", + "Task_14l19kv", + "Pnf_Con", + "setPONR_ScriptTask", + "postProcessAndCompletionRequest_ScriptTask", + "callCompleteMsoProcess_CallActivity", + "ScriptTask_2", + "CreateVCPE_EndEvent" + ); + + assertThat(pi).isEnded(); + + List messagesDelivered = grpcNettyServer.getMessagesDelivered(); + assertThat(messagesDelivered).containsSequence("config-assign", "config-deploy"); + } + + /** + * Mock the Dmaap Rest interface for Pnf topic. + */ + private void mockDmaapForPnf() { + + String pnfResponse = "[{\"correlationId\": \"PNFDemo\",\"key1\":\"value1\"}]"; + + /** + * Get the events from PNF topic + */ + wireMockServer + .stubFor(get(urlPathMatching("/events/pnfReady/consumerGroup.*")).willReturn(okJson(pnfResponse))); + } + + private void mockAai() { + + String aaiResponse = "{\n" + + " \"results\": [\n" + + " {\n" + + " \"resource-type\": \"service-instance\",\n" + + " \"resource-link\": \"https://localhost:8443/aai/v15/business/customers/customer/ADemoCustomerInCiti/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/key3\"\n" + + " }\n" + + " ]\n" + + "}"; + + String aaiPnfEntry = "{ \n" + + " \"pnf-name\":\"PNFDemo\",\n" + + " \"pnf-id\":\"testtest\",\n" + + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + + " \"pnf-ipv4-address\":\"1.1.1.1\",\n" + + " \"pnf-ipv6-address\":\"ipv6\"\n" + + "}"; + + /** + * Get the AAI entry for globalCustomerId as specified in the request file. + */ + wireMockServer.stubFor( + get(urlPathMatching("/aai/v15/business/customers/customer/ADemoCustomerInCiti.*")).willReturn(ok())); + + /** + * PUT the service to AAI with globalCustomerId, service type as specified in the request file. + * Service instance id is generated during runtime, REGEX is used to represent the information. + */ + wireMockServer.stubFor(put(urlPathMatching( + "/aai/v15/business/customers/customer/ADemoCustomerInCiti/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/.*"))); + + wireMockServer.stubFor(get(urlPathMatching( + "/aai/v15/business/customers/customer/ADemoCustomerInCiti/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/.*")) + .willReturn(okJson(aaiResponse))); + + /** + * Get the service from AAI + */ + wireMockServer.stubFor(get(urlPathMatching("/aai/v15/nodes/service-instances/service-instance/.*")) + .willReturn(okJson(aaiResponse))); + + /** + * Put the project as specified in the request file to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/v15/business/projects/project/Project-Demonstration"))); + + /** + * GET the project as specified in the request file to AAI. + */ + wireMockServer + .stubFor(get(urlPathMatching("/aai/v15/business/projects/project/Project-Demonstration")).willReturn(ok())); + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/v15/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor(get(urlEqualTo("/aai/v15/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /** + * Put the PNF relationship + */ + wireMockServer.stubFor( + put(urlEqualTo("/aai/v15/business/projects/project/Project-Demonstration/relationship-list/relationship"))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = FileUtil + .readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=f2daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=539b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=f2daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn deleted file mode 100644 index b33aad7443..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn +++ /dev/null @@ -1,54 +0,0 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_1v2f9n5 - - - - SequenceFlow_1v2f9n5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn deleted file mode 100644 index 807efae1af..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn +++ /dev/null @@ -1,55 +0,0 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_1epm19d - - - SequenceFlow_1 - SequenceFlow_1epm19d - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn deleted file mode 100644 index b2f280d7e9..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn +++ /dev/null @@ -1,38 +0,0 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn deleted file mode 100644 index 532ca867bb..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn +++ /dev/null @@ -1,53 +0,0 @@ - - - - - SequenceFlow_1ipu8um - - - SequenceFlow_1l4c4k0 - - - SequenceFlow_1ipu8um - SequenceFlow_1l4c4k0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn deleted file mode 100644 index 5e4400e9bd..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn +++ /dev/null @@ -1,53 +0,0 @@ - - - - - SequenceFlow_11sp3s9 - - - - SequenceFlow_11sp3s9 - SequenceFlow_0q1lfmf - - - - - SequenceFlow_0q1lfmf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn deleted file mode 100644 index 2867a671b6..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn +++ /dev/null @@ -1,53 +0,0 @@ - - - - - SequenceFlow_1537b7m - - - SequenceFlow_1mz2mgf - - - - SequenceFlow_1537b7m - SequenceFlow_1mz2mgf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn deleted file mode 100644 index 517df36c74..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn +++ /dev/null @@ -1,37 +0,0 @@ - - - - - SequenceFlow_0qi7pl3 - - - - SequenceFlow_0qi7pl3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn deleted file mode 100644 index ad4c3c816d..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/VCPE/stubprocess/Homing.bpmn +++ /dev/null @@ -1,35 +0,0 @@ - - - - - SequenceFlow_0tyavm9 - - - SequenceFlow_0tyavm9 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml index daf7279b70..fa753396cf 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml @@ -1,6 +1,10 @@ aai: auth: 5A1272FE739BECA4D4374A86B25C021DFE6745E3BB7BE6836BF64A6059B8220E586C21FD7567AF41DB42571EB7 endpoint: http://localhost:${wiremock.server.port} + #PnfCheckInputs + pnfEntryNotificationTimeout: P14D + #CreateVcpeResCustService:preProcessRequest + workflowAaiDistributionDelay: P14D appc: client: key: iaEMAfjsVsZnraBP @@ -55,6 +59,11 @@ mso: workflow: message: endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message + #${mso.adapters.requestDb.endpoint}:BBInputSetupUtils,RequestsDBClient + requestDb: + #${mso.adapters.requestDb.auth}: BBInputSetup + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:${wiremock.server.port} async: core-pool-size: 50 @@ -67,7 +76,8 @@ mso: callbackRetryAttempts: '5' catalog: db: - endpoint: http://localhost:${wiremock.server.port}/ + #CatalogDbUtils.groovy:getResponseFromCatalogDb + endpoint: http://localhost:${wiremock.server.port} spring: endpoint: http://localhost:${wiremock.server.port} correlation: @@ -90,6 +100,10 @@ mso: request: db: endpoint: http://localhost:${wiremock.server.port}/ + #request DB endpoint + requestDb: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + endpoint: http://localhost:${wiremock.server.port} rollback: 'true' sdnc: password: 3141634BF7E070AA289CF2892C986C0B @@ -111,6 +125,7 @@ mso: notification: name: GenericNotificationService sdncadapter: + #DoCreateServiceInstance.groovy: preProcessRequest callback: http://localhost:${wiremock.server.port}/mso/SDNCAdapterCallbackService vnfadapter: create: @@ -173,7 +188,6 @@ spring: database-platform: org.hibernate.dialect.MySQL5InnoDBDialect security: usercredentials: - - username: test password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' role: BPEL-Client @@ -192,3 +206,21 @@ camunda: deploy-changed-only: true job-execution: deployment-aware: true +# PnfEventReadyDmaapClient +pnf: + dmaap: + host: localhost + port: ${wiremock.server.port} + protocol: http + uriPathPrefix: events + topicName: pnfReady + consumerGroup: consumerGroup + consumerId: consumerId + topicListenerDelayInSeconds: 5 +# CDSProcessingClient +cds: + endpoint: localhost + port: 11011 + auth: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + timeout: 60 + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml deleted file mode 100644 index b1a8c4be07..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yml +++ /dev/null @@ -1,303 +0,0 @@ -aai: - auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C - dme2: - timeout: '30000' - endpoint: https://localhost:8443 -camunda: - bpm: - admin-user: - id: admin - password: admin - database: - type: h2 - history-level: FULL - metrics: - enabled: false - db-reporter-activate: false - application: - delete-upon-undeploy: false - scan-for-process-definitions: true - deploy-changed-only: true - job-execution: - deployment-aware: true -canopi: - auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C -csi: - aots: - addincidentmanagement: - endpoint: http://localhost:28090/AddIncidentManagementTicketRequest - networkstatus: - endpoint: http://localhost:28090/SendManagedNetworkStatusNotification -entitymanager: - packagesToScan: com - -mso: - correlation: - timeout: PT60S - logPath: logs - async: - core-pool-size: 50 - max-pool-size: 50 - queue-capacity: 500 - adapters: - completemsoprocess: - endpoint: http://localhost:30253/CompleteMsoProcess - db: - auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C - password: wLg4sjrAFUS8rfVfdvTXeQ== - endpoint: http://localhost:28090 - spring: - endpoint: http://localhost:28090 - network: - endpoint: http://localhost:30253/services/NetworkAdapter - rest: - endpoint: http://localhost:30253/services/rest/v1/networks - openecomp: - db: - endpoint: http://localhost:30257/services/RequestsDbAdapter - po: - auth: 5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C - password: 3141634BF7E070AA289CF2892C986C0B - sdnc: - endpoint: http://localhost:30254/adapters/SDNCAdapter - rest: - endpoint: http://localhost:30254/adapters/rest/v1/sdnc - timeout: PT60S - tenant: - endpoint: http://localhost:30253/services/TenantAdapter - vnf: - endpoint: http://localhost:30253/services/VnfAdapter - rest: - endpoint: http://localhost:30253/services/rest/v1/vnfs - volume-groups: - rest: - endpoint: http://localhost:30253/services/rest/v1/volume-groups - vnf-async: - endpoint: http://localhost:30253/services/VnfAdapterAsync - adiod: - vce: - service: - model: - invariant: - uuid: 1cc4e2e4-eb6e-404d-a66f-c8733cedcce8 - version: '5.0' - bpmn: - process: - historyTimeToLive: '30' - callbackRetryAttempts: '5' - catalog: - db: - endpoint: http://localhost:30258/ecomp/mso/catalog - spring: - endpoint: http://localhost:30258 - csi: - pwd: E684FA9977AF5DFB50F5ADC5B7425FDFA0CEBFF2E138E0477549879AEC8A9CE2DB7563 - sendmanagednetworkstatusnotification: - applicationname: NetworkManagementEthernetOverFiber - version: '212' - usrname: mso - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= - default: - adapter: - namespace: http://com.att.mso - gateway: - service: - model: - name: HNGWaaS for DHV Test - healthcheck: - log: - debug: 'false' - infra: - customer: - id: testCustIdInfra - msoKey: 07a7159d3bf51a0e53be7a8f89699be7 - oam: - network: - role: - gateway: HngwOamNetVto.OAM - portal: HnportalOamNetVto.OAM - po: - timeout: PT60S - portal: - service: - model: - name: HNPortalaaS for DHV Test - request: - db: - endpoint: http://localhost:28090/ - rollback: 'true' - sdnc: - firewall: - yang: - model: - version: '2015-05-15' - password: 3141634BF7E070AA289CF2892C986C0B - timeout: - firewall: - minutes: '20' - ucpe: - async: - hours: '120' - minutes: '5' - service: - agnostic: - sniro: - endpoint: /sniro/api/v2/placement - host: http://localhost:30253 - site-name: CamundaEngine - sniro: - auth: test:testpwd - callback: http://localhost:28090/adapters/rest/SDNCNotify - endpoint: http://localhost:28090/optimizationInstance/V1/create - policies: - dhv: - 2vvig: SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 - 4vvig: SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.VNFPolicy_vvigprimary2_v1,SNIRO.VNFPolicy_vvigsecondary2_v1,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 - timeout: PT30M - sriov: - network: - role: - gateway1: HngwSriovProviderNet.SR_IOV_Provider2_1 - gateway2: HngwSriovProviderNet.SR_IOV_Provider2_2 - portal1: HnportalSriovProviderNet3.SR_IOV_Provider2_1 - portal2: HnportalSriovProviderNet3.SR_IOV_Provider2_2 - workflow: - aai: - distribution: - delay: PT5S - CreateGenericVNFV1: - aai: - volume-group: - uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group - DHVCreateService: - aai: - customer: - uri: /aai/v9/business/customers/customer - createvce: - delay: - seconds: '1' - default: - aai: - version: '8' - cloud-region: - version: '9' - generic-vnf: - version: '9' - retry: - attempts: '1' - deleteCinderVolumeV1: - aai: - volume-group: - uri: /aai/v6/cloud-infrastructure/volume-groups/volume-group - global: - default: - aai: - namespace: http://org.openecomp.aai.inventory/ - l3ToHigherLayerAddBonding: - model: - invariantid: 50359538-066f-4a8d-807f-f2bc8eaa79dc - name: WAN Bonding v0.1 - version: '0.1' - versionid: 52dbec20-47aa-42e4-936c-331d8e350d44 - message: - endpoint: http://localhost:30252/mso/WorkflowMessage - notification: - name: GenericNotificationServiceATT - sdncadapter: - callback: http://localhost:30254/mso/SDNCAdapterCallbackService - vnfadapter: - create: - callback: http://localhost:30253/mso/vnfAdapterNotify - delete: - callback: http://localhost:30253/mso/vnfAdapterNotify - query: - callback: http://localhost:30253/mso/vnfAdapterNotify - rollback: - callback: http://localhost:30253/mso/vnfAdapterNotify -org: - onap: - so: - cloud-owner: CloudOwner -policy: - auth: Basic dGVzdHBkcDphbHBoYTEyMw== - client: - auth: Basic bTAzNzQzOnBvbGljeVIwY2sk - endpoint: https://localhost:8081/pdp/api/ - environment: TEST -sdnc: - auth: Basic YWRtaW46YWRtaW4= - host: https://localhost:8443 - path: /restconf/operations/GENERIC-RESOURCE-API -sdno: - health-check: - dmaap: - password: eHQ1cUJrOUc - publisher: - topic: com.att.sdno.test-health-diagnostic-v02 - subscriber: - topic: com.att.sdno.test-health-diagnostic-v02 - username: testuser -sniro: - conductor: - host: http://localhost:30253 - uri: /release - manager: - host: http://localhost:30253 - uri: /sniro/api/placement/v2 - headers.auth: Basic dGVzdDp0ZXN0cHdk - headers.patchVersion: 1 - headers.minorVersion: 1 - headers.latestVersion: 2 -server: - port: 8080 - tomcat: - max-threads: 50 - # ssl: - # key-store: /app/msoClientKeyStore.jks - # key-store-password: mso4you - # key-store-type: JKS - # trust-store: /app/msoTrustStore.jks - # trust-store-password: mso_Domain2.0_4you -spring: - h2: - console: - enabled: true - path: /h2 - datasource: - url: jdbc:h2:mem:AZ;;DB_CLOSE_ON_EXIT=FALSE - username: sa - password: sa - driverClassName: org.h2.Driver - security: - usercredentials: - - - username: test - password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' - role: BPMN-Client -# Hibernate -hibernate: - dialect: org.hibernate.dialect.MySQL5Dialect - show_sql: false - -management: - security: - enabled: false - -security: - basic: - enabled: false - -appc: - client: - topic: - read: - name: APPC-TEST-AMDOCS2 - timeout: 360000 - write: APPC-TEST-AMDOCS1-IST - response: - timeout: 360000 - key: LSl8QKolmKcC0yJR - secret: lgjXraD1HutKxv8jEN6tVouu - service: ueb - poolMembers: localhost:3904,localhost:3904,localhost:3904 diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml index 38a2ef6ef5..3b0bdb252f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/logback-test.xml @@ -1,44 +1,69 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level + %logger{1024} - %msg%n + + + - - - %d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level - %logger{1024} - %msg%n - - - + + ${LOGS}/testing.log + + %d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level + %logger{1024} - %msg%n + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/CreateVcpeResCustServiceSimplifiedTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/CreateVcpeResCustServiceSimplifiedTest.json new file mode 100644 index 0000000000..b43148aa73 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/CreateVcpeResCustServiceSimplifiedTest.json @@ -0,0 +1,47 @@ +{ + "requestDetails":{ + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"demo", + "productFamilyId":"vCPEid" + }, + "modelInfo":{ + "modelType":"service", + "modelInvariantUuid":"539b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelInvariantId":"539b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"f2daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "requestParameters":{ + "userParams":[ + { + "name":"aic_zone", + "value":"nova" + }, + { + "name":"pnfId", + "value":"PNFDemo" + } + ], + "subscriptionServiceType":"vCPE", + "aLaCarte":false, + "pnfCorrelationId": "PNFDemo" + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"regionOne", + "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" + }, + "subscriberInfo":{ + "globalSubscriberId":"ADemoCustomerInCiti" + }, + "project":{ + "projectName":"Project-Demonstration" + }, + "owningEntity":{ + "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", + "owningEntityName":"OE-Demonstration" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest.json new file mode 100644 index 0000000000..a88f261c30 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest.json @@ -0,0 +1,26 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelInvariantId":"539b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"f2daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "serviceType":"NA", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json new file mode 100644 index 0000000000..66d1a88ee8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/CreateVcpeResCustServiceSimplifiedTest_catalogdb.json @@ -0,0 +1,37 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "68dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_configuration_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/68dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=5df8b6de-2083-11e7-93ae-92361f002676" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn deleted file mode 100644 index 66f458425e..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/stubprocess/GenericStub.bpmn +++ /dev/null @@ -1,35 +0,0 @@ - - - - - SequenceFlow_0tyavm9 - - - SequenceFlow_0tyavm9 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 14eb42ff79..42073ed08a 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -131,7 +131,7 @@ org.onap.sdnc.northbound generic-resource-api-client - 1.5.0-SNAPSHOT + ${sdnc.northbound.version} javax.ws.rs -- cgit 1.2.3-korg