aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java/org
diff options
context:
space:
mode:
authorMichael Pruss <michael.pruss@bell.ca>2021-05-31 18:28:08 -0400
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-07-30 12:24:31 -0400
commited5c51313c1bd3745a554888c969e840341599b0 (patch)
tree27b6ed17d52f0d8b14428c98b0886d60a70670bc /mso-api-handlers/mso-api-handler-infra/src/test/java/org
parent1be8408f26d3f20cf2ffb923a956b7ba6dfbd994 (diff)
Support instantiation of same model vnfs/vf-modules
When instantiating a service with multiple vnfs and/or vfmodules SO would differentiate using ModelCustomizationId. This would cause issues when creating multiple instances of same model resource, and each lookup would return the same object. Instead of using ModelCustomizationId, this patch enables SO to use instanceName parameter to differentiate the resources. Validation was added to ensure that instanceNames are provided if there are multiple resources of the same model. If there are no duplicate resources and instanceName is not set, SO will default to previous logic using ModelCustomizationId. In order to properly associate vfmodules with their parent vnfs, the Resource class was augmented with a parent reference which maintains the relationship in further processing. Id generation logic was corrected to ensure that multiple resources of the same model are assigned unique instance ids and references to parent instanceId. Issue-ID: SO-3677 Change-Id: If39a0138f501177e12262f8e911137012e287fca Signed-off-by: Michael Pruss <michael.pruss@bell.ca>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/UserParamsValidationTest.java177
1 files changed, 177 insertions, 0 deletions
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 ba02254ad8..548b957303 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
@@ -32,6 +32,7 @@ import org.onap.so.exceptions.ValidationException;
import org.onap.so.serviceinstancebeans.Service;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.serviceinstancebeans.VfModules;
public class UserParamsValidationTest {
@@ -66,6 +67,182 @@ public class UserParamsValidationTest {
}
@Test
+ public void validateDuplicateInstanceNameDifferentCustomizationIdVnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName but different modelCustomizationId (instanceName should be unique) in userParams vnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(0).setInstanceName("UbuntuVNF2");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateInstanceNameSameCustomizationIdVnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams vnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(2).setInstanceName("UbuntuVNF2");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameSameCustomizationIdVnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: instanceName is missing or empty with same modelCustomizationId in userParams vnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(1).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateNullInstanceNameSameCustomizationIdVnfTest() throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams vnf resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(1).setInstanceName(null);
+ info.getUserParams().getResources().getVnfs().get(2).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDifferentInstanceNameSameCustomizationIdVnfTest() throws IOException, ValidationException {
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameDifferentCustomizationIdVnfTest() throws IOException, ValidationException {
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(0).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateInstanceNameDifferentCustomizationIdVfModuleInOneVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName but different modelCustomizationId (instanceName should be unique) in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(2).getVfModules().get(2).setInstanceName("lcm-demo-ubuntu-3");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateInstanceNameDifferentCustomizationIdVfModuleInMultipleVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName but different modelCustomizationId (instanceName should be unique) in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(0).getVfModules().get(0).setInstanceName("lcm-demo-ubuntu-3");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateInstanceNameSameCustomizationIdVfModuleInOneVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(2).getVfModules().get(1).setInstanceName("lcm-demo-ubuntu-2");
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateInstanceNameSameCustomizationIdVfModuleInMultipleVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ VfModules vfModule1 = info.getUserParams().getResources().getVnfs().get(0).getVfModules().get(0);
+ VfModules vfModule2 = info.getUserParams().getResources().getVnfs().get(1).getVfModules().get(0);
+ vfModule2.setInstanceName(vfModule1.getInstanceName());
+ vfModule2.getModelInfo().setModelCustomizationId(vfModule1.getModelInfo().getModelCustomizationId());
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameSameCustomizationIdVfModuleInOneVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: instanceName is missing or empty with same modelCustomizationId in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ info.getUserParams().getResources().getVnfs().get(2).getVfModules().get(1).setInstanceName(null);
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameSameCustomizationIdVfModuleInMultipleVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: instanceName is missing or empty with same modelCustomizationId in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ VfModules vfModule1 = info.getUserParams().getResources().getVnfs().get(0).getVfModules().get(0);
+ VfModules vfModule2 = info.getUserParams().getResources().getVnfs().get(1).getVfModules().get(0);
+ vfModule2.setInstanceName(null);
+ vfModule2.getModelInfo().setModelCustomizationId(vfModule1.getModelInfo().getModelCustomizationId());
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateDuplicateNullInstanceNameSameCustomizationIdVfModuleInMultipleVnfTest()
+ throws IOException, ValidationException {
+ thrown.expect(ValidationException.class);
+ thrown.expectMessage(
+ "No valid instanceName: same instanceName with same modelCustomizationId in userParams vfModule resources is specified");
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ VfModules vfModule1 = info.getUserParams().getResources().getVnfs().get(0).getVfModules().get(0);
+ VfModules vfModule2 = info.getUserParams().getResources().getVnfs().get(1).getVfModules().get(0);
+ vfModule1.setInstanceName(null);
+ vfModule2.setInstanceName(null);
+ vfModule2.getModelInfo().setModelCustomizationId(vfModule1.getModelInfo().getModelCustomizationId());
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateInstanceNameSameCustomizationIdVfModuleInVnfTest() throws IOException, ValidationException {
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ VfModules vfModule1 = info.getUserParams().getResources().getVnfs().get(0).getVfModules().get(0);
+ VfModules vfModule2 = info.getUserParams().getResources().getVnfs().get(1).getVfModules().get(0);
+ vfModule2.getModelInfo().setModelCustomizationId(vfModule1.getModelInfo().getModelCustomizationId());
+ validation.validate(info);
+ }
+
+ @Test
+ public void validateNullInstanceNameDifferentCustomizationIdVfModuleInVnfTest()
+ throws IOException, ValidationException {
+ ValidationInformation info = setupValidationInformation(
+ "src/test/resources/Validation/UserParamsValidation/DuplicateInstanceNames.json");
+ VfModules vfModule1 = info.getUserParams().getResources().getVnfs().get(0).getVfModules().get(0);
+ vfModule1.setInstanceName(null);
+ VfModules vfModule2 = info.getUserParams().getResources().getVnfs().get(2).getVfModules().get(2);
+ vfModule2.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");