aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-20 16:48:49 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-02-20 16:49:04 -0500
commit9484ccd079c2818f040a9b15fe744f6845efb76a (patch)
tree66bbf524379a0f76aa5dba2f96561921cddebba3
parent860edae04456562fd7cf249968cd54b30b1f7f12 (diff)
assignvfmodulebb must send use-preload
Corrections to JUnit data to account for usePreload usage. Resurrect usage of usePreload value and pass fromPreload to SDNC. Change-Id: I6fb52f6abf09ec501e90335a01e37db1c10ae2b3 Issue-ID: SO-1539 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java16
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java22
-rw-r--r--bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqParameters.json37
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java10
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java148
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json2
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java28
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java88
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json129
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleInvalid.json2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/VfModuleNoModelCustomization.json2
15 files changed, 486 insertions, 20 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java
index 5e49ffcf40..1e390701df 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java
@@ -49,6 +49,8 @@ public class RequestParameters implements Serializable {
private Boolean aLaCarte;
@JsonProperty("payload")
private String payload;
+ @JsonProperty("usePreload")
+ private Boolean usePreload;
public String getSubscriptionServiceType() {
return subscriptionServiceType;
@@ -95,6 +97,20 @@ public class RequestParameters implements Serializable {
}
return null;
}
+
+ public Boolean isUsePreload() {
+ return usePreload;
+ }
+
+ @JsonProperty("usePreload")
+ public Boolean getUsePreload() {
+ return usePreload;
+ }
+
+ @JsonProperty("usePreload")
+ public void setUsePreload(Boolean usePreload) {
+ this.usePreload = usePreload;
+ }
@JsonInclude(Include.NON_NULL)
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
index 1e77c35ee3..641f7f557c 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java
@@ -346,6 +346,7 @@ public class BBInputSetupMapperLayer {
protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
RequestParameters requestParams = new RequestParameters();
requestParams.setaLaCarte(requestParameters.getALaCarte());
+ requestParams.setUsePreload(requestParameters.getUsePreload());
requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
requestParams.setUserParams(requestParameters.getUserParams());
requestParams.setPayload(requestParameters.getPayload());
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
index 1babac68ca..7e76e52959 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
@@ -23,6 +23,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -53,6 +54,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
@@ -653,4 +655,24 @@ public class BBInputSetupMapperLayerTest {
assertFalse(actual.containsValue("ignore"));
}
+ @Test
+ public void testMapRequestParameters() throws IOException {
+ RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
+ RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
+
+ assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
+ assertEquals(actual.getSubscriptionServiceType(), requestDetails.getRequestParameters().getSubscriptionServiceType());
+ assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
+ }
+
+ protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setaLaCarte(requestParameters.getALaCarte());
+ requestParams.setUsePreload(requestParameters.getUsePreload());
+ requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
+ requestParams.setUserParams(requestParameters.getUserParams());
+ requestParams.setPayload(requestParameters.getPayload());
+ return requestParams;
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqParameters.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqParameters.json
new file mode 100644
index 0000000000..788c27b3fe
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_mapReqParameters.json
@@ -0,0 +1,37 @@
+{
+ "requestInfo": {
+ "callbackUrl": "callbackURL",
+ "productFamilyId": "productFamilyId",
+ "source": "source",
+ "suppressRollback": false,
+ "requestorId": "requestorId"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "subscriptionServiceType",
+ "aLaCarte": false,
+ "usePreload": false,
+ "payload": "string123",
+ "userParams": [
+ {
+ "name": "name1",
+ "value": "value1"
+ },
+ {
+ "name": "name2",
+ "value": "value2"
+ },
+ {
+ "ignore": "false",
+ "skip": "ignore"
+ }
+ ]
+
+ },
+ "configurationParameters": [
+ {
+ "availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]",
+ "xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"
+ }
+ ]
+}
+
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
index 9bbd665e4c..d7a9ff1cf7 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapper.java
@@ -115,7 +115,7 @@ public class GeneralTopologyObjectMapper {
/*
* Build GenericResourceApiVfModuleinformationVfModuleInformation
*/
- public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, boolean includeModelInformation) throws MapperException {
+ public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, boolean includeModelInformation) throws MapperException {
GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = new GenericResourceApiVfmoduleinformationVfModuleInformation();
if (includeModelInformation) {
if (vfModule.getModelInfoVfModule() == null) {
@@ -135,7 +135,13 @@ public class GeneralTopologyObjectMapper {
vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
}
vfModuleInformation.setVfModuleId(vfModule.getVfModuleId());
- vfModuleInformation.setFromPreload(null);
+ if (requestContext != null && requestContext.getRequestParameters() != null) {
+ vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload());
+ }
+ else {
+ vfModuleInformation.setFromPreload(null);
+ }
+
return vfModuleInformation;
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
index a6ef02bd4d..b656579c69 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java
@@ -95,7 +95,7 @@ public class VfModuleTopologyOperationRequestMapper {
requestAction);
GenericResourceApiServiceinformationServiceInformation serviceInformation = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, includeModelInformation);
GenericResourceApiVnfinformationVnfInformation vnfInformation = generalTopologyObjectMapper.buildVnfInformation(vnf, serviceInstance, includeModelInformation);
- GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper.buildVfModuleInformation(vfModule, vnf, serviceInstance, includeModelInformation);
+ GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = generalTopologyObjectMapper.buildVfModuleInformation(vfModule, vnf, serviceInstance, requestContext, includeModelInformation);
GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext);
GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
index ba7dc8d618..c039e308f8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/GeneralTopologyObjectMapperTest.java
@@ -22,9 +22,11 @@ package org.onap.so.client.sdnc.mapper;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import java.util.HashMap;
@@ -43,6 +45,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleinformationVfModuleInformation;
import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfinformationVnfInformation;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
@@ -51,10 +54,14 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
+import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.beans.SDNCSvcAction;
@@ -278,4 +285,145 @@ public class GeneralTopologyObjectMapperTest extends TestDataSetup {
assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
}
+
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelIsFromPreload() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ }
+ catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelIsNotFromPreload() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(false);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ }
+ catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertFalse(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelNoRequestContext() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, null, false);
+ }
+ catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertNull(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withNoModelNoRequestParameters() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, false);
+ }
+ catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNull(vfModule.getModelInfoVfModule());
+ assertNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertNull(gcRequestInput.getFromPreload());
+ }
+
+ @Test
+ public void buildVfModuleInformationTest_withModel() {
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("TestVfModuleId");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID");
+ modelInfoVfModule.setModelName("testModelName");
+ modelInfoVfModule.setModelVersion("testModelVersion");
+ modelInfoVfModule.setModelUUID("testModelUUID");
+ modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID");
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TestVnfId");
+ RequestContext requestContext = new RequestContext();
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
+ GenericResourceApiVfmoduleinformationVfModuleInformation gcRequestInput = null;
+ try {
+ gcRequestInput = genObjMapper.buildVfModuleInformation(vfModule, genericVnf, serviceInstance, requestContext, true);
+ }
+ catch (MapperException ex) {
+
+ }
+ assertNotNull(gcRequestInput);
+ assertNotNull(vfModule.getModelInfoVfModule());
+ assertNotNull(gcRequestInput.getOnapModelInformation());
+ assertEquals(modelInfoVfModule.getModelInvariantUUID(), gcRequestInput.getOnapModelInformation().getModelInvariantUuid());
+ assertEquals(modelInfoVfModule.getModelName(), gcRequestInput.getOnapModelInformation().getModelName());
+ assertEquals(modelInfoVfModule.getModelVersion(), gcRequestInput.getOnapModelInformation().getModelVersion());
+ assertEquals(modelInfoVfModule.getModelUUID(), gcRequestInput.getOnapModelInformation().getModelUuid());
+ assertEquals(modelInfoVfModule.getModelCustomizationUUID(), gcRequestInput.getOnapModelInformation().getModelCustomizationUuid());
+ assertEquals(vfModule.getVfModuleId(),gcRequestInput.getVfModuleId());
+ assertNotNull(gcRequestInput.getVfModuleId());
+ assertTrue(gcRequestInput.getFromPreload());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
index f492ba3ead..7d5aa9d1d9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java
@@ -88,6 +88,9 @@ public class VfModuleTopologyOperationRequestMapperTest {
userParams.put("key1", "value1");
requestContext.setUserParams(userParams);
requestContext.setProductFamilyId("productFamilyId");
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUsePreload(true);
+ requestContext.setRequestParameters(requestParameters);
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("testVnfId");
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json
index a344e8081e..777f3444d2 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json
@@ -55,7 +55,7 @@
"model-invariant-uuid" : "vfModuleModelInvariantUuid"
},
"vf-module-id" : "testVfModuleId",
- "from-preload" : null,
+ "from-preload" : true,
"vf-module-type": "vfModuleModelName"
},
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
index 4dfa1d4130..45f1accf2f 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
@@ -44,6 +44,8 @@ public class RequestParameters implements Serializable {
private Boolean aLaCarte;
@JsonProperty("payload")
private String payload;
+ @JsonProperty("usePreload")
+ private Boolean usePreload; // usePreload would always be true for Update
// DONOT USE. It is intended to handle older VID requests(prior to 1802)
@Deprecated
@@ -55,8 +57,6 @@ public class RequestParameters implements Serializable {
private Boolean cascadeDelete;
@JsonProperty("testApi")
private String testApi; // usePreload would always be true for Update
- @JsonProperty("usePreload")
- private Boolean usePreload; // usePreload would always be true for Update
@JsonProperty("rebuildVolumeGroups")
private Boolean rebuildVolumeGroups;
@@ -86,6 +86,20 @@ public class RequestParameters implements Serializable {
public void setPayload(String value){
this.payload = value;
}
+
+ public Boolean isUsePreload() {
+ return usePreload;
+ }
+
+ @JsonProperty("usePreload")
+ public Boolean getUsePreload() {
+ return usePreload;
+ }
+
+ @JsonProperty("usePreload")
+ public void setUsePreload(Boolean usePreload) {
+ this.usePreload = usePreload;
+ }
@Deprecated
@Transient
@@ -141,15 +155,7 @@ public class RequestParameters implements Serializable {
public void setCascadeDelete(Boolean cascadeDelete) {
this.cascadeDelete = cascadeDelete;
- }
-
- public Boolean isUsePreload() {
- return usePreload;
- }
-
- public void setUsePreload(Boolean usePreload) {
- this.usePreload = usePreload;
- }
+ }
public Boolean getRebuildVolumeGroups() {
return rebuildVolumeGroups;
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"
},