aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/java
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-12-11 13:59:53 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-12-13 14:26:21 -0500
commita0a017f918430fbd1c14c3af2718b993f0e9357c (patch)
treea5c356c563eff51e4cf21722bd16d0e73ec3aedb /bpmn/MSOCommonBPMN/src/test/java
parentd04057383159718b40dabc2a278c60c7813bb852 (diff)
Refactor WorkflowAction.valiadteResourceIdInAAI -
Refactor WorkflowAction.valiadteResourceIdInAAI - break up the method into smaller pieces to handle different resouce type separately. Include aai object id info in MultipleObjectsException. Do not throw DuplicateNameException when MultipleObjectsFoundException is caught. Handle BAU and let MOFException be thrown as illegal state exception. Issue-ID: SO-2564 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ib78fbbe9fbea3e4815a7b19071ea2ce30dce6c25
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java90
1 files changed, 66 insertions, 24 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index 53d167e4af..2b78690e27 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
@@ -480,7 +481,9 @@ public class BBInputSetupUtilsTest {
@Test
public void testGetOptionalAAIServiceInstanceByNameException() throws Exception {
- expectedException.expect(Exception.class);
+ expectedException.expect(MultipleObjectsFoundException.class);
+ expectedException.expectMessage(containsString(
+ "Multiple service instances found for customer-id: globalCustomerId, service-type: serviceType and service-instance-name: serviceInstanceId."));
String globalCustomerId = "globalCustomerId";
String serviceType = "serviceType";
@@ -628,7 +631,9 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedNetworkByNameFromServiceInstanceMultipleNetworksExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
+ expectedException.expect(MultipleObjectsFoundException.class);
+ expectedException.expectMessage(containsString(
+ "Multiple networks found for service-instance-id: serviceInstanceId and network-name: networkName."));
String serviceInstanceId = "serviceInstanceId";
String networkName = "networkName";
@@ -637,11 +642,12 @@ public class BBInputSetupUtilsTest {
network.setNetworkId("id123");
network.setNetworkName("name123");
- L3Networks expected = new L3Networks();
- expected.getL3Network().add(network);
- expected.getL3Network().add(network);
+ L3Networks l3Networks = new L3Networks();
+ l3Networks.getL3Network().add(network);
+ l3Networks.getL3Network().add(network);
+ Optional<L3Networks> optNetworks = Optional.of(l3Networks);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
+ doReturn(optNetworks).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName);
}
@@ -711,7 +717,9 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedVnfByNameFromServiceInstanceMultipleVnfsExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
+ expectedException.expect(MultipleObjectsFoundException.class);
+ expectedException.expectMessage(containsString(
+ "Multiple vnfs found for service-instance-id: serviceInstanceId and vnf-name: vnfName."));
String serviceInstanceId = "serviceInstanceId";
String vnfName = "vnfName";
@@ -720,11 +728,13 @@ public class BBInputSetupUtilsTest {
vnf.setVnfId("id123");
vnf.setVnfName("name123");
- GenericVnfs expectedVnf = new GenericVnfs();
- expectedVnf.getGenericVnf().add(vnf);
- expectedVnf.getGenericVnf().add(vnf);
+ GenericVnfs vnfs = new GenericVnfs();
+ vnfs.getGenericVnf().add(vnf);
+ vnfs.getGenericVnf().add(vnf);
+
+ Optional<GenericVnfs> optVnfs = Optional.of(vnfs);
- doReturn(expectedVnf).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
+ doReturn(optVnfs).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
}
@@ -756,7 +766,10 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedVolumeGroupByNameFromVnfMultipleVolumeGroupsExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
+ expectedException.expect(MultipleObjectsFoundException.class);
+ expectedException.expectMessage(containsString(
+ "Multiple volume-groups found for vnf-id: vnfId and volume-group-name: volumeGroupName."));
+
String vnfId = "vnfId";
String volumeGroupName = "volumeGroupName";
@@ -765,12 +778,12 @@ public class BBInputSetupUtilsTest {
volumeGroup.setVolumeGroupId("id123");
volumeGroup.setVolumeGroupName("name123");
- VolumeGroups expectedVolumeGroup = new VolumeGroups();
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
+ VolumeGroups volumeGroups = new VolumeGroups();
+ volumeGroups.getVolumeGroup().add(volumeGroup);
+ volumeGroups.getVolumeGroup().add(volumeGroup);
+ Optional<VolumeGroups> optVolumeGroups = Optional.of(volumeGroups);
- doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class),
- any(AAIResourceUri.class));
+ doReturn(optVolumeGroups).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName);
}
@@ -803,8 +816,9 @@ public class BBInputSetupUtilsTest {
@Test
public void getRelatedVolumeGroupByNameFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
-
+ expectedException.expect(MultipleObjectsFoundException.class);
+ expectedException.expectMessage(containsString(
+ "Multiple voulme-groups found for vnf-id: vnfId, vf-module-id: volumeGroupId and volume-group-name: volumeGroupName."));
String vnfId = "vnfId";
String volumeGroupId = "volumeGroupId";
String volumeGroupName = "volumeGroupName";
@@ -813,12 +827,13 @@ public class BBInputSetupUtilsTest {
volumeGroup.setVolumeGroupId("id123");
volumeGroup.setVolumeGroupName("name123");
- VolumeGroups expectedVolumeGroup = new VolumeGroups();
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
+ VolumeGroups volumeGroups = new VolumeGroups();
+ volumeGroups.getVolumeGroup().add(volumeGroup);
+ volumeGroups.getVolumeGroup().add(volumeGroup);
- doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class),
- any(AAIResourceUri.class));
+ Optional<VolumeGroups> optVolumeGroups = Optional.of(volumeGroups);
+
+ doReturn(optVolumeGroups).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
}
@@ -867,6 +882,33 @@ public class BBInputSetupUtilsTest {
}
@Test
+ public void getRelatedConfigurationByNameFromServiceInstanceExceptionTest() throws Exception {
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("id123");
+
+ Configurations configurations = new Configurations();
+ configurations.getConfiguration().add(configuration);
+ configurations.getConfiguration().add(configuration);
+
+ Optional<Configurations> optConfigurations = Optional.of(configurations);
+
+ doReturn(optConfigurations).when(MOCK_aaiResourcesClient).get(eq(Configurations.class),
+ any(AAIResourceUri.class));
+
+ expectedException.expect(MultipleObjectsFoundException.class);
+ this.bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123");
+ }
+
+ @Test
+ public void getRelatedConfigurationByNameFromServiceInstanceNotFoundTest() throws Exception {
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(Configurations.class),
+ any(AAIResourceUri.class));
+ Optional<Configuration> actualConfiguration =
+ bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123");
+ assertEquals(actualConfiguration, Optional.empty());
+ }
+
+ @Test
public void getRelatedConfigurationByNameFromServiceInstanceTest() throws Exception {
Optional<Configurations> expected = Optional.of(new Configurations());
Configuration configuration = new Configuration();