aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-06-06 14:23:36 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-06 15:38:14 -0400
commit62b2e47808fe1adcbac31dbcdf992617b7f0bd4d (patch)
tree6fbdcf652784be141c869259f2c2919d2a7ce378 /mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap
parentc4b90365d5c117bc6fd64af421a1468539a8aec3 (diff)
Accommodate WAN Networking
checked and evaluated naming policy only if infra bonding. Updated workflowAction to include vrf configuration for vpn-binding in resourceIds list. added in linked resource to service proxy cust committing the asdc controller classpath change added some unit tests for vrf validation and updated bbinput setup test update config resource cust foreign key mapping Moved mockbean for AssignVrfConfiguration task class into BaseBpmnTest. added in a check to see if list is empty before access added unit tests for bbinput setup for vrf config Update AssignFlows enum with correct AssignVrfConfiguration flow name Change-Id: Ibf14e36505638b19c1366ecebfce560c02e69e44 Issue-ID: SO-1975 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java24
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java83
2 files changed, 107 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
index c30b9dedf2..bc10aa744e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java
@@ -83,6 +83,12 @@ public class MsoRequestTest extends BaseTest {
return input;
}
+ public String inputStreamVpnBonding(String JsonInput) throws IOException {
+ JsonInput = "src/test/resources/Validation" + JsonInput;
+ String input = new String(Files.readAllBytes(Paths.get(JsonInput)));
+ return input;
+ }
+
// Tests for successful validation of incoming JSON requests through the parse method
@Test
@Parameters(method = "successParameters")
@@ -188,6 +194,8 @@ public class MsoRequestTest extends BaseTest {
instanceIdMapTest, Action.addRelationships, "5"},
{mapper.readValue(inputStream("/SuccessfulValidation/ServiceAssign.json"),
ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, "7"},
+ {mapper.readValue(inputStream("/RelatedInstances/ServiceInstanceVpnBondingService.json"),
+ ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "7"},
{mapper.readValue(inputStream("/SuccessfulValidation/ServiceUnassign.json"),
ServiceInstancesRequest.class), instanceIdMapTest, Action.unassignInstance, "7"}});
}
@@ -546,6 +554,22 @@ public class MsoRequestTest extends BaseTest {
mapper.readValue(inputStream("/RelatedInstances/v6AddRelationshipsInstanceName.json"),
ServiceInstancesRequest.class),
instanceIdMapTest, Action.addRelationships, 6},
+ {"No valid modelType in relatedInstance is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoModelType.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
+ {"No valid instanceId in relatedInstance is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceId.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
+ {"No valid instanceName in relatedInstance for vpnBinding modelType is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceNameVpnBinding.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
+ {"No valid instanceName in relatedInstance for network modelType is specified",
+ mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceNameNetwork.json"),
+ ServiceInstancesRequest.class),
+ instanceIdMapTest, Action.createInstance, 7},
{"No valid modelCustomizationName or modelCustomizationId in relatedInstance of vnf is specified",
mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelCustomizationId.json"),
ServiceInstancesRequest.class),
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
index 54da0baa92..93a19a9531 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java
@@ -25,15 +25,38 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import com.fasterxml.jackson.databind.ObjectMapper;
public class RelatedInstancesValidationTest extends BaseTest {
+ RelatedInstancesValidation validation = new RelatedInstancesValidation();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ public ValidationInformation setupValidationInformation(String path) throws IOException {
+ String jsonInput = new String(Files.readAllBytes(Paths.get(path)));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(jsonInput, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, null, Action.createInstance, 7, false,
+ sir.getRequestDetails().getRequestParameters());
+
+ info.setRequestScope("service");
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
+
+ info.setRequestInfo(sir.getRequestDetails().getRequestInfo());
+ return info;
+ }
+
@Test
public void testCreateVnfNetworkInstanceGroup() throws IOException, ValidationException {
String requestJson = new String(Files.readAllBytes(
@@ -50,4 +73,64 @@ public class RelatedInstancesValidationTest extends BaseTest {
assertEquals(info.getVnfType(), "Test/name");
}
+
+ @Test
+ public void testCreateSIVpnBonding() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(
+ Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(),
+ Action.createInstance, 7, false, sir.getRequestDetails().getRequestParameters());
+ info.setRequestScope("service");
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getModelInfo().setModelCustomizationName("name");
+ RelatedInstancesValidation validation = new RelatedInstancesValidation();
+ validation.validate(info);
+ RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
+
+ assertEquals(info.getRequestScope(), "service");
+ assertEquals(instanceList[0].getRelatedInstance().getModelInfo().getModelType().toString(), "vpnBinding");
+ assertEquals(instanceList[1].getRelatedInstance().getModelInfo().getModelType().toString(), "network");
+ }
+
+ @Test
+ public void validateModelTypeExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid modelType in relatedInstance is specified");
+ validation.validate(
+ setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoModelType.json"));
+ }
+
+ @Test
+ public void validateInstanceNameVpnBindingExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid instanceName in relatedInstance for vpnBinding modelType is specified");
+ validation.validate(setupValidationInformation(
+ "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json"));
+ }
+
+ @Test
+ public void validateInstanceNameNetworkExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid instanceName in relatedInstance for network modelType is specified");
+ validation.validate(setupValidationInformation(
+ "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json"));
+ }
+
+ @Test
+ public void validateInstanceIdExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid instanceId in relatedInstance is specified");
+ validation.validate(
+ setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json"));
+ }
+
+ @Test
+ public void validatemodelInvariantIdExceptionTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage("No valid modelInvariantId in relatedInstance is specified");
+ validation.validate(setupValidationInformation(
+ "src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json"));
+ }
}