aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/java/org/onap
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-12-11 14:00:42 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-12-11 14:00:42 -0500
commit043cf84e1b3624d3acb49adb29ec268da8c6ea54 (patch)
treea2bfd3f0a87a353264e9e7f38c57748fae7fac29 /bpmn/MSOCommonBPMN/src/test/java/org/onap
parent02c068ce771ee4522936f2d15f41c2b631e965a8 (diff)
Include service-instance-id and
Include service-instance-id and service-model-version-id in the exception message if service-instance or service model is not found. Issue-ID: SO-2565 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia088d241374af4422cb76d16e86ddd7ecc45593a
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java/org/onap')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java82
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundExceptionTest.java19
2 files changed, 100 insertions, 1 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index 955cf94618..aa049e9847 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -46,7 +46,9 @@ import java.util.Optional;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
@@ -87,6 +89,8 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException;
import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
@@ -149,6 +153,9 @@ public class BBInputSetupTest {
@Mock
private RequestsDbClient requestsDbClient;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
@Before
public void setup() {
SPY_bbInputSetup.setBbInputSetupUtils(SPY_bbInputSetupUtils);
@@ -462,19 +469,50 @@ public class BBInputSetupTest {
assertThat(actual, sameBeanAs(expected));
}
- @Test(expected = Exception.class)
+ @Test
public void testGetGBBALaCarteNonServiceWithoutServiceModelInfo() throws Exception {
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(
new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "si123");
String requestAction = "createInstance";
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
aaiServiceInstance.setModelVersionId("modelVersionId");
String resourceId = "123";
String vnfType = "vnfType";
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("si123");
+ doReturn(null).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+
+ expectedException.expect(ServiceModelNotFoundException.class);
+ expectedException.expectMessage(
+ "Related service instance model not found in MSO CatalogDB: model-version-id=modelVersionId");
+
+ SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
+ vnfType);
+ }
+
+ @Test
+ public void testGetGBBALaCarteNonServiceServiceInstanceNotFoundInAAI() throws Exception {
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "si123");
+ String requestAction = "createInstance";
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+
+ doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("si123");
+
+ expectedException.expect(NoServiceInstanceFoundException.class);
+ expectedException.expectMessage("Related service instance from AAI not found: service-instance-id=si123");
+
SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
vnfType);
}
@@ -2668,6 +2706,48 @@ public class BBInputSetupTest {
}
@Test
+ public void testGetGBBMacroExistingServiceServiceinstancenotFoundInAai() throws Exception {
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "si123");
+
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
+
+ doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("si123");
+
+ expectedException.expect(NoServiceInstanceFoundException.class);
+ expectedException.expectMessage("Related service instance from AAI not found: service-instance-id=si123");
+
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, "AssignVnfBB", "assign",
+ cloudConfiguration);
+ }
+
+ @Test
+ public void testGetGBBMacroExistingServiceServiceModelNotFound() throws Exception {
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "si123");
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
+
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("si123");
+ doReturn(null).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+
+ expectedException.expect(ServiceModelNotFoundException.class);
+ expectedException.expectMessage(
+ "Related service instance model not found in MSO CatalogDB: model-version-id=modelVersionId");
+
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap, "AssignVnfBB", "assign",
+ cloudConfiguration);
+ }
+
+ @Test
public void testGetVnfId() {
String expected = "vnfId";
ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundExceptionTest.java
new file mode 100644
index 0000000000..1ab1d7aa9a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundExceptionTest.java
@@ -0,0 +1,19 @@
+package org.onap.so.bpmn.servicedecomposition.tasks.exceptions;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class ServiceModelNotFoundExceptionTest {
+
+ @Test
+ public void testRequestValidationException() {
+
+ ServiceModelNotFoundException serviceModelNotFoundException = new ServiceModelNotFoundException();
+ Assert.assertNull(serviceModelNotFoundException.getMessage());
+
+ serviceModelNotFoundException = new ServiceModelNotFoundException("test message");
+ Assert.assertEquals("test message", serviceModelNotFoundException.getMessage());
+
+ }
+}