aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java24
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/UserParamsValidationTest.java69
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json91
3 files changed, 184 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java
index 8646a74a2f..728d4df4ee 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java
@@ -34,6 +34,7 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.Networks;
+import org.onap.so.serviceinstancebeans.Pnfs;
import org.onap.so.serviceinstancebeans.Service;
import org.onap.so.serviceinstancebeans.VfModules;
import org.onap.so.serviceinstancebeans.Vnfs;
@@ -116,6 +117,29 @@ public class UserParamsValidation implements ValidationRule {
validateDuplicateInstanceNames(vnfCustomIdToInstanceNames, "vnf");
validateDuplicateInstanceNames(vfModuleCustomIdToInstanceNames, "vfModule");
+ Map<String, Set<String>> pnfCustomIdToInstanceNames = new HashMap<>();
+
+ for (Pnfs pnf : validate.getResources().getPnfs()) {
+ if (pnf.getModelInfo() == null) {
+ throw new ValidationException("modelInfo in userParams pnf resources", true);
+ } else if (pnf.getModelInfo().getModelCustomizationId() == null) {
+ throw new ValidationException("modelCustomizationId in userParams pnf resources", true);
+ } else if (pnf.getModelInfo().getModelVersionId() == null) {
+ throw new ValidationException("modelVersionId in userParams pnf resources", true);
+ }
+ String pnfCustomizationId = pnf.getModelInfo().getModelCustomizationId();
+ pnfCustomIdToInstanceNames.putIfAbsent(pnfCustomizationId, new HashSet<>());
+ String pnfInstanceName = StringUtils.defaultString(pnf.getInstanceName());
+ Set<String> pnfVisitedInstanceNames = pnfCustomIdToInstanceNames.get(pnfCustomizationId);
+ if (!pnfVisitedInstanceNames.add(pnfInstanceName)) {
+ throw new ValidationException(
+ "instanceName: same instanceName with same modelCustomizationId in userParams pnf resources",
+ true);
+ }
+ }
+
+ validateDuplicateInstanceNames(pnfCustomIdToInstanceNames, "pnf");
+
List<Networks> validateNetworks = new ArrayList<>();
validateNetworks = validate.getResources().getNetworks();
if (validateNetworks != null) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/UserParamsValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/UserParamsValidationTest.java
index 548b957303..30b7662b59 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/UserParamsValidationTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/UserParamsValidationTest.java
@@ -243,6 +243,75 @@ public class UserParamsValidationTest {
}
@Test
+ public void validateDuplicateInstanceNameDifferentCustomizationIdPnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName but different modelCustomizationId (instanceName should be unique) in userParams pnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json");
+ info.getUserParams().getResources().getPnfs().get(0).setInstanceName("ORAN_SIM1_2106_pnf_01");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateInstanceNameSameCustomizationIdPnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams pnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json");
+ info.getUserParams().getResources().getPnfs().get(1).getModelInfo()
+ .setModelCustomizationId("88a3096a-af87-4853-99f6-7256a9ab6c3e");
+ info.getUserParams().getResources().getPnfs().get(1).setInstanceName("ORAN_SIM1_2106_pnf_01");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameSameCustomizationIdPnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: instanceName is missing or empty with same modelCustomizationId in userParams pnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json");
+ info.getUserParams().getResources().getPnfs().get(1).getModelInfo()
+ .setModelCustomizationId("88a3096a-af87-4853-99f6-7256a9ab6c3e");
+ info.getUserParams().getResources().getPnfs().get(1).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateNullInstanceNameSameCustomizationIdPnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams pnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json");
+ info.getUserParams().getResources().getPnfs().get(0).setInstanceName(null);
+ info.getUserParams().getResources().getPnfs().get(1).getModelInfo()
+ .setModelCustomizationId("88a3096a-af87-4853-99f6-7256a9ab6c3e");
+ info.getUserParams().getResources().getPnfs().get(1).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDifferentInstanceNameSameCustomizationIdPnfTest() throws IOException, ValidationException {
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json");
+ info.getUserParams().getResources().getPnfs().get(1).getModelInfo()
+ .setModelCustomizationId("88a3096a-af87-4853-99f6-7256a9ab6c3e");
+ info.getUserParams().getResources().getPnfs().get(1).setInstanceName("new-pnf-instance-name");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameDifferentCustomizationIdPnfTest() throws IOException, ValidationException {
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json");
+ info.getUserParams().getResources().getPnfs().get(0).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
public void validateInstanceNameExceptionTest() throws IOException, ValidationException {
thrown.expect(ValidationException.class);
thrown.expectMessage("instanceName in requestInfo does not match instanceName in userParams service");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json
new file mode 100644
index 0000000000..b5fb6a8d41
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNamesPnf.json
@@ -0,0 +1,91 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelInvariantId": "d6f8f4e8-7de9-47c1-aa5c-4b6868738f5c",
+ "modelType": "service",
+ "modelName": "service_pnf_2305",
+ "modelVersion": "2.0",
+ "modelVersionId": "e199ca4e-08f9-4f10-a15d-b94d50e52a6a",
+ "modelUuid": "e199ca4e-08f9-4f10-a15d-b94d50e52a6a",
+ "modelInvariantUuid": "d6f8f4e8-7de9-47c1-aa5c-4b6868738f5c"
+ },
+ "requestInfo": {
+ "productFamilyId": "5G",
+ "source": "VID",
+ "instanceName": "ORAN_SIM1_2106_1",
+ "suppressRollback": false,
+ "requestorId": "NBI"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "5GCustomer"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "5G",
+ "userParams": [{
+ "service": {
+ "modelInfo": {
+ "modelVersionId": "e199ca4e-08f9-4f10-a15d-b94d50e52a6a",
+ "modelName": "service_pnf_2305",
+ "modelType": "service"
+ },
+ "instanceName": "ORAN_SIM1_2106_1",
+ "instanceParams": [],
+ "resources": {
+ "pnfs": [{
+ "modelInfo": {
+ "modelCustomizationName": "pnf_only_2305 0",
+ "modelCustomizationId": "88a3096a-af87-4853-99f6-7256a9ab6c3e",
+ "modelInvariantId": "d6f8f4e8-7de9-47c1-aa5c-4b6868738f5c",
+ "modelVersionId": "a6a9dc3d-204c-4dbb-862b-46214788b0e5",
+ "modelName": "service_pnf_2305",
+ "modelType": "pnf",
+ "modelVersion": "2.0"
+ },
+ "platform": {
+ "platformName": "test"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "LOB-5GCustomer"
+ },
+ "productFamilyId": "5G",
+ "instanceParams": [],
+ "instanceName": "ORAN_SIM1_2106_pnf_01",
+ "processingPriority": 1
+ }, {
+ "modelInfo": {
+ "modelCustomizationName": "pnf_only_2305 0",
+ "modelCustomizationId": "different-model-info",
+ "modelInvariantId": "d6f8f4e8-7de9-47c1-aa5c-4b6868738f5c",
+ "modelVersionId": "a6a9dc3d-204c-4dbb-862b-46214788b0e5",
+ "modelName": "service_pnf_2305",
+ "modelType": "pnf",
+ "modelVersion": "2.0"
+ },
+ "platform": {
+ "platformName": "test"
+ },
+ "lineOfBusiness": {
+ "lineOfBusinessName": "LOB-5GCustomer"
+ },
+ "productFamilyId": "5G",
+ "instanceParams": [],
+ "instanceName": "ORAN_SIM1_2106_pnf_01",
+ "processingPriority": 2
+ }]
+ }
+ }
+ }, {
+ "Homing_Solution": "none"
+ }],
+ "aLaCarte": false,
+ "usePreload": false
+ },
+ "project": {
+ "projectName": "basicnw-project"
+ },
+ "owningEntity": {
+ "owningEntityId": "67f2e84c-734d-4e90-a1e4-d2ffa2e75849",
+ "owningEntityName": "OE-5GCustomer"
+ }
+ }
+} \ No newline at end of file