diff options
author | Kalkere Ramesh, Sharan <sharan.kalkere.ramesh@att.com> | 2019-12-05 14:59:33 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2019-12-05 14:59:33 -0500 |
commit | ffc9137380cf769b4b08b04a116e8a560165284f (patch) | |
tree | 9d9e63325e1113a45c5dbb2bfffbe64113877fc7 | |
parent | b9765b97e0fd8a99c5b27263638eb05483f14e29 (diff) |
update bb input setup to use request info for
update bb input setup to use request info for replace
fixed unit tests that were failing from code change
Update robot and format test file to pass formatting
Updated formatting so that verify job will pass
removed the change made to robot test for replace
update test that is failing in verify for replace
Issue-ID: SO-2554
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Ic6bb24282b024159dff024d5ff9d848854ca3081
2 files changed, 120 insertions, 21 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 763f163a2b..3f664cb821 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 @@ -257,15 +257,30 @@ public class BBInputSetup implements JavaDelegate { aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); } Service service = null; + boolean isReplace = false; if (aaiServiceInstance != null) { - service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + if (requestAction.equalsIgnoreCase("replaceInstance")) { + RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { + service = bbInputSetupUtils + .getCatalogServiceByModelUUID(relatedInstance.getModelInfo().getModelVersionId()); + isReplace = true; + } + } + } + } else { + service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + } } if (aaiServiceInstance != null && service != null) { ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); this.populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), requestDetails, service, bbName, serviceInstance, lookupKeyMap, resourceId, vnfType, executeBB.getBuildingBlock().getKey(), - executeBB.getConfigurationResourceKeys()); + executeBB.getConfigurationResourceKeys(), isReplace); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); } else { @@ -337,7 +352,7 @@ public class BBInputSetup implements JavaDelegate { protected void populateObjectsOnAssignAndCreateFlows(String requestId, RequestDetails requestDetails, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType, String configurationKey, - ConfigurationResourceKeys configurationResourceKeys) throws Exception { + ConfigurationResourceKeys configurationResourceKeys, boolean isReplace) throws Exception { ModelInfo modelInfo = requestDetails.getModelInfo(); String instanceName = requestDetails.getRequestInfo().getInstanceName(); String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); @@ -369,7 +384,7 @@ public class BBInputSetup implements JavaDelegate { } else { lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); this.populateVfModule(requestId, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); + relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace); } } else if (modelType.equals(ModelType.instanceGroup)) { lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId); @@ -501,13 +516,18 @@ public class BBInputSetup implements JavaDelegate { protected void populateVfModule(String requestId, ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, RelatedInstanceList[] relatedInstanceList, String instanceName, List<Map<String, String>> instanceParams, - CloudConfiguration cloudConfiguration) throws Exception { + CloudConfiguration cloudConfiguration, boolean isReplace) throws Exception { + String replaceVnfModelCustomizationUUID = null; String vnfModelCustomizationUUID = null; if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { - vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + if (isReplace) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } else { + vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } } if (relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, relatedInstance.getInstanceId()); @@ -542,12 +562,20 @@ public class BBInputSetup implements JavaDelegate { .getModelCustomizationId(); ModelInfo modelInfoVfModule = new ModelInfo(); modelInfoVfModule.setModelCustomizationId(vfModuleCustId); - mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID); + if (isReplace) { + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, replaceVnfModelCustomizationUUID); + } else { + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID); + } } if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { vfModule = createVfModule(lookupKeyMap, resourceId, instanceName, instanceParams); vnf.getVfModules().add(vfModule); - mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + if (isReplace) { + mapCatalogVfModule(vfModule, modelInfo, service, replaceVnfModelCustomizationUUID); + } else { + mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + } } if (vfModule != null) { updateInstanceName(requestId, ModelType.vfModule, vfModule.getVfModuleName()); @@ -1429,7 +1457,7 @@ public class BBInputSetup implements JavaDelegate { cloudConfig.setCloudOwner(cloudRegion.getCloudOwner()); this.populateVfModule(executeBB.getRequestId(), modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null, vfModules.getInstanceName(), vfModules.getInstanceParams(), - cloudConfig); + cloudConfig, false); } } else if (bbName.contains(NETWORK)) { networks = findNetworksByKey(key, resources); 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 335d5b9d70..955cf94618 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 @@ -450,7 +450,8 @@ public class BBInputSetupTest { doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), - requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); + requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, + false); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -501,7 +502,8 @@ public class BBInputSetupTest { doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), - requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); + requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, + false); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, @@ -804,7 +806,7 @@ public class BBInputSetupTest { doReturn(ModelType.network).when(modelInfo).getModelType(); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); verify(SPY_bbInputSetup, times(1)).populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); assertEquals("NetworkId populated", true, @@ -816,7 +818,7 @@ public class BBInputSetupTest { lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); verify(SPY_bbInputSetup, times(1)).populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId); @@ -828,7 +830,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); assertEquals("VolumeGroupId populated", true, @@ -837,11 +839,11 @@ public class BBInputSetupTest { doReturn(ModelType.vfModule).when(modelInfo).getModelType(); resourceId = "vfModuleId"; doNothing().when(SPY_bbInputSetup).populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); + lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null); + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); verify(SPY_bbInputSetup, times(1)).populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration); + lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId)); } @@ -1965,7 +1967,7 @@ public class BBInputSetupTest { SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class)); + any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); @@ -2249,7 +2251,7 @@ public class BBInputSetupTest { SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class)); + any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); @@ -2314,7 +2316,7 @@ public class BBInputSetupTest { SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class)); + any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); @@ -2883,7 +2885,76 @@ public class BBInputSetupTest { isA(Service.class), isA(String.class)); SPY_bbInputSetup.populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration); + resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false); + + verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + isA(Service.class), isA(String.class)); + assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, + 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"; + String volumeGroupId = "volumeGroupId"; + String vfModuleCustomizationId = "vfModuleCustomizationId"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(vfModuleCustomizationId); + Service service = new Service(); + String bbName = AssignFlows.VF_MODULE.toString(); + 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); + 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(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true); verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); |