aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test/java
diff options
context:
space:
mode:
authorSangalang, Felix <felix.sangalang@att.com>2019-06-14 14:45:16 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-14 14:45:22 -0400
commit3fea528d612cf90c57510f66dc0d0b42b607e6d5 (patch)
tree289eb335b64761172e85e8774eb58aca1004edb7 /bpmn/so-bpmn-tasks/src/test/java
parente29b04bca6367c14fdbd403bbd275e6c8c10fa60 (diff)
Validate names before writing to A&AI
Validate name for InstanceGroup, Configuration and Network. Change-Id: I494749e17a40c6c0cdd51dd28d9c9bca371410ac Issue-ID: SO-2022 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
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.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java21
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java19
4 files changed, 94 insertions, 1 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 b054cc17bb..7bb2bc689f 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
@@ -398,13 +398,21 @@ public class AAICreateTasksTest extends BaseTaskTest {
@Test
public void createNetworkTest() throws Exception {
network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER");
-
+ execution.setVariable("aLaCarte", Boolean.FALSE);
doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network, serviceInstance);
aaiCreateTasks.createNetwork(execution);
verify(aaiNetworkResources, times(1)).createNetworkConnectToServiceInstance(network, serviceInstance);
}
@Test
+ public void createNetworkNameInUseExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ execution.setVariable("aLaCarte", Boolean.TRUE);
+ doReturn(true).when(aaiNetworkResources).checkNetworkNameInUse(network.getNetworkName());
+ aaiCreateTasks.createNetwork(execution);
+ }
+
+ @Test
public void createNetworkExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
@@ -444,6 +452,7 @@ public class AAICreateTasksTest extends BaseTaskTest {
public void createNetworkCollectionInstanceGroupTest() throws Exception {
doNothing().when(aaiNetworkResources)
.createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
+ execution.setVariable("aLaCarte", Boolean.FALSE);
aaiCreateTasks.createNetworkCollectionInstanceGroup(execution);
verify(aaiNetworkResources, times(1))
.createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
@@ -509,11 +518,21 @@ public class AAICreateTasksTest extends BaseTaskTest {
public void createConfigurationTest() throws Exception {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiConfigurationResources).createConfiguration(configuration);
+ execution.setVariable("aLaCarte", Boolean.FALSE);
aaiCreateTasks.createConfiguration(execution);
verify(aaiConfigurationResources, times(1)).createConfiguration(configuration);
}
@Test
+ public void createConfigurationNameInUseExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doReturn(true).when(aaiConfigurationResources)
+ .checkConfigurationNameInUse(configuration.getConfigurationName());
+ execution.setVariable("aLaCarte", Boolean.TRUE);
+ aaiCreateTasks.createConfiguration(execution);
+ }
+
+ @Test
public void connectVnfToCloudRegionTest() throws Exception {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
@@ -543,14 +562,26 @@ public class AAICreateTasksTest extends BaseTaskTest {
@Test
public void createInstanceGroupVnfTest() throws Exception {
+ doReturn(false).when(aaiInstanceGroupResources)
+ .checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName());
doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup,
serviceInstance);
+ execution.setVariable("aLaCarte", Boolean.FALSE);
aaiCreateTasks.createInstanceGroupVnf(execution);
verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup,
serviceInstance);
}
@Test
+ public void createInstanceGroupVnfNameInUseExceptionTest() throws Exception {
+ expectedException.expect(BpmnError.class);
+ doReturn(true).when(aaiInstanceGroupResources)
+ .checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName());
+ execution.setVariable("aLaCarte", Boolean.TRUE);
+ aaiCreateTasks.createInstanceGroupVnf(execution);
+ }
+
+ @Test
public void createInstanceGroupVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiInstanceGroupResources)
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
index 91d9070c0f..68f3d20c82 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java
@@ -20,6 +20,8 @@
package org.onap.so.client.orchestration;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
@@ -44,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
@@ -240,4 +243,23 @@ public class AAIConfigurationResourcesTest extends TestDataSetup {
verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class),
any(org.onap.aai.domain.yang.Configuration.class));
}
+
+ @Test
+ public void checkConfigurationNameInUseTrueTest() throws Exception {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION)
+ .queryParam("configuration-name", "configurationName");
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri));
+ boolean nameInUse = aaiConfigurationResources.checkConfigurationNameInUse("configurationName");
+ assertTrue(nameInUse);
+ }
+
+ @Test
+ public void checkConfigurationNameInUseFalseTest() throws Exception {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION)
+ .queryParam("configuration-name", "configurationName");
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri));
+ boolean nameInUse = aaiConfigurationResources.checkConfigurationNameInUse("configurationName");
+ assertFalse(nameInUse);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
index 8c0d27f799..cb5683d9d8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java
@@ -22,6 +22,8 @@ package org.onap.so.client.orchestration;
import static org.mockito.ArgumentMatchers.eq;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doNothing;
@@ -40,6 +42,7 @@ import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
@@ -131,4 +134,22 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup {
verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class));
}
+ @Test
+ public void checkInstanceGroupNameInUseTrueTest() throws Exception {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP)
+ .queryParam("instance-group-name", "instanceGroupName");
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri));
+ boolean nameInUse = aaiInstanceGroupResources.checkInstanceGroupNameInUse("instanceGroupName");
+ assertTrue(nameInUse);
+ }
+
+ @Test
+ public void checkInstanceGroupNameInUseFalseTest() throws Exception {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP)
+ .queryParam("instance-group-name", "instanceGroupName");
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri));
+ boolean nameInUse = aaiInstanceGroupResources.checkInstanceGroupNameInUse("instanceGroupName");
+ assertFalse(nameInUse);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
index d41148d784..b6161d7669 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java
@@ -23,6 +23,7 @@ package org.onap.so.client.orchestration;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@@ -425,4 +426,22 @@ public class AAINetworkResourcesTest extends TestDataSetup {
verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class));
}
+ @Test
+ public void checkInstanceGroupNameInUseTrueTest() throws Exception {
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "networkName");
+ doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri));
+ boolean nameInUse = aaiNetworkResources.checkNetworkNameInUse("networkName");
+ assertTrue(nameInUse);
+ }
+
+ @Test
+ public void checkInstanceGroupNameInUseFalseTest() throws Exception {
+ AAIResourceUri uri =
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "networkName");
+ doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri));
+ boolean nameInUse = aaiNetworkResources.checkNetworkNameInUse("networkName");
+ assertFalse(nameInUse);
+ }
+
}