diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-04 17:18:37 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-04-04 17:18:59 -0400 |
commit | 2b0b9c4b6810d37b72fcb3bbbe5d8a1e1ed41c05 (patch) | |
tree | 8239461fcbe31f7a9ec801182bd41037a3cff2c2 /bpmn/so-bpmn-tasks | |
parent | f81920304c7b62637d32473e672a1e51275ce54b (diff) |
Add support to parse cdl inside LOB and platform
Add support to parse cdl inside LOB and platform
Change-Id: Ie1013d2ba606767d372cfedd4acfb500db209bd3
Issue-ID: SO-1748
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
3 files changed, 49 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 dad84e53a9..279957ca1e 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 @@ -28,6 +28,7 @@ import java.util.Optional; import java.util.TreeSet; import java.util.UUID; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -204,7 +205,8 @@ public class AAICreateTasks { if (platform.getPlatformName() == null || "".equals(platform.getPlatformName())) { logger.debug("PlatformName is null in input. Skipping create platform..."); } else { - aaiVnfResources.createPlatformandConnectVnf(platform,vnf); + List<String> platforms = splitCDL(platform.getPlatformName()); + platforms.stream().forEach(platformName -> aaiVnfResources.createPlatformandConnectVnf(new Platform(platformName),vnf)); } } } catch (Exception ex) { @@ -213,6 +215,13 @@ public class AAICreateTasks { } + public List<String> splitCDL(String str){ + return Stream.of(str.split(",")) + .map(String::trim) + .map (elem -> new String(elem)) + .collect(Collectors.toList()); + } + public void createLineOfBusiness(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); @@ -221,7 +230,8 @@ public class AAICreateTasks { if (lineOfBusiness.getLineOfBusinessName() == null || "".equals(lineOfBusiness.getLineOfBusinessName())) { logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); } else { - aaiVnfResources.createLineOfBusinessandConnectVnf(lineOfBusiness,vnf); + List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); + lineOfBussinesses.stream().forEach(lobName -> aaiVnfResources.createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName),vnf)); } } } catch (Exception ex) { 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 d0901eb689..8bbb6c7f46 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 @@ -267,7 +267,7 @@ public class TestDataSetup{ projectCounter++; Project project = new Project(); - project.setProjectName("testProjectName" + projectCounter); + project.setProjectName("testProjectName1 , testProjectName2 , testProjectName3" + projectCounter); return project; } @@ -485,11 +485,11 @@ public class TestDataSetup{ genericVnf.setIpv4OamAddress("10.222.22.2"); Platform platform = new Platform(); - platform.setPlatformName("testPlatformName"); + platform.setPlatformName(" testPlatformName, testPlatformName2 , testPlatformName3 , testPlatformName4"); genericVnf.setPlatform(platform); LineOfBusiness lob = new LineOfBusiness(); - lob.setLineOfBusinessName("testLineOfBusinessName"); + lob.setLineOfBusinessName(" testLineOfBusinessName , testLineOfBusinessName2, testLineOfBusinessName3, testLineOfBusinessName4"); genericVnf.setLineOfBusiness(lob); ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); 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 fcb95ca07e..5c1caccc2d 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 @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; @@ -31,6 +32,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.util.Arrays; +import java.util.List; import java.util.Optional; import java.util.TreeSet; @@ -43,6 +45,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Captor; import org.mockito.InjectMocks; +import org.mockito.Mockito; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -51,6 +54,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; @@ -61,6 +65,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; public class AAICreateTasksTest extends BaseTaskTest{ @@ -162,14 +167,41 @@ public class AAICreateTasksTest extends BaseTaskTest{ public void createPlatformTest() throws Exception { doNothing().when(aaiVnfResources).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf); aaiCreateTasks.createPlatform(execution); - verify(aaiVnfResources, times(1)).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf); + ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class); + ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class); + Mockito.verify(aaiVnfResources,times(4)).createPlatformandConnectVnf(platformCaptor.capture(),genericVnf.capture()); + + List<Platform> capturedPlatforms = platformCaptor.getAllValues(); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName".equals(item.getPlatformName()))); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName2".equals(item.getPlatformName()))); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName3".equals(item.getPlatformName()))); + assertTrue(capturedPlatforms.stream().anyMatch(item -> "testPlatformName4".equals(item.getPlatformName()))); } @Test public void createLineOfBusinessTest() throws Exception { doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf); aaiCreateTasks.createLineOfBusiness(execution); - verify(aaiVnfResources, times(1)).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf); + + ArgumentCaptor<LineOfBusiness> lobCaptor = ArgumentCaptor.forClass(LineOfBusiness.class); + ArgumentCaptor<GenericVnf> genericVnf = ArgumentCaptor.forClass(GenericVnf.class); + Mockito.verify(aaiVnfResources,times(4)).createLineOfBusinessandConnectVnf(lobCaptor.capture(),genericVnf.capture()); + + List<LineOfBusiness> capturedLOB = lobCaptor.getAllValues(); + assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName".equals(item.getLineOfBusinessName()))); + assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName2".equals(item.getLineOfBusinessName()))); + assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName3".equals(item.getLineOfBusinessName()))); + assertTrue(capturedLOB.stream().anyMatch(item -> "testLineOfBusinessName4".equals(item.getLineOfBusinessName()))); + + } + + @Test + public void splitCDL_Test() throws Exception { + List<String> strings = aaiCreateTasks.splitCDL("Test"); + assertEquals(strings.get(0),"Test"); + + List<String> strings2 = aaiCreateTasks.splitCDL(""); + assertEquals(strings2.get(0),""); } @Test |