Fix Bux 00/74200/1
authorSmokowski, Steve (ss835w) <ss835w@us.att.com>
Tue, 4 Dec 2018 18:08:35 +0000 (13:08 -0500)
committerSmokowski, Steve (ss835w) <ss835w@us.att.com>
Tue, 4 Dec 2018 18:11:52 +0000 (13:11 -0500)
Fix Bug with mapping  of VNFC Instance Groups

Change-Id: Idb35d33f47f9e4854d68590d665553f8385123ab
Issue-ID: SO-1267
Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.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 5296d59..7edf39d 100644 (file)
@@ -609,8 +609,9 @@ public class BBInputSetup implements JavaDelegate {
                                .getVnfcInstanceGroupCustomizations();
                for (VnfcInstanceGroupCustomization vnfcInstanceGroupCust : vnfcInstanceGroups) {
                        InstanceGroup instanceGroup = this.createInstanceGroup();
-                               instanceGroup.setModelInfoInstanceGroup(this.mapperLayer
-                                               .mapCatalogInstanceGroupToInstanceGroup(null, vnfcInstanceGroupCust.getInstanceGroup()));
+                       org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = bbInputSetupUtils.getCatalogInstanceGroup(vnfcInstanceGroupCust.getModelUUID());
+                       instanceGroup.setModelInfoInstanceGroup(this.mapperLayer
+                                       .mapCatalogInstanceGroupToInstanceGroup(null, catalogInstanceGroup));
                        instanceGroup.getModelInfoInstanceGroup().setFunction(vnfcInstanceGroupCust.getFunction());
                        instanceGroup.setDescription(vnfcInstanceGroupCust.getDescription());
                        genericVnf.getInstanceGroups().add(instanceGroup);
index e32362d..b36d6d4 100644 (file)
@@ -99,6 +99,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
 import org.onap.so.db.catalog.beans.Service;
 import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
 import org.onap.so.db.request.beans.InfraActiveRequests;
 import org.onap.so.serviceinstancebeans.CloudConfiguration;
 import org.onap.so.serviceinstancebeans.ModelInfo;
@@ -1202,6 +1203,31 @@ public class BBInputSetupTest {
                verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
        }
        
+       @Test
+       public void testMapVnfcCollectionInstanceGroup() {
+               VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
+               GenericVnf genericVnf = new GenericVnf();
+               ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+               Service service = Mockito.mock(Service.class);
+               List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
+               VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
+               vnfcInstanceGroupCust.setModelUUID("modelUUID");
+               vnfcInstanceGroupCust.setFunction("function");
+               vnfcInstanceGroupCust.setDescription("description");
+               vnfcInstanceGroups.add(vnfcInstanceGroupCust);
+               org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
+               instanceGroup.setModelUUID("modelUUID");
+               ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+               modelInfoInstanceGroup.setModelUUID("modelUUID");
+               doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
+               doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
+               doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
+               doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
+               
+               SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
+               
+               assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
+       }
        @Test
        public void testPopulateGenericVnfWhereVnfTypeIsNull()
                        throws JsonParseException, JsonMappingException, IOException {