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/OrchestrationRequests.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java90
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java2
6 files changed, 106 insertions, 6 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index ff8b5d14cd..e14b01792a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -290,7 +290,7 @@ public class OrchestrationRequests {
return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build();
}
- private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest)
+ protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest)
throws ApiException {
String requestBody = iar.getRequestBody();
Request request = new Request();
@@ -304,6 +304,11 @@ public class OrchestrationRequests {
String flowStatusMessage = iar.getFlowStatus();
String retryStatusMessage = iar.getRetryStatusMessage();
+ String originalRequestId = iar.getOriginalRequestId();
+ if (originalRequestId != null) {
+ request.setOriginalRequestId(originalRequestId);
+ }
+
InstanceReferences ir = new InstanceReferences();
if (iar.getNetworkId() != null)
ir.setNetworkInstanceId(iar.getNetworkId());
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 f6fc88d559..2a0718aeba 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
@@ -621,7 +621,8 @@ public class RequestHandlerUtils {
}
protected InfraActiveRequests createNewRecordCopyFromInfraActiveRequest(InfraActiveRequests infraActiveRequest,
- String requestId, Timestamp startTimeStamp, String source, String requestUri, String requestorId) {
+ String requestId, Timestamp startTimeStamp, String source, String requestUri, String requestorId,
+ String originalRequestId) {
InfraActiveRequests request = new InfraActiveRequests();
request.setRequestId(requestId);
request.setStartTime(startTimeStamp);
@@ -630,6 +631,7 @@ public class RequestHandlerUtils {
request.setProgress(new Long(5));
request.setRequestorId(requestorId);
request.setRequestStatus(Status.IN_PROGRESS.toString());
+ request.setOriginalRequestId(originalRequestId);
request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
if (infraActiveRequest != null) {
request.setTenantId(infraActiveRequest.getTenantId());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java
index 6ca23a339b..abf3729215 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java
@@ -106,7 +106,7 @@ public class ResumeOrchestrationRequest {
}
InfraActiveRequests currentActiveRequest = requestHandlerUtils.createNewRecordCopyFromInfraActiveRequest(
- infraActiveRequest, currentRequestId, startTimeStamp, source, requestUri, requestorId);
+ infraActiveRequest, currentRequestId, startTimeStamp, source, requestUri, requestorId, requestId);
if (infraActiveRequest == null) {
logger.error("No infraActiveRequest record found for requestId: {} in requesteDb lookup", requestId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
new file mode 100644
index 0000000000..19b9d7ea1e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 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;
+
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertThat;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.serviceinstancebeans.InstanceReferences;
+import org.onap.so.serviceinstancebeans.Request;
+import org.onap.so.serviceinstancebeans.RequestStatus;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OrchestrationRequestsUnitTest {
+
+ @Spy
+ private OrchestrationRequests orchestrationRequests;
+
+ private static final String REQUEST_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebba";
+ private static final String SERVICE_INSTANCE_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebbb";
+ private static final String ORIGINAL_REQUEST_ID = "8f2d38a6-7c20-465a-bd7e-075645f1394b";
+ private static final String SERVICE = "service";
+ private InfraActiveRequests iar;
+ boolean includeCloudRequest = false;
+
+ @Before
+ public void setup() {
+ iar = new InfraActiveRequests();
+ iar.setRequestScope(SERVICE);
+ iar.setRequestId(REQUEST_ID);
+ iar.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ }
+
+ @Test
+ public void mapInfraActiveRequestToRequestWithOriginalRequestIdTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ iar.setOriginalRequestId(ORIGINAL_REQUEST_ID);
+
+ Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest);
+ assertThat(result, sameBeanAs(expected));
+ }
+
+ @Test
+ public void mapInfraActiveRequestToRequestOriginalRequestIdNullTest() throws ApiException {
+ InstanceReferences instanceReferences = new InstanceReferences();
+ instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID);
+ RequestStatus requestStatus = new RequestStatus();
+ Request expected = new Request();
+ expected.setRequestId(REQUEST_ID);
+ expected.setInstanceReferences(instanceReferences);
+ expected.setRequestStatus(requestStatus);
+ expected.setRequestScope(SERVICE);
+
+ Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest);
+ assertThat(result, sameBeanAs(expected));
+ }
+
+}
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 e80fd9e690..b9d9974701 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
@@ -40,6 +40,7 @@ public class RequestHandlerUtilsUnitTest {
private RequestHandlerUtils requestHandler;
private static final String CURRENT_REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4";
+ private static final String RESUMED_REQUEST_ID = "59c7247f-839f-4923-90c3-05faa3ab354d";
private static final String SERVICE_INSTANCE_ID = "00032ab7-na18-42e5-965d-8ea592502018";
private final Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
private String requestUri =
@@ -88,6 +89,7 @@ public class RequestHandlerUtilsUnitTest {
currentActiveRequest.setRequestUrl(requestUri);
currentActiveRequest.setRequestorId("xxxxxx");
currentActiveRequest.setProgress(new Long(5));
+ currentActiveRequest.setOriginalRequestId(RESUMED_REQUEST_ID);
}
private void setCurrentActiveRequestNullInfraActive() throws IOException {
@@ -99,20 +101,21 @@ public class RequestHandlerUtilsUnitTest {
currentActiveRequestIARNull.setRequestUrl(requestUri);
currentActiveRequestIARNull.setRequestorId("xxxxxx");
currentActiveRequestIARNull.setProgress(new Long(5));
+ currentActiveRequestIARNull.setOriginalRequestId(RESUMED_REQUEST_ID);
}
@Test
public void createNewRecordCopyFromInfraActiveRequestTest() {
InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(infraActiveRequest,
- CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "xxxxxx");
+ CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "xxxxxx", RESUMED_REQUEST_ID);
assertThat(currentActiveRequest, sameBeanAs(result));
}
@Test
public void createNewRecordCopyFromInfraActiveRequestNullIARTest() {
InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(null, CURRENT_REQUEST_ID,
- startTimeStamp, "VID", requestUri, "xxxxxx");
+ startTimeStamp, "VID", requestUri, "xxxxxx", RESUMED_REQUEST_ID);
assertThat(currentActiveRequestIARNull, sameBeanAs(result));
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java
index 92490a66b8..7e49fff50d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java
@@ -169,7 +169,7 @@ public class ResumeOrchestrationRequestTest {
when(requestDbClient.getInfraActiveRequestbyRequestId(REQUEST_ID)).thenReturn(infraActiveRequest);
doReturn(currentActiveRequest).when(requestHandler).createNewRecordCopyFromInfraActiveRequest(
any(InfraActiveRequests.class), nullable(String.class), any(Timestamp.class), nullable(String.class),
- nullable(String.class), nullable(String.class));
+ nullable(String.class), nullable(String.class), anyString());
doReturn(response).when(resumeReq).resumeRequest(any(InfraActiveRequests.class), any(InfraActiveRequests.class),
anyString(), nullable(String.class));