diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-02-01 18:35:25 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-02-01 18:36:12 -0500 |
commit | d231a18148d7bf7f10afd3b72f4be0e0b9a3bb0e (patch) | |
tree | d15bd3c4323ba8849532b21fd7ae0333c2a6c2de /bpmn/so-bpmn-tasks/src/test/java/org/onap | |
parent | 62572d10fe5ea77726371c624b6bcbb33ff1707b (diff) |
auto generated vf module index param
added test for when this is the first vfmodule added
unit test no longer tests already created vnf
refactored test to be more clear about uuid grouping
Added javadoc for getLowestUnusedVfModIndex method.
Increment index by vf module model invariant uuid
Fix unnecessary whitespace delta for GenericVnf file
Fix GenericVnf and modify junit for setting vfmodules
Change-Id: Iacd31c5bf73c971c0b3c06e790d4c5193c3c9860
Issue-ID: SO-1458
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java/org/onap')
2 files changed, 91 insertions, 4 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index df1f0adcea..7375f09240 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -516,7 +516,7 @@ public class TestDataSetup{ VfModule vfModule = new VfModule(); vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter); vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter); - + vfModule.setModuleIndex(0); ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter); modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter); @@ -529,6 +529,10 @@ public class TestDataSetup{ } public VfModule setVfModule() { + return setVfModule(true); + } + + public VfModule setVfModule(boolean addToGenericVnf) { VfModule vfModule = buildVfModule(); GenericVnf genericVnf = null; @@ -539,7 +543,9 @@ public class TestDataSetup{ genericVnf = setGenericVnf(); } - genericVnf.getVfModules().add(vfModule); + if (addToGenericVnf) { + genericVnf.getVfModules().add(vfModule); + } lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); return vfModule; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index da7e727488..8e261cfa8e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -19,6 +19,7 @@ */ package org.onap.so.bpmn.infrastructure.aai.tasks; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; @@ -47,6 +48,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -268,9 +271,17 @@ public class AAICreateTasksTest extends BaseTaskTest{ @Test public void createVfModuleTest() throws Exception { - doNothing().when(aaiVfModuleResources).createVfModule(vfModule, genericVnf); + + VfModule newVfModule = setVfModule(false); + newVfModule.setModuleIndex(null); + newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1"); + doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf); + when(extractPojosForBB.extractByKey(any(),ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID), any())).thenReturn(newVfModule); + + assertEquals(null, newVfModule.getModuleIndex()); aaiCreateTasks.createVfModule(execution); - verify(aaiVfModuleResources, times(1)).createVfModule(vfModule, genericVnf); + assertEquals(1, newVfModule.getModuleIndex().intValue()); + verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf); } @Test @@ -445,4 +456,74 @@ public class AAICreateTasksTest extends BaseTaskTest{ aaiCreateTasks.connectVnfToTenant(execution); verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion()); } + @Test + public void createVfModuleGetLowestIndexTest() throws Exception { + GenericVnf vnf = new GenericVnf(); + ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf(); + vnf.setModelInfoGenericVnf(vnfInfo); + vnfInfo.setModelInvariantUuid("my-uuid"); + + ModelInfoVfModule infoA = new ModelInfoVfModule(); + infoA.setIsBaseBoolean(false); + infoA.setModelInvariantUUID("A"); + + ModelInfoVfModule infoB = new ModelInfoVfModule(); + infoB.setIsBaseBoolean(false); + infoB.setModelInvariantUUID("B"); + + ModelInfoVfModule infoC = new ModelInfoVfModule(); + infoB.setIsBaseBoolean(false); + infoB.setModelInvariantUUID("C"); + + VfModule newVfModuleA = new VfModule(); + VfModule newVfModuleB = new VfModule(); + VfModule newVfModuleC = new VfModule(); + + VfModule vfModule = new VfModule(); + vnf.getVfModules().add(vfModule); + + VfModule vfModule2 = new VfModule(); + vnf.getVfModules().add(vfModule2); + + VfModule vfModule3 = new VfModule(); + vnf.getVfModules().add(vfModule3); + + VfModule vfModule4 = new VfModule(); + vnf.getVfModules().add(vfModule4); + + VfModule vfModule5 = new VfModule(); + vnf.getVfModules().add(vfModule5); + + //A + newVfModuleA.setModelInfoVfModule(infoA); + vfModule.setModelInfoVfModule(infoA); + vfModule2.setModelInfoVfModule(infoA); + vfModule3.setModelInfoVfModule(infoA); + + //B + newVfModuleB.setModelInfoVfModule(infoB); + vfModule4.setModelInfoVfModule(infoB); + vfModule5.setModelInfoVfModule(infoB); + + //C + newVfModuleC.setModelInfoVfModule(infoC); + + + //A + vfModule.setModuleIndex(2); + vfModule2.setModuleIndex(0); + vfModule3.setModuleIndex(3); + + //B + vfModule4.setModuleIndex(0); + vfModule5.setModuleIndex(1); + + assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA), 1); + + assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB), 2); + + assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC), 0); + + + } } |