summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java14
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtils.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelPnfs.json91
-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
12 files changed, 337 insertions, 3 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
index cb4bd81918..aa5da4c790 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
@@ -35,6 +35,7 @@ public enum ResourceKey {
VPN_BONDING_LINK_ID,
INSTANCE_GROUP_ID,
PNF,
+ PNF_INSTANCE_NAME,
VNF_INSTANCE_NAME,
VF_MODULE_INSTANCE_NAME,
CHILD_SERVICE_INSTANCE_ID,
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
index cfcc1f9f3b..a44d5e972d 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
@@ -44,6 +44,7 @@ public class WorkflowResourceIds implements Serializable {
private String vfModuleInstanceName;
private String childServiceInstanceId;
private String childServiceInstanceName;
+ private String pnfInstanceName;
@@ -178,4 +179,12 @@ public class WorkflowResourceIds implements Serializable {
public void setChildServiceInstanceName(String childServiceInstanceName) {
this.childServiceInstanceName = childServiceInstanceName;
}
+
+ public String getPnfInstanceName() {
+ return pnfInstanceName;
+ }
+
+ public void setPnfInstanceName(String pnfInstanceName) {
+ this.pnfInstanceName = pnfInstanceName;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index b29b95a3b1..a0784b375e 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -264,6 +264,7 @@ public class BBInputSetup implements JavaDelegate {
lookupKeyMap.put(ResourceKey.VF_MODULE_INSTANCE_NAME, workflowResourceIds.getVfModuleInstanceName());
lookupKeyMap.put(ResourceKey.CHILD_SERVICE_INSTANCE_ID, workflowResourceIds.getChildServiceInstanceId());
lookupKeyMap.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, workflowResourceIds.getChildServiceInstanceName());
+ lookupKeyMap.put(ResourceKey.PNF_INSTANCE_NAME, workflowResourceIds.getPnfInstanceName());
}
protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB,
@@ -1634,9 +1635,16 @@ public class BBInputSetup implements JavaDelegate {
} else if (bbName.contains(PNF) || (bbName.contains(CONTROLLER)
&& (PNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
String pnfId = lookupKeyMap.get(ResourceKey.PNF);
- resources.getPnfs().stream()
- .filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst()
- .ifPresent(pnfs -> BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance));
+ String pnfInstanceName = lookupKeyMap.get(ResourceKey.PNF_INSTANCE_NAME);
+ if (StringUtils.isNotBlank(pnfInstanceName)) {
+ resources.getPnfs().stream().filter(pnfs -> Objects.equals(pnfInstanceName, pnfs.getInstanceName()))
+ .findFirst()
+ .ifPresent(pnfs -> BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance));
+ } else {
+ resources.getPnfs().stream()
+ .filter(pnfs -> Objects.equals(key, pnfs.getModelInfo().getModelCustomizationId())).findFirst()
+ .ifPresent(pnfs -> BBInputSetupPnf.populatePnfToServiceInstance(pnfs, pnfId, serviceInstance));
+ }
} else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP) || (bbName.contains(CONTROLLER)
&& (VF_MODULE).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) {
String vfModuleInstanceName = lookupKeyMap.get(ResourceKey.VF_MODULE_INSTANCE_NAME);
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 7f066af080..803d2bf8a3 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
@@ -2123,6 +2123,7 @@ public class BBInputSetupTest {
String vfModuleInstanceName = "vfModuleInstanceName";
String childServiceInstanceId = "childServiceInstanceId";
String childServiceInstanceName = "childServiceInstanceName";
+ String pnfInstanceName = "pnfInstanceName";
expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
expected.put(ResourceKey.NETWORK_ID, networkId);
@@ -2136,6 +2137,7 @@ public class BBInputSetupTest {
expected.put(ResourceKey.VF_MODULE_INSTANCE_NAME, vfModuleInstanceName);
expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_ID, childServiceInstanceId);
expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, childServiceInstanceName);
+ expected.put(ResourceKey.PNF_INSTANCE_NAME, pnfInstanceName);
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
@@ -2150,6 +2152,7 @@ public class BBInputSetupTest {
workflowResourceIds.setVfModuleInstanceName(vfModuleInstanceName);
workflowResourceIds.setChildServiceInstanceId(childServiceInstanceId);
workflowResourceIds.setChildServiceInstanceName(childServiceInstanceName);
+ workflowResourceIds.setPnfInstanceName(pnfInstanceName);
SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
index b56bd905a6..466b49644f 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversal.java
@@ -246,6 +246,7 @@ public class UserParamsServiceTraversal {
pnfResource.setModelCustomizationId(modelInfo.getModelCustomizationUuid());
pnfResource.setModelVersionId(modelInfo.getModelVersionId());
}
+ pnfResource.setInstanceName(pnf.getInstanceName());
pnfResource.setProcessingPriority(pnf.getProcessingPriority());
resourceList.add(pnfResource);
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtils.java
index 9cabf6665c..f3aafde2a2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtils.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtils.java
@@ -70,6 +70,8 @@ public final class WorkflowResourceIdsUtils {
workflowResourceIds.setVnfInstanceName(instanceName);
} else if (resourceType == WorkflowType.VFMODULE) {
workflowResourceIds.setVfModuleInstanceName(instanceName);
+ } else if (resourceType == WorkflowType.PNF) {
+ workflowResourceIds.setPnfInstanceName(instanceName);
}
}
@@ -110,6 +112,7 @@ public final class WorkflowResourceIdsUtils {
workflowResourceIds.setInstanceGroupId((String) execution.getVariable("instanceGroupId"));
workflowResourceIds.setVnfInstanceName((String) execution.getVariable("vnfInstanceName"));
workflowResourceIds.setVfModuleInstanceName((String) execution.getVariable("vfModuleInstanceName"));
+ workflowResourceIds.setPnfInstanceName((String) execution.getVariable("pnfInstanceName"));
return workflowResourceIds;
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
index cac7f872b3..cf6588e113 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
@@ -66,6 +66,7 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest {
private static final String MACRO_CREATE_WITHOUT_RESOURCES_JSON = "Macro/ServiceMacroCreateWithoutResources.json";
private static final String MACRO_CREATE_SVC_SAME_MODEL_VNF_VFMODULE =
"Macro/ServiceMacroCreateMultipleSameModelVnfsAndVfModules.json";
+ private static final String MACRO_CREATE_SVC_SAME_MODEL_PNF = "Macro/ServiceMacroCreateMultipleSameModelPnfs.json";
private static final String serviceInstanceId = "123";
private DelegateExecution execution;
private CatalogDbClient mockCatalogDbClient;
@@ -149,6 +150,30 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest {
}
@Test
+ public void getResourceListFromUserParamsMultiplePnfs() throws Exception {
+ initExecution("createInstance", readBpmnRequestFromFile(MACRO_CREATE_SVC_SAME_MODEL_PNF), false);
+
+ List<Resource> resourceListFromUserParams = userParamsServiceTraversal.getResourceListFromUserParams(execution,
+ getUserParams(), serviceInstanceId, requestAction);
+
+ assertEquals(3, resourceListFromUserParams.size());
+
+ Resource service = resourceListFromUserParams.get(0);
+ assertTrue(service.getResourceType() == WorkflowType.SERVICE);
+ assertEquals(2, service.getChildren().size());
+
+ Resource pnf1 = service.getChildren().get(0);
+ assertEquals(service, pnf1.getParent());
+ assertEquals("ORAN_SIM1_2106_pnf_01", pnf1.getInstanceName());
+ assertEquals("88a3096a-af87-4853-99f6-7256a9ab6c3e", pnf1.getResourceId());
+
+ Resource pnf2 = service.getChildren().get(1);
+ assertEquals(service, pnf2.getParent());
+ assertEquals("ORAN_SIM1_2106_pnf_02", pnf2.getInstanceName());
+ assertEquals("88a3096a-af87-4853-99f6-7256a9ab6c3e", pnf2.getResourceId());
+ }
+
+ @Test
public void getResourceListFromUserParamsForVnfs() throws Exception {
initExecution(requestAction, readBpmnRequestFromFile(MACRO_ASSIGN_JSON), false);
Mockito.doReturn(getVfModuleCustomization("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", true))
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java
index 996c0c07e1..f8bd963c49 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/utils/WorkflowResourceIdsUtilsTest.java
@@ -42,6 +42,7 @@ public class WorkflowResourceIdsUtilsTest {
private static final String CONFIGURATION_ID = "configurationId";
private static final String VNF_INSTANCE_NAME = "vnfInstanceNameId";
private static final String VF_MODULE_INSTANCE_NAME = "vfModuleInstanceNameId";
+ private static final String PNF_INSTANCE_NAME = "pnfInstanceNameId";
private WorkflowResourceIds workflowResourceIds;
@Before
@@ -60,6 +61,7 @@ public class WorkflowResourceIdsUtilsTest {
execution.setVariable("instanceGroupId", INSTANCE_GROUP_ID);
execution.setVariable("vnfInstanceName", VNF_INSTANCE_NAME);
execution.setVariable("vfModuleInstanceName", VF_MODULE_INSTANCE_NAME);
+ execution.setVariable("pnfInstanceName", PNF_INSTANCE_NAME);
workflowResourceIds = WorkflowResourceIdsUtils.getWorkflowResourceIdsFromExecution(execution);
@@ -71,6 +73,7 @@ public class WorkflowResourceIdsUtilsTest {
assertEquals(INSTANCE_GROUP_ID, workflowResourceIds.getInstanceGroupId());
assertEquals(VNF_INSTANCE_NAME, workflowResourceIds.getVnfInstanceName());
assertEquals(VF_MODULE_INSTANCE_NAME, workflowResourceIds.getVfModuleInstanceName());
+ assertEquals(PNF_INSTANCE_NAME, workflowResourceIds.getPnfInstanceName());
}
@Test
@@ -149,6 +152,12 @@ public class WorkflowResourceIdsUtilsTest {
workflowResourceIds::getVfModuleInstanceName);
}
+ @Test
+ public void shouldPropertySetPnfInstanceName() {
+ assertFieldSetProperlyInstanceName(WorkflowType.PNF, PNF_INSTANCE_NAME,
+ workflowResourceIds::getPnfInstanceName);
+ }
+
private void assertFieldSetProperly(WorkflowType workflowType, String expectedId,
Supplier<String> testedObjectField) {
WorkflowResourceIdsUtils.setResourceIdByWorkflowType(workflowResourceIds, workflowType, expectedId);
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelPnfs.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelPnfs.json
new file mode 100644
index 0000000000..4eb6faee64
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateMultipleSameModelPnfs.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": "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_02",
+ "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
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