aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java16
3 files changed, 34 insertions, 10 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 2dab494b07..ec1c4cb362 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -1125,12 +1125,16 @@ public class ServiceInstances {
mapper.setSerializationInclusion(Include.NON_NULL);
if(msoRawRequest != null){
ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
- if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null &&
+ if( serviceInstRequest != null &&
serviceInstRequest.getRequestDetails() != null &&
serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
- sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
- sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ if( !isAlaCarte && Action.createInstance.equals(action)) {
+ sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
+ sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ }
+ sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload());
}
+
logger.debug("Value as string: {}", mapper.writeValueAsString(sir));
return mapper.writeValueAsString(sir);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 23974ef1fa..d6c794ef2e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -194,6 +194,24 @@ public class ServiceInstancesTest extends BaseTest{
assertEquals("10",modelInfo.getModelUuid());
}
+
+
+ @Test
+ public void test_mapJSONtoMSOStyleUsePreload() throws IOException{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ String testRequest= inputStream("/ServiceInstanceDefault.json");
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails rd = new RequestDetails();
+ RequestParameters rp = new RequestParameters();
+ rp.setUsePreload(true);
+ rd.setRequestParameters(rp);
+ sir.setRequestDetails(rd);
+ String resultString = servInstances.mapJSONtoMSOStyle(testRequest, sir, false, null);
+ ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class);
+ assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload());
+ }
+
@Test
public void createServiceInstanceVIDDefault() throws IOException{
TestAppender.events.clear();
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
index 8d456e3f68..bd9b95dc12 100644
--- 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
@@ -50,7 +50,7 @@ public class RequestParametersValidationTest extends BaseTest{
sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
-
+ assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertFalse(info.getReqParameters().getUsePreload());
}
@@ -66,7 +66,8 @@ public class RequestParametersValidationTest extends BaseTest{
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
- assertTrue(info.getReqParameters().getUsePreload());
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
+ assertTrue(info.getReqParameters().getUsePreload());
}
@Test
@@ -82,6 +83,7 @@ public class RequestParametersValidationTest extends BaseTest{
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertTrue(info.getReqParameters().getUsePreload());
}
@@ -97,7 +99,7 @@ public class RequestParametersValidationTest extends BaseTest{
sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
-
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertTrue(info.getReqParameters().getUsePreload());
}
@@ -113,7 +115,7 @@ public class RequestParametersValidationTest extends BaseTest{
info.setRequestScope("service");
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
-
+ assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertFalse(info.getReqParameters().getUsePreload());
}
@@ -129,7 +131,7 @@ public class RequestParametersValidationTest extends BaseTest{
info.setRequestScope("service");
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
-
+ assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertFalse(info.getReqParameters().getUsePreload());
}
@@ -145,7 +147,7 @@ public class RequestParametersValidationTest extends BaseTest{
info.setRequestScope("service");
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
-
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertTrue(info.getReqParameters().getUsePreload());
}
@@ -161,7 +163,7 @@ public class RequestParametersValidationTest extends BaseTest{
info.setRequestScope("service");
RequestParametersValidation validation = new RequestParametersValidation();
validation.validate(info);
-
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertTrue(info.getReqParameters().getUsePreload());
}
}