From ea65e0397e030bbd0a685f473b1c8416dd0a82f3 Mon Sep 17 00:00:00 2001 From: Aleem Raja Date: Wed, 10 Aug 2022 21:20:12 +0530 Subject: Multiple PNFs with same ModelInfo but different instance name not able to be instantiated When instantiating a service with multiple PNFs, SO differentiates them using ModelCustomizationId. This causes issues when creating multiple instances of same model resource, and each lookup would return the same object. With this patch, Instead of using ModelCustomizationId, we enable SO to use instanceName parameter to differentiate the PNFs. Issue-ID: SO-3948 Signed-off-by: Aleem Raja Change-Id: I9dd039ac786a60f7cf4d4a9c456c7681f64d6786 --- .../validation/UserParamsValidationTest.java | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org') 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 @@ -242,6 +242,75 @@ public class UserParamsValidationTest { validation.validate(info); } + @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); -- cgit 1.2.3-korg