diff options
author | Steve Smokowski <ss835w@att.com> | 2019-02-06 12:05:32 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-02-06 12:05:32 +0000 |
commit | d109233f1a626d5bbb299209ff94dcee3aac4693 (patch) | |
tree | aed6027fafb2541e832f7606a09f8adad9d88dde /bpmn/so-bpmn-tasks/src/test/java | |
parent | d76c6f0f6da7bbce853c96c3d3472a446b2f3c1f (diff) | |
parent | 2a123ff7a50f3147a41135b559452563bca4727b (diff) |
Merge "logic to handle null values for vf module index"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java | 30 |
1 files changed, 25 insertions, 5 deletions
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 8e261cfa8e..5b92d858b9 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 @@ -30,6 +30,9 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.TreeSet; + import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Rule; @@ -515,15 +518,32 @@ public class AAICreateTasksTest extends BaseTaskTest{ vfModule3.setModuleIndex(3); //B - vfModule4.setModuleIndex(0); + vfModule4.setModuleIndex(null); vfModule5.setModuleIndex(1); - assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA), 1); + assertEquals(1, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleA)); - assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB), 2); + assertEquals(2, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleB)); - assertEquals(aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC), 0); - + assertEquals(0, aaiCreateTasks.getLowestUnusedVfModuleIndexFromAAIVnfResponse(vnf, newVfModuleC)); } + + @Test + public void calculateUnusedIndexTest() { + + TreeSet<Integer> a = new TreeSet<>(Arrays.asList(0,1,3)); + TreeSet<Integer> b = new TreeSet<>(Arrays.asList(0,1,8)); + TreeSet<Integer> c = new TreeSet<>(Arrays.asList(0,2,4)); + assertEquals(2, aaiCreateTasks.calculateUnusedIndex(a, 0)); + assertEquals(5, aaiCreateTasks.calculateUnusedIndex(a, 2)); + + assertEquals(4, aaiCreateTasks.calculateUnusedIndex(b, 2)); + assertEquals(3, aaiCreateTasks.calculateUnusedIndex(b, 1)); + + assertEquals(5, aaiCreateTasks.calculateUnusedIndex(c, 2)); + assertEquals(9, aaiCreateTasks.calculateUnusedIndex(c, 6)); + assertEquals(1, aaiCreateTasks.calculateUnusedIndex(c, 0)); + + } } |