aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-06 21:16:05 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-06 21:16:18 -0500
commit8195d32a2056fcd875001c4e569242506020940a (patch)
treed3822b424af1708fa9237327e58d942763d0adf7 /bpmn
parentd109233f1a626d5bbb299209ff94dcee3aac4693 (diff)
improve vf module logic
remove vf module from list when calculating index Change-Id: I4b88a679eb79bfac6f25a26b10671cca4cf3c48d Issue-ID: SO-1476 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java26
2 files changed, 24 insertions, 7 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 4dd0147163..e2caaf2a67 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -21,7 +21,9 @@
package org.onap.so.bpmn.infrastructure.aai.tasks;
import java.util.Arrays;
+import java.util.List;
import java.util.TreeSet;
+import java.util.stream.Collectors;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.onap.so.bpmn.common.BuildingBlockExecution;
@@ -455,9 +457,10 @@ public class AAICreateTasks {
if (genericVnf != null && genericVnf.getVfModules() != null && !genericVnf.getVfModules().isEmpty()) {
+ List<VfModule> modules = genericVnf.getVfModules().stream().filter(item -> !item.getVfModuleId().equals(newVfModule.getVfModuleId())).collect(Collectors.toList());
TreeSet<Integer> moduleIndices = new TreeSet<>();
int nullIndexFound = 0;
- for (VfModule vfModule : genericVnf.getVfModules()) {
+ for (VfModule vfModule : modules) {
if (vfModule.getModelInfoVfModule() != null) {
if (vfModule.getModelInfoVfModule().getModelInvariantUUID().equals(newVfModuleModelInvariantUUID)) {
if (vfModule.getModuleIndex() != null) {
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 5b92d858b9..4e05d720ea 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
@@ -475,28 +475,41 @@ public class AAICreateTasksTest extends BaseTaskTest{
infoB.setModelInvariantUUID("B");
ModelInfoVfModule infoC = new ModelInfoVfModule();
- infoB.setIsBaseBoolean(false);
- infoB.setModelInvariantUUID("C");
+ infoC.setIsBaseBoolean(false);
+ infoC.setModelInvariantUUID("C");
VfModule newVfModuleA = new VfModule();
+ newVfModuleA.setVfModuleId("a");
VfModule newVfModuleB = new VfModule();
+ newVfModuleB.setVfModuleId("b");
VfModule newVfModuleC = new VfModule();
+ newVfModuleC.setVfModuleId("c");
VfModule vfModule = new VfModule();
vnf.getVfModules().add(vfModule);
-
+ vfModule.setVfModuleId("1");
+
VfModule vfModule2 = new VfModule();
vnf.getVfModules().add(vfModule2);
-
+ vfModule2.setVfModuleId("2");
+
VfModule vfModule3 = new VfModule();
vnf.getVfModules().add(vfModule3);
-
+ vfModule3.setVfModuleId("3");
+
VfModule vfModule4 = new VfModule();
vnf.getVfModules().add(vfModule4);
-
+ vfModule4.setVfModuleId("4");
+
VfModule vfModule5 = new VfModule();
vnf.getVfModules().add(vfModule5);
+ vfModule5.setVfModuleId("5");
+ //modules are included in the vnf already
+ vnf.getVfModules().add(newVfModuleA);
+ vnf.getVfModules().add(newVfModuleB);
+ vnf.getVfModules().add(newVfModuleC);
+
//A
newVfModuleA.setModelInfoVfModule(infoA);
vfModule.setModelInfoVfModule(infoA);
@@ -504,6 +517,7 @@ public class AAICreateTasksTest extends BaseTaskTest{
vfModule3.setModelInfoVfModule(infoA);
//B
+
newVfModuleB.setModelInfoVfModule(infoB);
vfModule4.setModelInfoVfModule(infoB);
vfModule5.setModelInfoVfModule(infoB);