diff options
author | Rob Daugherty <rd472p@att.com> | 2018-12-10 16:20:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-12-10 16:20:41 +0000 |
commit | a578bc0b7df6ec2de62bc1fbd29dea387977b97a (patch) | |
tree | bd9c78dcc2bb95b714a7fbbb085d61a082184090 /bpmn | |
parent | ba49400b548acc433908e7a68846686cffebadca (diff) | |
parent | b0b12b71503f017e814c6aef6a0ab85f267e250c (diff) |
Merge "add in volume group model info lookup"
Diffstat (limited to 'bpmn')
2 files changed, 50 insertions, 10 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 b1e5d0d208..4be2f030b1 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 @@ -390,16 +390,10 @@ public class BBInputSetup implements JavaDelegate { ModelInfo vnfModelInfo = new ModelInfo(); vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); this.mapCatalogVnf(tempVnf, vnfModelInfo, service); - if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) { - for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { - String volumeGroupCustId = - this.bbInputSetupUtils.getAAIVolumeGroup(cloudConfiguration.getCloudOwner(), - cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); - if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { - lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); - break; - } - } + Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, modelInfo, cloudConfiguration.getCloudOwner(), + cloudConfiguration.getLcpCloudRegionId(), lookupKeyMap); + if(volumeGroupIdOp.isPresent()) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get()); } break; } @@ -428,6 +422,21 @@ public class BBInputSetup implements JavaDelegate { throw new Exception("Could not find relevant information for related VNF"); } } + + protected Optional<String> getVolumeGroupIdRelatedToVfModule(GenericVnf vnf, ModelInfo modelInfo, + String cloudOwner, String cloudRegionId, Map<ResourceKey, String> lookupKeyMap) { + if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) == null) { + for(VolumeGroup volumeGroup : vnf.getVolumeGroups()) { + String volumeGroupCustId = + bbInputSetupUtils.getAAIVolumeGroup(cloudOwner, + cloudRegionId, volumeGroup.getVolumeGroupId()).getModelCustomizationId(); + if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { + return Optional.of(volumeGroup.getVolumeGroupId()); + } + } + } + return Optional.empty(); + } protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, String vnfModelCustomizationUUID) { @@ -1029,6 +1038,13 @@ public class BBInputSetup implements JavaDelegate { ModelInfo vfModuleModelInfo = new ModelInfo(); vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID); this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID); + if(cloudRegion != null) { + Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(vnf, vfModuleModelInfo, cloudRegion.getCloudOwner(), + cloudRegion.getLcpCloudRegionId(), lookupKeyMap); + if(volumeGroupIdOp.isPresent()) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get()); + } + } break; } } 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 1654aa06de..cb63f73c9a 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 @@ -145,6 +145,30 @@ public class BBInputSetupTest { } @Test + public void testGetVolumeGroupIdRelatedToVfModule() { + String expected = "volumeGroupId"; + String modelCustomizationId = "modelCustomizationId"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(modelCustomizationId); + String cloudOwner = "cloudOwner"; + String cloudRegionId = "cloudRegionId"; + String volumeGroupId = "volumeGroupId"; + GenericVnf vnf = new GenericVnf(); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId(expected); + vnf.getVolumeGroups().add(volumeGroup); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, null); + org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup(); + aaiVolumeGroup.setModelCustomizationId(modelCustomizationId); + doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudOwner, cloudRegionId, volumeGroupId); + + Optional<String> actual = SPY_bbInputSetup.getVolumeGroupIdRelatedToVfModule(vnf, modelInfo, cloudOwner, cloudRegionId, lookupKeyMap); + + assertEquals(expected, actual.get()); + } + + @Test public void testGetAlaCarteServiceInstance() throws Exception { ServiceInstance expected = mapper.readValue( new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"), |