summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
authoreeginux <henry.xie@est.tech>2019-04-03 14:28:09 +0000
committereeginux <henry.xie@est.tech>2019-04-04 11:41:31 +0100
commit88c47a23b9428188ff5dd0b46941f8856465376b (patch)
tree3f1e028033ad56f398e8154f0be2272012b666b2 /bpmn/so-bpmn-infrastructure-common/src
parentb168125f237629b6dd7d73897548f2ee70139ed3 (diff)
PNF WF post instantiation configuration
Add PNF ipv4/v6 address for config Deploy Add Integration test for CreateVcpeResCustService_simplified.bpmn Modify the PnfEventReadyDmaapClient to avoid one more running thread Refactor the so-bpmn-infrastructure-flows test resources Modify the CreateVcpeResCustService_simplified.bpmn Add ConfigurePnfResource.bpmn Add Delegates Issue-ID: SO-1506 Change-Id: Iffb69d1441ef0b485ee8cd3fb5da5f1a35279a95 Signed-off-by: eeginux <henry.xie@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java97
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java22
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareCdsCallDelegate.java84
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegate.java79
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegate.java108
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java148
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java136
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java188
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java2
10 files changed, 865 insertions, 2 deletions
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<PnfResourceCustomization> 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<Pnf> 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<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>();
+ pnfResourceCustomizations.add(buildPnfResourceCustomization());
+ given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID))
+ .willReturn(pnfResourceCustomizations);
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ execution.setVariable(SERVICE_MODEL_INFO, TEST_SERVICE_MODEL_INFO);
+ }
+
+ private PnfResourceCustomization buildPnfResourceCustomization() {
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ pnfResourceCustomization.setSkipPostInstConf(true);
+ pnfResourceCustomization.setBlueprintName(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ pnfResourceCustomization.setBlueprintVersion(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ pnfResourceCustomization.setModelInstanceName(TEST_PNF_RESOURCE_INSTANCE_NAME);
+ pnfResourceCustomization.setModelCustomizationUUID(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ return pnfResourceCustomization;
+ }
+
+ @Test
+ public void testExecution_validCatalogdb_skipVariableSet() {
+ try {
+ configCheckerDelegate.execute(execution);
+ assertThat(execution.getVariable(MODEL_UUID)).isEqualTo(TEST_MODEL_UUID);
+ assertThat(execution.getVariable(SKIP_POST_INSTANTIATION_CONFIGURATION)).isEqualTo(Boolean.TRUE);
+ assertThat(execution.getVariable(PRC_BLUEPRINT_NAME)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(execution.getVariable(PRC_BLUEPRINT_VERSION)).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(execution.getVariable(PRC_CUSTOMIZATION_UUID)).isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(execution.getVariable(PRC_INSTANCE_NAME)).isEqualTo(TEST_PNF_RESOURCE_INSTANCE_NAME);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testExecution_EmptyPnfResourceCustomization_exceptionThrown() {
+ given(catalogDbClient.getPnfResourceCustomizationByModelUuid("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"))
+ .willReturn(Collections.EMPTY_LIST);
+
+ assertThatThrownBy(() -> configCheckerDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString()
+ .contains("Unable to find the PNF resource customizations of model service UUID")
+ .contains("f2daaac6-5017-4e1e-96c8-6a27dfbe1421");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+
+ @Test
+ public void testExecution_NonExistingServiceModelInfo_exceptionThrown() {
+ execution.removeVariable("serviceModelInfo");
+ assertThatThrownBy(() -> configCheckerDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString()
+ .contains("Unable to find parameter serviceModelInfo");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java
new file mode 100644
index 0000000000..8d817e5bca
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java
@@ -0,0 +1,136 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.cds.beans.ConfigAssignPropertiesForPnf;
+import org.onap.so.client.cds.beans.ConfigAssignRequestPnf;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ExceptionBuilder.class, PrepareConfigAssignDelegate.class})
+public class PrepareConfigAssignDelegateTest {
+
+ private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static String TEST_PROCESS_KEY = "processKey1";
+ private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+ private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+
+ @Autowired
+ private PrepareConfigAssignDelegate prepareConfigAssignDelegate;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp(){
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ }
+
+ @Test
+ public void testExecution_validPnf_executionObjectCreated() {
+ try {
+ prepareConfigAssignDelegate.execute(execution);
+ Object executionObject = execution.getVariable(EXECUTION_OBJECT);
+ assertThat(executionObject).isNotNull();
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ checkCDSPropertiesBean((AbstractCDSPropertiesBean) executionObject);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ private void checkCDSPropertiesBean(AbstractCDSPropertiesBean executionObject) {
+ assertThat(executionObject.getBlueprintName()).matches(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(executionObject.getBlueprintVersion()).matches(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(executionObject.getRequestId()).matches(TEST_MSO_REQUEST_ID);
+ assertThat(executionObject.getSubRequestId()).matches(TEST_PNF_UUID);
+ assertThat(executionObject.getMode()).matches("sync");
+ assertThat(executionObject.getActionName()).matches("config-assign");
+ assertThat(executionObject.getOriginatorId()).matches("SO");
+
+ assertThat(executionObject.getRequestObject()).isNotNull();
+ String requestObject = executionObject.getRequestObject();
+
+ checkRequestJson(requestObject);
+ }
+
+ private void checkRequestJson(String requestObject) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode tree = mapper.readTree(requestObject);
+ ConfigAssignRequestPnf configAssignRequestPnf = mapper
+ .treeToValue(tree.at("/config-assign-request"), ConfigAssignRequestPnf.class);
+ assertThat(configAssignRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID);
+
+ ConfigAssignPropertiesForPnf properties = configAssignRequestPnf.getConfigAssignPropertiesForPnf();
+ assertThat(properties.getServiceInstanceId()).matches(TEST_SERVICE_INSTANCE_ID);
+ assertThat(properties.getPnfName()).matches(TEST_PNF_CORRELATION_ID);
+ assertThat(properties.getPnfId()).matches(TEST_PNF_UUID);
+ assertThat(properties.getPnfCustomizationUuid()).matches(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(properties.getServiceModelUuid()).matches(TEST_MODEL_UUID);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("Check request body is json message" + e.getMessage());
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java
new file mode 100644
index 0000000000..77b6d9ffdd
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java
@@ -0,0 +1,188 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.Optional;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.cds.beans.ConfigDeployPropertiesForPnf;
+import org.onap.so.client.cds.beans.ConfigDeployRequestPnf;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {ExceptionBuilder.class, PrepareConfigDeployDelegate.class})
+public class PrepareConfigDeployDelegateTest {
+
+ private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static String TEST_PROCESS_KEY = "processKey1";
+ private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+ private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static String TEST_IPV4_ADDRESS = "1.1.1.1";
+ private static String TEST_IPV6_ADDRESS = "::1/128";
+
+ @Autowired
+ private PrepareConfigDeployDelegate prepareConfigDeployDelegate;
+
+ @MockBean
+ private PnfManagement pnfManagement;
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Before
+ public void setUp() throws IOException {
+ execution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ mockAai();
+ }
+
+ private void mockAai() throws IOException {
+ Pnf pnf = new Pnf();
+ pnf.setPnfIpv4Address(TEST_IPV4_ADDRESS);
+ pnf.setPnfIpv6Address(TEST_IPV6_ADDRESS);
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.of(pnf));
+ }
+
+ @Test
+ public void testExecution_validPnf_executionObjectCreated() {
+ try {
+ prepareConfigDeployDelegate.execute(execution);
+ Object executionObject = execution.getVariable(EXECUTION_OBJECT);
+ assertThat(executionObject).isNotNull();
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ checkCDSPropertiesBean((AbstractCDSPropertiesBean) executionObject);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testExecution_failedAaiConnection_exceptionThrown(){
+ try {
+ /**
+ * Mock the IOException from AAI.
+ */
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenThrow(new IOException("Connection failed"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertThatThrownBy(()->prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString().contains("Unable to fetch from AAI");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+
+ @Test
+ public void testExecution_aaiEntryNotExist_exceptionThrown(){
+ try {
+ /**
+ * Mock the AAI without PNF.
+ */
+ when(pnfManagement.getEntryFor(TEST_PNF_CORRELATION_ID)).thenReturn(Optional.empty());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertThatThrownBy(()->prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class);
+ assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString().contains("AAI entry for PNF: " + TEST_PNF_CORRELATION_ID + " does not exist");
+ assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class);
+ }
+
+ private void checkCDSPropertiesBean(AbstractCDSPropertiesBean executionObject) {
+ assertThat(executionObject.getBlueprintName()).matches(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ assertThat(executionObject.getBlueprintVersion()).matches(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ assertThat(executionObject.getRequestId()).matches(TEST_MSO_REQUEST_ID);
+ assertThat(executionObject.getSubRequestId()).matches(TEST_PNF_UUID);
+ assertThat(executionObject.getMode()).matches("async");
+ assertThat(executionObject.getActionName()).matches("config-deploy");
+ assertThat(executionObject.getOriginatorId()).matches("SO");
+
+ assertThat(executionObject.getRequestObject()).isNotNull();
+ String requestObject = executionObject.getRequestObject();
+
+ checkRequestJson(requestObject);
+ }
+
+ private void checkRequestJson(String requestObject) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode tree = mapper.readTree(requestObject);
+ ConfigDeployRequestPnf configDeployRequestPnf = mapper
+ .treeToValue(tree.at("/config-deploy-request"), ConfigDeployRequestPnf.class);
+ assertThat(configDeployRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID);
+
+ ConfigDeployPropertiesForPnf properties = configDeployRequestPnf
+ .getConfigDeployPropertiesForPnf();
+ assertThat(properties.getServiceInstanceId()).matches(TEST_SERVICE_INSTANCE_ID);
+ assertThat(properties.getPnfName()).matches(TEST_PNF_CORRELATION_ID);
+ assertThat(properties.getPnfId()).matches(TEST_PNF_UUID);
+ assertThat(properties.getPnfCustomizationUuid()).matches(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(properties.getServiceModelUuid()).matches(TEST_MODEL_UUID);
+ assertThat(properties.getPnfIpV4Address()).matches(TEST_IPV4_ADDRESS);
+ assertThat(properties.getPnfIpV6Address()).matches(TEST_IPV6_ADDRESS);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("Check request body is json message" + e.getMessage());
+ }
+ }
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
index 60f51ff783..cbfe6c1512 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -121,7 +121,7 @@ public class PnfEventReadyDmaapClientTest {
assertEquals(captor1.getValue().getURI().getScheme(),PROTOCOL);
assertEquals(captor1.getValue().getURI().getPath(),"/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
- verify(threadMockToNotifyCamundaFlow).run();
+ //verify(threadMockToNotifyCamundaFlow).run();
verify(executorMock).shutdown();
}