aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java105
-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/activity/ExecuteActivity.java18
-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/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/AssignNetwork.java9
-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/CreateNetworkCollection.java4
-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/namingservice/tasks/NamingServiceCreateTasks.java19
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java18
-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/aai/mapper/AAIObjectMapper.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java20
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java9
-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
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java32
27 files changed, 1551 insertions, 153 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java
index c223d3ff11..de6b75bd03 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java
@@ -28,9 +28,9 @@ import org.springframework.stereotype.Component;
@Component
public class HomingV2 {
- static final String HOMING_SNIRO = "sniro";
- static final String HOMING_OOF = "oof";
- static final String HOMING_SOLUTION = "Homing_Solution";
+ public static final String HOMING_SNIRO = "sniro";
+ public static final String HOMING_OOF = "oof";
+ public static final String HOMING_SOLUTION = "Homing_Solution";
private SniroHomingV2 sniroHomingV2;
private OofHomingV2 oofHomingV2;
@@ -59,6 +59,6 @@ public class HomingV2 {
private boolean isSniro(BuildingBlockExecution execution) {
return execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams().stream()
- .anyMatch(params -> HOMING_SNIRO.equals(params.get(HOMING_SOLUTION)));
+ .anyMatch(params -> HomingV2.HOMING_SNIRO.equals(params.get(HomingV2.HOMING_SOLUTION)));
}
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 22089dae1f..dab5102efd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -31,8 +31,6 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.onap.so.client.orchestration.AAIPnfResources;
-import org.onap.so.logger.LoggingAnchor;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -62,12 +60,14 @@ import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIConfigurationResources;
import org.onap.so.client.orchestration.AAIInstanceGroupResources;
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.AAIVpnBindingResources;
import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -274,18 +274,28 @@ public class AAICreateTasks {
* @param str
* @throws @return
*/
+ public void createPlatformForNetwork(BuildingBlockExecution execution) {
+ try {
+ L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ if (network != null) {
+ createPlatformNetwork(network);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * This method is used for separating (,) from the string.
+ *
+ * @param str
+ * @throws @return
+ */
public void createPlatform(BuildingBlockExecution execution) {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- Platform platform = vnf.getPlatform();
- if (platform != null) {
- if (platform.getPlatformName() == null || "".equals(platform.getPlatformName())) {
- logger.debug("PlatformName is null in input. Skipping create platform...");
- } else {
- List<String> platforms = splitCDL(platform.getPlatformName());
- platforms.stream().forEach(platformName -> aaiVnfResources
- .createPlatformandConnectVnf(new Platform(platformName), vnf));
- }
+ if (vnf != null) {
+ createPlatformVnf(vnf);
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
@@ -293,6 +303,30 @@ public class AAICreateTasks {
}
+ protected void createPlatformVnf(GenericVnf vnf) {
+ Platform platform = vnf.getPlatform();
+ if (Strings.isNullOrEmpty(platform.getPlatformName())) {
+ logger.debug("PlatformName is null in input. Skipping create platform...");
+ } else {
+ List<String> platforms = splitCDL(platform.getPlatformName());
+ platforms.stream().forEach(
+ platformName -> aaiVnfResources.createPlatformandConnectVnf(new Platform(platformName), vnf));
+ }
+ }
+
+ protected void createPlatformNetwork(L3Network network) {
+ Platform platform = network.getPlatform();
+ if (platform != null) {
+ if (Strings.isNullOrEmpty(platform.getPlatformName())) {
+ logger.debug("PlatformName is null in input. Skipping create platform...");
+ } else {
+ List<String> platforms = splitCDL(platform.getPlatformName());
+ platforms.stream().forEach(
+ platformName -> aaiNetworkResources.createPlatformAndConnectNetwork(platform, network));
+ }
+ }
+ }
+
/**
* This method is used for separating (,) from the string.
*
@@ -312,22 +346,51 @@ public class AAICreateTasks {
public void createLineOfBusiness(BuildingBlockExecution execution) {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness();
- if (lineOfBusiness != null) {
- if (lineOfBusiness.getLineOfBusinessName() == null
- || "".equals(lineOfBusiness.getLineOfBusinessName())) {
- logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness...");
- } else {
- List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName());
- lineOfBussinesses.stream().forEach(lobName -> aaiVnfResources
- .createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf));
- }
+ if (vnf != null) {
+ createLineOfBusinessVnf(vnf);
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
+ public void createLineOfBusinessForNetwork(BuildingBlockExecution execution) {
+ try {
+ L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
+ if (network != null) {
+ createLineOfBusinessNetwork(network);
+ }
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ protected void createLineOfBusinessVnf(GenericVnf vnf) {
+ LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness();
+ if (lineOfBusiness != null) {
+ if (Strings.isNullOrEmpty(lineOfBusiness.getLineOfBusinessName())) {
+ logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness...");
+ } else {
+ List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName());
+ lineOfBussinesses.stream().forEach(
+ lobName -> aaiVnfResources.createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf));
+ }
+ }
+ }
+
+ protected void createLineOfBusinessNetwork(L3Network network) {
+ LineOfBusiness lineOfBusiness = network.getLineOfBusiness();
+ if (lineOfBusiness != null) {
+ if (Strings.isNullOrEmpty(lineOfBusiness.getLineOfBusinessName())) {
+ logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness...");
+ } else {
+ List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName());
+ lineOfBussinesses.stream().forEach(lobName -> aaiNetworkResources
+ .createLineOfBusinessAndConnectNetwork(new LineOfBusiness(lobName), network));
+ }
+ }
+ }
+
/**
* This method is used for creating the volume group in A&AI.
*
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/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 533dd89276..4522f7f2e7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -24,6 +24,7 @@
package org.onap.so.bpmn.infrastructure.activity;
+import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@@ -89,8 +90,8 @@ public class ExecuteActivity implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
final String requestId = (String) execution.getVariable(G_REQUEST_ID);
- WorkflowException workflowException = null;
- String handlingCode = null;
+ WorkflowException workflowException;
+ String handlingCode;
try {
Boolean workflowSyncAckSent = (Boolean) execution.getVariable(WORKFLOW_SYNC_ACK_SENT);
if (workflowSyncAckSent == null || workflowSyncAckSent == false) {
@@ -114,7 +115,7 @@ public class ExecuteActivity implements JavaDelegate {
if (execution.getVariables() != null) {
execution.getVariables().forEach((key, value) -> {
if (value instanceof Serializable) {
- variables.put(key, (Serializable) value);
+ variables.put(key, value);
}
});
}
@@ -153,25 +154,22 @@ public class ExecuteActivity implements JavaDelegate {
}
protected BuildingBlock buildBuildingBlock(String activityName) {
- BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(activityName)
- .setMsoId(UUID.randomUUID().toString()).setKey("").setIsVirtualLink(false).setVirtualLinkKey("");
- return buildingBlock;
+ return new BuildingBlock().setBpmnFlowName(activityName).setMsoId(UUID.randomUUID().toString()).setKey("")
+ .setIsVirtualLink(false).setVirtualLinkKey("");
}
protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId,
- BuildingBlock buildingBlock) throws Exception {
+ BuildingBlock buildingBlock) throws IOException {
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID));
workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID));
String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
RequestDetails requestDetails = sIRequest.getRequestDetails();
- ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setaLaCarte(true)
- .setRequestAction((String) execution.getVariable(G_ACTION))
+ return new ExecuteBuildingBlock().setaLaCarte(true).setRequestAction((String) execution.getVariable(G_ACTION))
.setResourceId((String) execution.getVariable(VNF_ID))
.setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds)
.setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails);
- return executeBuildingBlock;
}
protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
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/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/AssignNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
index 164480d7c7..ff0f9e76a3 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.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
@@ -46,17 +48,16 @@ public class AssignNetwork {
* @return
*/
public boolean networkFoundByName(BuildingBlockExecution execution) {
- boolean networkFound = false;
try {
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
if (!OrchestrationStatus.PRECREATED.equals(l3network.getOrchestrationStatus())) {
- networkFound = true;
logger.debug("network found in NOT PRECREATED status");
+ return true;
}
} catch (Exception ex) {
- // return false if no network present
+ return false;
}
- return networkFound;
+ return false;
}
}
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/CreateNetworkCollection.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java
index 36eab8f981..5e925bf9c6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.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,8 +31,6 @@ 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.client.orchestration.AAINetworkResources;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
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/namingservice/tasks/NamingServiceCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
index ea0b408e41..ccbce2de6a 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
@@ -4,6 +4,8 @@
* ================================================================================
* 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
@@ -20,25 +22,16 @@
package org.onap.so.bpmn.infrastructure.namingservice.tasks;
-import java.util.List;
-import java.util.Optional;
-import org.onap.aai.domain.yang.Zone;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.InjectionHelper;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
-import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.Relationships;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.namingservice.NamingRequestObject;
import org.onap.so.client.namingservice.NamingServiceConstants;
@@ -65,7 +58,7 @@ public class NamingServiceCreateTasks {
this.bbInputSetupUtils = bbInputSetupUtils;
}
- public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+ public void createInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
String policyInstanceName = execution.getVariable("policyInstanceName");
String nfNamingCode = execution.getVariable("nfNamingCode");
@@ -79,7 +72,7 @@ public class NamingServiceCreateTasks {
instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
}
- public void createWanTransportServiceName(BuildingBlockExecution execution) throws Exception {
+ public void createWanTransportServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
NamingRequestObject namingRequestObject = new NamingRequestObject();
namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
@@ -98,7 +91,7 @@ public class NamingServiceCreateTasks {
serviceInstance.setServiceInstanceName(generatedWanTransportServiceName);
}
- public void createVpnBondingServiceName(BuildingBlockExecution execution) throws Exception {
+ public void createVpnBondingServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
index 507e14e42a..8d14bd3e89 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
@@ -4,6 +4,8 @@
* ================================================================================
* 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
@@ -26,6 +28,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
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.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.namingservice.NamingRequestObject;
import org.onap.so.client.orchestration.NamingServiceResources;
@@ -43,7 +46,7 @@ public class NamingServiceDeleteTasks {
@Autowired
private NamingServiceResources namingServiceResources;
- public void deleteInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+ public void deleteInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
try {
@@ -53,7 +56,7 @@ public class NamingServiceDeleteTasks {
}
}
- public void deleteServiceInstanceName(BuildingBlockExecution execution) throws Exception {
+ public void deleteServiceInstanceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
NamingRequestObject namingRequestObject = new NamingRequestObject();
namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java
index 192cb3fc90..89d62e0752 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.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
@@ -64,7 +66,7 @@ public class SDNCQueryTasks {
* @param execution
* @throws Exception
*/
- public void queryVnf(BuildingBlockExecution execution) throws Exception {
+ public void queryVnf(BuildingBlockExecution execution) throws BBObjectNotFoundException {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
@@ -99,7 +101,7 @@ public class SDNCQueryTasks {
* @param execution
* @throws Exception
*/
- public void queryVfModule(BuildingBlockExecution execution) throws Exception {
+ public void queryVfModule(BuildingBlockExecution execution) throws BBObjectNotFoundException {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
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 ba43444146..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;
+ }
}
}
@@ -533,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) {
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/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
index 11a7b83259..cf56964af3 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java
@@ -90,6 +90,17 @@ public class AAIObjectMapper {
}
public org.onap.aai.domain.yang.Pnf mapPnf(Pnf pnf) {
+ if (modelMapper.getTypeMap(Pnf.class, org.onap.aai.domain.yang.Pnf.class) == null) {
+ modelMapper.addMappings(new PropertyMap<Pnf, org.onap.aai.domain.yang.Pnf>() {
+ @Override
+ protected void configure() {
+ map().setModelCustomizationId(source.getModelInfoPnf().getModelCustomizationUuid());
+ map().setModelInvariantId(source.getModelInfoPnf().getModelInvariantUuid());
+ map().setModelVersionId(source.getModelInfoPnf().getModelUuid());
+ }
+ });
+ }
+
return modelMapper.map(pnf, org.onap.aai.domain.yang.Pnf.class);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
index bc702c9fb4..3af65815a6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java
@@ -30,6 +30,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
import org.onap.so.client.aai.AAIObjectPlurals;
@@ -38,8 +40,8 @@ import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.client.graphinventory.entities.uri.Depth;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -76,6 +78,22 @@ public class AAINetworkResources {
serviceInstanceURI);
}
+ public void createLineOfBusinessAndConnectNetwork(LineOfBusiness lineOfBusiness, L3Network network) {
+ AAIResourceUri lineOfBusinessURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName());
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
+ injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness))
+ .connect(networkURI, lineOfBusinessURI);
+ }
+
+ public void createPlatformAndConnectNetwork(Platform platform, L3Network network) {
+ AAIResourceUri platformURI =
+ AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName());
+ AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
+ injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(networkURI,
+ platformURI);
+ }
+
public void deleteNetwork(L3Network network) {
AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId());
injectionHelper.getAaiClient().delete(networkURI);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java
index 2ec63182a0..35e08563d1 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.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
@@ -32,10 +34,9 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.client.adapter.vnf.VnfVolumeAdapterClientImpl;
import org.onap.so.client.adapter.vnf.mapper.VnfAdapterObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import java.io.IOException;
@Component
public class VnfAdapterVolumeGroupResources {
@@ -48,13 +49,13 @@ public class VnfAdapterVolumeGroupResources {
public CreateVolumeGroupRequest createVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion,
OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
- VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws Exception {
+ VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws IOException {
return vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext,
serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
}
public DeleteVolumeGroupRequest deleteVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion,
- ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws Exception {
+ ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws IOException {
return vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance,
volumeGroup);
}
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;
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
index 821e70a8c8..dc64e4ee48 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* 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
@@ -41,6 +43,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget;
import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment;
@@ -55,6 +58,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -233,6 +237,34 @@ public class AAIObjectMapperTest {
}
@Test
+ public void pnfMap() {
+ final String pnfId = "PNF_id1";
+ final String pnfName = "PNF_name1";
+ final String modelCustomizationId = "8421fe03-fd1b-4bf7-845a-c3fe91edb03e";
+ final String modelInvariantId = "341a6f84-2cf9-4942-8f9e-2472ffe4e1d8";
+ final String modelVersionId = "b13a0706-46b9-4a98-a9f9-5b28431235e7";
+ final OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED;
+
+ Pnf pnf = new Pnf();
+ pnf.setPnfId(pnfId);
+ pnf.setPnfName(pnfName);
+ pnf.setModelInfoPnf(new ModelInfoPnf());
+ pnf.getModelInfoPnf().setModelCustomizationUuid(modelCustomizationId);
+ pnf.getModelInfoPnf().setModelInvariantUuid(modelInvariantId);
+ pnf.getModelInfoPnf().setModelUuid(modelVersionId);
+ pnf.setOrchestrationStatus(orchestrationStatus);
+
+ org.onap.aai.domain.yang.Pnf aaiPnf = aaiObjectMapper.mapPnf(pnf);
+
+ assertEquals(aaiPnf.getPnfId(), pnfId);
+ assertEquals(aaiPnf.getPnfName(), pnfName);
+ assertEquals(aaiPnf.getModelCustomizationId(), modelCustomizationId);
+ assertEquals(aaiPnf.getModelInvariantId(), modelInvariantId);
+ assertEquals(aaiPnf.getModelVersionId(), modelVersionId);
+ assertEquals(aaiPnf.getOrchestrationStatus(), orchestrationStatus.toString());
+ }
+
+ @Test
public void vfModuleMap() throws Exception {
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("a");