diff options
author | Steve Smokowski <ss835w@att.com> | 2019-02-22 15:14:25 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-02-22 15:14:25 +0000 |
commit | e82e1e68a19a3700030ebc3247ed562618cacfe4 (patch) | |
tree | 244a93378403dc7a22f7d7631e1b26b35cae683f /mso-api-handlers/mso-api-handler-infra | |
parent | d35a30a42edab60d8801bb3a2060548e2b9d1d35 (diff) | |
parent | 9484ccd079c2818f040a9b15fe744f6845efb76a (diff) |
Merge "assignvfmodulebb must send use-preload"
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
5 files changed, 232 insertions, 5 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java index c717999fbd..0b438a1b17 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java @@ -72,9 +72,19 @@ public class RequestParametersValidation implements ValidationRule{ } } if(requestScope.equalsIgnoreCase(ModelType.vfModule.name())){ - if(action == Action.createInstance || action == Action.updateInstance){ - if(requestParameters.isUsePreload() == null){ - requestParameters.setUsePreload(true); + if(action == Action.createInstance || action == Action.updateInstance){ + if(requestParameters.isUsePreload() == null){ + if(reqVersion >= 4){ + if (requestParameters.getALaCarte() == false) { + requestParameters.setUsePreload(false); + } + else { + requestParameters.setUsePreload(true); + } + } + else { + requestParameters.setUsePreload(true); + } } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java new file mode 100644 index 0000000000..3fc5a16d9d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.validation; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; + +import org.junit.Test; +import org.onap.so.apihandlerinfra.Action; +import org.onap.so.apihandlerinfra.BaseTest; +import org.onap.so.exceptions.ValidationException; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class RequestParametersValidationTest extends BaseTest{ + + @Test + public void testVfModuleWithFalseALaCarte() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleModelVersionId.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + sir.getRequestDetails().getRequestParameters().setUsePreload(null); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 6, false, sir.getRequestDetails().getRequestParameters()); + info.setRequestScope("vfModule"); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + + assertFalse(info.getReqParameters().getUsePreload()); + } + + @Test + public void testVfModuleWithTrueALaCarte() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + sir.getRequestDetails().getRequestParameters().setUsePreload(null); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 6, true, sir.getRequestDetails().getRequestParameters()); + info.setRequestScope("vfModule"); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + + assertTrue(info.getReqParameters().getUsePreload()); + } + + @Test + public void testVfModuleWithReqVersionBelow4() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleModelVersionId.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + sir.getRequestDetails().getRequestParameters().setUsePreload(null); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 3, false, sir.getRequestDetails().getRequestParameters()); + info.setRequestScope("vfModule"); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + + assertTrue(info.getReqParameters().getUsePreload()); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json new file mode 100644 index 0000000000..37da8af534 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json @@ -0,0 +1,129 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelName": "MOW vMX BV 1 Service", + "modelVersion": "10" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "{some project name}" + }, + "subscriberInfo": { + "globalSubscriberId": "{some subscriber id}" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "xxxxxx" + }, + "requestParameters": { + "subscriptionServiceType": "VMX", + "aLaCarte": true, + "userParams": [ + { + "service": { + "modelInfo": { + "modelName": "MOW vMX BV 1 Service", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelCustomizationId": "3c40d244-808e-42ca-b09a-256d83d19d0b" + }, + "instanceParams": [], + "resources": { + "vnfs": [ + { + "modelInfo": { + "modelCustomizationName": "2016-73_MOW-BV-L 0", + "modelName": "2016-73_MOW-BV-L", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelCustomizationId": "ab153b6e-c364-44c0-bef6-1f2982117f04" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "platform": { + "platformName": "someValue" + }, + "lineOfBusiness": { + "lineOfBusinessName": "someValue" + }, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "instanceParams": [ + { + "instanceName": "someVnfInstanceName" + } + ], + "vfModules": [ + { + "modelInfo": { + "modelName": "201673MowBvL._base_BV..module-0", + "modelCustomizationId": "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f" + }, + "instanceParams": [ + { + "vmx_int_net_len": "24", + "asn": "someValue" + } + ] + }, + { + "modelInfo": { + "modelName": "201673MowBvL._vRE_BV..module-1", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", + "modelType": "vfModule" + }, + "instanceParams": [ + { + "availability_zone_0": "mtpocdv-kvm-az01", + "vre_a_volume_size_0": "100" + } + ] + }, + { + "modelInfo": { + "modelName": "201673MowBvL._vRE_BV..module-1", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelCustomizationId": "72d9d1cd-f46d-447a-abdb-451d6fb05fa8" + }, + "instanceParams": [ + { + "availability_zone_0": "mtpocdv-kvm-az01", + "vre_a_volume_size_0": "50" + } + ] + }, + { + "modelInfo": { + "modelName": "201673MowBvL._vPFE_BV..module-2", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelCustomizationId": "da4d4327-fb7d-4311-ac7a-be7ba60cf969" + }, + "instanceParams": [ + { + "availability_zone_0": "mtpocdv-kvm-az01", + "vmx_vpfe_int_ip_0": "192.168.0.16" + } + ] + } + ] + } + ] + } + } + } + ] + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleInvalid.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleInvalid.json index ed77f9b9fb..866481ada9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleInvalid.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleInvalid.json @@ -15,7 +15,7 @@ "tenantId": "8b1df54faa3b49078e3416e21370a3ba" }, "requestParameters": { - "aLaCarte": false, + "aLaCarte": true, "autoBuildVfModules": false, "subscriptionServiceType": "test" }, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleNoModelCustomization.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleNoModelCustomization.json index a6b2b0bd2f..fc2940223f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleNoModelCustomization.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleNoModelCustomization.json @@ -15,7 +15,7 @@ "tenantId": "8b1df54faa3b49078e3416e21370a3ba" }, "requestParameters": { - "aLaCarte": false, + "aLaCarte": true, "autoBuildVfModules": false, "subscriptionServiceType": "test" }, |