diff options
author | Kalkere Ramesh, Sharan <sharan.kalkere.ramesh@att.com> | 2020-09-17 22:22:00 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-09-20 16:35:44 -0400 |
commit | 5c1f91666cff5d3b21d2d8cd706d09e186e3fe7d (patch) | |
tree | 3621957dcb36ce07609dc1e6996b6f3b4ec89ff9 /bpmn/MSOCommonBPMN | |
parent | 150548c32b0d38d5465f81b8b45923d20bb18f1b (diff) |
added changes for replace related to configuration
added changes for replace related to configuration
added in some changes to the unit test in bbinputsetup
Issue-ID: SO-3249
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Ia45b9ba621f9806771944d800c14ee69c3bdff71
Diffstat (limited to 'bpmn/MSOCommonBPMN')
3 files changed, 94 insertions, 5 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 5a8244266b..b181a60f74 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 @@ -443,6 +443,17 @@ public class BBInputSetup implements JavaDelegate { protected void populateConfiguration(BBInputSetupParameter parameter) { Configuration configuration = null; + String replaceVnfModelCustomizationUUID = ""; + if (parameter.getRelatedInstanceList() != null) { + for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + if (parameter.getIsReplace()) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } + } + } + } for (Configuration configurationTemp : parameter.getServiceInstance().getConfigurations()) { if (parameter.getLookupKeyMap().get(ResourceKey.CONFIGURATION_ID) != null && configurationTemp.getConfigurationId() @@ -465,8 +476,17 @@ public class BBInputSetup implements JavaDelegate { if (configuration != null && parameter.getBbName().contains("Fabric")) { Vnfc vnfc = getVnfcToConfiguration(parameter.getConfigurationResourceKeys().getVnfcName()); configuration.setVnfc(vnfc); - this.mapCatalogConfiguration(configuration, parameter.getModelInfo(), parameter.getService(), - parameter.getConfigurationResourceKeys()); + if (!parameter.getBbName().contains("Delete")) { + if (parameter.getIsReplace()) { + parameter.getConfigurationResourceKeys() + .setVnfResourceCustomizationUUID(replaceVnfModelCustomizationUUID); + mapCatalogConfiguration(configuration, parameter.getModelInfo(), + parameter.getServiceModel().getNewService(), parameter.getConfigurationResourceKeys()); + } else { + mapCatalogConfiguration(configuration, parameter.getModelInfo(), + parameter.getServiceModel().getCurrentService(), parameter.getConfigurationResourceKeys()); + } + } } else if (configuration != null && parameter.getBbName().contains("Vrf")) { configuration.setModelInfoConfiguration(mapperLayer.mapCatalogConfigurationToConfiguration( findConfigurationResourceCustomization(parameter.getModelInfo(), parameter.getService()), null)); 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 dd79d2772f..70bce65f5b 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 @@ -1337,6 +1337,10 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); String bbName = AssignFlows.FABRIC_CONFIGURATION.toString(); + + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys(); configResourceKeys.setVnfcName(vnfcName); Vnfc vnfc = new Vnfc(); @@ -1348,7 +1352,8 @@ public class BBInputSetupTest { BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID) .setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance) .setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName) - .setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails).build(); + .setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails) + .setServiceModel(serviceModel).build(); SPY_bbInputSetup.populateConfiguration(parameter); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); @@ -1374,6 +1379,52 @@ public class BBInputSetupTest { } @Test + public void testPopulateConfigurationReplace() throws JsonParseException, JsonMappingException, IOException { + String instanceName = "configurationName"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + + ServiceInstance serviceInstance = new ServiceInstance(); + Configuration configuration = new Configuration(); + configuration.setConfigurationId("configurationId"); + configuration.setConfigurationName("configurationName"); + serviceInstance.getConfigurations().add(configuration); + String resourceId = "configurationId"; + String vnfcName = "vnfcName"; + // Mock service + Service service = mapper.readValue( + new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class); + ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization(); + configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + service.getConfigurationCustomizations().add(configurationCust); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); + String bbName = AssignFlows.FABRIC_CONFIGURATION.toString(); + + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setNewService(service); + + ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys(); + configResourceKeys.setVnfcName(vnfcName); + Vnfc vnfc = new Vnfc(); + vnfc.setVnfcName(vnfcName); + RequestDetails requestDetails = mapper.readValue( + new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class); + doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, + configResourceKeys); + doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); + BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID) + .setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance) + .setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName) + .setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails) + .setServiceModel(serviceModel).setIsReplace(true).build(); + SPY_bbInputSetup.populateConfiguration(parameter); + configResourceKeys.setVnfResourceCustomizationUUID("my-test-uuid"); + verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, + configResourceKeys); + } + + @Test public void testMapCatalogConfiguration() { ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork(); L3Network network = new L3Network(); @@ -1420,6 +1471,9 @@ public class BBInputSetupTest { vnfc.setVnfcName(vnfcName); RequestDetails requestDetails = new RequestDetails(); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization(); ConfigurationResource configurationResource = new ConfigurationResource(); @@ -1432,7 +1486,8 @@ public class BBInputSetupTest { BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID) .setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance) .setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setInstanceName(instanceName) - .setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails).build(); + .setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails) + .setServiceModel(serviceModel).build(); SPY_bbInputSetup.populateConfiguration(parameter); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); @@ -1462,6 +1517,10 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId"); String bbName = AssignFlows.VNF.toString(); + + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + Platform expectedPlatform = new Platform(); LineOfBusiness expectedLineOfBusiness = new LineOfBusiness(); String resourceId = "123"; @@ -1481,7 +1540,8 @@ public class BBInputSetupTest { .setLineOfBusiness(lineOfBusiness).setService(service).setBbName(bbName) .setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap) .setRelatedInstanceList(requestDetails.getRelatedInstanceList()).setResourceId(resourceId) - .setVnfType(vnfType).setProductFamilyId(requestDetails.getRequestInfo().getProductFamilyId()).build(); + .setVnfType(vnfType).setProductFamilyId(requestDetails.getRequestInfo().getProductFamilyId()) + .setServiceModel(serviceModel).build(); SPY_bbInputSetup.populateGenericVnf(parameter); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_withRelatedInstanceList.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_withRelatedInstanceList.json index bb1612b11d..cad8b91779 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_withRelatedInstanceList.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_withRelatedInstanceList.json @@ -15,5 +15,14 @@ "modelUuid":"modelUUID" } } + }, + { + "relatedInstance":{ + "instanceId":"instanceId", + "modelInfo": { + "modelType": "vnf", + "modelCustomizationId": "my-test-uuid" + } + } }] } |