aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2019-04-27 06:59:54 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-27 06:59:54 +0000
commitd5a7006356a2f22a6e247fd96be7b06f67b1b573 (patch)
tree877aeb47f9744c9be2f821addc792e2ac05b9715
parent7c9df24c78e9bf609cdf571d84c68fe9df4e0877 (diff)
parente99a36d42af5eb7e7a756a1e0e618a15c3169b2b (diff)
Merge "JUnit tests for RequestsDBHelper"
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/requestsdb/RequestsDBHelperTest.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/requestsdb/RequestsDBHelperTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/requestsdb/RequestsDBHelperTest.java
new file mode 100644
index 0000000000..b37ca0af63
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/requestsdb/RequestsDBHelperTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Samsung 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.requestsdb;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RequestsDBHelperTest {
+
+ @InjectMocks
+ private RequestsDBHelper requestsDBHelper;
+
+ @Mock
+ private RequestsDbClient requestsDbClient;
+
+ @Test
+ public void updateInfraSuccessCompletion() {
+
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any())).thenReturn(new InfraActiveRequests());
+
+ requestsDBHelper.updateInfraSuccessCompletion("messageText", "requestId", "operationalEnvId");
+
+ ArgumentCaptor<InfraActiveRequests> infraActiveRequests = ArgumentCaptor.forClass(InfraActiveRequests.class);
+
+ verify(requestsDbClient, times(1)).save(infraActiveRequests.capture());
+ assertEquals("COMPLETE", infraActiveRequests.getValue().getRequestStatus());
+ assertEquals("APIH", infraActiveRequests.getValue().getLastModifiedBy());
+ assertEquals(Long.valueOf(100), infraActiveRequests.getValue().getProgress());
+ assertEquals("SUCCESSFUL, operationalEnvironmentId - operationalEnvId; Success Message: messageText",
+ infraActiveRequests.getValue().getStatusMessage());
+ assertEquals("operationalEnvId", infraActiveRequests.getValue().getOperationalEnvId());
+ }
+
+ @Test
+ public void updateInfraFailureCompletion() {
+
+ when(requestsDbClient.getInfraActiveRequestbyRequestId(any())).thenReturn(new InfraActiveRequests());
+
+ requestsDBHelper.updateInfraFailureCompletion("messageText", "requestId", "operationalEnvId");
+
+ ArgumentCaptor<InfraActiveRequests> infraActiveRequests = ArgumentCaptor.forClass(InfraActiveRequests.class);
+ verify(requestsDbClient, times(1)).save(infraActiveRequests.capture());
+ assertEquals("FAILED", infraActiveRequests.getValue().getRequestStatus());
+ assertEquals("APIH", infraActiveRequests.getValue().getLastModifiedBy());
+ assertEquals(Long.valueOf(100), infraActiveRequests.getValue().getProgress());
+ assertEquals("FAILURE, operationalEnvironmentId - operationalEnvId; Error message: messageText",
+ infraActiveRequests.getValue().getStatusMessage());
+ assertEquals("operationalEnvId", infraActiveRequests.getValue().getOperationalEnvId());
+
+ }
+}