aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java')
-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/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java72
3 files changed, 97 insertions, 13 deletions
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/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
index 29fa1a34b3..a26848bf21 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
@@ -109,7 +109,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -134,7 +134,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountZero);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -169,7 +169,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountTwo);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -208,7 +208,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -244,7 +244,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
serviceModelDb.setOperationalEnvId(operationalEnvironmentId);
serviceModelDb.setRetryCount(retryCountThree);
serviceModelDb.setServiceModelVersionDistrStatus(statusError);
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -276,7 +276,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*"))
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -339,7 +339,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -415,7 +415,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
InfraActiveRequests iar = new InfraActiveRequests();
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -477,7 +477,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
@@ -536,7 +536,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{
iar.setRequestId(requestIdOrig);
iar.setRequestStatus("PENDING");
- stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId"))
+ stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(mapper.writeValueAsString(serviceModelDb))
.withStatus(HttpStatus.SC_OK)));
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 2813ef7b70..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);
- assertFalse(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,71 @@ 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());
+ }
+
+ @Test
+ public void testServiceWithFalseALaCarte() 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());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+ assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload());
+ assertFalse(info.getReqParameters().getUsePreload());
+ }
+
+ @Test
+ public void testServiceWithNoALaCarte() throws IOException, ValidationException {
+ String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersNoALaCarte.json")));
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class);
+ ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance,
+ 6, false, sir.getRequestDetails().getRequestParameters());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ sir.getRequestDetails().getRequestParameters().setSubscriptionServiceType("subscriptionServiceType");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+ assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload());
+ assertFalse(info.getReqParameters().getUsePreload());
+ }
+
+ @Test
+ public void testServiceWithTrueALaCarte() 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());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
assertTrue(info.getReqParameters().getUsePreload());
}
+
+ @Test
+ public void testServiceWithReqVersionBelow4() 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());
+ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b");
+ info.setRequestScope("service");
+ RequestParametersValidation validation = new RequestParametersValidation();
+ validation.validate(info);
+ assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload());
+ assertTrue(info.getReqParameters().getUsePreload());
+ }
}