summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy119
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java169
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/CDSRequestProvider.java76
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java79
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java73
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java53
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java153
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java53
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java78
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java89
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java121
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java106
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/PayloadGenerationException.java39
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java27
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java205
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java127
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java342
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java139
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java62
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java80
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VnfCDSRequestProviderTest.java104
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn241
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java79
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java78
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java76
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java (renamed from bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java)18
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java109
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java92
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java92
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java89
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java116
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java142
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java)48
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java127
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java197
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java143
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java72
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java202
46 files changed, 4012 insertions, 293 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy
new file mode 100644
index 0000000000..ce474fa713
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # 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.common.scripts
+
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.db.request.beans.OperationStatus
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.web.util.UriUtils
+
+class RequestDBUtil {
+ private static final Logger logger = LoggerFactory.getLogger( RequestDBUtil.class);
+ private ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ /**
+ * update operation status in requestDB
+ * @param execution
+ * @param operationStatus
+ */
+ void prepareUpdateOperationStatus(DelegateExecution execution, final OperationStatus operationStatus){
+ logger.debug("start prepareUpdateOperationStatus")
+ try{
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
+ execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+
+ String serviceId = operationStatus.getServiceId()
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ String operationId = operationStatus.getOperationId()
+ String userId = operationStatus.getUserId()
+ String operationType = operationStatus.getOperation()
+ String result = operationStatus.getResult()
+ String progress = operationStatus.getProgress()
+ String operationContent = operationStatus.getOperationContent()
+ String reason = operationStatus.getReason()
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
+ <userId>${MsoUtils.xmlEscape(userId)}</userId>
+ <result>${MsoUtils.xmlEscape(result)}</result>
+ <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <reason>${MsoUtils.xmlEscape(reason)}</reason>
+ </ns:updateServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ execution.setVariable("updateOperationStatus", payload)
+
+ }catch(any){
+ String exceptionMessage = "Prepare update ServiceOperationStatus failed. cause - " + any.getMessage()
+ logger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ logger.trace("finished update OperationStatus")
+ }
+
+
+ /**
+ * get operation status from requestDB by serviceId and operationId
+ * @param execution
+ * @param serviceId
+ * @param operationId
+ */
+ void getOperationStatus(DelegateExecution execution, String serviceId, String operationId) {
+ logger.trace("start getOperationStatus")
+ try {
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
+ execution.setVariable("dbAdapterEndpoint", dbAdapterEndpoint)
+ logger.trace("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ operationId = UriUtils.encode(operationId,"UTF-8")
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:getServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
+ <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ </ns:getServiceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ execution.setVariable("getOperationStatus", payload)
+
+ } catch(any){
+ String exceptionMessage = "Get ServiceOperationStatus failed. cause - " + any.getMessage()
+ logger.error(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
index 424a4f3ecc..ebced8e933 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java
@@ -22,14 +22,18 @@
package org.onap.so.client.cds;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import com.google.protobuf.InvalidProtocolBufferException;
+import com.google.protobuf.Struct;
+import com.google.protobuf.Struct.Builder;
+import com.google.protobuf.util.JsonFormat;
+import io.grpc.Status;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.client.PreconditionFailedException;
import org.onap.so.client.RestPropertiesLoader;
import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
@@ -39,15 +43,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.protobuf.Struct;
-import com.google.protobuf.Struct.Builder;
-import com.google.protobuf.util.JsonFormat;
-import io.grpc.Status;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* Util class to support Call to CDS client
- *
*/
@Component
public class AbstractCDSProcessingBBUtils {
@@ -60,11 +60,7 @@ public class AbstractCDSProcessingBBUtils {
private static final String RESPONSE_PAYLOAD = "CDSResponsePayload";
private static final String CDS_STATUS = "CDSStatus";
private static final String EXEC_INPUT = "executionServiceInput";
-
-
- /**
- * indicate exception thrown.
- */
+ private static final String EXECUTION_OBJECT = "executionObject";
private static final String EXCEPTION = "Exception";
@Autowired
@@ -76,34 +72,33 @@ public class AbstractCDSProcessingBBUtils {
* @param execution DelegateExecution object
*/
public void constructExecutionServiceInputObject(DelegateExecution execution) {
- logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest ");
+ logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest for DelegateExecution object.");
try {
AbstractCDSPropertiesBean executionObject =
- (AbstractCDSPropertiesBean) execution.getVariable("executionObject");
-
- String payload = executionObject.getRequestObject();
-
- CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(executionObject.getOriginatorId())
- .setRequestId(executionObject.getRequestId()).setSubRequestId(executionObject.getSubRequestId())
- .build();
- ActionIdentifiers actionIdentifiers =
- ActionIdentifiers.newBuilder().setBlueprintName(executionObject.getBlueprintName())
- .setBlueprintVersion(executionObject.getBlueprintVersion())
- .setActionName(executionObject.getActionName()).setMode(executionObject.getMode()).build();
-
- Builder struct = Struct.newBuilder();
- try {
- JsonFormat.parser().merge(payload, struct);
- } catch (InvalidProtocolBufferException e) {
- logger.error("Failed to parse received message. blueprint({}:{}) for action({}). {}",
- executionObject.getBlueprintVersion(), executionObject.getBlueprintName(),
- executionObject.getActionName(), e);
- }
+ (AbstractCDSPropertiesBean) execution.getVariable(EXECUTION_OBJECT);
+
+ ExecutionServiceInput executionServiceInput = prepareExecutionServiceInput(executionObject);
+
+ execution.setVariable(EXEC_INPUT, executionServiceInput);
+
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- ExecutionServiceInput executionServiceInput =
- ExecutionServiceInput.newBuilder().setCommonHeader(commonHeader)
- .setActionIdentifiers(actionIdentifiers).setPayload(struct.build()).build();
+ /**
+ * Extracting data from execution object and building the ExecutionServiceInput Object
+ *
+ * @param execution BuildingBlockExecution object
+ */
+ public void constructExecutionServiceInputObject(BuildingBlockExecution execution) {
+ logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest for BuildingBlockExecution object.");
+
+ try {
+ AbstractCDSPropertiesBean executionObject = execution.getVariable(EXECUTION_OBJECT);
+
+ ExecutionServiceInput executionServiceInput = prepareExecutionServiceInput(executionObject);
execution.setVariable(EXEC_INPUT, executionServiceInput);
@@ -119,50 +114,98 @@ public class AbstractCDSProcessingBBUtils {
*/
public void sendRequestToCDSClient(DelegateExecution execution) {
- logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient ");
+ logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient for DelegateExecution object.");
try {
- CDSProperties props = RestPropertiesLoader.getInstance().getNewImpl(CDSProperties.class);
- if (props == null) {
- throw new PreconditionFailedException(
- "No RestProperty.CDSProperties implementation found on classpath, can't create client.");
- }
-
ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution.getVariable(EXEC_INPUT);
+ CDSResponse cdsResponse = getCdsResponse(executionServiceInput);
+ execution.setVariable(CDS_STATUS, cdsResponse.status);
- CDSResponse cdsResponse = new CDSResponse();
-
- try (CDSProcessingClient cdsClient = new CDSProcessingClient(new ResponseHandler(cdsResponse))) {
- CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
- countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
- } catch (InterruptedException ex) {
- logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
- Thread.currentThread().interrupt();
+ if (cdsResponse.payload != null) {
+ String payload = JsonFormat.printer().print(cdsResponse.payload);
+ execution.setVariable(RESPONSE_PAYLOAD, payload);
}
- String cdsResponseStatus = cdsResponse.status;
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
- /**
- * throw CDS failed exception.
- */
- if (!cdsResponseStatus.equals(SUCCESS)) {
- throw new BadResponseException("CDS call failed with status: " + cdsResponse.status
- + " and errorMessage: " + cdsResponse.errorMessage);
- }
+ /**
+ * get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period
+ *
+ * @param execution BuildingBlockExecution object
+ */
+ public void sendRequestToCDSClient(BuildingBlockExecution execution) {
- execution.setVariable(CDS_STATUS, cdsResponseStatus);
+ logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient for BuildingBlockExecution object.");
+ try {
+ ExecutionServiceInput executionServiceInput = execution.getVariable(EXEC_INPUT);
+ CDSResponse cdsResponse = getCdsResponse(executionServiceInput);
+ execution.setVariable(CDS_STATUS, cdsResponse.status);
if (cdsResponse.payload != null) {
String payload = JsonFormat.printer().print(cdsResponse.payload);
execution.setVariable(RESPONSE_PAYLOAD, payload);
}
-
-
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
+ private CDSResponse getCdsResponse(ExecutionServiceInput executionServiceInput) throws BadResponseException {
+ CDSProperties props = RestPropertiesLoader.getInstance().getNewImpl(CDSProperties.class);
+ if (props == null) {
+ throw new PreconditionFailedException(
+ "No RestProperty.CDSProperties implementation found on classpath, can't create client.");
+ }
+
+ CDSResponse cdsResponse = new CDSResponse();
+
+ try (CDSProcessingClient cdsClient = new CDSProcessingClient(new ResponseHandler(cdsResponse))) {
+ CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput);
+ countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS);
+ } catch (InterruptedException ex) {
+ logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex);
+ Thread.currentThread().interrupt();
+ }
+
+ String cdsResponseStatus = cdsResponse.status;
+
+ /**
+ * throw CDS failed exception.
+ */
+ if (!cdsResponseStatus.equals(SUCCESS)) {
+ throw new BadResponseException("CDS call failed with status: " + cdsResponse.status + " and errorMessage: "
+ + cdsResponse.errorMessage);
+ }
+ return cdsResponse;
+ }
+
+ private ExecutionServiceInput prepareExecutionServiceInput(AbstractCDSPropertiesBean executionObject) {
+ String payload = executionObject.getRequestObject();
+
+ CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(executionObject.getOriginatorId())
+ .setRequestId(executionObject.getRequestId()).setSubRequestId(executionObject.getSubRequestId())
+ .build();
+ ActionIdentifiers actionIdentifiers =
+ ActionIdentifiers.newBuilder().setBlueprintName(executionObject.getBlueprintName())
+ .setBlueprintVersion(executionObject.getBlueprintVersion())
+ .setActionName(executionObject.getActionName()).setMode(executionObject.getMode()).build();
+
+ Builder struct = Struct.newBuilder();
+ try {
+ JsonFormat.parser().merge(payload, struct);
+ } catch (InvalidProtocolBufferException e) {
+ logger.error("Failed to parse received message. blueprint({}:{}) for action({}). {}",
+ executionObject.getBlueprintVersion(), executionObject.getBlueprintName(),
+ executionObject.getActionName(), e);
+ }
+
+ return ExecutionServiceInput.newBuilder().setCommonHeader(commonHeader).setActionIdentifiers(actionIdentifiers)
+ .setPayload(struct.build()).build();
+ }
+
private class ResponseHandler implements CDSProcessingListener {
private CDSResponse cdsResponse;
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/CDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/CDSRequestProvider.java
new file mode 100644
index 0000000000..e01de69b74
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/CDSRequestProvider.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.onap.so.client.exception.PayloadGenerationException;
+import java.util.Optional;
+import static org.onap.so.client.cds.PayloadConstants.REQUEST;
+import static org.onap.so.client.cds.PayloadConstants.SEPARATOR;
+
+public interface CDSRequestProvider {
+
+ /**
+ * Build entire payload for CDS.
+ *
+ * @param action - action could be assign/deploy/undeploy etc.
+ * @return "payload":{ "config-<action>-<scope>":{ // information about resolution key, property configuration and
+ * template prefix based on the scope and action}
+ * @throws PayloadGenerationException If fail to build the payload.
+ */
+ Optional<String> buildRequestPayload(String action) throws PayloadGenerationException;
+
+ /**
+ * Get the blueprint name for CDS payload
+ *
+ * @return blueprint name
+ */
+ String getBlueprintName();
+
+ /**
+ * Get the blueprint version for CDS payload
+ *
+ * @return blueprint version
+ */
+ String getBlueprintVersion();
+
+ /**
+ * Set the executionObject(BuildingBlockExecution or DelegateExecution for PNF)
+ *
+ * @param executionObject object could be BuildingBlockExecution or DelegateExecution.
+ */
+ <T> void setExecutionObject(T executionObject);
+
+
+ /**
+ * Build Request payload for CDS
+ *
+ * @param cdsPropertyObject - Json Object
+ * @param action - action could be assign/deploy/undeploy etc.
+ * @return Request Payload
+ */
+ default String buildRequestJsonObject(JsonObject cdsPropertyObject, String action) {
+ String requestBasedOnAction = action.concat(SEPARATOR).concat(REQUEST);
+ JsonObject requestObject = new JsonObject();
+ requestObject.add(requestBasedOnAction, cdsPropertyObject);
+ return requestObject.toString();
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java
new file mode 100644
index 0000000000..6f850fa898
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModule.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.onap.so.client.cds.ExtractServiceFromUserParameters;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class ConfigureInstanceParamsForVfModule {
+
+ @Autowired
+ private ExtractServiceFromUserParameters extractServiceFromUserParameters;
+
+ /**
+ * Read instance parameters for VF-Module and put into JsonObject.
+ *
+ * @param jsonObject- JsonObject which will hold the payload to send to CDS.
+ * @param userParamsFromRequest - User parameters for a vf-module
+ * @param vnfCustomizationUuid - Unique ID for vnf.
+ * @param vfModuleCustomizationUuid - Unique ID for vf-module.
+ * @throws PayloadGenerationException- If it doesn't able to populate instance parameters from SO payload.
+ */
+ public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest,
+ String vnfCustomizationUuid, String vfModuleCustomizationUuid) throws PayloadGenerationException {
+ try {
+ Service service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest);
+
+ List<Map<String, String>> instanceParamsList =
+ getInstanceParams(service, vnfCustomizationUuid, vfModuleCustomizationUuid);
+
+ instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream())
+ .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue()));
+ } catch (Exception e) {
+ throw new PayloadGenerationException("Couldn't able to resolve instance parameters", e);
+ }
+ }
+
+ private List<Map<String, String>> getInstanceParams(Service service, String vnfCustomizationUuid,
+ String vfModuleCustomizationUuid) throws PayloadGenerationException {
+
+ Vnfs foundedVnf = service.getResources().getVnfs().stream()
+ .filter(vnfs -> vnfs.getModelInfo().getModelCustomizationId().equals(vnfCustomizationUuid)).findFirst()
+ .orElseThrow(() -> new PayloadGenerationException(String
+ .format("Can not find vnf for genericVnfModelCustomizationUuid: %s", vnfCustomizationUuid)));
+
+ VfModules vfModule = foundedVnf.getVfModules().stream().filter(
+ vfModules -> vfModules.getModelInfo().getModelCustomizationId().equals(vfModuleCustomizationUuid))
+ .findFirst().orElseThrow(() -> new PayloadGenerationException(String
+ .format("Can not find vnf for vfModuleCustomizationUuid: %s", vfModuleCustomizationUuid)));
+
+ return vfModule.getInstanceParams();
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java
new file mode 100644
index 0000000000..22c9a7bee4
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForVnf.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.Vnfs;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+@Component
+public class ConfigureInstanceParamsForVnf {
+
+ @Autowired
+ private ExtractServiceFromUserParameters extractServiceFromUserParameters;
+
+ /**
+ * Read instance parameters for VNF and put into JsonObject.
+ *
+ * @param jsonObject - JsonObject which will hold the payload to send to CDS.
+ * @param userParamsFromRequest - User parameters.
+ * @param modelCustomizationUuid - Unique ID for Vnf.
+ * @throws PayloadGenerationException if it doesn't able to populate instance parameters from SO payload.
+ */
+ public void populateInstanceParams(JsonObject jsonObject, List<Map<String, Object>> userParamsFromRequest,
+ String modelCustomizationUuid) throws PayloadGenerationException {
+ try {
+ Service service = extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest);
+ List<Map<String, String>> instanceParamsList = getInstanceParamForVnf(service, modelCustomizationUuid);
+
+ instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream())
+ .forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue()));
+ } catch (Exception e) {
+ throw new PayloadGenerationException("Couldn't able to resolve instance parameters", e);
+ }
+ }
+
+ private List<Map<String, String>> getInstanceParamForVnf(Service service, String genericVnfModelCustomizationUuid)
+ throws PayloadGenerationException {
+ Optional<Vnfs> foundedVnf = service.getResources().getVnfs().stream()
+ .filter(vnfs -> vnfs.getModelInfo().getModelCustomizationId().equals(genericVnfModelCustomizationUuid))
+ .findFirst();
+
+ if (foundedVnf.isPresent()) {
+ return foundedVnf.get().getInstanceParams();
+ } else {
+ throw new PayloadGenerationException(String.format(
+ "Can not find vnf for genericVnfModelCustomizationUuid: %s", genericVnfModelCustomizationUuid));
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java
new file mode 100644
index 0000000000..43fabd3253
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ExtractServiceFromUserParameters.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.onap.so.serviceinstancebeans.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class ExtractServiceFromUserParameters {
+
+ private static final String SERVICE_KEY = "service";
+
+ @Autowired
+ private ObjectMapper objectMapper;
+
+ public Service getServiceFromRequestUserParams(List<Map<String, Object>> userParams) throws Exception {
+ Map<String, Object> serviceMap = userParams.stream().filter(key -> key.containsKey(SERVICE_KEY)).findFirst()
+ .orElseThrow(() -> new Exception("Can not find service in userParams section in generalBuildingBlock"));
+ return getServiceObjectFromServiceMap(serviceMap);
+ }
+
+ private Service getServiceObjectFromServiceMap(Map<String, Object> serviceMap) throws PayloadGenerationException {
+ try {
+ String serviceFromJson = objectMapper.writeValueAsString(serviceMap.get(SERVICE_KEY));
+ return objectMapper.readValue(serviceFromJson, Service.class);
+ } catch (Exception e) {
+ throw new PayloadGenerationException("An exception occurred while converting json object to Service object",
+ e);
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java
new file mode 100644
index 0000000000..fb79880572
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/GeneratePayloadForCds.java
@@ -0,0 +1,153 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * Modifications Copyright (c) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import java.util.UUID;
+
+@Component
+public class GeneratePayloadForCds {
+
+ private static final String ORIGINATOR_ID = "SO";
+ private static final String BUILDING_BLOCK = "buildingBlock";
+ private static final String DEFAULT_SYNC_MODE = "sync";
+ private static final String MSO_REQUEST_ID = "msoRequestId";
+
+ @Autowired
+ private VnfCDSRequestProvider vnfCDSRequestProvider;
+
+ @Autowired
+ private VfModuleCDSRequestProvider vfModuleCDSRequestProvider;
+
+ @Autowired
+ private ServiceCDSRequestProvider serviceCDSRequestProvider;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private PnfCDSRequestProvider pnfCDSRequestProvider;
+
+ /**
+ * Build properties like (blueprint name, version, action etc..) along with the request payload for vnf, vf-module
+ * and service.
+ *
+ * @param execution - A building block execution object.
+ * @return AbstractCDSPropertiesBean - A POJO which contains CDS related information.
+ * @throws PayloadGenerationException - Throw an exception if it fails to build payload for CDS.
+ */
+ public AbstractCDSPropertiesBean buildCdsPropertiesBean(BuildingBlockExecution execution)
+ throws PayloadGenerationException {
+
+ ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
+ BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
+ final String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
+ final String scope = buildingBlock.getBpmnScope();
+ final String action = buildingBlock.getBpmnAction();
+
+
+ CDSRequestProvider requestProvider = getRequestProviderByScope(scope);
+ requestProvider.setExecutionObject(execution);
+
+ final String requestPayload = requestProvider.buildRequestPayload(action)
+ .orElseThrow(() -> new PayloadGenerationException("Failed to build payload for CDS"));
+
+ return prepareAndSetCdsPropertyBean(requestProvider, requestPayload, requestId, action, DEFAULT_SYNC_MODE);
+ }
+
+ /**
+ * Build properties like (blueprint name, version, action etc..) along with the request payload for pnf.
+ *
+ * @param execution - A building block execution object.
+ * @return AbstractCDSPropertiesBean - A POJO which contains CDS related information.
+ * @throws PayloadGenerationException - Throw an exception if it fails to build payload for CDS.
+ */
+ public AbstractCDSPropertiesBean buildCdsPropertiesBean(DelegateExecution execution)
+ throws PayloadGenerationException {
+
+ final String scope = String.valueOf(execution.getVariable(PayloadConstants.SCOPE));
+ final String action = String.valueOf(execution.getVariable(PayloadConstants.ACTION));
+ final String requestId = String.valueOf(execution.getVariable(MSO_REQUEST_ID));
+ final String mode = extractAndSetMode(execution);
+
+ CDSRequestProvider requestProvider = getRequestProviderByScope(scope);
+ requestProvider.setExecutionObject(execution);
+
+ final String requestPayload = requestProvider.buildRequestPayload(action)
+ .orElseThrow(() -> new PayloadGenerationException("Failed to build payload for CDS"));
+
+ return prepareAndSetCdsPropertyBean(requestProvider, requestPayload, requestId, action, mode);
+ }
+
+ private AbstractCDSPropertiesBean prepareAndSetCdsPropertyBean(CDSRequestProvider requestProvider,
+ String requestPayload, String requestId, String action, String mode) {
+ final AbstractCDSPropertiesBean cdsPropertiesBean = new AbstractCDSPropertiesBean();
+ cdsPropertiesBean.setRequestObject(requestPayload);
+ cdsPropertiesBean.setBlueprintName(requestProvider.getBlueprintName());
+ cdsPropertiesBean.setBlueprintVersion(requestProvider.getBlueprintVersion());
+ cdsPropertiesBean.setRequestId(requestId);
+ cdsPropertiesBean.setOriginatorId(ORIGINATOR_ID);
+ cdsPropertiesBean.setSubRequestId(UUID.randomUUID().toString());
+ cdsPropertiesBean.setActionName(action);
+ cdsPropertiesBean.setMode(mode);
+ return cdsPropertiesBean;
+ }
+
+ private String extractAndSetMode(DelegateExecution execution) {
+ String mode = DEFAULT_SYNC_MODE;
+ Object obj = execution.getVariable(PayloadConstants.MODE);
+ if (obj != null && !String.valueOf(obj).isEmpty()) {
+ mode = String.valueOf(obj);
+ }
+ return mode;
+ }
+
+ private CDSRequestProvider getRequestProviderByScope(String scope) throws PayloadGenerationException {
+ CDSRequestProvider requestProvider;
+ switch (scope) {
+ case PayloadConstants.VNF_SCOPE:
+ requestProvider = vnfCDSRequestProvider;
+ break;
+ case PayloadConstants.VF_MODULE_SCOPE:
+ requestProvider = vfModuleCDSRequestProvider;
+ break;
+ case PayloadConstants.SERVICE_SCOPE:
+ requestProvider = serviceCDSRequestProvider;
+ break;
+ case PayloadConstants.PNF_SCOPE:
+ requestProvider = pnfCDSRequestProvider;
+ break;
+ default:
+ throw new PayloadGenerationException("No scope defined with " + scope);
+ }
+ return requestProvider;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java
new file mode 100644
index 0000000000..808d427d65
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PayloadConstants.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * Modifications Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+public final class PayloadConstants {
+
+ private PayloadConstants() {
+
+ }
+
+ public static final String REQUEST = "request";
+ public static final String PROPERTIES = "properties";
+ public static final String SCOPE = "scope";
+ public static final String ACTION = "action";
+ public static final String MODE = "mode";
+ public static final String SEPARATOR = "-";
+ public static final String PNF_SCOPE = "pnf";
+ public static final String VNF_SCOPE = "vnf";
+ public static final String VF_MODULE_SCOPE = "vfModule";
+ public static final String SERVICE_SCOPE = "service";
+ public static final String RESOLUTION_KEY = "resolution-key";
+ public static final String CDS_ACTOR = "cds";
+
+ public static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName";
+ public static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
+ public static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
+ public static final String PRC_TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+
+ public final static String PNF_CORRELATION_ID = "pnfCorrelationId";
+ public final static String PNF_UUID = "pnfUuid";
+ public final static String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ public final static String MODEL_UUID = "modelUuid";
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java
new file mode 100644
index 0000000000..86bca755ed
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/PnfCDSRequestProvider.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import java.util.Optional;
+import static org.onap.so.client.cds.PayloadConstants.*;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class PnfCDSRequestProvider implements CDSRequestProvider {
+ private String blueprintName;
+ private String blueprintVersion;
+ private DelegateExecution execution;
+
+ @Override
+ public String getBlueprintName() {
+ return blueprintName;
+ }
+
+ @Override
+ public String getBlueprintVersion() {
+ return blueprintVersion;
+ }
+
+ @Override
+ public <T> void setExecutionObject(T executionObject) {
+ execution = (DelegateExecution) executionObject;
+ }
+
+ @Override
+ public Optional<String> buildRequestPayload(String action) {
+
+ final JsonObject pnfObject = new JsonObject();
+ final String resolutionKey = String.valueOf(execution.getVariable(PNF_CORRELATION_ID));
+ blueprintName = String.valueOf(execution.getVariable(PRC_BLUEPRINT_NAME));
+ blueprintVersion = String.valueOf(execution.getVariable(PRC_BLUEPRINT_VERSION));
+
+ extractAndSetExecutionVariable("service-instance-id", SERVICE_INSTANCE_ID, pnfObject);
+ extractAndSetExecutionVariable("service-model-uuid", MODEL_UUID, pnfObject);
+ extractAndSetExecutionVariable("pnf-id", PNF_UUID, pnfObject);
+ extractAndSetExecutionVariable("pnf-name", PNF_CORRELATION_ID, pnfObject);
+ extractAndSetExecutionVariable("pnf-customization-uuid", PRC_CUSTOMIZATION_UUID, pnfObject);
+ extractAndSetExecutionVariable("target-software-version", PRC_TARGET_SOFTWARE_VERSION, pnfObject);
+
+ final JsonObject cdsPropertyObject = new JsonObject();
+ cdsPropertyObject.addProperty(RESOLUTION_KEY, resolutionKey);
+ cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, pnfObject);
+
+ return Optional.of(buildRequestJsonObject(cdsPropertyObject, action));
+ }
+
+ private void extractAndSetExecutionVariable(String jsonProperty, String executionProperty, JsonObject pnfObject) {
+ if (execution.getVariable(executionProperty) != null) {
+ pnfObject.addProperty(jsonProperty, String.valueOf(execution.getVariable(executionProperty)));
+ }
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java
new file mode 100644
index 0000000000..12c841a2c6
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ServiceCDSRequestProvider.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import java.util.Optional;
+import static org.onap.so.client.cds.PayloadConstants.PROPERTIES;
+import static org.onap.so.client.cds.PayloadConstants.SEPARATOR;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class ServiceCDSRequestProvider implements CDSRequestProvider {
+
+ private static final String EMPTY_STRING = "";
+ private String resolutionKey;
+ private BuildingBlockExecution execution;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Override
+ public String getBlueprintName() {
+ return EMPTY_STRING;
+ }
+
+ @Override
+ public String getBlueprintVersion() {
+ return EMPTY_STRING;
+ }
+
+ @Override
+ public <T> void setExecutionObject(T executionObject) {
+ execution = (BuildingBlockExecution) executionObject;
+ }
+
+ @Override
+ public Optional<String> buildRequestPayload(String action) throws PayloadGenerationException {
+ JsonObject cdsPropertyObject = new JsonObject();
+ JsonObject serviceObject = new JsonObject();
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+
+ resolutionKey = serviceInstance.getServiceInstanceName();
+
+ // TODO Need to figure out how to populate blueprint name and version for service.
+
+ serviceObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId());
+ serviceObject.addProperty("service-model-uuid",
+ serviceInstance.getModelInfoServiceInstance().getModelUuid());
+
+ } catch (Exception e) {
+ throw new PayloadGenerationException("Failed to buildPropertyObjectForService", e);
+ }
+
+ cdsPropertyObject.addProperty("resolution-key", resolutionKey);
+ cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, serviceObject);
+
+ return Optional.of(buildRequestJsonObject(cdsPropertyObject, action));
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java
new file mode 100644
index 0000000000..bba8925f21
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java
@@ -0,0 +1,121 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import static org.onap.so.client.cds.PayloadConstants.PROPERTIES;
+import static org.onap.so.client.cds.PayloadConstants.SEPARATOR;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class VfModuleCDSRequestProvider implements CDSRequestProvider {
+ private String blueprintName;
+ private String blueprintVersion;
+ private BuildingBlockExecution execution;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private ConfigureInstanceParamsForVfModule configureInstanceParamsForVfModule;
+
+ @Override
+ public String getBlueprintName() {
+ return blueprintName;
+ }
+
+ @Override
+ public String getBlueprintVersion() {
+ return blueprintVersion;
+ }
+
+ @Override
+ public <T> void setExecutionObject(T executionObject) {
+ execution = (BuildingBlockExecution) executionObject;
+ }
+
+ @Override
+ public Optional<String> buildRequestPayload(String action) throws PayloadGenerationException {
+ JsonObject cdsPropertyObject = new JsonObject();
+ JsonObject vfModuleObject = new JsonObject();
+ String vfModuleName;
+
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ final String modelCustomizationUuidForVnf = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
+
+ blueprintName = genericVnf.getBlueprintName();
+ blueprintVersion = genericVnf.getBlueprintVersion();
+
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ vfModuleName = vfModule.getVfModuleName();
+
+ final String modelCustomizationUuidForVfModule =
+ vfModule.getModelInfoVfModule().getModelCustomizationUUID();
+
+ vfModuleObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId());
+ vfModuleObject.addProperty("service-model-uuid",
+ serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ vfModuleObject.addProperty("vnf-id", genericVnf.getVnfId());
+ vfModuleObject.addProperty("vnf-name", genericVnf.getVnfName());
+ vfModuleObject.addProperty("vf-module-id", vfModule.getVfModuleId());
+ vfModuleObject.addProperty("vf-module-name", vfModule.getVfModuleName());
+ vfModuleObject.addProperty("vf-module-customization-uuid",
+ vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+
+ final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
+ List<Map<String, Object>> userParamsFromRequest =
+ buildingBlock.getRequestContext().getRequestParameters().getUserParams();
+
+ configureInstanceParamsForVfModule.populateInstanceParams(vfModuleObject, userParamsFromRequest,
+ modelCustomizationUuidForVnf, modelCustomizationUuidForVfModule);
+ } catch (Exception e) {
+ throw new PayloadGenerationException("Failed to buildPropertyObject for VF-Module", e);
+ }
+
+ // Not sure for resolutionKey should be same as vfModule name.
+ cdsPropertyObject.addProperty("resolution-key", vfModuleName);
+ cdsPropertyObject.addProperty("template-prefix", vfModuleName + action);
+ cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, vfModuleObject);
+
+ return Optional.of(buildRequestJsonObject(cdsPropertyObject, action));
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java
new file mode 100644
index 0000000000..d33976d229
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import static org.onap.so.client.cds.PayloadConstants.PROPERTIES;
+import static org.onap.so.client.cds.PayloadConstants.SEPARATOR;
+
+@Component
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+public class VnfCDSRequestProvider implements CDSRequestProvider {
+ private String blueprintName;
+ private String blueprintVersion;
+ private BuildingBlockExecution execution;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private ConfigureInstanceParamsForVnf configureInstanceParamsForVnf;
+
+ @Override
+ public String getBlueprintName() {
+ return blueprintName;
+ }
+
+ @Override
+ public String getBlueprintVersion() {
+ return blueprintVersion;
+ }
+
+ @Override
+ public <T> void setExecutionObject(T executionObject) {
+ execution = (BuildingBlockExecution) executionObject;
+ }
+
+ @Override
+ public Optional<String> buildRequestPayload(String action) throws PayloadGenerationException {
+ JsonObject cdsPropertyObject = new JsonObject();
+ JsonObject vnfObject = new JsonObject();
+ String resolutionKey;
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+
+ final String modelCustomizationUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
+
+ resolutionKey = genericVnf.getVnfName();
+ blueprintName = genericVnf.getBlueprintName();
+ blueprintVersion = genericVnf.getBlueprintVersion();
+
+ vnfObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId());
+ vnfObject.addProperty("service-model-uuid", serviceInstance.getModelInfoServiceInstance().getModelUuid());
+ vnfObject.addProperty("vnf-id", genericVnf.getVnfId());
+ vnfObject.addProperty("vnf-name", genericVnf.getVnfName());
+ vnfObject.addProperty("vnf-customization-uuid", modelCustomizationUuid);
+
+ final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
+ List<Map<String, Object>> userParamsFromRequest =
+ buildingBlock.getRequestContext().getRequestParameters().getUserParams();
+
+ configureInstanceParamsForVnf.populateInstanceParams(vnfObject, userParamsFromRequest,
+ modelCustomizationUuid);
+ } catch (Exception e) {
+ throw new PayloadGenerationException("Failed to buildPropertyObjectForVnf", e);
+ }
+
+ cdsPropertyObject.addProperty("resolution-key", resolutionKey);
+ cdsPropertyObject.add(action + SEPARATOR + PROPERTIES, vnfObject);
+
+ return Optional.of(buildRequestJsonObject(cdsPropertyObject, action));
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/PayloadGenerationException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/PayloadGenerationException.java
new file mode 100644
index 0000000000..3c148a17a5
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/PayloadGenerationException.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.exception;
+
+public class PayloadGenerationException extends Exception {
+
+ /**
+ * @param message The message to dump
+ */
+ public PayloadGenerationException(final String message) {
+ super(message);
+ }
+
+ /**
+ * @param message The message to dump.
+ * @param cause The throwable cause object.
+ */
+ public PayloadGenerationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
index f558932d33..10844ec652 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
@@ -34,6 +34,7 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
import org.onap.so.client.exception.ExceptionBuilder;
@@ -69,7 +70,7 @@ public class AbstractCDSProcessingBBUtilsTest {
}
@Test
- public void preProcessRequestTest() throws Exception {
+ public void preProcessRequestDETest() throws Exception {
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean);
@@ -80,7 +81,7 @@ public class AbstractCDSProcessingBBUtilsTest {
}
@Test
- public void sendRequestToCDSClientTest() {
+ public void sendRequestToCDSClientDETest() {
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean);
@@ -90,4 +91,26 @@ public class AbstractCDSProcessingBBUtilsTest {
}
+ @Test
+ public void preProcessRequestBBTest() throws Exception {
+
+ BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
+ when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean);
+
+ abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution);
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), anyInt(),
+ any(Exception.class));
+ }
+
+ @Test
+ public void sendRequestToCDSClientBBTest() {
+
+ BuildingBlockExecution execution = mock(BuildingBlockExecution.class);
+ when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean);
+ abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution);
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), anyInt(),
+ any(Exception.class));
+
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java
new file mode 100644
index 0000000000..9c3ce60400
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java
@@ -0,0 +1,205 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonParser;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.serviceinstancebeans.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public abstract class AbstractVnfCDSRequestProviderTest {
+
+ protected static final String GENERIC_VNF_ID = "vnfId_configVnfTest1";
+ protected static final String VF_MODULE_ID = "vf-module-id-1";
+ protected static final String VF_MODULE_NAME = "vf-module-name-1";
+ protected static final String VF_MODULE_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce1";
+ protected static final String GENERIC_VNF_NAME = "vnf-name-1";
+ protected static final String SERVICE_INSTANCE_ID = "serviceInst_configTest";
+ protected static final String SERVICE_MODEL_UUID = "b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4";
+ protected static final String SERVICE_INSTANCE_NAME = "test-service-instance";
+ protected static final String VNF_MODEL_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4";
+ protected static final String GENERAL_BLOCK_EXECUTION_MAP_KEY = "gBBInput";
+ protected static final String VNF_SCOPE = "vnf";
+ protected static final String SERVICE_SCOPE = "service";
+ protected static final String SERVICE_ACTION = "create";
+ protected static final String VF_SCOPE = "vfModule";
+ protected static final String ASSIGN_ACTION = "configAssign";
+ protected static final String DEPLOY_ACTION = "configDeploy";
+ protected static final String MSO_REQUEST_ID = "1234";
+ protected static final String BUILDING_BLOCK = "buildingBlock";
+ protected static final String PUBLIC_NET_ID = "public-net-id";
+ protected static final String CLOUD_REGION = "acl-cloud-region";
+
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+
+ protected BuildingBlockExecution buildingBlockExecution;
+
+ protected ExecuteBuildingBlock executeBuildingBlock;
+
+
+ @Before
+ public void setUp() {
+ buildingBlockExecution = createBuildingBlockExecution();
+ executeBuildingBlock = new ExecuteBuildingBlock();
+ }
+
+ protected BuildingBlockExecution createBuildingBlockExecution() {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(GENERAL_BLOCK_EXECUTION_MAP_KEY, createGeneralBuildingBlock());
+ return new DelegateExecutionImpl(execution);
+ }
+
+ protected GeneralBuildingBlock createGeneralBuildingBlock() {
+ GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(createRequestUserParams());
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId(MSO_REQUEST_ID);
+ generalBuildingBlock.setRequestContext(requestContext);
+ return generalBuildingBlock;
+ }
+
+ protected ServiceInstance createServiceInstance() {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceName(SERVICE_INSTANCE_NAME);
+ serviceInstance.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelUuid(SERVICE_MODEL_UUID);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ return serviceInstance;
+ }
+
+ protected GenericVnf createGenericVnf() {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId(GENERIC_VNF_ID);
+ genericVnf.setVnfName(GENERIC_VNF_NAME);
+ genericVnf.setBlueprintName("test");
+ genericVnf.setBlueprintVersion("1.0.0");
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelCustomizationUuid(VNF_MODEL_CUSTOMIZATION_UUID);
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ return genericVnf;
+ }
+
+ protected VfModule createVfModule() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId(VF_MODULE_ID);
+ vfModule.setVfModuleName(VF_MODULE_NAME);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelCustomizationUUID(VF_MODULE_CUSTOMIZATION_UUID);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ return vfModule;
+ }
+
+ protected List<Map<String, Object>> createRequestUserParams() {
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ Map<String, Object> userParamMap = new HashMap<>();
+ userParamMap.put("service", getUserParams());
+ userParams.add(userParamMap);
+ return userParams;
+ }
+
+ protected Service getUserParams() {
+ Service service = new Service();
+ Resources resources = new Resources();
+ resources.setVnfs(createVnfList());
+ service.setResources(resources);
+ return service;
+ }
+
+ protected List<Vnfs> createVnfList() {
+ List<Map<String, String>> instanceParamsListSearchedVnf = new ArrayList<>();
+ Map<String, String> instanceParam = new HashMap<>();
+ instanceParam.put("public_net_id", PUBLIC_NET_ID);
+ instanceParam.put("acl-cloud-region", CLOUD_REGION);
+ instanceParamsListSearchedVnf.add(instanceParam);
+ Vnfs searchedVnf = createVnf(instanceParamsListSearchedVnf);
+ List<Vnfs> vnfList = new ArrayList<>();
+ vnfList.add(searchedVnf);
+ return vnfList;
+ }
+
+ protected Vnfs createVnf(List<Map<String, String>> instanceParamsList) {
+ Vnfs vnf = new Vnfs();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(VNF_MODEL_CUSTOMIZATION_UUID);
+ vnf.setModelInfo(modelInfo);
+ vnf.setInstanceParams(instanceParamsList);
+
+ // Set instance parameters and modelinfo for vf-module
+ VfModules vfModule = new VfModules();
+ ModelInfo modelInfoForVfModule = new ModelInfo();
+ modelInfoForVfModule.setModelCustomizationId(VF_MODULE_CUSTOMIZATION_UUID);
+ vfModule.setModelInfo(modelInfoForVfModule);
+
+ List<Map<String, String>> instanceParamsListSearchedVfModule = new ArrayList<>();
+ Map<String, String> instanceParams = new HashMap<>();
+ instanceParams.put("public-net-vf-module-id", PUBLIC_NET_ID);
+ instanceParams.put("aci-cloud-region-vf-module", CLOUD_REGION);
+
+ instanceParamsListSearchedVfModule.add(instanceParams);
+ vfModule.setInstanceParams(instanceParamsListSearchedVfModule);
+
+ List<VfModules> vfModules = new ArrayList<>();
+ vfModules.add(vfModule);
+
+ vnf.setVfModules(vfModules);
+
+ return vnf;
+ }
+
+ protected boolean verfiyJsonFromString(String payload) {
+ JsonParser parser = new JsonParser();
+ return parser.parse(payload).isJsonObject();
+ }
+
+ protected void setScopeAndAction(String scope, String action) {
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnScope(scope);
+ buildingBlock.setBpmnAction(action);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ buildingBlockExecution.setVariable(BUILDING_BLOCK, executeBuildingBlock);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java
new file mode 100644
index 0000000000..9baf5dc5bf
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ConfigureInstanceParamsForVfModuleTest.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.client.cds;
+
+import com.google.gson.JsonObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.Resources;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.Mockito.doReturn;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class ConfigureInstanceParamsForVfModuleTest {
+
+ @InjectMocks
+ private ConfigureInstanceParamsForVfModule configureInstanceParamsForVfModule;
+
+ @Mock
+ private ExtractServiceFromUserParameters extractServiceFromUserParameters;
+
+ private static final String TEST_VNF_MODEL_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4";
+ private static final String TEST_VF_MODULE_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce2";
+ private static final String TEST_INSTANCE_PARAM_VALUE_1 = "vf-module-1-value";
+ private static final String TEST_INSTANCE_PARAM_VALUE_2 = "vf-module-2-value";
+ private static final String TEST_INSTANCE_PARAM_KEY_1 = "instance-param-1";
+ private static final String TEST_INSTANCE_PARAM_KEY_2 = "instance-param-2";
+
+ @Test
+ public void testInstanceParamsForVfModule() throws Exception {
+ // given
+ List<Map<String, Object>> userParamsFromRequest = createRequestParameters();
+ JsonObject jsonObject = new JsonObject();
+ doReturn(getUserParams()).when(extractServiceFromUserParameters).getServiceFromRequestUserParams(anyList());
+
+ // when
+ configureInstanceParamsForVfModule.populateInstanceParams(jsonObject, userParamsFromRequest,
+ TEST_VNF_MODEL_CUSTOMIZATION_UUID, TEST_VF_MODULE_CUSTOMIZATION_UUID);
+
+ // verify
+ assertEquals(TEST_INSTANCE_PARAM_VALUE_1, jsonObject.get(TEST_INSTANCE_PARAM_KEY_1).getAsString());
+ assertEquals(TEST_INSTANCE_PARAM_VALUE_2, jsonObject.get(TEST_INSTANCE_PARAM_KEY_2).getAsString());
+ }
+
+ private List<Map<String, Object>> createRequestParameters() {
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ Map<String, Object> userParamMap = new HashMap<>();
+ userParamMap.put("service", getUserParams());
+ userParams.add(userParamMap);
+ return userParams;
+ }
+
+ private Service getUserParams() {
+ Service service = new Service();
+ Resources resources = new Resources();
+ resources.setVnfs(createVnfs());
+ service.setResources(resources);
+ return service;
+ }
+
+ private List<Vnfs> createVnfs() {
+ Vnfs searchedVnf = createVnf();
+ List<Vnfs> vnfList = new ArrayList<>();
+ vnfList.add(searchedVnf);
+ return vnfList;
+ }
+
+ private Vnfs createVnf() {
+ Vnfs vnf = new Vnfs();
+ ModelInfo modelInfoForVnf = new ModelInfo();
+ modelInfoForVnf.setModelCustomizationId(TEST_VNF_MODEL_CUSTOMIZATION_UUID);
+ vnf.setModelInfo(modelInfoForVnf);
+
+ VfModules vfModule = new VfModules();
+
+ ModelInfo modelInfoForVfModule = new ModelInfo();
+ modelInfoForVfModule.setModelCustomizationId(TEST_VF_MODULE_CUSTOMIZATION_UUID);
+
+ vfModule.setModelInfo(modelInfoForVfModule);
+
+ // Set instance parameters.
+ List<Map<String, String>> instanceParamsListSearchedVfModule = new ArrayList<>();
+ Map<String, String> instanceParams = new HashMap<>();
+ instanceParams.put("instance-param-1", TEST_INSTANCE_PARAM_VALUE_1);
+ instanceParams.put("instance-param-2", TEST_INSTANCE_PARAM_VALUE_2);
+
+ instanceParamsListSearchedVfModule.add(instanceParams);
+ vfModule.setInstanceParams(instanceParamsListSearchedVfModule);
+
+ List<VfModules> vfModules = new ArrayList<>();
+ vfModules.add(vfModule);
+
+ vnf.setVfModules(vfModules);
+
+ return vnf;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java
new file mode 100644
index 0000000000..24962a0c14
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/GeneratePayloadForCdsTest.java
@@ -0,0 +1,342 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada.
+ * ================================================================================
+ * 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.client.cds;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.PayloadGenerationException;
+import org.onap.so.serviceinstancebeans.*;
+import java.util.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.ThrowableAssert.catchThrowable;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class GeneratePayloadForCdsTest {
+ private static final String VF_MODULE_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce1";
+ private static final String VNF_MODEL_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4";
+ private static final String GENERAL_BLOCK_EXECUTION_MAP_KEY = "gBBInput";
+ private static final String VNF_SCOPE = "vnf";
+ private static final String SERVICE_SCOPE = "service";
+ private static final String SERVICE_ACTION = "create";
+ private static final String VF_SCOPE = "vfModule";
+ private static final String ASSIGN_ACTION = "configAssign";
+ private static final String DEPLOY_ACTION = "configDeploy";
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String MSO_REQUEST_ID = "1234";
+ private static final String BUILDING_BLOCK = "buildingBlock";
+ private static final String PUBLIC_NET_ID = "public-net-id";
+ private static final String CLOUD_REGION = "acl-cloud-region";
+ private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static final String TEST_PROCESS_KEY = "processKey1";
+ private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static final String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static final String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static final String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static final String TEST_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+ private static final String PNF_CORRELATION_ID = "pnfCorrelationId";
+ private static final String PNF_UUID = "pnfUuid";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ private static final String MODEL_UUID = "modelUuid";
+ private static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
+ private static final String PRC_INSTANCE_NAME = "PRC_instanceName";
+ private static final String PRC_TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+ private static final String SCOPE = "scope";
+ private static final String ACTION = "action";
+ private static final String PROCESS_KEY = "testProcessKey";
+ private static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName";
+ private static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+
+ private BuildingBlockExecution buildingBlockExecution;
+ private ExecuteBuildingBlock executeBuildingBlock;
+
+ @InjectMocks
+ private GeneratePayloadForCds configurePayloadForCds;
+
+ @Mock
+ private VnfCDSRequestProvider vnfCDSRequestProvider;
+
+ @Mock
+ private VfModuleCDSRequestProvider vfModuleCDSRequestProvider;
+
+ @Mock
+ private ServiceCDSRequestProvider serviceCDSRequestProvider;
+
+ @Mock
+ private PnfCDSRequestProvider pnfCDSRequestProvider;
+
+
+ @Before
+ public void setup() {
+ buildingBlockExecution = createBuildingBlockExecution();
+ executeBuildingBlock = new ExecuteBuildingBlock();
+ }
+
+ @Test
+ public void testBuildCdsPropertiesBeanAssignVnf() throws Exception {
+ // given
+ final String assignPayload =
+ "{\"configAssign-request\":{\"resolution-key\":\"vnf-name-1\",\"configAssign-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\",\"vnf-id\":\"vnfId_configVnfTest1\",\"vnf-name\":\"vnf-name-1\",\"vnf-customization-uuid\":\"23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4\",\"acl-cloud-region\":\"acl-cloud-region\",\"public_net_id\":\"public-net-id\"}}}";
+ setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
+ doReturn(Optional.of(assignPayload)).when(vnfCDSRequestProvider).buildRequestPayload(ASSIGN_ACTION);
+
+ // when
+ AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
+
+ // verify
+ assertNotNull(propertyBean);
+ String payload = propertyBean.getRequestObject();
+ assertThat(assignPayload.equals(payload));
+ assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
+ assertThat(propertyBean.getOriginatorId().equals("SO"));
+ assertNotNull(propertyBean.getSubRequestId());
+ assertThat(propertyBean.getActionName().equals(ASSIGN_ACTION));
+ assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
+ }
+
+ @Test
+ public void testBuildCdsPropertiesBeanDeployVnf() throws Exception {
+ // given
+ final String deployPayload =
+ "{\"configDeploy-request\":{\"resolution-key\":\"vnf-name-1\",\"configDeploy-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\",\"vnf-id\":\"vnfId_configVnfTest1\",\"vnf-name\":\"vnf-name-1\",\"vnf-customization-uuid\":\"23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4\",\"acl-cloud-region\":\"acl-cloud-region\",\"public_net_id\":\"public-net-id\"}}}";
+ setScopeAndAction(VNF_SCOPE, DEPLOY_ACTION);
+ doReturn(Optional.of(deployPayload)).when(vnfCDSRequestProvider).buildRequestPayload(DEPLOY_ACTION);
+
+ // when
+ AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
+
+ // verify
+ assertNotNull(propertyBean);
+ String payload = propertyBean.getRequestObject();
+ assertThat(deployPayload.equals(payload));
+ assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
+ assertThat(propertyBean.getOriginatorId().equals("SO"));
+ assertNotNull(propertyBean.getSubRequestId());
+ assertThat(propertyBean.getActionName().equals(DEPLOY_ACTION));
+ assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
+ }
+
+ @Test
+ public void testBuildCdsPropertiesBeanCreateService() throws Exception {
+ // given
+ final String servicePayload =
+ "{\"create-request\":{\"resolution-key\":\"test-service-instance\",\"create-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\"}}}";
+ setScopeAndAction(SERVICE_SCOPE, SERVICE_ACTION);
+ doReturn(Optional.of(servicePayload)).when(serviceCDSRequestProvider).buildRequestPayload(SERVICE_ACTION);
+
+ // when
+ AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
+
+ // verify
+ assertNotNull(propertyBean);
+ String payload = propertyBean.getRequestObject();
+ assertThat(servicePayload.equals(payload));
+ assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
+ assertThat(propertyBean.getOriginatorId().equals("SO"));
+ assertNotNull(propertyBean.getSubRequestId());
+ assertThat(propertyBean.getActionName().equals(SERVICE_ACTION));
+ assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
+ }
+
+ @Test
+ public void testBuildCdsPropertiesBeanConfigDeployVfModule() throws Exception {
+ // given
+ final String deployVfModulePayload =
+ "{\"configDeploy-request\":{\"resolution-key\":\"vf-module-name-1\",\"template-prefix\":\"vf-module-name-1configDeploy\",\"configDeploy-properties\":{\"service-instance-id\":\"serviceInst_configTest\",\"service-model-uuid\":\"b45b5780-e5dd-11e9-81b4-2a2ae2dbcce4\",\"vnf-id\":\"vnfId_configVnfTest1\",\"vnf-name\":\"vnf-name-1\",\"vf-module-id\":\"vf-module-id-1\",\"vf-module-name\":\"vf-module-name-1\",\"vf-module-customization-uuid\":\"23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce1\",\"aci-cloud-region-vf-module\":\"acl-cloud-region\",\"public-net-vf-module-id\":\"public-net-id\"}}}";
+ setScopeAndAction(VF_SCOPE, DEPLOY_ACTION);
+ doReturn(Optional.of(deployVfModulePayload)).when(vfModuleCDSRequestProvider)
+ .buildRequestPayload(DEPLOY_ACTION);
+
+ // when
+ AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
+
+ // verify
+ assertNotNull(propertyBean);
+ String payload = propertyBean.getRequestObject();
+ assertThat(deployVfModulePayload.equals(payload));
+ assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
+ assertThat(propertyBean.getOriginatorId().equals("SO"));
+ assertNotNull(propertyBean.getSubRequestId());
+ assertThat(propertyBean.getActionName().equals(DEPLOY_ACTION));
+ assertThat(propertyBean.getMode().equalsIgnoreCase("sync"));
+ }
+
+ @Test
+ public void testBuildCdsPropertiesBeanDownloadPnf() throws Exception {
+ // given
+ final String downloadPayload =
+ "{\"downloadNeSw-request\":{\"resolution-key\":\"PNFDemo\",\"downloadNeSw-properties\":{\"service-instance-id\":\"test_service_id\",\"service-model-uuid\":\"6bc0b04d-1873-4721-b53d-6615225b2a28\",\"pnf-id\":\"5df8b6de-2083-11e7-93ae-92361f002671\",\"pnf-name\":\"PNFDemo\",\"pnf-customization-uuid\":\"9acb3a83-8a52-412c-9a45-901764938144\",\"target-software-version\":\"demo-sw-ver2.0.0\"}}}";
+ DelegateExecution execution = prepareDelegateExecutionObj(PayloadConstants.PNF_SCOPE, DOWNLOAD_ACTION);
+ doReturn(Optional.of(downloadPayload)).when(pnfCDSRequestProvider).buildRequestPayload(DOWNLOAD_ACTION);
+ doReturn(TEST_PNF_RESOURCE_BLUEPRINT_NAME).when(pnfCDSRequestProvider).getBlueprintName();
+ doReturn(TEST_PNF_RESOURCE_BLUEPRINT_VERSION).when(pnfCDSRequestProvider).getBlueprintVersion();
+
+ // when
+ AbstractCDSPropertiesBean propertyBean = configurePayloadForCds.buildCdsPropertiesBean(execution);
+
+ // verify
+ assertNotNull(propertyBean);
+ String payload = propertyBean.getRequestObject();
+ assertThat(downloadPayload.equals(payload));
+ assertThat(propertyBean.getRequestId().equals(MSO_REQUEST_ID));
+ assertThat(propertyBean.getOriginatorId().equals("SO"));
+ assertNotNull(propertyBean.getSubRequestId());
+ assertThat(propertyBean.getActionName().equals(DOWNLOAD_ACTION));
+ assertThat(propertyBean.getMode().equalsIgnoreCase("async"));
+ assertThat(propertyBean.getBlueprintName().equalsIgnoreCase(TEST_PNF_RESOURCE_BLUEPRINT_NAME));
+ assertThat(propertyBean.getBlueprintVersion().equalsIgnoreCase(TEST_PNF_RESOURCE_BLUEPRINT_VERSION));
+ }
+
+ @Test
+ public void testFailureWhenServiceInstanceIsNotPresent() throws Exception {
+ // given
+ setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
+ doThrow(PayloadGenerationException.class).when(serviceCDSRequestProvider).buildRequestPayload(ASSIGN_ACTION);
+
+ // when
+ final Throwable throwable =
+ catchThrowable(() -> configurePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution));
+
+ // verify
+ assertThat(throwable).isInstanceOf(PayloadGenerationException.class)
+ .hasMessage("Failed to build payload for CDS");
+ }
+
+ private BuildingBlockExecution createBuildingBlockExecution() {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(GENERAL_BLOCK_EXECUTION_MAP_KEY, createGeneralBuildingBlock());
+ return new DelegateExecutionImpl(execution);
+ }
+
+ private GeneralBuildingBlock createGeneralBuildingBlock() {
+ GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(createRequestUserParams());
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId(MSO_REQUEST_ID);
+ generalBuildingBlock.setRequestContext(requestContext);
+ return generalBuildingBlock;
+ }
+
+ private List<Map<String, Object>> createRequestUserParams() {
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ Map<String, Object> userParamMap = new HashMap<>();
+ userParamMap.put("service", getUserParams());
+ userParams.add(userParamMap);
+ return userParams;
+ }
+
+ private Service getUserParams() {
+ Service service = new Service();
+ Resources resources = new Resources();
+ resources.setVnfs(createVnfList());
+ service.setResources(resources);
+ return service;
+ }
+
+ private List<Vnfs> createVnfList() {
+ List<Map<String, String>> instanceParamsListSearchedVnf = new ArrayList<>();
+ Map<String, String> instanceParam = new HashMap<>();
+ instanceParam.put("public_net_id", PUBLIC_NET_ID);
+ instanceParam.put("acl-cloud-region", CLOUD_REGION);
+ instanceParamsListSearchedVnf.add(instanceParam);
+ Vnfs searchedVnf = createVnf(instanceParamsListSearchedVnf);
+ List<Vnfs> vnfList = new ArrayList<>();
+ vnfList.add(searchedVnf);
+ return vnfList;
+ }
+
+ private Vnfs createVnf(List<Map<String, String>> instanceParamsList) {
+ Vnfs vnf = new Vnfs();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(VNF_MODEL_CUSTOMIZATION_UUID);
+ vnf.setModelInfo(modelInfo);
+ vnf.setInstanceParams(instanceParamsList);
+
+ // Set instance parameters and modelinfo for vf-module
+ VfModules vfModule = new VfModules();
+ ModelInfo modelInfoForVfModule = new ModelInfo();
+ modelInfoForVfModule.setModelCustomizationId(VF_MODULE_CUSTOMIZATION_UUID);
+ vfModule.setModelInfo(modelInfoForVfModule);
+
+ List<Map<String, String>> instanceParamsListSearchedVfModule = new ArrayList<>();
+ Map<String, String> instanceParams = new HashMap<>();
+ instanceParams.put("public-net-vf-module-id", PUBLIC_NET_ID);
+ instanceParams.put("aci-cloud-region-vf-module", CLOUD_REGION);
+
+ instanceParamsListSearchedVfModule.add(instanceParams);
+ vfModule.setInstanceParams(instanceParamsListSearchedVfModule);
+
+ List<VfModules> vfModules = new ArrayList<>();
+ vfModules.add(vfModule);
+
+ vnf.setVfModules(vfModules);
+
+ return vnf;
+ }
+
+ private void setScopeAndAction(String scope, String action) {
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnScope(scope);
+ buildingBlock.setBpmnAction(action);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ buildingBlockExecution.setVariable(BUILDING_BLOCK, executeBuildingBlock);
+ }
+
+ private DelegateExecution prepareDelegateExecutionObj(String scope, String action) {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_TARGET_SOFTWARE_VERSION, TEST_SOFTWARE_VERSION);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ execution.setVariable(SCOPE, scope);
+ execution.setVariable(ACTION, action);
+ execution.setVariable("mode", "async");
+ return execution;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java
new file mode 100644
index 0000000000..e5cbc9a369
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/PnfCDSRequestProviderTest.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.JsonParser;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.junit.MockitoJUnitRunner;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class PnfCDSRequestProviderTest {
+
+ @InjectMocks
+ private PnfCDSRequestProvider pnfCDSRequestProvider;
+
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String ACTIVATE_ACTION = "activateNeSw";
+ private static final String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
+ private static final String TEST_SERVICE_INSTANCE_ID = "test_service_id";
+ private static final String TEST_PROCESS_KEY = "processKey1";
+ private static final String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
+ private static final String TEST_PNF_CORRELATION_ID = "PNFDemo";
+ private static final String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
+ private static final String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static final String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static final String TEST_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+ private static final String PNF_CORRELATION_ID = "pnfCorrelationId";
+ private static final String PNF_UUID = "pnfUuid";
+ private static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
+ private static final String MSO_REQUEST_ID = "msoRequestId";
+ private static final String MODEL_UUID = "modelUuid";
+ private static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid";
+ private static final String PRC_INSTANCE_NAME = "PRC_instanceName";
+ private static final String PRC_TARGET_SOFTWARE_VERSION = "targetSoftwareVersion";
+ private static final String SCOPE = "scope";
+ private static final String ACTION = "action";
+ private static final String PROCESS_KEY = "testProcessKey";
+ private static final String PRC_BLUEPRINT_NAME = "PRC_blueprintName";
+ private static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
+ private static final String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
+
+ @Test
+ public void testBuildRequestPayloadDownloadActionPnf() {
+ try {
+ runTest(DOWNLOAD_ACTION);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testBuildRequestPayloadActivateActionPnf() {
+ try {
+ runTest(ACTIVATE_ACTION);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ private void runTest(String action) throws Exception {
+ // given
+ DelegateExecution execution = prepareDelegateExecutionObj(PayloadConstants.PNF_SCOPE, action);
+
+ // when
+ pnfCDSRequestProvider.setExecutionObject(execution);
+ String payload = pnfCDSRequestProvider.buildRequestPayload(action).get();
+ System.out.println(payload);
+
+ // verify
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode payloadJson = mapper.readTree(payload);
+ JsonNode requestNode = payloadJson.findValue(action + "-request");
+ JsonNode propertiesNode = payloadJson.findValue(action + "-properties");
+
+ assertNotNull(payload);
+ assertTrue(verfiyJsonFromString(payload));
+ assertThat(requestNode.get("resolution-key").asText()).isEqualTo(TEST_PNF_CORRELATION_ID);
+ assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(TEST_SERVICE_INSTANCE_ID);
+ assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(TEST_MODEL_UUID);
+ assertThat(propertiesNode.get("pnf-id").asText()).isEqualTo(TEST_PNF_UUID);
+ assertThat(propertiesNode.get("pnf-customization-uuid").asText())
+ .isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ assertThat(propertiesNode.get("target-software-version").asText()).isEqualTo(TEST_SOFTWARE_VERSION);
+ assertThat(pnfCDSRequestProvider.getBlueprintName().equals(TEST_PNF_RESOURCE_BLUEPRINT_NAME));
+ assertThat(pnfCDSRequestProvider.getBlueprintVersion().equals(TEST_PNF_RESOURCE_BLUEPRINT_VERSION));
+ }
+
+ private DelegateExecution prepareDelegateExecutionObj(String scope, String action) {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(PROCESS_KEY, TEST_PROCESS_KEY);
+ execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
+ execution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
+ execution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
+ execution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
+ execution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ execution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ execution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ execution.setVariable(PRC_TARGET_SOFTWARE_VERSION, TEST_SOFTWARE_VERSION);
+ execution.setVariable(SCOPE, scope);
+ execution.setVariable(ACTION, action);
+ execution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ execution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ return execution;
+ }
+
+ private boolean verfiyJsonFromString(String payload) {
+ JsonParser parser = new JsonParser();
+ return parser.parse(payload).isJsonObject();
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java
new file mode 100644
index 0000000000..70ce3a1eed
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/ServiceCDSRequestProviderTest.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+public class ServiceCDSRequestProviderTest extends AbstractVnfCDSRequestProviderTest {
+
+ @InjectMocks
+ private ServiceCDSRequestProvider serviceCDSRequestProvider;
+
+ @Test
+ public void testRequestPayloadForCreateService() throws Exception {
+ // given
+ setScopeAndAction(SERVICE_SCOPE, SERVICE_ACTION);
+ ServiceInstance instance = createServiceInstance();
+ doReturn(instance).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.SERVICE_INSTANCE_ID);
+
+ // when
+ serviceCDSRequestProvider.setExecutionObject(buildingBlockExecution);
+ String payload = serviceCDSRequestProvider.buildRequestPayload(SERVICE_ACTION).get();
+
+ // verify
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode payloadJson = mapper.readTree(payload);
+ JsonNode requestNode = payloadJson.findValue("create-request");
+ JsonNode propertiesNode = payloadJson.findValue("create-properties");
+
+ assertNotNull(payload);
+ assertTrue(verfiyJsonFromString(payload));
+ assertThat(requestNode.get("resolution-key").asText()).isEqualTo(SERVICE_INSTANCE_NAME);
+ assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
+ assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java
new file mode 100644
index 0000000000..2ca09d9ab3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+public class VfModuleCDSRequestProviderTest extends AbstractVnfCDSRequestProviderTest {
+
+ @InjectMocks
+ private VfModuleCDSRequestProvider vfModuleCDSRequestProvider;
+
+ @Mock
+ protected ConfigureInstanceParamsForVfModule configureInstanceParamsForVfModule;
+
+ @Test
+ public void testRequestPayloadForConfigDeployVfModule() throws Exception {
+ // given
+ setScopeAndAction(VF_SCOPE, DEPLOY_ACTION);
+ ServiceInstance serviceInstance = createServiceInstance();
+
+ doReturn(serviceInstance).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.SERVICE_INSTANCE_ID);
+ doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.GENERIC_VNF_ID);
+ doReturn(createVfModule()).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.VF_MODULE_ID);
+ doNothing().when(configureInstanceParamsForVfModule).populateInstanceParams(any(), any(), anyString(),
+ anyString());
+
+ // when
+ vfModuleCDSRequestProvider.setExecutionObject(buildingBlockExecution);
+ String payload = vfModuleCDSRequestProvider.buildRequestPayload(DEPLOY_ACTION).get();
+
+ // verify
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode payloadJson = mapper.readTree(payload);
+ JsonNode requestNode = payloadJson.findValue("configDeploy-request");
+ JsonNode propertiesNode = payloadJson.findValue("configDeploy-properties");
+
+ assertNotNull(payload);
+ assertTrue(verfiyJsonFromString(payload));
+ assertThat(requestNode.get("resolution-key").asText()).isEqualTo(VF_MODULE_NAME);
+ assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
+ assertThat(propertiesNode.get("vf-module-id").asText()).isEqualTo(VF_MODULE_ID);
+ assertThat(propertiesNode.get("vf-module-name").asText()).isEqualTo(VF_MODULE_NAME);
+ assertThat(propertiesNode.get("vf-module-customization-uuid").asText()).isEqualTo(VF_MODULE_CUSTOMIZATION_UUID);
+ assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
+ assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VnfCDSRequestProviderTest.java
new file mode 100644
index 0000000000..7aafd900d4
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VnfCDSRequestProviderTest.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.client.cds;
+
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
+public class VnfCDSRequestProviderTest extends AbstractVnfCDSRequestProviderTest {
+
+ @InjectMocks
+ private VnfCDSRequestProvider vnfCDSRequestProvider;
+
+ @Mock
+ protected ConfigureInstanceParamsForVnf configureInstanceParamsForVnf;
+
+ @Test
+ public void testBuildRequestPayloadAssignActionVnf() throws Exception {
+ // given
+ setScopeAndAction(VNF_SCOPE, ASSIGN_ACTION);
+ ServiceInstance instance = createServiceInstance();
+
+ doReturn(instance).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.SERVICE_INSTANCE_ID);
+ doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.GENERIC_VNF_ID);
+ doNothing().when(configureInstanceParamsForVnf).populateInstanceParams(any(), any(), anyString());
+
+ // when
+ vnfCDSRequestProvider.setExecutionObject(buildingBlockExecution);
+ String payload = vnfCDSRequestProvider.buildRequestPayload(ASSIGN_ACTION).get();
+
+ // verify
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode payloadJson = mapper.readTree(payload);
+ JsonNode requestNode = payloadJson.findValue("configAssign-request");
+ JsonNode propertiesNode = payloadJson.findValue("configAssign-properties");
+
+ assertNotNull(payload);
+ assertTrue(verfiyJsonFromString(payload));
+ assertThat(requestNode.get("resolution-key").asText()).isEqualTo(GENERIC_VNF_NAME);
+ assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
+ assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
+ assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
+ assertThat(propertiesNode.get("vnf-customization-uuid").asText()).isEqualTo(VNF_MODEL_CUSTOMIZATION_UUID);
+ }
+
+ @Test
+ public void testBuildRequestPayloadDeployActionVnf() throws Exception {
+ // given
+ setScopeAndAction(VNF_SCOPE, DEPLOY_ACTION);
+ ServiceInstance instance = createServiceInstance();
+
+ doReturn(instance).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.SERVICE_INSTANCE_ID);
+ doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution,
+ ResourceKey.GENERIC_VNF_ID);
+ doNothing().when(configureInstanceParamsForVnf).populateInstanceParams(any(), any(), any());
+
+ // when
+ vnfCDSRequestProvider.setExecutionObject(buildingBlockExecution);
+ String payload = vnfCDSRequestProvider.buildRequestPayload(DEPLOY_ACTION).get();
+
+ // verify
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode payloadJson = mapper.readTree(payload);
+ JsonNode requestNode = payloadJson.findValue("configDeploy-request");
+ JsonNode propertiesNode = payloadJson.findValue("configDeploy-properties");
+
+ assertNotNull(payload);
+ assertTrue(verfiyJsonFromString(payload));
+ assertThat(requestNode.get("resolution-key").asText()).isEqualTo(GENERIC_VNF_NAME);
+ assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID);
+ assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID);
+ assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID);
+ assertThat(propertiesNode.get("vnf-customization-uuid").asText()).isEqualTo(VNF_MODEL_CUSTOMIZATION_UUID);
+ }
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn
new file mode 100644
index 0000000000..32d3bce469
--- /dev/null
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1ahlzqg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0">
+ <bpmn:process id="ControllerExecution" name="ControllerExecutionBB" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1">
+ <bpmn:outgoing>SequenceFlow_0gmfit3</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0gmfit3" sourceRef="StartEvent_1" targetRef="ServiceTask_0inxg9l" />
+ <bpmn:endEvent id="EndEvent_0lgvk82">
+ <bpmn:incoming>SequenceFlow_1mkhog2</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0no1qag</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_1mkhog2" sourceRef="Task_1hs1mn0" targetRef="EndEvent_0lgvk82" />
+ <bpmn:callActivity id="CallActivity_1gfzi2g" name="Abstract CDS&#10;(CDS Call)&#10;" calledElement="AbstractCDSProcessingBB">
+ <bpmn:extensionElements>
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:out source="CDSStatus" target="CDSStatus" />
+ <camunda:in source="executionObject" target="executionObject" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>SequenceFlow_05qembo</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0cvsnuu</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:serviceTask id="Task_1hs1mn0" name="Update AAI" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)),InjectExecution.execute(execution, execution.getVariable(&#34;scope&#34;)),InjectExecution.execute(execution, execution.getVariable(&#34;action&#34;)))}">
+ <bpmn:incoming>SequenceFlow_07tqu82</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1mkhog2</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_05qembo" sourceRef="Task_0bhf6tp" targetRef="CallActivity_1gfzi2g" />
+ <bpmn:serviceTask id="Task_0bhf6tp" name="PreProcess Abstract CDS Processing" camunda:expression="${GenericCDSProcessing.buildPayloadBasedOnScopeAndAction(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0vzx2yr</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_05qembo</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:exclusiveGateway id="ExclusiveGateway_13q340y" default="SequenceFlow_15gxql1">
+ <bpmn:incoming>SequenceFlow_0cvsnuu</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_07tqu82</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_15gxql1</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="SequenceFlow_0cvsnuu" sourceRef="CallActivity_1gfzi2g" targetRef="ExclusiveGateway_13q340y" />
+ <bpmn:sequenceFlow id="SequenceFlow_07tqu82" name="success" sourceRef="ExclusiveGateway_13q340y" targetRef="Task_1hs1mn0">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("CDSStatus").equals("Success")}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:endEvent id="EndEvent_0mnaj50">
+ <bpmn:incoming>SequenceFlow_15gxql1</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_1s1hqgm" errorRef="Error_0aovtfv" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_15gxql1" sourceRef="ExclusiveGateway_13q340y" targetRef="EndEvent_0mnaj50" />
+ <bpmn:serviceTask id="ServiceTask_0inxg9l" name="Set Actor, Scope and Action Params" camunda:expression="${ControllerExecution.setControllerActorScopeAction(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0gmfit3</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_05j6hg6</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_1lspfyy</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_05j6hg6" sourceRef="ServiceTask_0inxg9l" targetRef="ExclusiveGateway_0plxwkg" />
+ <bpmn:exclusiveGateway id="ExclusiveGateway_0plxwkg" default="SequenceFlow_1t7hs4k">
+ <bpmn:incoming>SequenceFlow_1lspfyy</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_05j6hg6</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1t7hs4k</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_0vzx2yr</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="SequenceFlow_1lspfyy" sourceRef="ServiceTask_0inxg9l" targetRef="ExclusiveGateway_0plxwkg" />
+ <bpmn:callActivity id="BBToExecute" name="BB to Execute&#10;" calledElement="${bbName}">
+ <bpmn:extensionElements>
+ <camunda:out source="WorkflowException" target="WorkflowException" />
+ <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" />
+ <camunda:in source="executionObject" target="executionObject" />
+ <camunda:in source="mso-request-id" target="mso-request-id" />
+ <camunda:in source="isRollback" target="isRollback" />
+ <camunda:out source="StatusMessage" target="StatusMessage" />
+ </bpmn:extensionElements>
+ <bpmn:incoming>SequenceFlow_0fv03vt</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0no1qag</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_0op5irz</bpmn:outgoing>
+ </bpmn:callActivity>
+ <bpmn:sequenceFlow id="SequenceFlow_1t7hs4k" sourceRef="ExclusiveGateway_0plxwkg" targetRef="Task_1rc2j9" />
+ <bpmn:sequenceFlow id="SequenceFlow_0no1qag" sourceRef="BBToExecute" targetRef="EndEvent_0lgvk82" />
+ <bpmn:sequenceFlow id="SequenceFlow_0fv03vt" sourceRef="Task_1rc2j9" targetRef="BBToExecute" />
+ <bpmn:serviceTask id="Task_1rc2j9" name="select BB " camunda:expression="${ControllerExecution.selectBB(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_1t7hs4k</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0fv03vt</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:endEvent id="EndEvent_1lxwuh2">
+ <bpmn:incoming>SequenceFlow_0op5irz</bpmn:incoming>
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_0z001cu" errorRef="Error_0aovtfv" />
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="SequenceFlow_0op5irz" sourceRef="BBToExecute" targetRef="EndEvent_1lxwuh2" />
+ <bpmn:sequenceFlow id="SequenceFlow_0vzx2yr" name="Actor= CDS" sourceRef="ExclusiveGateway_0plxwkg" targetRef="Task_0bhf6tp">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("controller_actor") == "CDS"}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ </bpmn:process>
+ <bpmn:error id="Error_0aovtfv" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ControllerExecution">
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="160" y="323" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-17" y="279" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0gmfit3_di" bpmnElement="SequenceFlow_0gmfit3">
+ <di:waypoint x="196" y="341" />
+ <di:waypoint x="259" y="341" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="32.5" y="236" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="EndEvent_0lgvk82_di" bpmnElement="EndEvent_0lgvk82">
+ <dc:Bounds x="1129" y="323" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1025" y="251" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1mkhog2_di" bpmnElement="SequenceFlow_1mkhog2">
+ <di:waypoint x="1079" y="462" />
+ <di:waypoint x="1147" y="462" />
+ <di:waypoint x="1147" y="359" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="918" y="357" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="CallActivity_1gfzi2g_di" bpmnElement="CallActivity_1gfzi2g">
+ <dc:Bounds x="725" y="422" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0404s6a_di" bpmnElement="Task_1hs1mn0">
+ <dc:Bounds x="979" y="422" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_05qembo_di" bpmnElement="SequenceFlow_05qembo">
+ <di:waypoint x="672" y="462" />
+ <di:waypoint x="725" y="462" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="503.5" y="357" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_01mv1si_di" bpmnElement="Task_0bhf6tp">
+ <dc:Bounds x="572" y="422" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ExclusiveGateway_13q340y_di" bpmnElement="ExclusiveGateway_13q340y" isMarkerVisible="true">
+ <dc:Bounds x="868" y="437" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="698" y="327" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0cvsnuu_di" bpmnElement="SequenceFlow_0cvsnuu">
+ <di:waypoint x="825" y="462" />
+ <di:waypoint x="868" y="462" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="651.5" y="357" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_07tqu82_di" bpmnElement="SequenceFlow_07tqu82">
+ <di:waypoint x="918" y="462" />
+ <di:waypoint x="979" y="462" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="856" y="409" width="41" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="EndEvent_0mnaj50_di" bpmnElement="EndEvent_0mnaj50">
+ <dc:Bounds x="875" y="565" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="698" y="531" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_15gxql1_di" bpmnElement="SequenceFlow_15gxql1">
+ <di:waypoint x="893" y="487" />
+ <di:waypoint x="893" y="565" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="713" y="436" width="90" height="20" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0inxg9l_di" bpmnElement="ServiceTask_0inxg9l">
+ <dc:Bounds x="259" y="301" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_05j6hg6_di" bpmnElement="SequenceFlow_05j6hg6">
+ <di:waypoint x="359" y="341" />
+ <di:waypoint x="399" y="341" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="184" y="240" width="90" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ExclusiveGateway_0plxwkg_di" bpmnElement="ExclusiveGateway_0plxwkg" isMarkerVisible="true">
+ <dc:Bounds x="399" y="316" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="309" y="255" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1lspfyy_di" bpmnElement="SequenceFlow_1lspfyy">
+ <di:waypoint x="359" y="341" />
+ <di:waypoint x="399" y="341" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="229" y="240" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="CallActivity_01dem38_di" bpmnElement="BBToExecute">
+ <dc:Bounds x="824" y="168" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1t7hs4k_di" bpmnElement="SequenceFlow_1t7hs4k">
+ <di:waypoint x="424" y="316" />
+ <di:waypoint x="424" y="208" />
+ <di:waypoint x="572" y="208" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="271" y="89" width="83" height="36" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0no1qag_di" bpmnElement="SequenceFlow_0no1qag">
+ <di:waypoint x="924" y="208" />
+ <di:waypoint x="1147" y="208" />
+ <di:waypoint x="1147" y="323" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="840.5" y="107" width="90" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0fv03vt_di" bpmnElement="SequenceFlow_0fv03vt">
+ <di:waypoint x="672" y="208" />
+ <di:waypoint x="824" y="208" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="598" y="107" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0qd9p4w_di" bpmnElement="Task_1rc2j9">
+ <dc:Bounds x="572" y="168" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="EndEvent_1lxwuh2_di" bpmnElement="EndEvent_1lxwuh2">
+ <dc:Bounds x="856" y="84" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="679" y="50" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0op5irz_di" bpmnElement="SequenceFlow_0op5irz">
+ <di:waypoint x="874" y="168" />
+ <di:waypoint x="874" y="120" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="739" y="58" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0vzx2yr_di" bpmnElement="SequenceFlow_0vzx2yr">
+ <di:waypoint x="424" y="366" />
+ <di:waypoint x="424" y="462" />
+ <di:waypoint x="572" y="462" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="455" y="436" width="60" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions> \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
index fb95ae3993..11707c4149 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIDeleteServiceInstance.java
@@ -7,9 +7,9 @@
* 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.
@@ -27,9 +27,15 @@ import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class AAIDeleteServiceInstance implements JavaDelegate {
+ private static final Logger logger = LoggerFactory.getLogger(AAIDeleteServiceInstance.class);
+ private static final String ERROR_MESSAGE =
+ "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI.";
+
ExceptionUtil exceptionUtil = new ExceptionUtil();
public void execute(DelegateExecution execution) throws Exception {
@@ -41,8 +47,8 @@ public class AAIDeleteServiceInstance implements JavaDelegate {
aaiRC.delete(serviceInstanceURI);
execution.setVariable("GENDS_SuccessIndicator", true);
} catch (Exception ex) {
- String msg = "Exception in Delete Serivce Instance. Service Instance could not be deleted in AAI."
- + ex.getMessage();
+ logger.debug(ERROR_MESSAGE, ex);
+ String msg = ERROR_MESSAGE + ex.getMessage();
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java
index 2d69351744..f7b0c662db 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/aai/groovyflows/AAIServiceInstance.java
@@ -7,9 +7,9 @@
* 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.
@@ -30,17 +30,70 @@ public class AAIServiceInstance {
String environmentContext;
String workloadContext;
- public AAIServiceInstance(String serviceInstanceName, String serviceType, String serviceRole,
- String orchestrationStatus, String modelInvariantUuid, String modelVersionId, String environmentContext,
- String workloadContext) {
- this.serviceInstanceName = serviceInstanceName;
- this.serviceType = serviceType;
- this.serviceRole = serviceRole;
- this.orchestrationStatus = orchestrationStatus;
- this.modelInvariantUuid = modelInvariantUuid;
- this.modelVersionId = modelVersionId;
- this.environmentContext = environmentContext;
- this.workloadContext = workloadContext;
+ public class AAIServiceInstanceBuilder {
+ private String serviceInstanceName;
+ private String serviceType;
+ private String serviceRole;
+ private String orchestrationStatus;
+ private String modelInvariantUuid;
+ private String modelVersionId;
+ private String environmentContext;
+ private String workloadContext;
+
+ public AAIServiceInstanceBuilder setServiceInstanceName(String serviceInstanceName) {
+ this.serviceInstanceName = serviceInstanceName;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setServiceRole(String serviceRole) {
+ this.serviceRole = serviceRole;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setOrchestrationStatus(String orchestrationStatus) {
+ this.orchestrationStatus = orchestrationStatus;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setModelInvariantUuid(String modelInvariantUuid) {
+ this.modelInvariantUuid = modelInvariantUuid;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setEnvironmentContext(String environmentContext) {
+ this.environmentContext = environmentContext;
+ return this;
+ }
+
+ public AAIServiceInstanceBuilder setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ return this;
+ }
+
+ public AAIServiceInstance createAAIServiceInstance() {
+ return new AAIServiceInstance(this);
+ }
+ }
+
+ public AAIServiceInstance(AAIServiceInstanceBuilder aaiServiceInstanceBuilder) {
+ this.serviceInstanceName = aaiServiceInstanceBuilder.serviceInstanceName;
+ this.serviceType = aaiServiceInstanceBuilder.serviceType;
+ this.serviceRole = aaiServiceInstanceBuilder.serviceRole;
+ this.orchestrationStatus = aaiServiceInstanceBuilder.orchestrationStatus;
+ this.modelInvariantUuid = aaiServiceInstanceBuilder.modelInvariantUuid;
+ this.modelVersionId = aaiServiceInstanceBuilder.modelVersionId;
+ this.environmentContext = aaiServiceInstanceBuilder.environmentContext;
+ this.workloadContext = aaiServiceInstanceBuilder.workloadContext;
}
public String getServiceInstanceName() {
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
index 6d5b2a2f28..693dd922e2 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ConfigurePnfResource.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_13i2vsn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_13i2vsn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.5">
<bpmn:process id="ConfigurePnfResource" name="ConfigurePnfResource" isExecutable="true">
<bpmn:startEvent id="ConfigurePnfResource_StartEvent">
<bpmn:outgoing>SequenceFlow_069mxkg</bpmn:outgoing>
@@ -57,6 +57,7 @@
<camunda:inputOutput>
<camunda:inputParameter name="action">config-assign</camunda:inputParameter>
<camunda:inputParameter name="scope">pnf</camunda:inputParameter>
+ <camunda:inputParameter name="mode">sync</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0j3pm2g</bpmn:incoming>
@@ -68,6 +69,7 @@
<camunda:inputOutput>
<camunda:inputParameter name="action">config-deploy</camunda:inputParameter>
<camunda:inputParameter name="scope">pnf</camunda:inputParameter>
+ <camunda:inputParameter name="mode">async</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1owbpsy</bpmn:incoming>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
index 4d5494d18c..8a6c4c2796 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java
@@ -5,13 +5,14 @@
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
+ * Modifications Copyright (c) 2019 Bell Canada.
* ================================================================================
* 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.
@@ -22,39 +23,23 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
-import java.util.List;
-import java.util.Map;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.*;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
-import org.onap.so.client.orchestration.AAICollectionResources;
-import org.onap.so.client.orchestration.AAIConfigurationResources;
-import org.onap.so.client.orchestration.AAINetworkResources;
-import org.onap.so.client.orchestration.AAIPnfResources;
-import org.onap.so.client.orchestration.AAIServiceInstanceResources;
-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.*;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.util.List;
+import java.util.Map;
@Component
public class AAIUpdateTasks {
@@ -340,7 +325,6 @@ public class AAIUpdateTasks {
* BPMN access method to update status of VfModule to Created in AAI
*
* @param execution
- *
*/
public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) {
try {
@@ -357,7 +341,6 @@ public class AAIUpdateTasks {
* BPMN access method to update aaiDeactivateVfModuleRollback to true for deactivating the VfModule
*
* @param execution
- * @throws buildAndThrowWorkflowException
*/
public void updateOrchestrationStatusDeactivateVfModule(BuildingBlockExecution execution) {
execution.setVariable("aaiDeactivateVfModuleRollback", false);
@@ -794,7 +777,6 @@ public class AAIUpdateTasks {
logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigDeployConfigureVnf", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
-
}
/**
@@ -806,11 +788,55 @@ public class AAIUpdateTasks {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED);
-
} catch (Exception ex) {
logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusConfigDeployConfiguredVnf", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
+ }
+ /**
+ * BPMN access method to update status of VNF/VF-Module based on SO scope and action.
+ *
+ * @param execution - BuildingBlockExecution
+ * @param scope - SO scope (vnf/vfModule)
+ * @param action - action (configAssign/configDeploy/configUndeploy etc..)
+ */
+ public void updateOrchestrationStatusForCds(BuildingBlockExecution execution, String scope, String action) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ OrchestrationStatus status = getOrchestrationStatus(action);
+ switch (scope) {
+ case "vnf":
+ aaiVnfResources.updateOrchestrationStatusVnf(vnf, status);
+ break;
+ case "vfModule":
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, status);
+ break;
+ default:
+ throw new IllegalArgumentException(
+ "Invalid scope to update orchestration status for CDS : " + action);
+ }
+ } catch (Exception ex) {
+ logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusForCds", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ private OrchestrationStatus getOrchestrationStatus(String action) {
+ /**
+ * At this state, OrcherstationStatus enum associated with configAssign and configDeploy. I am not sure which is
+ * the correct approach. 1. Are we going to map each specific action to OrchestrationStauts ? 2. We will have
+ * only one generic status for all actions ?
+ */
+
+ switch (action) {
+ case "configAssign":
+ return OrchestrationStatus.ASSIGNED;
+ case "configDeploy":
+ return OrchestrationStatus.CONFIGURED;
+ default:
+ throw new IllegalArgumentException("Invalid action to set Orchestration status: " + action);
+ }
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
index 4285e9aa84..663b097b78 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java
@@ -121,7 +121,7 @@ public class VnfAdapterCreateTasks {
try {
volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
} catch (BBObjectNotFoundException bbException) {
- logger.error("Exception occurred if bb objrct not found in VnfAdapterCreateTasks createVfModule ",
+ logger.error("Exception occurred if bb object not found in VnfAdapterCreateTasks createVfModule ",
bbException);
}
CloudRegion cloudRegion = gBBInput.getCloudRegion();
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 79ccd9216f..00d0fdc01d 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
@@ -6,12 +6,14 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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.
@@ -29,7 +31,6 @@ import java.util.Optional;
import org.onap.so.logger.LoggingAnchor;
import org.json.JSONArray;
import org.json.JSONObject;
-import org.onap.aai.domain.yang.Vserver;
import org.onap.appc.client.lcm.model.Action;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.core.json.JsonUtils;
@@ -143,7 +144,7 @@ public class AppcRunTasks {
ControllerSelectionReference controllerSelectionReference = catalogDbClient
.getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString());
- String controllerType = null;
+ String controllerType;
if (controllerSelectionReference != null) {
controllerType = controllerSelectionReference.getControllerName();
} else {
@@ -191,13 +192,13 @@ public class AppcRunTasks {
logger.error("Error Message: {}", appcMessage);
logger.error("ERROR CODE: {}", appcCode);
logger.trace("End of runAppCommand ");
- if (appcCode != null && !appcCode.equals("0")) {
+ if (appcCode != null && !"0".equals(appcCode)) {
exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
}
}
protected void mapRollbackVariables(BuildingBlockExecution execution, Action action, String appcCode) {
- if (appcCode != null && appcCode.equals("0") && action != null) {
+ if ("0".equals(appcCode) && action != null) {
if (action.equals(Action.Lock)) {
execution.setVariable(ROLLBACK_VNF_LOCK, true);
} else if (action.equals(Action.Unlock)) {
@@ -216,7 +217,7 @@ public class AppcRunTasks {
private HashMap<String, String> buildPayloadInfo(String vnfName, String aicIdentity, String vnfHostIpAddress,
String vmIdList, String vserverIdList, String identityUrl, String vfModuleId) {
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ HashMap<String, String> payloadInfo = new HashMap<>();
payloadInfo.put("vnfName", vnfName);
payloadInfo.put("aicIdentity", aicIdentity);
payloadInfo.put("vnfHostIpAddress", vnfHostIpAddress);
@@ -242,44 +243,39 @@ public class AppcRunTasks {
return payload;
}
- protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception {
+ protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws RuntimeException {
AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf);
- if (aaiRW != null && aaiRW.getRelationships() != null && aaiRW.getRelationships().isPresent()) {
- Relationships relationships = aaiRW.getRelationships().get();
- if (relationships != null) {
- List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER);
- JSONArray vserverIds = new JSONArray();
- JSONArray vserverSelfLinks = new JSONArray();
- if (vserverUris != null) {
- for (AAIResourceUri j : vserverUris) {
- if (j != null) {
- if (j.getURIKeys() != null) {
- String vserverId = j.getURIKeys().get("vserver-id");
- vserverIds.put(vserverId);
- }
- Optional<Vserver> oVserver = aaiVnfResources.getVserver(j);
- if (oVserver.isPresent()) {
- Vserver vserver = oVserver.get();
- if (vserver != null) {
- String vserverSelfLink = vserver.getVserverSelflink();
- vserverSelfLinks.put(vserverSelfLink);
- }
- }
- }
+ if (aaiRW == null || aaiRW.getRelationships() == null || !aaiRW.getRelationships().isPresent()) {
+ return;
+ }
+ Relationships relationships = aaiRW.getRelationships().get();
+ List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER);
+ JSONArray vserverIds = new JSONArray();
+ JSONArray vserverSelfLinks = new JSONArray();
+ if (vserverUris != null) {
+ for (AAIResourceUri j : vserverUris) {
+ if (j != null) {
+ if (j.getURIKeys() != null) {
+ String vserverId = j.getURIKeys().get("vserver-id");
+ vserverIds.put(vserverId);
}
+ aaiVnfResources.getVserver(j).ifPresent((vserver) -> {
+ String vserverSelfLink = vserver.getVserverSelflink();
+ vserverSelfLinks.put(vserverSelfLink);
+ });
}
-
- JSONObject vmidsArray = new JSONObject();
- JSONObject vserveridsArray = new JSONObject();
- vmidsArray.put("vmIds", vserverSelfLinks.toString());
- vserveridsArray.put("vserverIds", vserverIds.toString());
- logger.debug("vmidsArray is: {}", vmidsArray.toString());
- logger.debug("vserveridsArray is: {}", vserveridsArray.toString());
-
- execution.setVariable("vmIdList", vmidsArray.toString());
- execution.setVariable("vserverIdList", vserveridsArray.toString());
}
}
+
+ JSONObject vmidsArray = new JSONObject();
+ JSONObject vserveridsArray = new JSONObject();
+ vmidsArray.put("vmIds", vserverSelfLinks.toString());
+ vserveridsArray.put("vserverIds", vserverIds.toString());
+ logger.debug("vmidsArray is: {}", vmidsArray.toString());
+ logger.debug("vserveridsArray is: {}", vserveridsArray.toString());
+
+ execution.setVariable("vmIdList", vmidsArray.toString());
+ execution.setVariable("vserverIdList", vserveridsArray.toString());
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java
index 6b0cbc0396..ffd49e6b84 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java
@@ -24,6 +24,7 @@ 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.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.PayloadConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -31,14 +32,23 @@ import org.springframework.stereotype.Component;
* This implementation of {@ref ControllerRunnable} is used for Self service, i.e, blueprint based Controller.
*/
@Component
-public class CdsControllerDE extends AbstractCDSProcessingBBUtils implements ControllerRunnable<DelegateExecution> {
+public class PnfConfigCdsControllerDE implements ControllerRunnable<DelegateExecution> {
+
+ private static final String ASSIGN_ACTION = "config-assign";
+ private static final String DEPLOY_ACTION = "config-deploy";
@Autowired(required = false)
private List<ControllerPreparable<DelegateExecution>> prepareList;
+ @Autowired
+ private AbstractCDSProcessingBBUtils cdsDispatcher;
+
@Override
public Boolean understand(ControllerContext<DelegateExecution> context) {
- return context.getControllerActor().equalsIgnoreCase("cds");
+ return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
+ && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(context.getControllerScope())
+ && (ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction())
+ || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction())); // legacy behavior
}
@Override
@@ -55,7 +65,7 @@ public class CdsControllerDE extends AbstractCDSProcessingBBUtils implements Con
@Override
public void run(ControllerContext<DelegateExecution> context) {
DelegateExecution execution = context.getExecution();
- constructExecutionServiceInputObject(execution);
- sendRequestToCDSClient(execution);
+ cdsDispatcher.constructExecutionServiceInputObject(execution);
+ cdsDispatcher.sendRequestToCDSClient(execution);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java
new file mode 100644
index 0000000000..86d56005f6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Tech Mahindra
+ * ================================================================================
+ * 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.flowspecific.tasks;
+
+import java.util.Optional;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+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.db.catalog.beans.BBNameSelectionReference;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ControllerExecution {
+ private static final Logger logger = LoggerFactory.getLogger(ControllerExecution.class);
+ private static final String CONTROLLER_ACTOR = "controllerActor";
+ private static final String BUILDING_BLOCK = "buildingBlock";
+ private static final String SCOPE = "scope";
+ private static final String ACTION = "action";
+ private static final String BBNAME = "bbName";
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ /**
+ * Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
+ *
+ * @param execution - BuildingBlockExecution object
+ */
+ public void setControllerActorScopeAction(BuildingBlockExecution execution) {
+ try {
+ GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ String modleUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
+ VnfResourceCustomization vnfResourceCustomization =
+ catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modleUuid);
+
+ // Fetching Controller Actor at VNF level if null then Controller Actor is set as "APPC"
+ String controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
+ ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
+ BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
+ String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(
+ () -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
+ String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(
+ () -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
+ execution.setVariable(SCOPE, scope);
+ execution.setVariable(ACTION, action);
+ execution.setVariable(CONTROLLER_ACTOR, controllerActor);
+ logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}",
+ controllerActor, scope, action);
+
+ } catch (Exception ex) {
+ logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * Selecting bbName from BBNameSelectionReference and setting the value in a variable of BuildingBlockExecution
+ *
+ * @param execution - BuildingBlockExecution object
+ */
+ public void selectBB(BuildingBlockExecution execution) {
+ try {
+
+ String controllerActor = execution.getVariable(CONTROLLER_ACTOR);
+ String action = Optional.of((String) execution.getVariable(ACTION)).get();
+ String scope = Optional.of((String) execution.getVariable(SCOPE)).get();
+ BBNameSelectionReference bbNameSelectionReference =
+ catalogDbClient.getBBNameSelectionReference(controllerActor, scope, action);
+ String bbName = bbNameSelectionReference.getBbName();
+ execution.setVariable(BBNAME, bbName);
+ logger.debug(" Executing {} BPMN", bbName);
+ } catch (Exception ex) {
+ logger.error("An exception occurred while getting bbname from catalogdb ", ex);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+
+ }
+
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java
new file mode 100644
index 0000000000..f568026aa5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBB.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada
+ * ================================================================================
+ * 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.flowspecific.tasks;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.GeneratePayloadForCds;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * For Vnf/Vf-Module/Service BuildingBlockExecution is being used.
+ *
+ * @param - BuildingBlockExecution
+ */
+@Component
+public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockExecution> {
+ private static final Logger logger = LoggerFactory.getLogger(GenericCDSProcessingBB.class);
+ private static final String EXECUTION_OBJECT = "executionObject";
+ public static final String CDS_ACTOR = "cds";
+ public static final String VNF_SCOPE = "vnf";
+ public static final String VF_MODULE_SCOPE = "vf-module";
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ @Autowired
+ private AbstractCDSProcessingBBUtils cdsDispather;
+
+ @Autowired
+ private GeneratePayloadForCds generatePayloadForCds;
+
+ @Override
+ public Boolean understand(ControllerContext<BuildingBlockExecution> context) {
+ String scope = context.getControllerScope();
+ return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
+ && (VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope));
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<BuildingBlockExecution> context) {
+ return true;
+ }
+
+ @Override
+ public void prepare(ControllerContext<BuildingBlockExecution> context) {
+ BuildingBlockExecution buildingBlockExecution = context.getExecution();
+ try {
+ AbstractCDSPropertiesBean abstractCDSPropertiesBean =
+ generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
+ buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
+ } catch (Exception ex) {
+ logger.error("An exception occurred when creating payload for CDS request", ex);
+ exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex);
+ }
+ }
+
+ @Override
+ public void run(ControllerContext<BuildingBlockExecution> context) {
+ BuildingBlockExecution obj = context.getExecution();
+ cdsDispather.constructExecutionServiceInputObject(obj);
+ cdsDispather.sendRequestToCDSClient(obj);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java
new file mode 100644
index 0000000000..d5423b2ff7
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.flowspecific.tasks;
+
+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.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.GeneratePayloadForCds;
+import org.onap.so.client.cds.PayloadConstants;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * For pnf, DelegateExecution is being used.
+ *
+ * @param - DelegateExecution
+ */
+@Component
+public class GenericPnfCDSProcessingDE implements ControllerRunnable<DelegateExecution> {
+ private static final Logger logger = LoggerFactory.getLogger(GenericPnfCDSProcessingDE.class);
+ private static final String EXECUTION_OBJECT = "executionObject";
+ private static final String ASSIGN_ACTION = "config-assign";
+ private static final String DEPLOY_ACTION = "config-deploy";
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Autowired
+ private AbstractCDSProcessingBBUtils cdsDispather;
+
+ @Autowired
+ private GeneratePayloadForCds generatePayloadForCds;
+
+ @Override
+ public Boolean understand(ControllerContext<DelegateExecution> context) {
+ final String scope = context.getControllerScope();
+ return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
+ && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(scope)
+ && !(ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction())
+ || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction()));
+ }
+
+ @Override
+ public Boolean ready(ControllerContext<DelegateExecution> context) {
+ return true;
+ }
+
+ @Override
+ public void prepare(ControllerContext<DelegateExecution> context) {
+ DelegateExecution delegateExecution = context.getExecution();
+ try {
+ AbstractCDSPropertiesBean abstractCDSPropertiesBean =
+ generatePayloadForCds.buildCdsPropertiesBean(delegateExecution);
+
+ delegateExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
+
+ } catch (Exception ex) {
+ logger.error("An exception occurred when creating payload for CDS request", ex);
+ exceptionBuilder.buildAndThrowWorkflowException(delegateExecution, 7000, ex);
+ }
+ }
+
+ @Override
+ public void run(ControllerContext<DelegateExecution> context) {
+ DelegateExecution obj = context.getExecution();
+ cdsDispather.constructExecutionServiceInputObject(obj);
+ cdsDispather.sendRequestToCDSClient(obj);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
index 64f0072991..1cde9fb8f6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidator.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
@@ -29,11 +31,9 @@ import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.exception.OrchestrationStatusValidationException;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
-import org.onap.so.db.catalog.beans.OrchestrationAction;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective;
import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
-import org.onap.so.db.catalog.beans.ResourceType;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,8 +52,6 @@ public class OrchestrationStatusValidator {
"Orchestration Status Validation failed. ResourceType=(%s), TargetAction=(%s), OrchestrationStatus=(%s)";
private static final String ORCHESTRATION_STATUS_VALIDATION_RESULT = "orchestrationStatusValidationResult";
private static final String ALACARTE = "aLaCarte";
- private static final String MULTI_STAGE_DESIGN_OFF = "false";
- private static final String MULTI_STAGE_DESIGN_ON = "true";
@Autowired
private ExtractPojosForBB extractPojosForBB;
@@ -86,7 +84,7 @@ public class OrchestrationStatusValidator {
String.format(BUILDING_BLOCK_DETAIL_NOT_FOUND, buildingBlockFlowName));
}
- OrchestrationStatus orchestrationStatus = null;
+ OrchestrationStatus orchestrationStatus;
switch (buildingBlockDetail.getResourceType()) {
case SERVICE:
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 80c6f0b969..33625882f6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -94,6 +94,7 @@ import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.util.CollectionUtils;
@Component
public class WorkflowAction {
@@ -410,15 +411,17 @@ public class WorkflowAction {
}
}
- if (flowsToExecute == null || flowsToExecute.isEmpty()) {
+ if (CollectionUtils.isEmpty(flowsToExecute)) {
throw new IllegalStateException("Macro did not come up with a valid execution path.");
}
+
List<String> flowNames = new ArrayList<>();
logger.info("List of BuildingBlocks to execute:");
- for (ExecuteBuildingBlock ebb : flowsToExecute) {
+
+ flowsToExecute.forEach(ebb -> {
logger.info(ebb.getBuildingBlock().getBpmnFlowName());
flowNames.add(ebb.getBuildingBlock().getBpmnFlowName());
- }
+ });
if (!isResume) {
bbInputSetupUtils.persistFlowExecutionPath(requestId, flowsToExecute);
@@ -431,7 +434,12 @@ public class WorkflowAction {
execution.setVariable("isRollbackComplete", false);
} catch (Exception ex) {
- buildAndThrowException(execution, "Exception while setting execution list. ", ex);
+ if (!(execution.hasVariable("WorkflowException")
+ || execution.hasVariable("WorkflowExceptionExceptionMessage"))) {
+ buildAndThrowException(execution, "Exception while setting execution list. ", ex);
+ } else {
+ throw ex;
+ }
}
}
@@ -463,9 +471,7 @@ public class WorkflowAction {
List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(type);
for (AAIResultWrapper vnfcResultWrapper : vnfcResultWrappers) {
Optional<T> vnfcOp = vnfcResultWrapper.asBean(resultClass);
- if (vnfcOp.isPresent()) {
- vnfcs.add(vnfcOp.get());
- }
+ vnfcOp.ifPresent(vnfcs::add);
}
}
return vnfcs;
@@ -485,9 +491,7 @@ public class WorkflowAction {
this.getResultWrappersFromRelationships(relationships, type);
for (AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
- if (configurationOp.isPresent()) {
- configurations.add(configurationOp.get());
- }
+ configurationOp.ifPresent(configurations::add);
}
}
return configurations;
@@ -537,7 +541,7 @@ public class WorkflowAction {
if (configurations.size() > 1) {
String multipleRelationshipsError =
"Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations";
- buildAndThrowException(dataObj.getExecution(), multipleRelationshipsError,
+ buildAndThrowException(dataObj.getExecution(), "Exception in getConfigBuildingBlock: ",
new Exception(multipleRelationshipsError));
}
for (org.onap.aai.domain.yang.Configuration configuration : configurations) {
@@ -566,8 +570,6 @@ public class WorkflowAction {
protected List<OrchestrationFlow> getVfModuleReplaceBuildingBlocks(ConfigBuildingBlocksDataObject dataObj)
throws Exception {
- List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
-
String vnfId = dataObj.getWorkflowResourceIds().getVnfId();
String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId();
@@ -631,19 +633,15 @@ public class WorkflowAction {
if (!relationshipsOp.isPresent()) {
logger.debug("No relationships were found for Configuration in AAI");
return null;
- } else {
- Relationships relationships = relationshipsOp.get();
- List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC);
- if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) {
- logger.debug("Too many vnfcs or no vnfc found that are related to configuration");
- }
- Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class);
- if (vnfcOp.isPresent()) {
- return vnfcOp.get().getVnfcName();
- } else {
- return null;
- }
}
+ Relationships relationships = relationshipsOp.get();
+ List<AAIResultWrapper> vnfcResultWrappers = relationships.getByType(AAIObjectType.VNFC);
+ if (vnfcResultWrappers.size() > 1 || vnfcResultWrappers.isEmpty()) {
+ logger.debug("Too many vnfcs or no vnfc found that are related to configuration");
+ }
+ Optional<Vnfc> vnfcOp = vnfcResultWrappers.get(0).asBean(Vnfc.class);
+ return vnfcOp.map(Vnfc::getVnfcName).orElse(null);
+
}
protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
@@ -808,7 +806,7 @@ public class WorkflowAction {
vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork);
String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork);
if (existingAAIVrfConfiguration != null) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration));
+ aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration));
}
resourceCounter.add(new Resource(WorkflowType.CONFIGURATION,
service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false));
@@ -956,12 +954,11 @@ public class WorkflowAction {
resourceCounter.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false));
if (serviceInstanceMSO.getVnfs() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
resourceCounter.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
if (vnf.getVfModules() != null) {
for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(
- new Pair<WorkflowType, String>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
Resource resource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false);
resource.setBaseVfModule(vfModule.getModelInfoVfModule().getIsBaseBoolean());
resourceCounter.add(resource);
@@ -970,8 +967,7 @@ public class WorkflowAction {
if (vnf.getVolumeGroups() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
.getVolumeGroups()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP,
- volumeGroup.getVolumeGroupId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
resourceCounter
.add(new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
}
@@ -981,14 +977,14 @@ public class WorkflowAction {
if (serviceInstanceMSO.getNetworks() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO
.getNetworks()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, network.getNetworkId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.NETWORK, network.getNetworkId()));
resourceCounter.add(new Resource(WorkflowType.NETWORK, network.getNetworkId(), false));
}
}
if (serviceInstanceMSO.getCollection() != null) {
logger.debug("found networkcollection");
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION,
- serviceInstanceMSO.getCollection().getId()));
+ aaiResourceIds
+ .add(new Pair<>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId()));
resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,
serviceInstanceMSO.getCollection().getId(), false));
}
@@ -1000,8 +996,7 @@ public class WorkflowAction {
for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) {
if (relationship.getRelatedTo().contains("vnfc")
|| relationship.getRelatedTo().contains("vpn-binding")) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION,
- config.getConfigurationId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.getConfigurationId()));
resourceCounter.add(
new Resource(WorkflowType.CONFIGURATION, config.getConfigurationId(), false));
break;
@@ -1027,12 +1022,11 @@ public class WorkflowAction {
if (serviceInstanceMSO.getVnfs() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) {
if (vnf.getVnfId().equals(vnfId)) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, vnf.getVnfId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId()));
resourceCounter.add(new Resource(WorkflowType.VNF, vnf.getVnfId(), false));
if (vnf.getVfModules() != null) {
for (VfModule vfModule : vnf.getVfModules()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE,
- vfModule.getVfModuleId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId()));
resourceCounter
.add(new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false));
findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(),
@@ -1042,8 +1036,8 @@ public class WorkflowAction {
if (vnf.getVolumeGroups() != null) {
for (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup volumeGroup : vnf
.getVolumeGroups()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP,
- volumeGroup.getVolumeGroupId()));
+ aaiResourceIds
+ .add(new Pair<>(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId()));
resourceCounter.add(
new Resource(WorkflowType.VOLUMEGROUP, volumeGroup.getVolumeGroupId(), false));
}
@@ -1073,8 +1067,7 @@ public class WorkflowAction {
Optional<Configuration> config =
workflowActionUtils.extractRelationshipsConfiguration(relationshipsOp.get());
if (config.isPresent()) {
- aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION,
- config.get().getConfigurationId()));
+ aaiResourceIds.add(new Pair<>(WorkflowType.CONFIGURATION, config.get().getConfigurationId()));
resourceCounter.add(
new Resource(WorkflowType.CONFIGURATION, config.get().getConfigurationId(), false));
}
@@ -1248,7 +1241,7 @@ public class WorkflowAction {
Pattern patt = Pattern.compile("[vV]\\d+.*?(?:(?:/(?<type>" + SUPPORTEDTYPES
+ ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?(?:/resume)?)?$");
Matcher m = patt.matcher(uri);
- Boolean generated = false;
+ boolean generated = false;
if (m.find()) {
logger.debug("found match on {} : {} ", uri, m);
@@ -1358,7 +1351,7 @@ public class WorkflowAction {
} else if (ebb.getBuildingBlock().getBpmnFlowName().equals(CREATENETWORKBB)
|| ebb.getBuildingBlock().getBpmnFlowName().equals(ACTIVATENETWORKBB)) {
continue;
- } else if (!ebb.getBuildingBlock().getBpmnFlowName().equals("")) {
+ } else if (!"".equals(ebb.getBuildingBlock().getBpmnFlowName())) {
sortedOrchFlows.add(ebb);
}
}
@@ -1549,9 +1542,7 @@ public class WorkflowAction {
if (!flow.getFlowName().contains("BB") && !flow.getFlowName().contains("Activity")) {
List<OrchestrationFlow> macroQueryFlows =
catalogDbClient.getOrchestrationFlowByAction(flow.getFlowName());
- for (OrchestrationFlow macroFlow : macroQueryFlows) {
- listToExecute.add(macroFlow);
- }
+ listToExecute.addAll(macroQueryFlows);
} else {
listToExecute.add(flow);
}
@@ -1574,7 +1565,7 @@ public class WorkflowAction {
public void handleRuntimeException(DelegateExecution execution) {
StringBuilder wfeExpMsg = new StringBuilder("Runtime error ");
- String runtimeErrorMessage = null;
+ String runtimeErrorMessage;
try {
String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg");
if (javaExpMsg != null && !javaExpMsg.isEmpty()) {
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
new file mode 100644
index 0000000000..682a0471ee
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * 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.workflow.tasks.listeners;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.logging.log4j.util.Strings;
+import org.onap.so.bpmn.common.BBConstants;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+@Component
+public class SkipCDSBuildingBlockListener implements FlowManipulator {
+
+ @Autowired
+ private CatalogDbClient catalogDbClient;
+
+ private Set<String> vnfActions =
+ new HashSet<String>(Arrays.asList("config-assign", "config-deploy", "VnfConfigAssign", "VnfConfigDeploy"));
+
+ private Set<String> vFModuleAction =
+ new HashSet<String>(Arrays.asList("VfModuleConfigAssign", "VfModuleConfigDeploy"));
+
+ @Override
+ public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) {
+
+ return "ControllerExecutionBB".equals(currentBBName);
+ }
+
+ /**
+ * Skip the CDS Building block according to the Skip Flag.
+ *
+ * @param flowsToExecute - List of ExecuteBuildingBlock object.
+ * @param execution - BuildingBlockExecution object
+ * @param currentBB - ExecuteBuildingBlock object
+ *
+ */
+ @Override
+ public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB,
+ BuildingBlockExecution execution) {
+ String customizationUUID = currentBB.getBuildingBlock().getKey();
+
+ if (Strings.isEmpty(customizationUUID)) {
+ return;
+ }
+
+ if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VNF")
+ && containsIgnoreCaseAction(currentBB, vnfActions)) {
+ List<VnfResourceCustomization> vnfResourceCustomizations =
+ catalogDbClient.getVnfResourceCustomizationByModelUuid(
+ currentBB.getRequestDetails().getModelInfo().getModelUuid());
+ if (!CollectionUtils.isEmpty(vnfResourceCustomizations)) {
+ VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(customizationUUID,
+ vnfResourceCustomizations);
+ if (null != vrc) {
+ boolean skipConfigVNF = vrc.isSkipPostInstConf();
+ currentSequenceSkipCheck(execution, skipConfigVNF);
+ }
+
+ }
+ } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("VFModule")
+ && containsIgnoreCaseAction(currentBB, vFModuleAction)) {
+
+ VfModuleCustomization vfc =
+ catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(customizationUUID);
+
+ if (null != vfc) {
+ boolean skipVfModule = vfc.isSkipPostInstConf();
+ currentSequenceSkipCheck(execution, skipVfModule);
+ }
+ }
+
+
+ }
+
+ private boolean containsIgnoreCaseAction(ExecuteBuildingBlock currentBB, Set<String> actions) {
+ return actions.stream().filter(action -> action.equalsIgnoreCase(currentBB.getBuildingBlock().getBpmnAction()))
+ .findFirst().isPresent();
+ }
+
+
+ private void currentSequenceSkipCheck(BuildingBlockExecution execution, boolean skipModule) {
+ if (skipModule) {
+ int currentSequence = execution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, currentSequence + 1);
+ }
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
index d78fa69680..3f81e432e1 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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.
@@ -52,6 +54,7 @@ import org.onap.so.entity.MsoRequest;
import org.onap.so.openstack.beans.NetworkRollback;
import org.onap.so.openstack.beans.RouteTarget;
import org.onap.so.openstack.beans.Subnet;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -65,8 +68,7 @@ public class NetworkAdapterObjectMapper {
public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network,
- Map<String, String> userInput, String cloudRegionPo, Customer customer)
- throws UnsupportedEncodingException {
+ Map<String, String> userInput, String cloudRegionPo, Customer customer) {
CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
// set cloudSiteId as determined for cloud region PO instead of cloudRegion.getLcpCloudRegionId()
@@ -119,7 +121,7 @@ public class NetworkAdapterObjectMapper {
}
public DeleteNetworkRequest deleteNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
- ServiceInstance serviceInstance, L3Network l3Network) throws UnsupportedEncodingException {
+ ServiceInstance serviceInstance, L3Network l3Network) {
DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest();
deleteNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
@@ -150,14 +152,14 @@ public class NetworkAdapterObjectMapper {
/**
* Access method to build Rollback Network Request
- *
+ *
* @return
* @throws UnsupportedEncodingException
*/
public RollbackNetworkRequest createNetworkRollbackRequestMapper(RequestContext requestContext,
CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance,
L3Network l3Network, Map<String, String> userInput, String cloudRegionPo,
- CreateNetworkResponse createNetworkResponse) throws UnsupportedEncodingException {
+ CreateNetworkResponse createNetworkResponse) {
RollbackNetworkRequest rollbackNetworkRequest = new RollbackNetworkRequest();
rollbackNetworkRequest = setCommonRollbackRequestFields(rollbackNetworkRequest, requestContext);
@@ -171,7 +173,7 @@ public class NetworkAdapterObjectMapper {
public UpdateNetworkRequest createNetworkUpdateRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network,
- Map<String, String> userInput, Customer customer) throws UnsupportedEncodingException {
+ Map<String, String> userInput, Customer customer) {
UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest();
updateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
@@ -198,11 +200,10 @@ public class NetworkAdapterObjectMapper {
}
private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,
- RequestContext requestContext) throws UnsupportedEncodingException {
+ RequestContext requestContext) {
request.setSkipAAI(true);
String messageId = requestContext.getMsoRequestId();
request.setMessageId(messageId);
- // request.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
return request;
}
@@ -240,7 +241,7 @@ public class NetworkAdapterObjectMapper {
return UUID.randomUUID().toString();
}
- protected String createCallbackUrl(String messageType, String correlator) throws UnsupportedEncodingException {
+ protected String createCallbackUrl(String messageType, String correlator) {
String endpoint = this.getEndpoint();
while (endpoint.endsWith("/")) {
@@ -256,14 +257,14 @@ public class NetworkAdapterObjectMapper {
/**
* Use BB L3Network object to build subnets list of type org.onap.so.openstack.beans.Subnet
- *
+ *
* @param L3Network
* @return List<org.onap.so.openstack.beans.Subnet>
*/
protected List<Subnet> buildOpenstackSubnetList(L3Network l3Network) {
List<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet> subnets = l3Network.getSubnets();
- List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<org.onap.so.openstack.beans.Subnet>();
+ List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<>();
// create mapper from onap Subnet to openstack bean Subnet
if (modelMapper.getTypeMap(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class,
org.onap.so.openstack.beans.Subnet.class) == null) {
@@ -292,7 +293,7 @@ public class NetworkAdapterObjectMapper {
.setCidr(subnet.getNetworkStartAddress().concat(FORWARD_SLASH).concat(subnet.getCidrMask()));
List<org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute> hostRouteList = subnet.getHostRoutes();
List<org.onap.so.openstack.beans.HostRoute> openstackHostRouteList = new ArrayList<>();
- org.onap.so.openstack.beans.HostRoute openstackHostRoute = null;
+ org.onap.so.openstack.beans.HostRoute openstackHostRoute;
// TODO only 2 fields available on openstack object. Confirm it is sufficient or add as needed
for (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute hostRoute : hostRouteList) {
openstackHostRoute = new org.onap.so.openstack.beans.HostRoute();
@@ -319,10 +320,9 @@ public class NetworkAdapterObjectMapper {
private ProviderVlanNetwork buildProviderVlanNetwork(L3Network l3Network) {
ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork();
providerVlanNetwork.setPhysicalNetworkName(l3Network.getPhysicalNetworkName());
- List<Integer> vlans = new ArrayList<Integer>();
- List<org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment> segmentationAssignments =
- l3Network.getSegmentationAssignments();
- for (org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment assignment : segmentationAssignments) {
+ List<Integer> vlans = new ArrayList<>();
+ List<SegmentationAssignment> segmentationAssignments = l3Network.getSegmentationAssignments();
+ for (SegmentationAssignment assignment : segmentationAssignments) {
vlans.add(Integer.valueOf(assignment.getSegmentationId()));
}
providerVlanNetwork.setVlans(vlans);
@@ -401,7 +401,7 @@ public class NetworkAdapterObjectMapper {
private Map<String, String> addSharedAndExternal(Map<String, String> userInput, L3Network l3Network) {
if (userInput == null)
- userInput = new HashMap<String, String>();
+ userInput = new HashMap<>();
if (!userInput.containsKey("shared")) {
userInput.put("shared", Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java
index 3d3058da0b..362f64d720 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
@@ -24,7 +26,7 @@ import java.util.HashMap;
public class NamingRequestObject {
- private HashMap<String, String> namingRequestMap = new HashMap<String, String>();
+ private HashMap<String, String> namingRequestMap = new HashMap<>();
public HashMap<String, String> getNamingRequestObjectMap() {
return this.namingRequestMap;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
index fc1528526c..9b104f3250 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
@@ -37,14 +39,11 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class AAIServiceInstanceResources {
- private static final Logger logger = LoggerFactory.getLogger(AAIServiceInstanceResources.class);
@Autowired
private InjectionHelper injectionHelper;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
index 5513122560..dba1693e5d 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* 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
@@ -33,14 +35,11 @@ import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.namingservice.NamingClient;
import org.onap.so.client.namingservice.NamingRequestObject;
import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class NamingServiceResources {
- private static final Logger logger = LoggerFactory.getLogger(NamingServiceResources.class);
private static final String NAMING_TYPE = "instanceGroup";
@Autowired
@@ -53,14 +52,14 @@ public class NamingServiceResources {
throws BadResponseException, IOException {
Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName,
NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName());
- List<Element> elements = new ArrayList<Element>();
+ List<Element> elements = new ArrayList<>();
elements.add(element);
return (namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements)));
}
public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException, IOException {
Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId());
- List<Deleteelement> deleteElements = new ArrayList<Deleteelement>();
+ List<Deleteelement> deleteElements = new ArrayList<>();
deleteElements.add(deleteElement);
return (namingClient
.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements)));
@@ -70,8 +69,8 @@ public class NamingServiceResources {
throws BadResponseException, IOException {
HashMap<String, String> nsRequestObject = namingRequestObject.getNamingRequestObjectMap();
Element element = new Element();
- nsRequestObject.forEach((k, v) -> element.put(k, v));
- List<Element> elements = new ArrayList<Element>();
+ nsRequestObject.forEach(element::put);
+ List<Element> elements = new ArrayList<>();
elements.add(element);
return (namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements)));
}
@@ -81,7 +80,7 @@ public class NamingServiceResources {
HashMap<String, String> nsRequestObject = namingRequestObject.getNamingRequestObjectMap();
Deleteelement delElement = new Deleteelement();
nsRequestObject.forEach((k, v) -> delElement.setExternalKey(v));
- List<Deleteelement> delElements = new ArrayList<Deleteelement>();
+ List<Deleteelement> delElements = new ArrayList<>();
delElements.add(delElement);
return (namingClient.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(delElements)));
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
index 860780a2fc..275cd18f0b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/ControllerExecutionDETestIT.java
@@ -19,50 +19,63 @@
package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.AssertionsForClassTypes.fail;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
-import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
import com.google.protobuf.Struct;
-import java.util.List;
import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
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.BaseIntegrationTest;
import org.onap.so.GrpcNettyServer;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.client.aai.AAIVersion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.fail;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+@RunWith(Parameterized.class)
public class ControllerExecutionDETestIT extends BaseIntegrationTest {
private Logger logger = LoggerFactory.getLogger(this.getClass());
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule smr = new SpringMethodRule();
+
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String ACTIVATE_ACTION = "activateNeSw";
+ private static final String PRECHECK_ACTION = "precheck";
+ private static final String POSTCHECK_ACTION = "postcheck";
+ private static final String ASSIGN_ACTION = "config-assign";
+ private static final String DEPLOY_ACTION = "config-deploy";
+ private static final String CDS_ACTOR = "cds";
+
@Autowired
private ControllerExecutionDE controllerExecutionDE;
@Autowired
private GrpcNettyServer grpcNettyServer;
- private GenericVnf genericVnf;
-
private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
private static String TEST_PROCESS_KEY = "processKey1";
private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
- private static String TEST_CDS_ACTION = "config-assign";
- private static String TEST_APPC_ACTION = "HealthCheck";
+ private static final AAIVersion VERSION = AAIVersion.LATEST;
private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
@@ -70,75 +83,112 @@ public class ControllerExecutionDETestIT extends BaseIntegrationTest {
private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
+ private static String TEST_SOFTWARE_VERSION = "demo-sw-ver2.0.0";
+
+ private String description;
+ private String action;
+ private String scope;
+
+ public ControllerExecutionDETestIT(String desc, String action, String scope) {
+ this.description = desc;
+ this.action = action;
+ this.scope = scope;
+
+ }
+
+ @Parameterized.Parameters(name = "index {0}")
+ public static Collection<String[]> data() {
+ return Arrays.asList(
+ new String[][] {{"Test JSON for action:" + ACTIVATE_ACTION + " scope:pnf", ACTIVATE_ACTION, "pnf"},
+ {"Test JSON for action:" + DOWNLOAD_ACTION + " scope:pnf", DOWNLOAD_ACTION, "pnf"},
+ {"Test JSON for action:" + ASSIGN_ACTION + " scope:pnf", ASSIGN_ACTION, "pnf"},
+ {"Test JSON for action:" + DEPLOY_ACTION + " scope:pnf", DEPLOY_ACTION, "pnf"},
+ {"Test JSON for action:" + PRECHECK_ACTION + " scope:pnf", PRECHECK_ACTION, "pnf"},
+ {"Test JSON for action:" + POSTCHECK_ACTION + " scope:pnf", POSTCHECK_ACTION, "pnf"}});
+ }
@Before
public void setUp() {
+ delegateExecution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ delegateExecution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
delegateExecution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
delegateExecution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
delegateExecution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
- delegateExecution.setVariable("testProcessKey", TEST_PROCESS_KEY);
+ delegateExecution.setVariable(PNF_UUID, TEST_PNF_UUID);
+ delegateExecution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
+ delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ delegateExecution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
+ delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
+ delegateExecution.setVariable("targetSoftwareVersion", TEST_SOFTWARE_VERSION);
+
+ delegateExecution.setVariable("actor", CDS_ACTOR);
+ delegateExecution.setVariable("action", this.action);
+ delegateExecution.setVariable("scope", this.scope);
+
+
+ /**
+ * Get the PNF entry from AAI.
+ */
+ if (action.equalsIgnoreCase(DEPLOY_ACTION)) {
+ final String aaiPnfEntry = "{ \n" + " \"pnf-name\":\"PNFDemo\",\n" + " \"pnf-id\":\"testtest\",\n"
+ + " \"in-maint\":true,\n" + " \"resource-version\":\"1541720264047\",\n"
+ + " \"ipaddress-v4-oam\":\"1.1.1.1\",\n" + " \"ipaddress-v6-oam\":\"::/128\"\n" + "}";
+ wireMockServer.stubFor(
+ get(urlEqualTo("/aai/" + VERSION + "/network/pnfs/pnf/PNFDemo")).willReturn(okJson(aaiPnfEntry)));
+ }
grpcNettyServer.cleanMessage();
}
@Test
- public void testExecution_cdsConfigAssign_actionExecuted() {
-
- configureCdsConfigAssign();
+ public void testExecution_cds_actions() {
controllerExecutionDE.execute(delegateExecution);
List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
assertThat(detailedMessages).hasSize(1);
try {
- checkConfigAssign(detailedMessages.get(0));
+ verifyRequestContentForAction(detailedMessages.get(0));
} catch (Exception e) {
e.printStackTrace();
- fail("ConfigAssign request exception", e);
+ fail(this.action + " request exception", e);
}
}
- private void configureCdsConfigAssign() {
- delegateExecution.setVariable("actor", "cds");
- delegateExecution.setVariable("action", TEST_CDS_ACTION);
- delegateExecution.setVariable("scope", "pnf");
+ private void verifyRequestContentForAction(ExecutionServiceInput executionServiceInput) {
- delegateExecution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
- delegateExecution.setVariable(PNF_UUID, TEST_PNF_UUID);
- delegateExecution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
- delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
- delegateExecution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
- delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
- }
-
- private void checkConfigAssign(ExecutionServiceInput executionServiceInput) {
-
- logger.info("Checking the configAssign request");
+ logger.info("Checking the " + this.action + " request");
ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
- /**
- * the fields of actionIdentifiers should match the one in the
- * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json.
- */
assertThat(actionIdentifiers.getBlueprintName()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
- assertThat(actionIdentifiers.getActionName()).isEqualTo(TEST_CDS_ACTION);
- assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+ assertThat(actionIdentifiers.getActionName()).isEqualTo(this.action);
CommonHeader commonHeader = executionServiceInput.getCommonHeader();
assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
assertThat(commonHeader.getRequestId()).isEqualTo(TEST_MSO_REQUEST_ID);
Struct payload = executionServiceInput.getPayload();
- Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue();
+ Struct requeststruct = payload.getFieldsOrThrow(this.action + "-request").getStructValue();
assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue())
.isEqualTo(TEST_PNF_CORRELATION_ID);
- Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue();
+ Struct propertiesStruct = requeststruct.getFieldsOrThrow(this.action + "-properties").getStructValue();
assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo(TEST_PNF_CORRELATION_ID);
assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).isEqualTo(TEST_MODEL_UUID);
assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
.isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
+ if (action.equalsIgnoreCase(DEPLOY_ACTION)) {
+ assertThat(actionIdentifiers.getMode()).isEqualTo("async");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv4-address").getStringValue()).isEqualTo("1.1.1.1");
+ assertThat(propertiesStruct.getFieldsOrThrow("pnf-ipv6-address").getStringValue()).isEqualTo("::/128");
+ } else if (!action.equalsIgnoreCase(ASSIGN_ACTION)) {
+ assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+ assertThat(propertiesStruct.getFieldsOrThrow("target-software-version").getStringValue())
+ .isEqualTo(TEST_SOFTWARE_VERSION);
+ } else {
+ assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
+ }
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java
index 79bce8a1f4..d8f607f6d9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDETest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDETest.java
@@ -26,8 +26,10 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
import org.onap.so.client.exception.ExceptionBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
@@ -35,11 +37,12 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {CdsControllerDE.class, ExceptionBuilder.class})
-public class CdsControllerDETest {
+@ContextConfiguration(
+ classes = {PnfConfigCdsControllerDE.class, ExceptionBuilder.class, AbstractCDSProcessingBBUtils.class})
+public class PnfConfigCdsControllerDETest {
@Autowired
- private CdsControllerDE cdsControllerDE;
+ private PnfConfigCdsControllerDE pnfConfigCdsControllerDE;
@MockBean
private ControllerContext controllerContext;
@@ -47,20 +50,49 @@ public class CdsControllerDETest {
@MockBean
private ControllerPreparable<DelegateExecution> preparable;
- @Before
- public void setUp() {
+ @Mock
+ private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils;
+
+ @Test
+ public void testUnderstand_action_assign_TrueReturned() {
+ // when
when(controllerContext.getControllerActor()).thenReturn("cds");
+ when(controllerContext.getControllerScope()).thenReturn("pnf");
+ when(controllerContext.getControllerAction()).thenReturn("config-assign");
+
+ // verify
+ assertTrue(pnfConfigCdsControllerDE.understand(controllerContext));
}
@Test
- public void testUnderstand_validContext_TrueReturned() {
- assertTrue(cdsControllerDE.understand(controllerContext));
+ public void testUnderstand_action_deploy_TrueReturned() {
+ // when
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ when(controllerContext.getControllerScope()).thenReturn("pnf");
+ when(controllerContext.getControllerAction()).thenReturn("config-deploy");
+
+ // verify
+ assertTrue(pnfConfigCdsControllerDE.understand(controllerContext));
+ }
+
+ @Test
+ public void testUnderstand_action_any_FalseReturned() {
+ // when
+ when(controllerContext.getControllerActor()).thenReturn("cds");
+ when(controllerContext.getControllerScope()).thenReturn("pnf");
+ when(controllerContext.getControllerAction()).thenReturn("any-action");
+
+ // verify
+ assertFalse(pnfConfigCdsControllerDE.understand(controllerContext));
}
@Test
public void testUnderstand_invalidContext_FalseReturned() {
+ // when
when(controllerContext.getControllerActor()).thenReturn("appc");
- assertFalse(cdsControllerDE.understand(controllerContext));
+
+ // verify
+ assertFalse(pnfConfigCdsControllerDE.understand(controllerContext));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java
new file mode 100644
index 0000000000..72a987c395
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java
@@ -0,0 +1,127 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Tech Mahindra
+ * ================================================================================
+ * 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.flowspecific.tasks;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.when;
+import java.util.UUID;
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.db.catalog.beans.BBNameSelectionReference;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+
+
+public class ControllerExecutionTest extends BaseTaskTest {
+
+ @InjectMocks
+ private ControllerExecution controllerExecution = new ControllerExecution();
+
+ private static final String TEST_SCOPE = "vfModule";
+ private static final String TEST_BBNAME = "ConfigurationScaleOut";
+ private static final String TEST_ACTION = "configScaleOut";
+ private static final String TEST_CONTROLLER_ACTOR = "APPC";
+
+ private BuildingBlock buildingBlock = new BuildingBlock();
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ private ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+ private GenericVnf genericVnf;
+ private ServiceInstance serviceInstance;
+ private RequestContext requestContext;
+ private String msoRequestId;
+
+
+ @Before
+ public void before() throws BBObjectNotFoundException {
+
+ genericVnf = setGenericVnf();
+ serviceInstance = setServiceInstance();
+ msoRequestId = UUID.randomUUID().toString();
+ requestContext = setRequestContext();
+ requestContext.setMsoRequestId(msoRequestId);
+ gBBInput.setRequestContext(requestContext);
+ buildingBlock.setBpmnAction(TEST_ACTION);
+ buildingBlock.setBpmnScope(TEST_SCOPE);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ execution.setVariable("buildingBlock", executeBuildingBlock);
+
+ doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
+ .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
+
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ .thenReturn(genericVnf);
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ .thenReturn(serviceInstance);
+
+
+ }
+
+ @Test
+ public void testSetControllerActorScopeAction() throws Exception {
+
+
+ doReturn(vnfResourceCustomization).when(catalogDbClient).getVnfResourceCustomizationByModelCustomizationUUID(
+ genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid());
+ controllerExecution.setControllerActorScopeAction(execution);
+ assertEquals(TEST_SCOPE, execution.getVariable("scope"));
+ assertEquals(TEST_ACTION, execution.getVariable("action"));
+ assertEquals(TEST_CONTROLLER_ACTOR, execution.getVariable("controllerActor"));
+
+ }
+
+
+ @Test
+ public void testSelectBB() throws Exception {
+ // given
+ BBNameSelectionReference bbNameSelectionReference = new BBNameSelectionReference();
+ bbNameSelectionReference.setBbName(TEST_BBNAME);
+ bbNameSelectionReference.setAction(TEST_ACTION);
+ bbNameSelectionReference.setControllerActor(TEST_CONTROLLER_ACTOR);
+ bbNameSelectionReference.setScope(TEST_SCOPE);
+ doReturn(bbNameSelectionReference).when(catalogDbClient).getBBNameSelectionReference(TEST_CONTROLLER_ACTOR,
+ TEST_SCOPE, TEST_ACTION);
+ execution.setVariable("controllerActor", TEST_CONTROLLER_ACTOR);
+ execution.setVariable("scope", TEST_SCOPE);
+ execution.setVariable("action", TEST_ACTION);
+
+ // when
+ controllerExecution.selectBB(execution);
+ // verify
+ assertEquals(TEST_BBNAME, execution.getVariable("bbName"));
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java
new file mode 100644
index 0000000000..24bbc78afb
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericCDSProcessingBBTest.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Bell Canada.
+ * ================================================================================
+ * 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.flowspecific.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.cds.*;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.Resources;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.Vnfs;
+import org.springframework.beans.factory.annotation.Autowired;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.*;
+
+public class GenericCDSProcessingBBTest extends BaseTaskTest {
+
+ private static final String VNF_SCOPE = "vnf";
+ private static final String TEST_VNF_MODEL_CUSTOMIZATION_UUID = "23ce9ac4-e5dd-11e9-81b4-2a2ae2dbcce4";
+ private static final String DEPLOY_ACTION_FOR_CDS = "configDeploy";
+ private static final String GENERAL_BLOCK_EXECUTION_MAP_KEY = "gBBInput";
+ private static final String BUILDING_BLOCK = "buildingBlock";
+ private static final String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
+ private static final String EXECUTION_OBJECT = "executionObject";
+ private static final String BLUEPRINT_NAME = "test";
+ private static final String BLUEPRINT_VERSION = "1.0.0";
+
+ @InjectMocks
+ private GenericCDSProcessingBB controllerRunnable;
+
+ @Mock
+ private AbstractCDSProcessingBBUtils cdsDispather;
+
+ @Mock
+ private GeneratePayloadForCds generatePayloadForCds;
+
+ private BuildingBlockExecution buildingBlockExecution;
+
+ private ExecuteBuildingBlock executeBuildingBlock;
+
+ @Before
+ public void setUp() {
+ buildingBlockExecution = createBuildingBlockExecution();
+ executeBuildingBlock = new ExecuteBuildingBlock();
+ }
+
+ @Test
+ public void testExecutionObjectCreationForVnf() throws Exception {
+ // given
+ ControllerContext<BuildingBlockExecution> controllerContext = new ControllerContext<>();
+ controllerContext.setExecution(buildingBlockExecution);
+ controllerContext.setControllerActor("CDS");
+ controllerContext.setControllerScope("vnf");
+ setScopeAndAction(VNF_SCOPE, DEPLOY_ACTION_FOR_CDS);
+ AbstractCDSPropertiesBean cdsBean = prepareCDSBean();
+
+ doReturn(cdsBean).when(generatePayloadForCds).buildCdsPropertiesBean(buildingBlockExecution);
+ doNothing().when(cdsDispather).constructExecutionServiceInputObject(buildingBlockExecution);
+ doNothing().when(cdsDispather).sendRequestToCDSClient(buildingBlockExecution);
+
+ // when
+ Boolean isUnderstandable = controllerRunnable.understand(controllerContext);
+ Boolean isReady = controllerRunnable.ready(controllerContext);
+ controllerRunnable.prepare(controllerContext);
+ controllerRunnable.run(controllerContext);
+
+ // verify
+ assertEquals(isUnderstandable, true);
+ assertEquals(isReady, true);
+ AbstractCDSPropertiesBean executionObject = buildingBlockExecution.getVariable(EXECUTION_OBJECT);
+ assertNotNull(executionObject);
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ assertEquals(BLUEPRINT_NAME, executionObject.getBlueprintName());
+ assertEquals(BLUEPRINT_VERSION, executionObject.getBlueprintVersion());
+ assertEquals(TEST_MSO_REQUEST_ID, executionObject.getRequestId());
+ assertNotNull(executionObject.getRequestObject());
+ }
+
+ private AbstractCDSPropertiesBean prepareCDSBean() {
+ AbstractCDSPropertiesBean cdsBean = new AbstractCDSPropertiesBean();
+ cdsBean.setBlueprintName(BLUEPRINT_NAME);
+ cdsBean.setBlueprintVersion(BLUEPRINT_VERSION);
+ cdsBean.setRequestId(TEST_MSO_REQUEST_ID);
+ cdsBean.setRequestObject("requestObject");
+
+ return cdsBean;
+ }
+
+ private GeneralBuildingBlock createGeneralBuildingBlock() {
+ GeneralBuildingBlock generalBuildingBlock = new GeneralBuildingBlock();
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(createRequestParameters());
+ requestContext.setRequestParameters(requestParameters);
+ requestContext.setMsoRequestId(TEST_MSO_REQUEST_ID);
+ generalBuildingBlock.setRequestContext(requestContext);
+ return generalBuildingBlock;
+ }
+
+ private List<Map<String, Object>> createRequestParameters() {
+ List<Map<String, Object>> userParams = new ArrayList<>();
+ Map<String, Object> userParamMap = new HashMap<>();
+ userParamMap.put("service", getUserParams());
+ userParams.add(userParamMap);
+ return userParams;
+ }
+
+ private Service getUserParams() {
+ Service service = new Service();
+ Resources resources = new Resources();
+ resources.setVnfs(createVnfList());
+ service.setResources(resources);
+ return service;
+ }
+
+ private List<Vnfs> createVnfList() {
+ List<Map<String, String>> instanceParamsListSearchedVnf = new ArrayList<>();
+ Map<String, String> instanceParam = new HashMap<>();
+ instanceParam.put("sec_group", "sec_group");
+ instanceParam.put("net_id", "acl-cloud-region");
+ instanceParamsListSearchedVnf.add(instanceParam);
+ Vnfs searchedVnf = createVnf(instanceParamsListSearchedVnf);
+ List<Vnfs> vnfList = new ArrayList<>();
+ vnfList.add(searchedVnf);
+ return vnfList;
+ }
+
+ private Vnfs createVnf(List<Map<String, String>> instanceParamsList) {
+ Vnfs vnf = new Vnfs();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(TEST_VNF_MODEL_CUSTOMIZATION_UUID);
+ vnf.setModelInfo(modelInfo);
+ vnf.setInstanceParams(instanceParamsList);
+ return vnf;
+ }
+
+ private BuildingBlockExecution createBuildingBlockExecution() {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable(GENERAL_BLOCK_EXECUTION_MAP_KEY, createGeneralBuildingBlock());
+ return new DelegateExecutionImpl(execution);
+ }
+
+ private void setScopeAndAction(String scope, String action) {
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnScope(scope);
+ buildingBlock.setBpmnAction(action);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ buildingBlockExecution.setVariable(BUILDING_BLOCK, executeBuildingBlock);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java
new file mode 100644
index 0000000000..c69adeec50
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDETest.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix
+ * ================================================================================
+ * 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.flowspecific.tasks;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
+import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
+import org.onap.so.client.cds.GeneratePayloadForCds;
+import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import java.util.Arrays;
+import java.util.Collection;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*;
+
+@RunWith(Parameterized.class)
+public class GenericPnfCDSProcessingDETest extends BaseTaskTest {
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule smr = new SpringMethodRule();
+
+ @InjectMocks
+ private GenericPnfCDSProcessingDE controllerRunnable;
+
+ @Mock
+ private GeneratePayloadForCds generatePayloadForCds;
+
+ @Mock
+ private AbstractCDSProcessingBBUtils cdsDispather;
+
+ private static final String PRECHECK_ACTION = "precheck";
+ private static final String DOWNLOAD_ACTION = "downloadNeSw";
+ private static final String ACTIVATE_ACTION = "activateNeSw";
+ private static final String POSTCHECK_ACTION = "postcheck";
+
+ private String description;
+ private String action;
+ private String scope;
+ private String expectedJson;
+
+ public GenericPnfCDSProcessingDETest(String desc, String action, String scope, String expectedJson) {
+ this.description = desc;
+ this.action = action;
+ this.scope = scope;
+ this.expectedJson = expectedJson;
+
+ }
+
+ @Parameterized.Parameters(name = "index {0}")
+ public static Collection<String[]> data() {
+ return Arrays.asList(new String[][] {
+ {"Test JSON for action:" + PRECHECK_ACTION + " scope:pnf", PRECHECK_ACTION, "pnf",
+ buildExpectedJson(PRECHECK_ACTION, "pnf")},
+ {"Test JSON for action:" + DOWNLOAD_ACTION + " scope:pnf", DOWNLOAD_ACTION, "pnf",
+ buildExpectedJson(DOWNLOAD_ACTION, "pnf")},
+ {"Test JSON for action:" + ACTIVATE_ACTION + " scope:pnf", ACTIVATE_ACTION, "pnf",
+ buildExpectedJson(ACTIVATE_ACTION, "pnf")},
+ {"Test JSON for action:" + POSTCHECK_ACTION + " scope:pnf", POSTCHECK_ACTION, "pnf",
+ buildExpectedJson(POSTCHECK_ACTION, "pnf")},});
+ }
+
+ private static String buildExpectedJson(String action, String scope) {
+ return "{\"" + action + "-request\":" + "{\"" + action + "-" + "properties\":"
+ + "{\"service-instance-id\":\"test_service_id\","
+ + "\"pnf-customization-uuid\":\"9acb3a83-8a52-412c-9a45-901764938144\","
+ + "\"pnf-id\":\"5df8b6de-2083-11e7-93ae-92361f002671\","
+ + "\"target-software-version\":\"demo-sw-ver2.0.0\"," + "\"pnf-name\":\"PNFDemo\","
+ + "\"service-model-uuid\":\"6bc0b04d-1873-4721-b53d-6615225b2a28\"}," + "\"resolution-key\":\"PNFDemo\""
+ + "}" + "}";
+ }
+
+ private DelegateExecution execution = new DelegateExecutionFake();
+
+ @Test
+ public void testExecution_validPnf_action_executionObjectCreated() {
+ try {
+
+ // given
+ ControllerContext controllerContext = new ControllerContext();
+ controllerContext.setExecution(execution);
+ controllerContext.setControllerActor("cds");
+ controllerContext.setControllerAction(this.action);
+ controllerContext.setControllerScope(this.scope);
+ AbstractCDSPropertiesBean bean = new AbstractCDSPropertiesBean();
+ doNothing().when(cdsDispather).constructExecutionServiceInputObject(execution);
+ doNothing().when(cdsDispather).sendRequestToCDSClient(execution);
+ doReturn(bean).when(generatePayloadForCds).buildCdsPropertiesBean(execution);
+
+ // when
+ Boolean isUnderstandable = controllerRunnable.understand(controllerContext);
+ Boolean isReady = controllerRunnable.ready(controllerContext);
+ controllerRunnable.prepare(controllerContext);
+ controllerRunnable.run(controllerContext);
+
+ // verify
+ assertEquals(isUnderstandable, true);
+ assertEquals(isReady, true);
+ Object executionObject = execution.getVariable(EXECUTION_OBJECT);
+ assertThat(executionObject).isNotNull();
+ assertThat(executionObject).isInstanceOf(AbstractCDSPropertiesBean.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception thrown" + e.getMessage());
+ }
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 8e47c34cb0..4fdd97d95a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -41,6 +41,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
@@ -228,6 +229,77 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
+ public void selectExecutionListExceptionAlreadyBuiltTest() throws Exception {
+ DelegateExecution delegateExecution = new DelegateExecutionFake();
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ delegateExecution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+ delegateExecution.setVariable("requestAction", gAction);
+ String bpmnRequest =
+ new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+ delegateExecution.setVariable("bpmnRequest", bpmnRequest);
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("apiVersion", "7");
+ delegateExecution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+
+ NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ northBoundRequest.setOrchestrationFlowList(orchFlows);
+
+ when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
+ true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
+
+ doAnswer(invocation -> {
+ DelegateExecutionFake execution = invocation.getArgument(0);
+ execution.setVariable("WorkflowException", "exception");
+ execution.setVariable("WorkflowExceptionErrorMessage", "errorMessage");
+ throw new BpmnError("WorkflowException");
+ }).when(exceptionUtil).buildAndThrowWorkflowException(delegateExecution, 7000,
+ "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations");
+
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+ vnfc.setModelInvariantId("modelInvariantId");
+ vnfc.setVnfcName("testVnfcName");
+ vnfcs.add(vnfc);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
+
+ List<org.onap.aai.domain.yang.Configuration> configurations =
+ new ArrayList<org.onap.aai.domain.yang.Configuration>();
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setModelCustomizationId("modelCustimizationId");
+ configuration.setConfigurationName("testConfigurationName");
+ configurations.add(configuration);
+ org.onap.aai.domain.yang.Configuration configuration1 = new org.onap.aai.domain.yang.Configuration();
+ configuration1.setConfigurationId("configurationId");
+ configuration1.setModelCustomizationId("modelCustimizationId");
+ configuration1.setConfigurationName("testConfigurationName");
+ configurations.add(configuration1);
+ doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
+
+ doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(any());
+
+ thrown.expect(BpmnError.class);
+ SPY_workflowAction.selectExecutionList(delegateExecution);
+ assertEquals(
+ "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations",
+ delegateExecution.getVariable("WorkflowException"));
+ }
+
+ @Test
public void selectExecutionListDuplicateNameExceptionTest() throws Exception {
String gAction = "createInstance";
execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java
new file mode 100644
index 0000000000..fb162f857b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java
@@ -0,0 +1,202 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 Tech Mahindra
+ * ================================================================================
+ * 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.workflow.tasks.listeners;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.List;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BBConstants;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class SkipCDSBuildingBlockListenerTest {
+
+ private static final String VNF_SCOPE = "VNF";
+ private static final String VF_SCOPE = "VFModule";
+ private static final String TEST_MODELUUID = "123456789";
+ private static final String VNF_TEST_ACTION = "VnfConfigAssign";
+ private static final String VFModule_TEST_ACTION = "VfModuleConfigAssign";
+ private static final String MODELCUSTOMIZATIONUUID = "123456789";
+ private static final String BBNAME = "ControllerExecutionBB";
+ private static final boolean ISFIRST = true;
+
+ private int actual;
+ private List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+ private List<VnfResourceCustomization> vnfResourceCustomization;
+ private List<VfModuleCustomization> vfModuleCustomization;
+ private ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+ private RequestDetails reqDetail = new RequestDetails();
+ private BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ private VnfResourceCustomization vnfCust = new VnfResourceCustomization();
+ private VfModuleCustomization vfCust = new VfModuleCustomization();
+ private BuildingBlock buildingBlock = new BuildingBlock();
+
+ @InjectMocks
+ private SkipCDSBuildingBlockListener skipCDSBuildingBlockListener;
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
+ @Before
+ public void before() {
+ ModelInfo model = new ModelInfo();
+ model.setModelUuid(TEST_MODELUUID);
+ reqDetail.setModelInfo(model);
+ executeBuildingBlock.setRequestDetails(reqDetail);
+ }
+
+ @Test
+ public void testTrigger() {
+ BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ skipCDSBuildingBlockListener.shouldRunFor(BBNAME, ISFIRST, execution);
+ assertEquals("ControllerExecutionBB", BBNAME);
+ }
+
+ @Test
+ public void testProcessForVNFToSkipCDSBB() {
+ // given
+ setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0);
+ vnfResourceCustomization = getVnfResourceCustomizationList(true);
+
+ when(catalogDbClient.getVnfResourceCustomizationByModelUuid(
+ executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid()))
+ .thenReturn(vnfResourceCustomization);
+ when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(),
+ vnfResourceCustomization)).thenReturn(vnfCust);
+
+ // when
+ skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+ // then
+ actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ assertEquals(1, actual);
+
+ }
+
+ @Test
+ public void testProcessForVNFNotToSkipCDSBB() {
+ // given
+ setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0);
+ vnfResourceCustomization = getVnfResourceCustomizationList(false);
+
+ when(catalogDbClient.getVnfResourceCustomizationByModelUuid(
+ executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid()))
+ .thenReturn(vnfResourceCustomization);
+ when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(),
+ vnfResourceCustomization)).thenReturn(vnfCust);
+
+ // when
+ skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+ // then
+ actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ assertEquals(0, actual);
+
+ }
+
+
+ @Test
+ public void testProcessForVFToSkipCDSBB() {
+ // given
+ setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0);
+ vfModuleCustomization = getVfModuleCustomizationList(true);
+
+ when(catalogDbClient
+ .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
+ .thenReturn(vfCust);
+
+ // when
+ skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+ // then
+ actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ assertEquals(1, actual);
+
+ }
+
+ @Test
+ public void testProcessForVFNotToSkipCDSBB() {
+ // given
+ setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0);
+ vfModuleCustomization = getVfModuleCustomizationList(false);
+
+ when(catalogDbClient
+ .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
+ .thenReturn(vfCust);
+
+ // when
+ skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
+
+ // then
+ actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
+ assertEquals(0, actual);
+
+ }
+
+ /**
+ * setting scope action in buildingBlock and BB current sequence in BuildingBlockExecution
+ *
+ * @param scope
+ * @param action
+ * @param squence
+ */
+ private void setBuildingBlockAndCurrentSequence(String scope, String action, int sequence) {
+ buildingBlock.setBpmnScope(scope);
+ buildingBlock.setBpmnAction(action);
+ buildingBlock.setBpmnFlowName("ControllerExecutionBB");
+ buildingBlock.setKey(MODELCUSTOMIZATIONUUID);
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+ buildingBlockExecution.setVariable(BBConstants.G_CURRENT_SEQUENCE, sequence);
+
+ }
+
+ private List<VnfResourceCustomization> getVnfResourceCustomizationList(boolean setSkippost) {
+ List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
+ vnfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
+ vnfCust.setSkipPostInstConf(setSkippost);
+ vnfResourceCustomizations.add(vnfCust);
+ return vnfResourceCustomizations;
+ }
+
+ private List<VfModuleCustomization> getVfModuleCustomizationList(boolean setSkippost) {
+ List<VfModuleCustomization> vfModuleCustomizations = new ArrayList<>();
+ vfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
+ vfCust.setSkipPostInstConf(setSkippost);
+ vfModuleCustomizations.add(vfCust);
+ return vfModuleCustomizations;
+ }
+
+}