aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2019-05-31 11:48:34 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-05-31 11:48:47 -0400
commita5af334f3b70d927565c33390807d5c49593822e (patch)
tree460d2272b7c3f53c7182344f9cdf28f6a3e8f615 /mso-api-handlers/mso-api-handler-infra/src/test
parentec71f01963e4c5c70d11f41842c7cd9cfd38316d (diff)
apih to populate original request id
Updated schema.sql to fix failing tests Added constants for request parameters Added originalRequestId to be saved on resume request Added originalRequestId to orchestrationRequests response Change-Id: If2b86d233ee3db9bbe0e1185d92874bca2b3a07a Issue-ID: SO-1960 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test')
-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
3 files changed, 96 insertions, 3 deletions
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));