add in volume group model info lookup 03/74403/2
authorKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
Fri, 7 Dec 2018 17:05:06 +0000 (12:05 -0500)
committerKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
Mon, 10 Dec 2018 15:25:31 +0000 (10:25 -0500)
added in the lookup of volume group for vf on macro as well

Change-Id: Ie3582724b78e88a0b2dd90c37dff086b5e2c3bf9
Issue-ID: SO-1298
Signed-off-by: Kalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java

index c0f1c48..433a1f4 100644 (file)
@@ -386,16 +386,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;
                        }
@@ -424,6 +418,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) {
@@ -1025,6 +1034,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;
                                        }
                                }
index 8399fe1..5931548 100644 (file)
@@ -40,6 +40,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.junit.Before;
@@ -139,6 +140,30 @@ public class BBInputSetupTest {
                SPY_bbInputSetup.setMapperLayer(bbInputSetupMapperLayer);
        }
        
+       @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(