summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java153
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java225
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java135
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java4
18 files changed, 611 insertions, 35 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index dab5102efd..bbdcbf7ae3 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -66,7 +66,7 @@ import org.onap.so.client.orchestration.AAIVfModuleResources;
import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.client.orchestration.AAIVolumeGroupResources;
import org.onap.so.client.orchestration.AAIVpnBindingResources;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 4522f7f2e7..415d4614da 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -42,7 +42,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.client.exception.ExceptionBuilder;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
index e5f28aa4c3..8b78560521 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java
@@ -38,7 +38,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.exceptions.MarshallerException;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
index 00d0fdc01d..332c390c7d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
@@ -50,7 +50,7 @@ import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIVnfResources;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
index 95e270a071..40034aa26c 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java
@@ -24,7 +24,6 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
-import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.ExceptionBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,9 +43,6 @@ public abstract class LcmControllerDE implements ControllerRunnable<DelegateExec
@Autowired
protected List<ControllerPreparable<DelegateExecution>> prepareList;
- @Autowired
- protected ApplicationControllerAction client;
-
@Override
public void prepare(ControllerContext<DelegateExecution> context) {
prepareList.stream().filter(prepare -> prepare.understand(context))
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java
new file mode 100644
index 0000000000..badce18a51
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common;
+
+public interface SoPropertyConstants {
+ String TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+
+ String SO_ACTION = "action";
+ String SO_ACTION_MODE = "mode";
+
+ String ACTION_ACTIVATE_N_E_SW = "activateNESw";
+ String ACTION_DOWNLOAD_N_E_SW = "downloadNESw";
+ String ACTION_POST_CHECK = "postCheck";
+ String ACTION_PRE_CHECK = "preCheck";
+
+ String CONTROLLER_STATUS = "ControllerStatus";
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java
new file mode 100644
index 0000000000..b29009ff1d
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java
@@ -0,0 +1,153 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+
+import java.util.Arrays;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.json.JsonUtils;
+import org.onap.so.client.sdnc.lcm.beans.payload.*;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
+
+public class SDNCLcmPayloadBuilder {
+
+ private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilder.class);
+
+ public static ActivateNESwPayload buildActivateNESwPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION));
+ if (targetSwVersion == null) {
+ targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion");
+ }
+ activateNESwPayload.setSwVersionToBeActivated(targetSwVersion);
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "activateNESwPlaybook");
+ if (playbookName != null) {
+ activateNESwPayload.setPlaybookName(playbookName);
+ }
+
+ return activateNESwPayload;
+ }
+
+ public static DownloadNESwPayload buildDownloadNESwPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String swToBeDownloadedString = JsonUtils.getJsonValue(requestPayload, "swToBeDownloaded");
+ SwToBeDownloadedElement[] swToBeDownloadedArray;
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ swToBeDownloadedArray = mapper.readValue(swToBeDownloadedString, SwToBeDownloadedElement[].class);
+ downloadNESwPayload.setSwToBeDownloaded(Arrays.asList(swToBeDownloadedArray));
+ } catch (Exception e) {
+ logger.error("Parse SwToBeDownloaded error: ", e);
+ }
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "downloadNESwPlaybook");
+ if (playbookName != null) {
+ downloadNESwPayload.setPlaybookName(playbookName);
+ }
+
+ return downloadNESwPayload;
+ }
+
+ public static UpgradePostCheckPayload buildUpgradePostCheckPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion");
+ upgradePostCheckPayload.setOldSwVersion(oldSwVersion);
+
+ String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION));
+ if (targetSwVersion == null) {
+ targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion");
+ }
+ upgradePostCheckPayload.setTargetSwVersion(targetSwVersion);
+
+ String ruleName = JsonUtils.getJsonValue(requestPayload, "postCheckRuleName");
+ upgradePostCheckPayload.setRuleName(ruleName);
+
+ String additionalData = JsonUtils.getJsonValue(requestPayload, "postCheckAdditionalData");
+ upgradePostCheckPayload.setAdditionalData(additionalData);
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "postCheckPlaybook");
+ if (playbookName != null) {
+ upgradePostCheckPayload.setPlaybookName(playbookName);
+ }
+
+ return upgradePostCheckPayload;
+ }
+
+ public static UpgradePreCheckPayload buildUpgradePreCheckPayload(DelegateExecution execution) {
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+
+ UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload();
+
+ String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam");
+ upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam);
+
+ String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion");
+ upgradePreCheckPayload.setOldSwVersion(oldSwVersion);
+
+ String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION));
+ if (targetSwVersion == null) {
+ targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion");
+ }
+ upgradePreCheckPayload.setTargetSwVersion(targetSwVersion);
+
+ String ruleName = JsonUtils.getJsonValue(requestPayload, "preCheckRuleName");
+ upgradePreCheckPayload.setRuleName(ruleName);
+
+ String additionalData = JsonUtils.getJsonValue(requestPayload, "preCheckAdditionalData");
+ upgradePreCheckPayload.setAdditionalData(additionalData);
+
+ String playbookName = JsonUtils.getJsonValue(requestPayload, "preCheckPlaybook");
+ if (playbookName != null) {
+ upgradePreCheckPayload.setPlaybookName(playbookName);
+ }
+
+ return upgradePreCheckPayload;
+ }
+
+ public static String convertToSting(Object msgObject) throws JsonProcessingException {
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.writeValueAsString(msgObject);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
index db0d402f6e..ed865e058f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix
+ * Modifications Copyright (C) 2020 Huawei
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,16 +20,24 @@
package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+import java.util.List;
+import java.util.UUID;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.stereotype.Component;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.json.JsonUtils;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE;
-import org.springframework.stereotype.Component;
+import org.onap.so.client.sdnc.common.SDNCConstants;
+import org.onap.so.client.sdnc.lcm.*;
+import org.onap.so.client.sdnc.lcm.beans.*;
+import org.onap.so.client.sdnc.lcm.beans.payload.*;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.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.REQUEST_PAYLOAD;
-/**
- * This class is created to demonstrate how to support {@link DelegateExecution} API based SDNC controller.
- *
- * Function wise, it's similar to the Appc Controller, like in the AppcClient groovy code.
- */
@Component
public class SdncControllerDE extends LcmControllerDE {
@@ -44,14 +53,33 @@ public class SdncControllerDE extends LcmControllerDE {
return true;
}
- /**
- * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here.
- *
- * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator},
- * {@ref ApplicationControllerClient} or create your own SDNC Client proxy.
- */
@Override
protected int callLcmClient(ControllerContext<DelegateExecution> context) {
+ DelegateExecution execution = context.getExecution();
+
+ logger.debug("Running activity for id: {}, name: {}", execution.getCurrentActivityId(),
+ execution.getCurrentActivityName());
+
+ boolean result;
+ try {
+ LcmInput lcmInput = buildLcmInput(execution);
+ if (lcmInput != null) {
+ result = sendLcmRequest(execution, lcmInput);
+ } else {
+ logger.error("Build LCM Input error");
+ result = false;
+ }
+ } catch (Exception e) {
+ logger.error("Call SDNC LCM Client failure: ", e);
+ result = false;
+ }
+
+ if (result) {
+ execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Success");
+ } else {
+ execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Failure");
+ }
+
return 0;
}
@@ -59,4 +87,177 @@ public class SdncControllerDE extends LcmControllerDE {
protected int getErrorCode() {
return SDNC_DELEGATE_EXECUTION_ERROR_CODE;
}
+
+ private LcmOutput sendSyncRequest(String operation, LcmInput lcmInput) {
+ SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder();
+ SDNCLcmRestClient sdncLcmRestClient;
+ try {
+ sdncLcmRestClient = sdncLcmClientBuilder.newSDNCLcmRestClient(operation);
+ } catch (SDNCLcmClientBuilderException e) {
+ logger.error("Create SDNCLcmRestClient error: ", e);
+ return null;
+ }
+
+ return sdncLcmRestClient.sendRequest(lcmInput);
+ }
+
+ private LcmOutput selectLcmOutputFromDmaapResponses(List<LcmDmaapResponse> lcmDmaapResponses, LcmInput lcmInput) {
+ String expectedCorrelationId =
+ lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId();
+
+ for (LcmDmaapResponse lcmDmaapResponse : lcmDmaapResponses) {
+ String correlationId = lcmDmaapResponse.getCorrelationId();
+ if (expectedCorrelationId.equals(correlationId)) {
+ return lcmDmaapResponse.getBody().getOutput();
+ }
+ }
+
+ return null;
+ }
+
+ private LcmOutput sendAsyncRequest(String operation, LcmInput lcmInput) {
+ SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder();
+ SDNCLcmDmaapClient sdncLcmDmaapClient;
+ try {
+ sdncLcmDmaapClient = sdncLcmClientBuilder.newSDNCLcmDmaapClient();
+ } catch (SDNCLcmClientBuilderException e) {
+ logger.error("Create SDNCLcmDmaapClient error: ", e);
+ return null;
+ }
+
+ LcmDmaapRequest lcmDmaapRequest = SDNCLcmMessageBuilder.buildLcmDmaapRequest(operation, lcmInput);
+ try {
+ sdncLcmDmaapClient.sendRequest(lcmDmaapRequest);
+ } catch (Exception e) {
+ logger.error("SDNCLcmDmaapClient sends request error: ", e);
+ return null;
+ }
+
+ long timeout = sdncLcmClientBuilder.getSDNCLcmProperties().getActionTimeout();
+ long startTime = System.currentTimeMillis();
+ while (true) {
+ List<LcmDmaapResponse> lcmDmaapResponses = sdncLcmDmaapClient.getResponse();
+ if (lcmDmaapResponses.size() > 0) {
+ LcmOutput lcmOutput = selectLcmOutputFromDmaapResponses(lcmDmaapResponses, lcmInput);
+ if (lcmOutput != null) {
+ return lcmOutput;
+ }
+ }
+
+ long stopTime = System.currentTimeMillis();
+ if ((stopTime - startTime) > timeout) {
+ logger.error("Timeout for SDNC LCM action {}", lcmInput.getAction());
+ return null;
+ }
+ }
+ }
+
+ public static String toLowerHyphen(String lcmAction) {
+ String regex = "([a-z0-9A-Z])(?=[A-Z])";
+ String replacement = "$1-";
+ return lcmAction.replaceAll(regex, replacement).toLowerCase();
+ }
+
+ private LcmInput buildLcmInput(DelegateExecution execution) throws JsonProcessingException {
+ String requestId = String.valueOf(execution.getVariable(REQUEST_ID));
+ String requestAction = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION));
+ String pnfName = String.valueOf(execution.getVariable(PNF_CORRELATION_ID));
+ logger.debug(String.format("requestId: %s, action: %s, pnfName: %s", requestId, requestAction, pnfName));
+
+ String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD));
+ logger.debug("SO request payload: " + requestPayload);
+
+ String lcmAction;
+ String lcmPayload;
+
+ switch (requestAction) {
+ case SoPropertyConstants.ACTION_PRE_CHECK:
+ lcmAction = SDNCLcmActionConstants.UPGRADE_PRE_CHECK;
+
+ UpgradePreCheckPayload upgradePreCheckPayload;
+ upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload);
+ break;
+ case SoPropertyConstants.ACTION_DOWNLOAD_N_E_SW:
+ lcmAction = SDNCLcmActionConstants.DOWNLOAD_N_E_SW;
+
+ DownloadNESwPayload downloadNESwPayload;
+ downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload);
+ break;
+ case SoPropertyConstants.ACTION_ACTIVATE_N_E_SW:
+ lcmAction = SDNCLcmActionConstants.ACTIVATE_N_E_SW;
+
+ ActivateNESwPayload activateNESwPayload;
+ activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload);
+ break;
+ case SoPropertyConstants.ACTION_POST_CHECK:
+ lcmAction = SDNCLcmActionConstants.UPGRADE_POST_CHECK;
+
+ UpgradePostCheckPayload upgradePostCheckPayload;
+ upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution);
+ lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload);
+ break;
+ default:
+ logger.error("Unsupported SO Action: " + requestAction);
+ return null;
+ }
+
+ logger.debug("SDNC LCM payload for {}: {}", lcmAction, lcmPayload);
+
+ String subRequestId = UUID.randomUUID().toString();
+ LcmInput lcmInput =
+ SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload);
+
+ ObjectMapper mapper = new ObjectMapper();
+ String lcmInputMsg = mapper.writeValueAsString(lcmInput);
+ logger.debug("SDNC input message:\n" + lcmInputMsg);
+
+ return lcmInput;
+ }
+
+ private boolean parseLcmOutput(LcmOutput lcmOutput, String lcmAction) {
+ if (lcmOutput == null) {
+ logger.error("Call SDNC LCM API failure");
+ return false;
+ }
+
+ LcmStatus lcmStatus = lcmOutput.getStatus();
+
+ if (lcmStatus.getCode() == SDNCConstants.LCM_OUTPUT_SUCCESS_CODE) {
+ logger.debug("Call SDNC LCM API success: " + lcmStatus.getMessage());
+ } else {
+ logger.error("Call SDNC LCM API failure: " + lcmStatus.getMessage());
+ }
+
+ String outputPayload = lcmOutput.getPayload();
+ logger.debug("SDNC LCM action: {}, result: {}", lcmAction, outputPayload);
+ if (outputPayload != null) {
+ String result = JsonUtils.getJsonValue(outputPayload, "result");
+ if ("Success".equals(result)) {
+ logger.debug("Run SDNC LCM action {} success", lcmAction);
+ return true;
+ } else {
+ String reason = JsonUtils.getJsonValue(outputPayload, "reason");
+ logger.error("Run SDNC LCM action {} failure, reason: {}", lcmAction, reason);
+ }
+ }
+
+ return false;
+ }
+
+ private boolean sendLcmRequest(DelegateExecution execution, LcmInput lcmInput) {
+ String actionMode = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION_MODE));
+ String lcmOperation = toLowerHyphen(lcmInput.getAction());
+
+ LcmOutput lcmOutput;
+ if ("async".equals(actionMode)) {
+ lcmOutput = sendAsyncRequest(lcmOperation, lcmInput);
+ } else {
+ lcmOutput = sendSyncRequest(lcmOperation, lcmInput);
+ }
+
+ return parseLcmOutput(lcmOutput, lcmInput.getAction());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
index ff9d7376de..7930a33a2a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java
@@ -39,7 +39,7 @@ import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java
index 1a7d22c0dd..2d39cc185e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java
@@ -35,7 +35,7 @@ import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java
index 6bfe618460..7bfcd56c42 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java
@@ -24,7 +24,7 @@ import org.onap.so.logger.LoggingAnchor;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.client.ticket.ExternalTicket;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
index cf56964af3..9de8e184f2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
@@ -282,6 +282,7 @@ public class AAIObjectMapper {
map().setConfigurationType(source.getModelInfoConfiguration().getConfigurationType());
map().setConfigurationSubType(source.getModelInfoConfiguration().getConfigurationRole());
map().setConfigPolicyName(source.getModelInfoConfiguration().getPolicyName());
+ skip().setConfigurationRole(null);
}
});
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
index 088ce1ac38..dd9ecbead4 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java
@@ -31,7 +31,7 @@ import org.onap.namingservice.model.NameGenResponse;
import org.onap.namingservice.model.NameGenResponseError;
import org.onap.namingservice.model.Respelement;
import org.onap.so.client.exception.BadResponseException;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
index e7e4e25af2..01ac675d83 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpStatus;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.MapperException;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
index a41c79b171..f6642ab76a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
@@ -48,7 +48,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
-import org.onap.so.logger.ErrorCode;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
index 5bd4df74bb..9adae88a5a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java
@@ -24,10 +24,15 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks;
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import javax.xml.bind.JAXBException;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.glassfish.jersey.message.internal.OutboundJaxrsResponse;
+import org.glassfish.jersey.message.internal.OutboundMessageContext;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -39,8 +44,8 @@ import org.onap.so.adapters.nwrest.DeleteNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkError;
import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
-import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.NetworkAdapterResources;
import org.onap.so.utils.Components;
import org.onap.logging.filter.base.ONAPComponents;
import static org.junit.Assert.assertTrue;
@@ -54,13 +59,19 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
-public class NetworkAdapterRestV1Test extends BaseTaskTest {
+public class NetworkAdapterRestV1Test {
- @InjectMocks
- NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1();
@Mock
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+ private ExceptionBuilder exceptionBuilder;
+ @Mock
+ private NetworkAdapterResources networkAdapterResources;
+ @InjectMocks
+ private NetworkAdapterRestV1 networkAdapterRestV1Tasks;
+
+ private DelegateExecution delegateExecution;
private static final String CREATE_NETWORK_RESPONSE = "createNetworkResponse";
private static final String DELETE_NETWORK_RESPONSE = "deleteNetworkResponse";
@@ -73,6 +84,7 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest {
@Before
public void setup() {
+ initMocks(this);
delegateExecution = new DelegateExecutionFake();
}
@@ -187,6 +199,53 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest {
}
}
+ @Test
+ public void callNetworkAdapter_CreateNetworkRequestSuccess() throws Exception {
+ // given
+ String messageId = "createNetReqMessageId";
+ CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
+ createNetworkRequest.setMessageId(messageId);
+ delegateExecution.setVariable("networkAdapterRequest", createNetworkRequest);
+ Status status = Status.OK;
+ String responseEntity = "createNetworkResponse";
+ Optional<Response> response = Optional.of(createResponse(status, responseEntity));
+ when(networkAdapterResources.createNetworkAsync(createNetworkRequest)).thenReturn(response);
+ // when
+ networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution);
+ // then
+ verifyExecutionContent(status, responseEntity, messageId);
+ }
+
+ @Test
+ public void callNetworkAdapter_DeleteNetworkRequestSuccess() throws Exception {
+ // given
+ String messageId = "DeleteNetReqMessageId";
+ DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
+ deleteNetworkRequest.setMessageId(messageId);
+ delegateExecution.setVariable("networkAdapterRequest", deleteNetworkRequest);
+ Status status = Status.OK;
+ String responseEntity = "createNetworkResponse";
+ Optional<Response> response = Optional.of(createResponse(status, responseEntity));
+ when(networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest)).thenReturn(response);
+ // when
+ networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution);
+ // then
+ verifyExecutionContent(status, responseEntity, messageId);
+ }
+
+ private void verifyExecutionContent(Status status, String responseEntity, String messageId) {
+ assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterStatusCode"),
+ Integer.toString(status.getStatusCode()));
+ assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterResponse"), responseEntity);
+ assertEquals(delegateExecution.getVariable("NetworkAResponse_CORRELATOR"), messageId);
+ }
+
+ private Response createResponse(Status status, String responseEntity) {
+ OutboundMessageContext outboundMessageContext = new OutboundMessageContext();
+ outboundMessageContext.setEntity(responseEntity);
+ return new OutboundJaxrsResponse(status, outboundMessageContext);
+ }
+
private String createNetworkResponse(String networkResponseType, String networkId) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><" + networkResponseType + "><networkId>"
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java
new file mode 100644
index 0000000000..61f2ee3432
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.junit.runner.RunWith;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants;
+import org.onap.so.client.sdnc.lcm.beans.payload.*;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+public class SDNCLcmPayloadBuilderTest {
+ private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilderTest.class);
+
+ protected static String payload = "{" + "\"ipaddressV4Oam\": \"192.168.1.10\"," + "\"oldSwVersion\": \"v1\","
+ + "\"preCheckRuleName\": \"r101\"," + "\"preCheckAdditionalData\": \"{}\","
+ + "\"preCheckPlaybook\": \"precheck_playbook\"," + "\"swToBeDownloaded\": \"[{"
+ + "\\\"swLocation\\\": \\\"http://192.168.1.20/test.zip\\\"," + "\\\"swFileSize\\\": 123456,"
+ + "\\\"swFileCompression\\\": \\\"ZIP\\\"," + "\\\"swFileFormat\\\": \\\"binary\\\"}]\","
+ + "\"downloadNESwPlaybook\": \"downloadnesw_playbook\","
+ + "\"activateNESwPlaybook\": \"activatenesw_playbook\"," + "\"postCheckRuleName\": \"r102\","
+ + "\"postCheckAdditionalData\": \"{}\"," + "\"postCheckPlaybook\": \"postcheck_playbook\"" + "}";
+ protected String targetSoftwareVersion = "v2";
+
+ @MockBean
+ private DelegateExecution execution;
+
+ public static String getRequestPayload() {
+ return payload;
+ }
+
+ @Before
+ public void setUp() {
+ when(execution.getVariable(REQUEST_PAYLOAD)).thenReturn(payload);
+ when(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)).thenReturn(targetSoftwareVersion);
+ }
+
+
+ @Test
+ public final void testBuildActivateNESwPayload() {
+ String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"activatenesw_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}";
+
+ ActivateNESwPayload activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload);
+ logger.debug("ActivateNESwPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert ActivateNESwPayload to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testBuildDownloadNESwPayload() {
+ String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\","
+ + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}";
+ String expectedPayload =
+ "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"downloadnesw_playbook\","
+ + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}";
+
+ DownloadNESwPayload downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload);
+ logger.debug("DownloadNESwPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert DownloadNESwPayload to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testBuildUpgradePostCheckPayload() {
+ String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"postcheck_playbook\"," + "\"oldSwVersion\":\"v1\","
+ + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}";
+
+ UpgradePostCheckPayload upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload);
+ logger.debug("UpgradePostCheckPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert UpgradePostCheckPayload to String error: " + e.toString());
+ }
+ }
+
+ @Test
+ public final void testBuildUpgradePreCheckPayload() {
+ String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\","
+ + "\"playbook-name\":\"precheck_playbook\"," + "\"oldSwVersion\":\"v1\","
+ + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}";
+
+ UpgradePreCheckPayload upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution);
+ try {
+ String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload);
+ logger.debug("UpgradePreCheckPayload:\n" + payload);
+
+ assertEquals(expectedPayload, payload);
+ } catch (JsonProcessingException e) {
+ fail("Convert UpgradePreCheckPayload to String error: " + e.toString());
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
index 674167624e..02c7dca9ae 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java
@@ -28,7 +28,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
-import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.ExceptionBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -48,9 +47,6 @@ public class SdncControllerDETest {
@MockBean
private ControllerPreparable<DelegateExecution> preparable;
- @MockBean
- protected ApplicationControllerAction client;
-
@Before
public void setUp() {
when(controllerContext.getControllerActor()).thenReturn("sdnc");