Merge "Corrected enum formatting by plugin"
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
index 3419e6d..1e61d4d 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java
@@ -79,6 +79,9 @@
     @Autowired
     private Environment env;
 
+    @Autowired
+    private HttpClient client;
+
     public String getMsbHost() {
         // MSB_IP will be set as ONAP_IP environment parameter in install flow.
         String msbIp = System.getenv().get(ONAP_IP);
@@ -111,8 +114,6 @@
             RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(timeout).setConnectTimeout(timeout)
                     .setConnectionRequestTimeout(timeout).build();
 
-            HttpClient client = HttpClientBuilder.create().build();
-
             if ("POST".equalsIgnoreCase(methodType)) {
                 HttpPost httpPost = new HttpPost(msbUrl);
                 httpPost.setConfig(requestConfig);
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java
new file mode 100644
index 0000000..c388016
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/test/java/org/onap/so/adapters/vfc/util/RestfulUtilTest.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019 Samsung. 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.adapters.vfc.util;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.adapters.vfc.model.RestfulResponse;
+import org.springframework.http.HttpStatus;
+import javax.ws.rs.HttpMethod;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RestfulUtilTest {
+
+    @InjectMocks
+    @Spy
+    private RestfulUtil restfulUtil;
+
+    @Mock
+    private HttpClient client;
+
+    private HttpEntity httpEntity;
+    private HttpResponse httpResponse;
+    private StatusLine statusLine;
+
+    @Before
+    public void setUp() {
+        httpEntity = mock(HttpEntity.class);
+        httpResponse = mock(HttpResponse.class);
+        statusLine = mock(StatusLine.class);
+    }
+
+    private void sendInit() throws IOException {
+
+        doReturn("https://testHost/").when(restfulUtil).getMsbHost();
+
+        when(statusLine.getStatusCode()).thenReturn(HttpStatus.OK.value());
+        when(httpResponse.getStatusLine()).thenReturn(statusLine);
+        when(httpResponse.getEntity()).thenReturn(httpEntity);
+    }
+
+    @Test
+    public void sendGet() throws Exception {
+
+        sendInit();
+
+        ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("GET").getBytes());
+        when(client.execute(any(HttpGet.class))).thenReturn(httpResponse);
+        when(httpEntity.getContent()).thenReturn(responseStream);
+
+        RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.GET, "some request content");
+
+        assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+        assertEquals("GET", restfulResponse.getResponseContent());
+
+    }
+
+    @Test
+    public void sendPost() throws Exception {
+
+        sendInit();
+
+
+        ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("POST").getBytes());
+        when(client.execute(any(HttpPost.class))).thenReturn(httpResponse);
+        when(httpEntity.getContent()).thenReturn(responseStream);
+
+        RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.POST, "some request content");
+
+        assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+        assertEquals("POST", restfulResponse.getResponseContent());
+
+    }
+
+    @Test
+    public void sendPut() throws Exception {
+
+        sendInit();
+
+        ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("PUT").getBytes());
+        when(client.execute(any(HttpPut.class))).thenReturn(httpResponse);
+        when(httpEntity.getContent()).thenReturn(responseStream);
+
+        RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.PUT, "some request content");
+
+        assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+        assertEquals("PUT", restfulResponse.getResponseContent());
+
+    }
+
+    @Test
+    public void sendDelete() throws Exception {
+
+        sendInit();
+
+        ByteArrayInputStream responseStream = new ByteArrayInputStream(new String("DELETE").getBytes());
+        when(client.execute(any(HttpDelete.class))).thenReturn(httpResponse);
+        when(httpEntity.getContent()).thenReturn(responseStream);
+
+        RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.DELETE, "some request content");
+
+        assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus());
+        assertEquals("DELETE", restfulResponse.getResponseContent());
+
+    }
+
+    @Test
+    public void sendOptions() throws Exception {
+
+        doReturn("https://testHost/").when(restfulUtil).getMsbHost();
+
+        RestfulResponse restfulResponse = restfulUtil.send("test", HttpMethod.OPTIONS, "some request content");
+
+        assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), restfulResponse.getStatus());
+        assertEquals("Error processing request to VFC", restfulResponse.getResponseContent());
+
+    }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
index dabfc81..870b936 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
@@ -153,65 +153,67 @@
     }
 
     public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) {
-        logger.info("Building a WorkflowException for Subflow");
+        logger.debug("Processing Audit Results");
+        String auditListString = (String) execution.getVariable("auditInventoryResult");
+        if (auditListString != null) {
+            StringBuilder errorMessage = new StringBuilder();
+            String processKey = getProcessKey(execution.getDelegateExecution());
+            try {
+                ExtractPojosForBB extractPojosForBB = getExtractPojosForBB();
+                VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+                String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId();
 
-        StringBuilder errorMessage = new StringBuilder();
-        String processKey = getProcessKey(execution.getDelegateExecution());
-        try {
-            ExtractPojosForBB extractPojosForBB = getExtractPojosForBB();
-            VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
-            String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId();
+                GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
+                AAIObjectAuditList auditList =
+                        objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class);
 
-            GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
-            String auditListString = (String) execution.getVariable("auditInventoryResult");
-            AAIObjectAuditList auditList =
-                    objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class);
+                errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId()
+                        + " failed due to incomplete AAI vserver inventory population after stack "
+                        + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType()
+                        + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that the following was not "
+                        + auditList.getAuditType() + "d in AAI: ");
 
-            errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId()
-                    + " failed due to incomplete A&AI vserver inventory population after stack "
-                    + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType()
-                    + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that AIC RO did not "
-                    + auditList.getAuditType() + " ");
+                Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream()
+                        .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName())
+                                || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName()));
+                List<AAIObjectAudit> filteredAuditStream =
+                        vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList());
 
-            Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream()
-                    .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName())
-                            || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName()));
-            List<AAIObjectAudit> filteredAuditStream =
-                    vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList());
-
-            for (AAIObjectAudit object : filteredAuditStream) {
-                if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) {
-                    LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class);
-                    errorMessage = errorMessage
-                            .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", ");
-                } else {
-                    Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class);
-                    errorMessage =
-                            errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", ");
+                for (AAIObjectAudit object : filteredAuditStream) {
+                    if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) {
+                        LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class);
+                        errorMessage = errorMessage
+                                .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", ");
+                    } else {
+                        Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class);
+                        errorMessage =
+                                errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", ");
+                    }
                 }
+
+                if (errorMessage.length() > 0) {
+                    errorMessage.setLength(errorMessage.length() - 2);
+                    errorMessage = errorMessage.append(".");
+                }
+
+            } catch (IOException | BBObjectNotFoundException e) {
+                errorMessage = errorMessage.append("process objects in AAI. ");
             }
 
-            if (errorMessage.length() > 0) {
-                errorMessage.setLength(errorMessage.length() - 2);
-                errorMessage = errorMessage.append(" in AAI. ");
+            if (flowShouldContinue) {
+                execution.setVariable("StatusMessage", errorMessage.toString());
+            } else {
+                WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
+                execution.setVariable("WorkflowException", exception);
+                execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString());
+                logger.info("Outgoing WorkflowException is {}", exception);
+                logger.info("Throwing MSOWorkflowException");
+                throw new BpmnError("AAIInventoryFailure");
             }
 
-        } catch (IOException | BBObjectNotFoundException e) {
-            errorMessage = errorMessage.append("process objects in AAI. ");
-        }
-
-        errorMessage.append(
-                "Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.");
-
-        if (flowShouldContinue) {
-            execution.setVariable("StatusMessage", errorMessage.toString());
         } else {
-            WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
-            execution.setVariable("WorkflowException", exception);
-            execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString());
-            logger.info("Outgoing WorkflowException is {}", exception);
-            logger.info("Throwing MSOWorkflowException");
-            throw new BpmnError("AAIInventoryFailure");
+            logger.debug("Unable to process audit results due to auditInventoryResult being null");
         }
     }
+
 }
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
index 549f16b..5f9aef6 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
@@ -138,7 +138,7 @@
             WorkflowException we = execution.getVariable("WorkflowException");
             assertNotNull(we);
             assertEquals(
-                    "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.",
+                    "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.",
                     we.getErrorMessage());
         }
     }
@@ -151,7 +151,7 @@
             String sm = execution.getVariable("StatusMessage");
             assertNotNull(sm);
             assertEquals(
-                    "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.",
+                    "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.",
                     sm);
         } catch (BpmnError bpmnException) {
             fail();
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java
index fbdb27c..75a6ba8 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Request.java
@@ -22,7 +22,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -36,6 +35,7 @@
     protected String finishTime;
     protected String requestScope;
     protected String requestType;
+    protected String originalRequestId;
     protected RequestDetails requestDetails;
     protected InstanceReferences instanceReferences;
     protected RequestStatus requestStatus;
@@ -124,6 +124,14 @@
         this.cloudRequestData = cloudRequestData;
     }
 
+    public String getOriginalRequestId() {
+        return originalRequestId;
+    }
+
+    public void setOriginalRequestId(String originalRequestId) {
+        this.originalRequestId = originalRequestId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this).append("requestId", requestId).append("startTime", startTime)
@@ -131,6 +139,6 @@
                 .append("requestType", requestType).append("requestDetails", requestDetails)
                 .append("instanceReferences", instanceReferences).append("requestStatus", requestStatus)
                 .append("requestProcessingData", requestProcessingData).append("cloudRequestData", cloudRequestData)
-                .toString();
+                .append("originalRequestId", originalRequestId).toString();
     }
 }
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 ff8b5d1..e14b017 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 @@
         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 @@
         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 f6fc88d..2a0718a 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 @@
     }
 
     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 @@
         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 6ca23a3..abf3729 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 @@
         }
 
         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 0000000..19b9d7e
--- /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 e80fd9e..b9d9974 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 @@
     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 @@
         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 @@
         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 92490a6..7e49fff 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 @@
         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));
 
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
index 65372b7..ef13df5 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
@@ -96,7 +96,8 @@
     OPERATIONAL_ENV_NAME VARCHAR SELECTIVITY 1,
     INSTANCE_GROUP_ID VARCHAR SELECTIVITY 1,
     INSTANCE_GROUP_NAME VARCHAR SELECTIVITY 1,
-    REQUEST_URL VARCHAR SELECTIVITY 1
+    REQUEST_URL VARCHAR SELECTIVITY 1,
+    ORIGINAL_REQUEST_ID VARCHAR SELECTIVITY 1
 );          
 
 INSERT INTO PUBLIC.INFRA_ACTIVE_REQUESTS(REQUEST_ID, CLIENT_REQUEST_ID, ACTION, REQUEST_STATUS, STATUS_MESSAGE, PROGRESS, START_TIME, END_TIME, SOURCE, VNF_ID, VNF_NAME, VNF_TYPE, SERVICE_TYPE, AIC_NODE_CLLI, TENANT_ID, PROV_STATUS, VNF_PARAMS, VNF_OUTPUTS, REQUEST_BODY, RESPONSE_BODY, LAST_MODIFIED_BY, MODIFY_TIME, REQUEST_TYPE, VOLUME_GROUP_ID, VOLUME_GROUP_NAME, VF_MODULE_ID, VF_MODULE_NAME, VF_MODULE_MODEL_NAME, AAI_SERVICE_ID, AIC_CLOUD_REGION, CALLBACK_URL, CORRELATOR, NETWORK_ID, NETWORK_NAME, NETWORK_TYPE, REQUEST_SCOPE, REQUEST_ACTION, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUESTOR_ID, CONFIGURATION_ID, CONFIGURATION_NAME, OPERATIONAL_ENV_ID, OPERATIONAL_ENV_NAME, REQUEST_URL) VALUES
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java
index 37fbfd0..9aa04ea 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraActiveRequests.java
@@ -87,6 +87,7 @@
                 .append("networkName", getNetworkName()).append("networkType", getNetworkType())
                 .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId())
                 .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId())
-                .append("operationalEnvName", getOperationalEnvName()).append("requestUrl", getRequestUrl()).toString();
+                .append("operationalEnvName", getOperationalEnvName()).append("requestUrl", getRequestUrl())
+                .append("originalRequestId", getOriginalRequestId()).toString();
     }
 }
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
index 7c58c61..1a925f2 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
@@ -152,6 +152,8 @@
     private String instanceGroupName;
     @Column(name = "REQUEST_URL", length = 500)
     private String requestUrl;
+    @Column(name = "ORIGINAL_REQUEST_ID", length = 45)
+    private String originalRequestId;
 
     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
     @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID")
@@ -569,6 +571,14 @@
         this.requestUrl = requestUrl;
     }
 
+    public String getOriginalRequestId() {
+        return this.originalRequestId;
+    }
+
+    public void setOriginalRequestId(String originalRequestId) {
+        this.originalRequestId = originalRequestId;
+    }
+
     @PrePersist
     protected void onCreate() {
         if (requestScope == null)
@@ -630,6 +640,7 @@
                 .append("requestorId", getRequestorId()).append("configurationId", getConfigurationId())
                 .append("configurationName", getConfigurationName()).append("operationalEnvId", getOperationalEnvId())
                 .append("operationalEnvName", getOperationalEnvName()).append("instanceGroupId", getInstanceGroupId())
-                .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl()).toString();
+                .append("instanceGroupName", getInstanceGroupName()).append("requestUrl", getRequestUrl())
+                .append("originalRequestId", originalRequestId).toString();
     }
 }