aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorKalkere Ramesh, Sharan <sharan.kalkere.ramesh@att.com>2020-01-14 14:12:35 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-01-16 10:43:45 -0500
commitda98b2732bfb929574d4759cea58152a08990baa (patch)
tree73ac1127c619146e4ff81350fe64108dc2fdae4f /bpmn
parent41595605a5c8beefd25d72ee5d6df7577a95c545 (diff)
update bb input setup to handle replace for
update bb input setup to handle replace for service vnf vf modules that are not replace will get correct model data added in a unit test as well as added in check for vnf Issue-ID: SO-2599 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I538f6037791905d1086d6d553d1895abd6f2026e
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java23
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java94
2 files changed, 101 insertions, 16 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index bc8b54e444..d506c78966 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -247,7 +247,8 @@ public class BBInputSetup implements JavaDelegate {
if (serviceInstanceId != null) {
aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
if (aaiServiceInstance != null) {
- if (requestAction.equalsIgnoreCase("replaceInstance")) {
+ if (requestAction.equalsIgnoreCase("replaceInstance")
+ || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) {
RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
if (relatedInstanceList != null) {
for (RelatedInstanceList relatedInstList : relatedInstanceList) {
@@ -363,7 +364,8 @@ public class BBInputSetup implements JavaDelegate {
} else if (modelType.equals(ModelType.vnf)) {
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, resourceId);
this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance,
- lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId);
+ lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId,
+ isReplace);
} else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule)
&& (bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString()) || bbName.startsWith(CREATEVOLUME)))) {
lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId);
@@ -555,7 +557,8 @@ public class BBInputSetup implements JavaDelegate {
.getModelCustomizationId();
ModelInfo modelInfoVfModule = new ModelInfo();
modelInfoVfModule.setModelCustomizationId(vfModuleCustId);
- if (isReplace) {
+ if (isReplace && lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null
+ && vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) {
mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, replaceVnfModelCustomizationUUID);
} else {
mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID);
@@ -738,11 +741,12 @@ public class BBInputSetup implements JavaDelegate {
org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName,
ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap,
RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType,
- List<Map<String, String>> instanceParams, String productFamilyId, String applicationId) {
+ List<Map<String, String>> instanceParams, String productFamilyId, String applicationId, boolean isReplace) {
GenericVnf vnf = null;
ModelInfo instanceGroupModelInfo = null;
String instanceGroupId = null;
String generatedVnfType = vnfType;
+ String replaceVnfModelCustomizationUUID = null;
if (generatedVnfType == null || generatedVnfType.isEmpty()) {
generatedVnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName();
}
@@ -753,6 +757,9 @@ public class BBInputSetup implements JavaDelegate {
instanceGroupModelInfo = relatedInstance.getModelInfo();
instanceGroupId = relatedInstance.getInstanceId();
}
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf) && isReplace) {
+ replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
+ }
}
}
for (GenericVnf vnfTemp : serviceInstance.getVnfs()) {
@@ -760,6 +767,12 @@ public class BBInputSetup implements JavaDelegate {
&& vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
String vnfModelCustId =
bbInputSetupUtils.getAAIGenericVnf(vnfTemp.getVnfId()).getModelCustomizationId();
+ if (isReplace && replaceVnfModelCustomizationUUID != null
+ && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) {
+ modelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID);
+ } else {
+ modelInfo.setModelCustomizationUuid(vnfModelCustId);
+ }
modelInfo.setModelCustomizationUuid(vnfModelCustId);
vnf = vnfTemp;
break;
@@ -1433,7 +1446,7 @@ public class BBInputSetup implements JavaDelegate {
String applicationId = "";
this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(),
vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType,
- vnfs.getInstanceParams(), productFamilyId, applicationId);
+ vnfs.getInstanceParams(), productFamilyId, applicationId, false);
} else if (bbName.contains(PNF)) {
String pnfId = lookupKeyMap.get(ResourceKey.PNF);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index e4b1153f4b..517bdfffb8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -855,13 +855,13 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null,
- productFamilyId, applicationId);
+ productFamilyId, applicationId, false);
SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
lookupKeyMap, resourceId, vnfType, null, null, false);
verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null,
- productFamilyId, applicationId);
+ productFamilyId, applicationId, false);
assertEquals("VnfId populated", true,
lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
@@ -1433,13 +1433,13 @@ public class BBInputSetupTest {
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
+ requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
+ requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false);
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
instanceName = "vnfName2";
@@ -1454,7 +1454,7 @@ public class BBInputSetupTest {
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
+ requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false);
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
@@ -1531,13 +1531,13 @@ public class BBInputSetupTest {
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
+ requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
+ requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false);
verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
instanceName = "vnfName2";
@@ -1551,7 +1551,7 @@ public class BBInputSetupTest {
doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId(), applicationId);
+ requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false);
verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
@@ -2015,7 +2015,7 @@ public class BBInputSetupTest {
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
- any(String.class), any(String.class));
+ any(String.class), any(String.class), Mockito.anyBoolean());
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -2298,7 +2298,7 @@ public class BBInputSetupTest {
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
isA(ServiceInstance.class), any(), ArgumentMatchers.isNull(), any(String.class),
- ArgumentMatchers.isNull(), any(), any(String.class), any());
+ ArgumentMatchers.isNull(), any(), any(String.class), any(), Mockito.anyBoolean());
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -2363,7 +2363,7 @@ public class BBInputSetupTest {
isA(org.onap.so.serviceinstancebeans.Platform.class),
isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
- any(String.class), any(String.class));
+ any(String.class), any(String.class), Mockito.anyBoolean());
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
@@ -2995,6 +2995,78 @@ public class BBInputSetupTest {
}
@Test
+ public void testPopulateVfModuleIsReplaceCorrectPopulationOfVfs() throws Exception {
+ String vnfId = "vnfId";
+ String vfModuleId = "vfModuleId";
+ String volumeGroupId = "volumeGroupId";
+ String vfModuleCustomizationId = "vfModuleCustomizationId";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(vfModuleCustomizationId);
+ Service service = new Service();
+ String bbName = "ActivateVfModuleBB";
+ ServiceInstance serviceInstance = new ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId(vnfId);
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(volumeGroupId);
+ vnf.getVolumeGroups().add(volumeGroup);
+ serviceInstance.getVnfs().add(vnf);
+ VfModule vfModule1 = new VfModule();
+ vfModule1.setVfModuleId("vfModuleId1");
+ VfModule vfModule2 = new VfModule();
+ vfModule2.setVfModuleId("vfModuleId2");
+ vnf.getVfModules().add(vfModule1);
+ vnf.getVfModules().add(vfModule2);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId1");
+ String resourceId = vfModuleId;
+ RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1];
+ RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList();
+ RelatedInstance relatedInstance = new RelatedInstance();
+ relatedInstance.setInstanceId(vnfId);
+
+ ModelInfo vnfModelInfo = new ModelInfo();
+ vnfModelInfo.setModelCustomizationId("vnfCustomizationId");
+ vnfModelInfo.setModelType(ModelType.vnf);
+ relatedInstance.setModelInfo(vnfModelInfo);
+ relatedInstanceListObj.setRelatedInstance(relatedInstance);
+ relatedInstanceList[0] = relatedInstanceListObj;
+
+ String instanceName = "vfModuleName";
+ List<Map<String, String>> instanceParams = null;
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+
+ org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
+ vnfAAI.setModelCustomizationId("vnfModelCustId");
+ org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup();
+ volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId);
+ org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule();
+ vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId);
+
+ doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER,
+ cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class));
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class),
+ isA(Service.class));
+ doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ isA(Service.class), isA(String.class));
+
+ SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true);
+
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ isA(Service.class), eq("vnfModelCustId"));
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ isA(Service.class), eq("vnfCustomizationId"));
+ assertEquals("Lookup Key Map populated with VfModule Id", "vfModuleId1",
+ lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
+ assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId,
+ lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
+ }
+
+ @Test
public void testPopulateVfModuleIsReplace() throws Exception {
String vnfId = "vnfId";
String vfModuleId = "vfModuleId";