aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java9
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json19
4 files changed, 48 insertions, 12 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 4e910e5382..f88d244a88 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -52,6 +52,7 @@ import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.TestApi;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
@@ -638,7 +639,7 @@ public class RequestHandlerUtils {
request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
if (infraActiveRequest != null) {
request.setTenantId(infraActiveRequest.getTenantId());
- request.setRequestBody(infraActiveRequest.getRequestBody());
+ request.setRequestBody(updateRequestorIdInRequestBody(infraActiveRequest, requestorId));
request.setAicCloudRegion(infraActiveRequest.getAicCloudRegion());
request.setRequestScope(infraActiveRequest.getRequestScope());
request.setRequestAction(infraActiveRequest.getRequestAction());
@@ -707,4 +708,10 @@ public class RequestHandlerUtils {
}
}
+ protected String updateRequestorIdInRequestBody(InfraActiveRequests infraActiveRequest, String newRequestorId) {
+ String requestBody = infraActiveRequest.getRequestBody();
+ return requestBody.replaceAll(
+ "(?s)(\"requestInfo\"\\s*?:\\s*?\\{.*?\"requestorId\"\\s*?:\\s*?\")(.*?)(\"[ ]*(?:,|\\R|\\}))",
+ "$1" + newRequestorId + "$3");
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java
index e92417728c..3cb4e0c9c2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java
@@ -114,14 +114,14 @@ public class RequestHandlerUtilsUnitTest {
currentActiveRequest.setSource("VID");
currentActiveRequest.setStartTime(startTimeStamp);
currentActiveRequest.setTenantId("tenant-id");
- currentActiveRequest.setRequestBody(getRequestBody("/RequestBody.json"));
+ currentActiveRequest.setRequestBody(getRequestBody("/RequestBodyNewRequestorId.json"));
currentActiveRequest.setAicCloudRegion("cloudRegion");
currentActiveRequest.setRequestScope("service");
currentActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString());
currentActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
currentActiveRequest.setRequestAction(Action.createInstance.toString());
currentActiveRequest.setRequestUrl(requestUri);
- currentActiveRequest.setRequestorId("xxxxxx");
+ currentActiveRequest.setRequestorId("yyyyyy");
currentActiveRequest.setProgress(new Long(5));
currentActiveRequest.setOriginalRequestId(RESUMED_REQUEST_ID);
}
@@ -140,10 +140,12 @@ public class RequestHandlerUtilsUnitTest {
@Test
- public void createNewRecordCopyFromInfraActiveRequestTest() {
+ public void createNewRecordCopyFromInfraActiveRequestTest() throws IOException {
doNothing().when(requestHandler).setInstanceIdAndName(infraActiveRequest, currentActiveRequest);
+ doReturn(getRequestBody("/RequestBodyNewRequestorId.json")).when(requestHandler)
+ .updateRequestorIdInRequestBody(infraActiveRequest, "yyyyyy");
InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(infraActiveRequest,
- CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "xxxxxx", RESUMED_REQUEST_ID);
+ CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "yyyyyy", RESUMED_REQUEST_ID);
assertThat(currentActiveRequest, sameBeanAs(result));
}
@@ -396,4 +398,12 @@ public class RequestHandlerUtilsUnitTest {
assertEquals(modelTypeResult, modelTypeExpected);
}
+ @Test
+ public void updateRequestorIdInRequestBodyTest() throws IOException {
+ String newRequestorId = "yyyyyy";
+ String expected = getRequestBody("/RequestBodyNewRequestorId.json");
+ String result = requestHandler.updateRequestorIdInRequestBody(infraActiveRequest, newRequestorId);
+ assertEquals(expected, result);
+ }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json
index 7e8ed4dee1..d6406338a0 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json
@@ -1,5 +1,11 @@
{
"requestDetails":{
+ "modelInfo":{
+ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965",
+ "modelVersion": "1.0",
+ "modelType":"service",
+ "modelName":"serviceModel"
+ },
"requestInfo":{
"source":"VID",
"requestorId":"xxxxxx",
@@ -8,12 +14,6 @@
},
"requestParameters":{
"aLaCarte":"false"
- },
- "modelInfo":{
- "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965",
- "modelVersion": "1.0",
- "modelType":"service",
- "modelName":"serviceModel"
- }
+ }
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json
new file mode 100644
index 0000000000..740d4e2ec2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json
@@ -0,0 +1,19 @@
+{
+ "requestDetails":{
+ "modelInfo":{
+ "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965",
+ "modelVersion": "1.0",
+ "modelType":"service",
+ "modelName":"serviceModel"
+ },
+ "requestInfo":{
+ "source":"VID",
+ "requestorId":"yyyyyy",
+ "instanceName":"testService",
+ "productFamilyId":"test"
+ },
+ "requestParameters":{
+ "aLaCarte":"false"
+ }
+ }
+} \ No newline at end of file