From 9d8d8d99489dc92951d9e587e8fdc8f048d53e26 Mon Sep 17 00:00:00 2001 From: rameshiyer27 Date: Wed, 29 Jul 2020 18:39:01 +0100 Subject: Refactor PNF names in BPMN workflows Issue-ID: SO-3105 Signed-off-by: zrrmmua Change-Id: I8cab1afa54ea8a1981fcddcf0c25f6f86bb14421 --- .../scripts/GenericPnfSoftwareUpgrade.groovy | 124 +++++++ .../scripts/PNFSoftwareUpgrade.groovy | 124 ------- .../resources/process/GenericPnfHealthCheck.bpmn | 2 +- .../resources/process/GenericPnfSWUPDownload.bpmn | 315 +++++++++++++++++ .../process/GenericPnfSoftwareUpgrade.bpmn | 385 +++++++++++++++++++++ .../main/resources/process/PNFSWUPDownload.bpmn | 315 ----------------- .../main/resources/process/PNFSoftwareUpgrade.bpmn | 385 --------------------- .../resources/process/ServiceLevelUpgrade.bpmn | 6 +- .../process/GenericPnfSWUPDownloadTest.java | 232 +++++++++++++ .../process/GenericPnfSoftwareUpgradeTest.java | 248 +++++++++++++ .../process/PNFSWUPDownloadTest.java | 230 ------------ .../process/PNFSoftwareUpgradeTest.java | 247 ------------- .../process/ServiceLevelUpgradeTest.java | 2 +- .../request/GenericPnfSoftwareUpgradeTest.json | 54 +++ .../resources/request/PNFSoftwareUpgradeTest.json | 54 --- .../response/GenericPnfSoftwareUpgradeTest.json | 26 ++ .../GenericPnfSoftwareUpgradeTest_catalogdb.json | 39 +++ .../resources/response/PNFSoftwareUpgradeTest.json | 26 -- .../response/PNFSoftwareUpgradeTest_catalogdb.json | 39 --- .../service/level/impl/ServiceLevelConstants.java | 2 +- 20 files changed, 1429 insertions(+), 1426 deletions(-) create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy new file mode 100644 index 0000000000..89902209a0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/GenericPnfSoftwareUpgrade.groovy @@ -0,0 +1,124 @@ +/*- + * ============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.scripts + +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.workflow.context.WorkflowContext +import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder +import org.onap.so.bpmn.core.WorkflowException +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.* + +class GenericPnfSoftwareUpgrade extends AbstractServiceTaskProcessor { + private static final Logger logger = LoggerFactory.getLogger(GenericPnfSoftwareUpgrade.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + String prefix = "PnfSwUpgrade_" + + @Override + void preProcessRequest(DelegateExecution execution) { + } + + void sendResponse(DelegateExecution execution) { + def requestId = execution.getVariable(REQUEST_ID) + def instanceId = execution.getVariable(PNF_CORRELATION_ID) + logger.debug("Send response for requestId: {}, instanceId: {}", requestId, instanceId) + + String response = """{"requestReferences":{"requestId":"${requestId}", "instanceId":"${instanceId}"}}""".trim() + sendWorkflowResponse(execution, 200, response) + } + + static WorkflowContext getWorkflowContext(DelegateExecution execution) { + String requestId = execution.getVariable(REQUEST_ID) + return WorkflowContextHolder.getInstance().getWorkflowContext(requestId) + } + + void prepareCompletion(DelegateExecution execution) { + try { + String requestId = execution.getVariable(REQUEST_ID) + logger.debug("Prepare Completion of PNF Software Upgrade for requestId: {}", requestId) + + String msoCompletionRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + VID + + PNF has been upgraded successfully. + PNF_SOFTWARE_UPGRADE + """ + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + execution.setVariable(prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) + + logger.debug("CompleteMsoProcessRequest of PNF Software Upgrade - " + "\n" + xmlMsoCompletionRequest) + } catch (Exception e) { + String msg = "Prepare Completion error for PNF software upgrade - " + e.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + void prepareFalloutHandler(DelegateExecution execution) { + WorkflowContext workflowContext = getWorkflowContext(execution) + if (workflowContext == null) { + logger.debug("Error occurred before sending response to API handler, and send it now") + sendResponse(execution) + } + + try { + String requestId = execution.getVariable(REQUEST_ID) + logger.debug("Prepare FalloutHandler of PNF Software Upgrade for requestId: {}", requestId) + + WorkflowException workflowException = execution.getVariable("WorkflowException") + String errorCode = String.valueOf(workflowException.getErrorCode()) + String errorMessage = workflowException.getErrorMessage() + String falloutHandlerRequest = + """ + + ${MsoUtils.xmlEscape(requestId)} + UPDATE + VID + + + ${MsoUtils.xmlEscape(errorMessage)} + ${MsoUtils.xmlEscape(errorCode)} + + """ + String xmlFalloutHandlerRequest = utils.formatXml(falloutHandlerRequest) + + execution.setVariable(prefix + "FalloutHandlerRequest", xmlFalloutHandlerRequest) + + logger.debug("FalloutHandlerRequest of PNF Software Upgrade - " + "\n" + xmlFalloutHandlerRequest) + } catch (Exception e) { + String msg = "Prepare FalloutHandler error for PNF software upgrade - " + e.getMessage() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy deleted file mode 100644 index 8e7a4f727d..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/PNFSoftwareUpgrade.groovy +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============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.scripts - -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.onap.so.bpmn.common.workflow.context.WorkflowContext -import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder -import org.onap.so.bpmn.core.WorkflowException -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.* - -class PNFSoftwareUpgrade extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger(PNFSoftwareUpgrade.class) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - String prefix = "PnfSwUpgrade_" - - @Override - void preProcessRequest(DelegateExecution execution) { - } - - void sendResponse(DelegateExecution execution) { - def requestId = execution.getVariable(REQUEST_ID) - def instanceId = execution.getVariable(PNF_CORRELATION_ID) - logger.debug("Send response for requestId: {}, instanceId: {}", requestId, instanceId) - - String response = """{"requestReferences":{"requestId":"${requestId}", "instanceId":"${instanceId}"}}""".trim() - sendWorkflowResponse(execution, 200, response) - } - - static WorkflowContext getWorkflowContext(DelegateExecution execution) { - String requestId = execution.getVariable(REQUEST_ID) - return WorkflowContextHolder.getInstance().getWorkflowContext(requestId) - } - - void prepareCompletion(DelegateExecution execution) { - try { - String requestId = execution.getVariable(REQUEST_ID) - logger.debug("Prepare Completion of PNF Software Upgrade for requestId: {}", requestId) - - String msoCompletionRequest = - """ - - ${MsoUtils.xmlEscape(requestId)} - UPDATE - VID - - PNF has been upgraded successfully. - PNF_SOFTWARE_UPGRADE - """ - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable(prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) - - logger.debug("CompleteMsoProcessRequest of PNF Software Upgrade - " + "\n" + xmlMsoCompletionRequest) - } catch (Exception e) { - String msg = "Prepare Completion error for PNF software upgrade - " + e.getMessage() - logger.error(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - } - - void prepareFalloutHandler(DelegateExecution execution) { - WorkflowContext workflowContext = getWorkflowContext(execution) - if (workflowContext == null) { - logger.debug("Error occurred before sending response to API handler, and send it now") - sendResponse(execution) - } - - try { - String requestId = execution.getVariable(REQUEST_ID) - logger.debug("Prepare FalloutHandler of PNF Software Upgrade for requestId: {}", requestId) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - String errorCode = String.valueOf(workflowException.getErrorCode()) - String errorMessage = workflowException.getErrorMessage() - String falloutHandlerRequest = - """ - - ${MsoUtils.xmlEscape(requestId)} - UPDATE - VID - - - ${MsoUtils.xmlEscape(errorMessage)} - ${MsoUtils.xmlEscape(errorCode)} - - """ - String xmlFalloutHandlerRequest = utils.formatXml(falloutHandlerRequest) - - execution.setVariable(prefix + "FalloutHandlerRequest", xmlFalloutHandlerRequest) - - logger.debug("FalloutHandlerRequest of PNF Software Upgrade - " + "\n" + xmlFalloutHandlerRequest) - } catch (Exception e) { - String msg = "Prepare FalloutHandler error for PNF software upgrade - " + e.getMessage() - logger.error(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn index 1722137056..36f6221da9 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfHealthCheck.bpmn @@ -56,7 +56,7 @@ taskProcessor.prepareCompletion(execution) SequenceFlow_05haut5 SequenceFlow_09y0mpc import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn new file mode 100644 index 0000000000..8b1b8367f8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSWUPDownload.bpmn @@ -0,0 +1,315 @@ + + + + + SequenceFlow_1fdclh0 + + + SequenceFlow_1fdclh0 + SequenceFlow_0kusy70 + + + SequenceFlow_0mjjdia + + + + SequenceFlow_0o6b6a8 + SequenceFlow_078xmlz + SequenceFlow_0qznt4u + + + SequenceFlow_078xmlz + + + + SequenceFlow_1ccldpp + SequenceFlow_0s6i4o9 + SequenceFlow_1tfbzn1 + + + SequenceFlow_1tfbzn1 + + + + SequenceFlow_1kaikh5 + SequenceFlow_1gawssm + SequenceFlow_1d2rfyx + + + SequenceFlow_1gawssm + + + + + + downloadNESw + pnf + async + + + SequenceFlow_0s6i4o9 + SequenceFlow_0o6b6a8 + + + + + postCheck + pnf + async + + + SequenceFlow_0qznt4u + SequenceFlow_1kaikh5 + + + + + preCheck + pnf + async + + + SequenceFlow_12155q6 + SequenceFlow_1ccldpp + + + + + + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + + SequenceFlow_0swi04u + + + + SequenceFlow_0swi04u + SequenceFlow_1ppn4a8 + import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() +pnfSwUpgrade.prepareFalloutHandler(execution) + + + + + + SequenceFlow_1ppn4a8 + SequenceFlow_1ahmdun + + + SequenceFlow_1ahmdun + + + + + + + + SequenceFlow_0kusy70 + SequenceFlow_12155q6 + import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() +pnfSwUpgrade.sendResponse(execution) + + + + SequenceFlow_1d2rfyx + SequenceFlow_183s0wo + import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() +pnfSwUpgrade.prepareCompletion(execution) + + + + + + SequenceFlow_183s0wo + SequenceFlow_0mjjdia + + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn new file mode 100644 index 0000000000..f4a6196fc1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/GenericPnfSoftwareUpgrade.bpmn @@ -0,0 +1,385 @@ + + + + + SequenceFlow_1ng4b6l + + + SequenceFlow_1ng4b6l + SequenceFlow_12ejx4m + + + + SequenceFlow_0tle5zb + + + + + SequenceFlow_0cchgih + SequenceFlow_1lr7vgu + SequenceFlow_1eljvek + + + SequenceFlow_1lr7vgu + + + + SequenceFlow_0j26xlx + SequenceFlow_1nsmyr5 + SequenceFlow_0piri91 + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + SequenceFlow_0piri91 + + + + + + SequenceFlow_015y785 + SequenceFlow_0dqnb6c + SequenceFlow_0eiif6e + + + SequenceFlow_0dqnb6c + + + + + SequenceFlow_0g3qcd0 + SequenceFlow_1p0axph + SequenceFlow_1atiydu + + + SequenceFlow_1p0axph + + + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + #{execution.getVariable("ControllerStatus").equals("Success")} + + + + + downloadNESw + pnf + async + + + SequenceFlow_1nsmyr5 + SequenceFlow_0cchgih + + + + + + activateNESw + pnf + async + + + SequenceFlow_1eljvek + SequenceFlow_015y785 + + + + + + postCheck + pnf + async + + + SequenceFlow_084orr1 + SequenceFlow_0g3qcd0 + + + + + + preCheck + pnf + async + + + SequenceFlow_0ks3p41 + SequenceFlow_0j26xlx + + + + SequenceFlow_0eiif6e + SequenceFlow_084orr1 + + + + SequenceFlow_12ejx4m + SequenceFlow_0ks3p41 + import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() +pnfSwUpgrade.sendResponse(execution) + + + + SequenceFlow_1atiydu + SequenceFlow_0ipc3nt + import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() +pnfSwUpgrade.prepareCompletion(execution) + + + + + + + SequenceFlow_0ipc3nt + SequenceFlow_0tle5zb + + + + + SequenceFlow_05haut5 + + + + SequenceFlow_05haut5 + SequenceFlow_09y0mpc + import org.onap.so.bpmn.infrastructure.scripts.* +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() +pnfSwUpgrade.prepareFalloutHandler(execution) + + + + + + SequenceFlow_09y0mpc + SequenceFlow_1tcjlty + + + SequenceFlow_1tcjlty + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn deleted file mode 100644 index 5d523194bb..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSWUPDownload.bpmn +++ /dev/null @@ -1,315 +0,0 @@ - - - - - SequenceFlow_1fdclh0 - - - SequenceFlow_1fdclh0 - SequenceFlow_0kusy70 - - - SequenceFlow_0mjjdia - - - - SequenceFlow_0o6b6a8 - SequenceFlow_078xmlz - SequenceFlow_0qznt4u - - - SequenceFlow_078xmlz - - - - SequenceFlow_1ccldpp - SequenceFlow_0s6i4o9 - SequenceFlow_1tfbzn1 - - - SequenceFlow_1tfbzn1 - - - - SequenceFlow_1kaikh5 - SequenceFlow_1gawssm - SequenceFlow_1d2rfyx - - - SequenceFlow_1gawssm - - - - - - downloadNESw - pnf - async - - - SequenceFlow_0s6i4o9 - SequenceFlow_0o6b6a8 - - - - - postCheck - pnf - async - - - SequenceFlow_0qznt4u - SequenceFlow_1kaikh5 - - - - - preCheck - pnf - async - - - SequenceFlow_12155q6 - SequenceFlow_1ccldpp - - - - - - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - - SequenceFlow_0swi04u - - - - SequenceFlow_0swi04u - SequenceFlow_1ppn4a8 - import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.prepareFalloutHandler(execution) - - - - - - SequenceFlow_1ppn4a8 - SequenceFlow_1ahmdun - - - SequenceFlow_1ahmdun - - - - - - - - SequenceFlow_0kusy70 - SequenceFlow_12155q6 - import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.sendResponse(execution) - - - - SequenceFlow_1d2rfyx - SequenceFlow_183s0wo - import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.prepareCompletion(execution) - - - - - - SequenceFlow_183s0wo - SequenceFlow_0mjjdia - - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn deleted file mode 100644 index 4ff0af4549..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/PNFSoftwareUpgrade.bpmn +++ /dev/null @@ -1,385 +0,0 @@ - - - - - SequenceFlow_1ng4b6l - - - SequenceFlow_1ng4b6l - SequenceFlow_12ejx4m - - - - SequenceFlow_0tle5zb - - - - - SequenceFlow_0cchgih - SequenceFlow_1lr7vgu - SequenceFlow_1eljvek - - - SequenceFlow_1lr7vgu - - - - SequenceFlow_0j26xlx - SequenceFlow_1nsmyr5 - SequenceFlow_0piri91 - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - SequenceFlow_0piri91 - - - - - - SequenceFlow_015y785 - SequenceFlow_0dqnb6c - SequenceFlow_0eiif6e - - - SequenceFlow_0dqnb6c - - - - - SequenceFlow_0g3qcd0 - SequenceFlow_1p0axph - SequenceFlow_1atiydu - - - SequenceFlow_1p0axph - - - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - #{execution.getVariable("ControllerStatus").equals("Success")} - - - - - downloadNESw - pnf - async - - - SequenceFlow_1nsmyr5 - SequenceFlow_0cchgih - - - - - - activateNESw - pnf - async - - - SequenceFlow_1eljvek - SequenceFlow_015y785 - - - - - - postCheck - pnf - async - - - SequenceFlow_084orr1 - SequenceFlow_0g3qcd0 - - - - - - preCheck - pnf - async - - - SequenceFlow_0ks3p41 - SequenceFlow_0j26xlx - - - - SequenceFlow_0eiif6e - SequenceFlow_084orr1 - - - - SequenceFlow_12ejx4m - SequenceFlow_0ks3p41 - import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.sendResponse(execution) - - - - SequenceFlow_1atiydu - SequenceFlow_0ipc3nt - import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.prepareCompletion(execution) - - - - - - - SequenceFlow_0ipc3nt - SequenceFlow_0tle5zb - - - - - SequenceFlow_05haut5 - - - - SequenceFlow_05haut5 - SequenceFlow_09y0mpc - import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() -pnfSwUpgrade.prepareFalloutHandler(execution) - - - - - - SequenceFlow_09y0mpc - SequenceFlow_1tcjlty - - - SequenceFlow_1tcjlty - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn index a1d4178962..3d37430723 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ServiceLevelUpgrade.bpmn @@ -55,14 +55,14 @@ Flow_1b392qs Flow_1v0mxe7 import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.sendResponse(execution) Flow_0l67uzl Flow_0frhsd0 import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareCompletion(execution) @@ -78,7 +78,7 @@ pnfSwUpgrade.prepareCompletion(execution) Flow_0iayg6u Flow_0lb7zv5 import org.onap.so.bpmn.infrastructure.scripts.* -def pnfSwUpgrade = new PNFSoftwareUpgrade() +def pnfSwUpgrade = new GenericPnfSoftwareUpgrade() pnfSwUpgrade.prepareFalloutHandler(execution) diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java new file mode 100644 index 0000000000..b9c5fdf145 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSWUPDownloadTest.java @@ -0,0 +1,232 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.assertj.core.api.Assertions; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for GenericPnfSWUPDownloadTest.bpmn workflow. + */ +public class GenericPnfSWUPDownloadTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfSWUPDownload"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map executionVariables = new HashMap(); + private final String[] actionNames = new String[3]; + private String responseObject; + private String requestObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/GenericPnfSoftwareUpgradeTest.json"); + responseObject = FileUtil.readResourceFile("response/GenericPnfSoftwareUpgradeTest.json"); + + executionVariables.put("bpmnRequest", requestObject); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("download_StartEvent", "ServiceTask_1mpt2eq", "ServiceTask_1nl90ao", + "ExclusiveGateway_1rj84ne", "ServiceTask_0yavde3", "ExclusiveGateway_1ja7grm", "ServiceTask_1wxo7xz", + "ExclusiveGateway_08lusga", "download_EndEvent"); + + List detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 3); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action, msoRequestId); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("GenericPnfSWUPDownload request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action, String msoRequestId) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the + * response/GenericPnfSoftwareUpgradeTest_catalogdb.json. + */ + Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + Assertions.assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + Assertions.assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + Assertions.assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + Assertions.assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + Assertions.assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + Assertions.assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = + FileUtil.readResourceFile("response/GenericPnfSoftwareUpgradeTest_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java new file mode 100644 index 0000000000..de81f91e66 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/GenericPnfSoftwareUpgradeTest.java @@ -0,0 +1,248 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.process; + +import com.google.protobuf.Struct; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.so.BaseBPMNTest; +import org.onap.so.GrpcNettyServer; +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.aaiclient.client.aai.AAIVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import static com.github.tomakehurst.wiremock.client.WireMock.okJson; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.put; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.assertj.core.api.Assertions.fail; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; + +/** + * Basic Integration test for GenericPnfSoftwareUpgrade.bpmn workflow. + */ +public class GenericPnfSoftwareUpgradeTest extends BaseBPMNTest { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + private static final long WORKFLOW_WAIT_TIME = 1000L; + + private static final String TEST_PROCESSINSTANCE_KEY = "GenericPnfSoftwareUpgrade"; + private static final AAIVersion VERSION = AAIVersion.LATEST; + private static final Map executionVariables = new HashMap(); + private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; + private final String[] actionNames = new String[4]; + private String requestObject; + private String responseObject; + + @Autowired + private GrpcNettyServer grpcNettyServer; + + @Before + public void setUp() throws IOException { + actionNames[0] = "preCheck"; + actionNames[1] = "downloadNESw"; + actionNames[2] = "activateNESw"; + actionNames[3] = "postCheck"; + + executionVariables.clear(); + + requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); + responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); + + executionVariables.put("bpmnRequest", requestObject); + executionVariables.put("requestId", REQUEST_ID); + + /** + * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. + */ + executionVariables.put("isAsyncProcess", "true"); + executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); + + /** + * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api + * handler and then convert to CamudaInput + */ + executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); + } + + + @Test + public void workflow_validInput_expectedOutput() throws InterruptedException { + + mockCatalogDb(); + mockRequestDb(); + mockAai(); + + final String msoRequestId = UUID.randomUUID().toString(); + executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); + + final String testBusinessKey = UUID.randomUUID().toString(); + logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); + + ProcessInstance pi = + runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); + + int waitCount = 10; + while (!isProcessInstanceEnded() && waitCount >= 0) { + Thread.sleep(WORKFLOW_WAIT_TIME); + waitCount--; + } + + // Layout is to reflect the bpmn visual layout + assertThat(pi).isEnded().hasPassedInOrder("softwareUpgrade_startEvent", "ServiceTask_042uz7n", + "ScriptTask_10klpg8", "ServiceTask_0slpahe", "ExclusiveGateway_0x6h0ni", "ServiceTask_0x5cje8", + "ExclusiveGateway_0v3l3wv", "ServiceTask_02lxf48", "ExclusiveGateway_0ch3fef", "ServiceTask_0y2uysu", + "ExclusiveGateway_1ny9b1z", "ScriptTask_1igtc83", "CallActivity_0o1mi8u", "softwareUpgrade_endEvent"); + + List detailedMessages = grpcNettyServer.getDetailedMessages(); + assertThat(detailedMessages.size() == 4); + int count = 0; + try { + for (ExecutionServiceInput eSI : detailedMessages) { + for (String action : actionNames) { + if (action.equals(eSI.getActionIdentifiers().getActionName()) + && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { + checkWithActionName(eSI, action); + count++; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + fail("GenericPnfSoftwareUpgrade request exception", e); + } + assertThat(count == actionNames.length); + } + + private boolean isProcessInstanceEnded() { + return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) + .singleResult() == null; + } + + private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { + + logger.info("Checking the " + action + " request"); + ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); + + /** + * the fields of actionIdentifiers should match the one in the + * response/GenericPnfSoftwareUpgrade_catalogdb.json. + */ + assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); + assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); + assertThat(actionIdentifiers.getActionName()).isEqualTo(action); + assertThat(actionIdentifiers.getMode()).isEqualTo("async"); + + CommonHeader commonHeader = executionServiceInput.getCommonHeader(); + assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); + + Struct payload = executionServiceInput.getPayload(); + Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); + + assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); + Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); + + assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); + assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) + .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); + assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) + .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); + assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) + .isEqualTo("demo-sw-ver2.0.0"); + } + + private void mockAai() { + + String aaiPnfEntry = + "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" + + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" + + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; + + /** + * PUT the PNF correlation ID to AAI. + */ + wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + + /** + * Get the PNF entry from AAI. + */ + wireMockServer.stubFor( + get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); + + /* + * Post the pnf to AAI + */ + wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); + } + + private void mockRequestDb() { + /** + * Update Request DB + */ + wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID))); + + } + + /** + * Mock the catalobdb rest interface. + */ + private void mockCatalogDb() { + + String catalogdbClientResponse = + FileUtil.readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); + + + /** + * Return valid json for the model UUID in the request file. + */ + wireMockServer + .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(responseObject))); + + /** + * Return valid json for the service model InvariantUUID as specified in the request file. + */ + wireMockServer.stubFor( + get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) + .willReturn(okJson(responseObject))); + + /** + * Return valid spring data rest json for the service model UUID as specified in the request file. + */ + wireMockServer.stubFor(get(urlEqualTo( + "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) + .willReturn(okJson(catalogdbClientResponse))); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java deleted file mode 100644 index a0ef90d7b8..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSWUPDownloadTest.java +++ /dev/null @@ -1,230 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.process; - -import com.google.protobuf.Struct; -import org.assertj.core.api.Assertions; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.so.BaseBPMNTest; -import org.onap.so.GrpcNettyServer; -import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; -import org.onap.so.bpmn.mock.FileUtil; -import org.onap.aaiclient.client.aai.AAIVersion; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import static com.github.tomakehurst.wiremock.client.WireMock.okJson; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; - -/** - * Basic Integration test for PNFSWUPDownloadTest.bpmn workflow. - */ -public class PNFSWUPDownloadTest extends BaseBPMNTest { - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private static final long WORKFLOW_WAIT_TIME = 1000L; - - private static final String TEST_PROCESSINSTANCE_KEY = "PNFSWUPDownload"; - private static final AAIVersion VERSION = AAIVersion.LATEST; - private static final Map executionVariables = new HashMap(); - private final String[] actionNames = new String[3]; - private String responseObject; - private String requestObject; - - @Autowired - private GrpcNettyServer grpcNettyServer; - - @Before - public void setUp() throws IOException { - - actionNames[0] = "preCheck"; - actionNames[1] = "downloadNESw"; - actionNames[2] = "postCheck"; - - executionVariables.clear(); - - requestObject = FileUtil.readResourceFile("request/PNFSoftwareUpgradeTest.json"); - responseObject = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest.json"); - - executionVariables.put("bpmnRequest", requestObject); - - /** - * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. - */ - executionVariables.put("isAsyncProcess", "true"); - executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); - - /** - * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api - * handler and then convert to CamudaInput - */ - executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); - } - - - @Test - public void workflow_validInput_expectedOutput() throws InterruptedException { - - mockCatalogDb(); - mockAai(); - - final String msoRequestId = UUID.randomUUID().toString(); - executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); - - final String testBusinessKey = UUID.randomUUID().toString(); - logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); - - ProcessInstance pi = - runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); - - int waitCount = 10; - while (!isProcessInstanceEnded() && waitCount >= 0) { - Thread.sleep(WORKFLOW_WAIT_TIME); - waitCount--; - } - - // Layout is to reflect the bpmn visual layout - assertThat(pi).isEnded().hasPassedInOrder("download_StartEvent", "ServiceTask_1mpt2eq", "ServiceTask_1nl90ao", - "ExclusiveGateway_1rj84ne", "ServiceTask_0yavde3", "ExclusiveGateway_1ja7grm", "ServiceTask_1wxo7xz", - "ExclusiveGateway_08lusga", "download_EndEvent"); - - List detailedMessages = grpcNettyServer.getDetailedMessages(); - assertThat(detailedMessages.size() == 3); - int count = 0; - try { - for (ExecutionServiceInput eSI : detailedMessages) { - for (String action : actionNames) { - if (action.equals(eSI.getActionIdentifiers().getActionName()) - && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { - checkWithActionName(eSI, action, msoRequestId); - count++; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - fail("PNFSWUPDownload request exception", e); - } - assertThat(count == actionNames.length); - } - - private boolean isProcessInstanceEnded() { - return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) - .singleResult() == null; - } - - private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action, String msoRequestId) { - - logger.info("Checking the " + action + " request"); - ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); - - /** - * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. - */ - Assertions.assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); - Assertions.assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); - Assertions.assertThat(actionIdentifiers.getActionName()).isEqualTo(action); - Assertions.assertThat(actionIdentifiers.getMode()).isEqualTo("async"); - - CommonHeader commonHeader = executionServiceInput.getCommonHeader(); - Assertions.assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); - Assertions.assertThat(commonHeader.getRequestId()).isEqualTo(msoRequestId); - - Struct payload = executionServiceInput.getPayload(); - Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); - - Assertions.assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); - Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); - - Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); - Assertions.assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) - .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); - Assertions.assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) - .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); - Assertions.assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) - .isEqualTo("demo-sw-ver2.0.0"); - } - - private void mockAai() { - - String aaiPnfEntry = - "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" - + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" - + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; - - /** - * PUT the PNF correlation ID to AAI. - */ - wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); - - /** - * Get the PNF entry from AAI. - */ - wireMockServer.stubFor( - get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); - } - - /** - * Mock the catalobdb rest interface. - */ - private void mockCatalogDb() { - - String catalogdbClientResponse = FileUtil.readResourceFile("response/PNFSoftwareUpgradeTest_catalogdb.json"); - - - /** - * Return valid json for the model UUID in the request file. - */ - wireMockServer - .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) - .willReturn(okJson(responseObject))); - - /** - * Return valid json for the service model InvariantUUID as specified in the request file. - */ - wireMockServer.stubFor( - get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) - .willReturn(okJson(responseObject))); - - /** - * Return valid spring data rest json for the service model UUID as specified in the request file. - */ - wireMockServer.stubFor(get(urlEqualTo( - "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) - .willReturn(okJson(catalogdbClientResponse))); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java deleted file mode 100644 index 0bf14d7443..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/PNFSoftwareUpgradeTest.java +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.process; - -import com.google.protobuf.Struct; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; -import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.so.BaseBPMNTest; -import org.onap.so.GrpcNettyServer; -import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames; -import org.onap.so.bpmn.mock.FileUtil; -import org.onap.aaiclient.client.aai.AAIVersion; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import static com.github.tomakehurst.wiremock.client.WireMock.okJson; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.assertj.core.api.Assertions.fail; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; - -/** - * Basic Integration test for PNFSoftwareUpgrade.bpmn workflow. - */ -public class PNFSoftwareUpgradeTest extends BaseBPMNTest { - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private static final long WORKFLOW_WAIT_TIME = 1000L; - - private static final String TEST_PROCESSINSTANCE_KEY = "PNFSoftwareUpgrade"; - private static final AAIVersion VERSION = AAIVersion.LATEST; - private static final Map executionVariables = new HashMap(); - private static final String REQUEST_ID = "50ae41ad-049c-4fe2-9950-539f111120f5"; - private final String[] actionNames = new String[4]; - private String requestObject; - private String responseObject; - - @Autowired - private GrpcNettyServer grpcNettyServer; - - @Before - public void setUp() throws IOException { - actionNames[0] = "preCheck"; - actionNames[1] = "downloadNESw"; - actionNames[2] = "activateNESw"; - actionNames[3] = "postCheck"; - - executionVariables.clear(); - - requestObject = FileUtil.readResourceFile("request/" + getClass().getSimpleName() + ".json"); - responseObject = FileUtil.readResourceFile("response/" + getClass().getSimpleName() + ".json"); - - executionVariables.put("bpmnRequest", requestObject); - executionVariables.put("requestId", REQUEST_ID); - - /** - * This variable indicates that the flow was invoked asynchronously. It's injected by {@link WorkflowProcessor}. - */ - executionVariables.put("isAsyncProcess", "true"); - executionVariables.put(ExecutionVariableNames.PRC_CUSTOMIZATION_UUID, "38dc9a92-214c-11e7-93ae-92361f002680"); - - /** - * Temporary solution to add pnfCorrelationId to context. this value is getting from the request to SO api - * handler and then convert to CamudaInput - */ - executionVariables.put(ExecutionVariableNames.PNF_CORRELATION_ID, "PNFDemo"); - } - - - @Test - public void workflow_validInput_expectedOutput() throws InterruptedException { - - mockCatalogDb(); - mockRequestDb(); - mockAai(); - - final String msoRequestId = UUID.randomUUID().toString(); - executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId); - - final String testBusinessKey = UUID.randomUUID().toString(); - logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey); - - ProcessInstance pi = - runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables); - - int waitCount = 10; - while (!isProcessInstanceEnded() && waitCount >= 0) { - Thread.sleep(WORKFLOW_WAIT_TIME); - waitCount--; - } - - // Layout is to reflect the bpmn visual layout - assertThat(pi).isEnded().hasPassedInOrder("softwareUpgrade_startEvent", "ServiceTask_042uz7n", - "ScriptTask_10klpg8", "ServiceTask_0slpahe", "ExclusiveGateway_0x6h0ni", "ServiceTask_0x5cje8", - "ExclusiveGateway_0v3l3wv", "ServiceTask_02lxf48", "ExclusiveGateway_0ch3fef", "ServiceTask_0y2uysu", - "ExclusiveGateway_1ny9b1z", "ScriptTask_1igtc83", "CallActivity_0o1mi8u", "softwareUpgrade_endEvent"); - - List detailedMessages = grpcNettyServer.getDetailedMessages(); - assertThat(detailedMessages.size() == 4); - int count = 0; - try { - for (ExecutionServiceInput eSI : detailedMessages) { - for (String action : actionNames) { - if (action.equals(eSI.getActionIdentifiers().getActionName()) - && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) { - checkWithActionName(eSI, action); - count++; - } - } - } - } catch (Exception e) { - e.printStackTrace(); - fail("PNFSoftwareUpgrade request exception", e); - } - assertThat(count == actionNames.length); - } - - private boolean isProcessInstanceEnded() { - return runtimeService.createProcessInstanceQuery().processDefinitionKey(TEST_PROCESSINSTANCE_KEY) - .singleResult() == null; - } - - private void checkWithActionName(ExecutionServiceInput executionServiceInput, String action) { - - logger.info("Checking the " + action + " request"); - ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers(); - - /** - * the fields of actionIdentifiers should match the one in the response/PNFSoftwareUpgrade_catalogdb.json. - */ - assertThat(actionIdentifiers.getBlueprintName()).isEqualTo("test_pnf_software_upgrade_restconf"); - assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo("1.0.0"); - assertThat(actionIdentifiers.getActionName()).isEqualTo(action); - assertThat(actionIdentifiers.getMode()).isEqualTo("async"); - - CommonHeader commonHeader = executionServiceInput.getCommonHeader(); - assertThat(commonHeader.getOriginatorId()).isEqualTo("SO"); - - Struct payload = executionServiceInput.getPayload(); - Struct requeststruct = payload.getFieldsOrThrow(action + "-request").getStructValue(); - - assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue()).isEqualTo("PNFDemo"); - Struct propertiesStruct = requeststruct.getFieldsOrThrow(action + "-properties").getStructValue(); - - assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo("PNFDemo"); - assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()) - .isEqualTo("32daaac6-5017-4e1e-96c8-6a27dfbe1421"); - assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue()) - .isEqualTo("38dc9a92-214c-11e7-93ae-92361f002680"); - assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue()) - .isEqualTo("demo-sw-ver2.0.0"); - } - - private void mockAai() { - - String aaiPnfEntry = - "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n" + " \"in-maint\":true,\n" - + " \"resource-version\":\"1541720264047\",\n" + " \"swVersion\":\"demo-1.1\",\n" - + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}"; - - /** - * PUT the PNF correlation ID to AAI. - */ - wireMockServer.stubFor(put(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); - - /** - * Get the PNF entry from AAI. - */ - wireMockServer.stubFor( - get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry))); - - /* - * Post the pnf to AAI - */ - wireMockServer.stubFor(post(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo"))); - } - - private void mockRequestDb() { - /** - * Update Request DB - */ - wireMockServer.stubFor(put(urlEqualTo("/infraActiveRequests/" + REQUEST_ID))); - - } - - /** - * Mock the catalobdb rest interface. - */ - private void mockCatalogDb() { - - String catalogdbClientResponse = - FileUtil.readResourceFile("response/" + getClass().getSimpleName() + "_catalogdb.json"); - - - /** - * Return valid json for the model UUID in the request file. - */ - wireMockServer - .stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) - .willReturn(okJson(responseObject))); - - /** - * Return valid json for the service model InvariantUUID as specified in the request file. - */ - wireMockServer.stubFor( - get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=339b7a2f-9524-4dbf-9eee-f2e05521df3f")) - .willReturn(okJson(responseObject))); - - /** - * Return valid spring data rest json for the service model UUID as specified in the request file. - */ - wireMockServer.stubFor(get(urlEqualTo( - "/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=32daaac6-5017-4e1e-96c8-6a27dfbe1421")) - .willReturn(okJson(catalogdbClientResponse))); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java index 00dda299b6..bdad46f3ca 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/ServiceLevelUpgradeTest.java @@ -145,7 +145,7 @@ public class ServiceLevelUpgradeTest extends BaseBPMNTest { } } catch (Exception e) { e.printStackTrace(); - fail("PNFSoftwareUpgrade request exception", e); + fail("GenericPnfSoftwareUpgrade request exception", e); } assertThat(count == actionNames.length); } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json new file mode 100644 index 0000000000..a101118623 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/GenericPnfSoftwareUpgradeTest.json @@ -0,0 +1,54 @@ +{ + "requestDetails":{ + "requestInfo":{ + "source":"VID", + "suppressRollback":false, + "requestorId":"demo", + "productFamilyId":"SWUPid" + }, + "modelInfo":{ + "modelType":"service", + "modelInvariantUuid":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelInvariantId":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"32daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "requestParameters":{ + "userParams":[ + { + "name":"aic_zone", + "value":"nova" + }, + { + "name":"pnfId", + "value":"PNFDemo" + }, + { + "name":"targetSoftwareVersion", + "value":"demo-sw-ver2.0.0" + }, + { + "name":"pnfName", + "value":"PNFDemo" + } + ], + "subscriptionServiceType":"SWUP", + "aLaCarte":false + }, + "cloudConfiguration":{ + "lcpCloudRegionId":"regionOne", + "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" + }, + "subscriberInfo":{ + "globalSubscriberId":"ADemoCustomerInEric" + }, + "project":{ + "projectName":"Project-Demonstration" + }, + "owningEntity":{ + "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", + "owningEntityName":"OE-Demonstration" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json deleted file mode 100644 index a101118623..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/request/PNFSoftwareUpgradeTest.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "requestDetails":{ - "requestInfo":{ - "source":"VID", - "suppressRollback":false, - "requestorId":"demo", - "productFamilyId":"SWUPid" - }, - "modelInfo":{ - "modelType":"service", - "modelInvariantUuid":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", - "modelInvariantId":"339b7a2f-9524-4dbf-9eee-f2e05521df3f", - "modelUuid":"32daaac6-5017-4e1e-96c8-6a27dfbe1421", - "modelName":"PNF_int_service_2", - "modelVersion":"1.0" - }, - "requestParameters":{ - "userParams":[ - { - "name":"aic_zone", - "value":"nova" - }, - { - "name":"pnfId", - "value":"PNFDemo" - }, - { - "name":"targetSoftwareVersion", - "value":"demo-sw-ver2.0.0" - }, - { - "name":"pnfName", - "value":"PNFDemo" - } - ], - "subscriptionServiceType":"SWUP", - "aLaCarte":false - }, - "cloudConfiguration":{ - "lcpCloudRegionId":"regionOne", - "tenantId":"09a63533072f4a579d5c99c3b8fe94c6" - }, - "subscriberInfo":{ - "globalSubscriberId":"ADemoCustomerInEric" - }, - "project":{ - "projectName":"Project-Demonstration" - }, - "owningEntity":{ - "owningEntityId":"5eae949c-1c50-4780-b8b5-7cbeb08856b4", - "owningEntityName":"OE-Demonstration" - } - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json new file mode 100644 index 0000000000..32539844ba --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest.json @@ -0,0 +1,26 @@ +{ + "serviceResources":{ + "modelInfo":{ + "modelInvariantId":"439b7a2f-9524-4dbf-9eee-f2e05521df3f", + "modelUuid":"42daaac6-5017-4e1e-96c8-6a27dfbe1421", + "modelName":"PNF_int_service_2", + "modelVersion":"1.0" + }, + "serviceType":"NA", + "environmentContext":"Luna", + "serviceRole":"NA", + "workloadContext":"Oxygen", + "serviceVnfs":[ + + ], + "serviceNetworks":[ + + ], + "serviceAllottedResources":[ + + ], + "configResource":[ + + ] + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json new file mode 100644 index 0000000000..faec947fec --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/GenericPnfSoftwareUpgradeTest_catalogdb.json @@ -0,0 +1,39 @@ +{ + "_embedded": { + "pnfResourceCustomization": [ + { + "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", + "modelInstanceName": "PNF routing", + "created": "2019-03-08 12:00:29.000", + "nfFunction": "routing", + "nfType": "routing", + "nfRole": "routing", + "nfNamingCode": "routing", + "multiStageDesign": null, + "resourceInput": null, + "blueprintName": "test_pnf_software_upgrade_restconf", + "blueprintVersion": "1.0.0", + "skipPostInstConf": false, + "softwareVersion": "1.0.0", + "creationTimestamp": "2019-03-08T12:00:29.000+0000", + "controllerActor": "cds", + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResourceCustomization": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" + }, + "pnfResources": { + "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json deleted file mode 100644 index 32539844ba..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "serviceResources":{ - "modelInfo":{ - "modelInvariantId":"439b7a2f-9524-4dbf-9eee-f2e05521df3f", - "modelUuid":"42daaac6-5017-4e1e-96c8-6a27dfbe1421", - "modelName":"PNF_int_service_2", - "modelVersion":"1.0" - }, - "serviceType":"NA", - "environmentContext":"Luna", - "serviceRole":"NA", - "workloadContext":"Oxygen", - "serviceVnfs":[ - - ], - "serviceNetworks":[ - - ], - "serviceAllottedResources":[ - - ], - "configResource":[ - - ] - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json deleted file mode 100644 index faec947fec..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/response/PNFSoftwareUpgradeTest_catalogdb.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "_embedded": { - "pnfResourceCustomization": [ - { - "modelCustomizationUUID": "38dc9a92-214c-11e7-93ae-92361f002680", - "modelInstanceName": "PNF routing", - "created": "2019-03-08 12:00:29.000", - "nfFunction": "routing", - "nfType": "routing", - "nfRole": "routing", - "nfNamingCode": "routing", - "multiStageDesign": null, - "resourceInput": null, - "blueprintName": "test_pnf_software_upgrade_restconf", - "blueprintVersion": "1.0.0", - "skipPostInstConf": false, - "softwareVersion": "1.0.0", - "creationTimestamp": "2019-03-08T12:00:29.000+0000", - "controllerActor": "cds", - "_links": { - "self": { - "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" - }, - "pnfResourceCustomization": { - "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680" - }, - "pnfResources": { - "href": "http://localhost:41023/pnfResourceCustomization/38dc9a92-214c-11e7-93ae-92361f002680/pnfResources" - } - } - } - ] - }, - "_links": { - "self": { - "href": "http://localhost:41023/pnfResourceCustomization/search/findPnfResourceCustomizationByModelUuid?SERVICE_MODEL_UUID=4df8b6de-2083-11e7-93ae-92361f002676" - } - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java index d94641846d..7b73fff20c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/level/impl/ServiceLevelConstants.java @@ -45,7 +45,7 @@ public class ServiceLevelConstants { Map.of(PNF, "GenericPnfHealthCheck", VNF, "GenericVNFHealthCheck"); public static final Map DEFAULT_SOFTWARE_UP_WORKFLOWS = - Map.of(PNF, "PNFSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade"); + Map.of(PNF, "GenericPnfSoftwareUpgrade", VNF, "GenericVnfSoftwareUpgrade"); // Maps operation name with workflows public static final Map> WORKFLOW_OPERATIONS_MAP = Map.of(HEALTH_CHECK_OPERATION, -- cgit 1.2.3-korg