aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-sdnc-adapter/src
diff options
context:
space:
mode:
authorroot <arcot.sindhuri@huawei.com>2018-04-17 12:23:29 +0000
committerroot <arcot.sindhuri@huawei.com>2018-04-18 10:38:30 +0000
commite2d5322ba8f80fc143547c849dc003a368f098a4 (patch)
treeb5bae279a62662c16b6cbd85558285e4da4e4609 /adapters/mso-sdnc-adapter/src
parent21005fb11f754fd25d5a2c2872c0834950295ccf (diff)
UT modification for adaptes - db,sdnc
UT changes for mso-sdnc-adapter and mso-requests-db Issue-ID: SO-369 Change-Id: Id201617addb3a83d7ed9773f7991907917c46129 Signed-off-by: root <arcot.sindhuri@huawei.com>
Diffstat (limited to 'adapters/mso-sdnc-adapter/src')
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java63
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java26
2 files changed, 56 insertions, 33 deletions
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
index 6e05402736..98b368f5fa 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCAdapterRestImplTest.java
@@ -20,43 +20,60 @@
package org.openecomp.mso.adapters.sdnc.impl;
-import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.logger.MsoLogger;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(SDNCAdapterRestImpl.class)
public class SDNCAdapterRestImplTest {
- SDNCAdapterRestImpl test = new SDNCAdapterRestImpl();
+ SDNCAdapterRestImpl test;
- /*Need to revist this .. commenting for now to proceed
- @Test(expected = ClassFormatError.class)
- public void testMSORequestException() {
+ @Before
+ public void init(){
- test.MSORequest("reqXML");
- Assert.assertFalse(true);
-
+ test = new SDNCAdapterRestImpl();
}
- @Test(expected = NoClassDefFoundError.class)
- public void testHealthCheckException() {
+ @Test
+ public void testBadReqNoServiceRsp() {
- test.healthcheck("1a25a7c0-4c91-4f74-9a78-8c11b7a57f1a");
- Assert.assertFalse(true);
- }
+ HealthCheckUtils hCU = PowerMockito.mock(HealthCheckUtils.class);
+ try {
+ PowerMockito.whenNew(HealthCheckUtils.class).withNoArguments().thenReturn(hCU);
+ when(hCU.siteStatusCheck(any(MsoLogger.class))).thenReturn(true);
- @Test(expected = ClassFormatError.class)
- public void testglobalHealthcheckException() {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- test.globalHealthcheck(true);
- Assert.assertFalse(true);
- }
+ String reqXML = "<xml>test</xml>";
+
+ Response response = test.MSORequest(reqXML);
+ assertEquals(400,response.getStatus());
+
+ response = test.healthcheck("1a25a7c0-4c91-4f74-9a78-8c11b7a57f1a");
+ assertEquals(503,response.getStatus());
+ response = test.globalHealthcheck(true);
+ assertEquals(503,response.getStatus());
- @Test(expected = NoClassDefFoundError.class)
- public void testNodeHealthCheckException() {
+ response = test.nodeHealthcheck();
+ assertEquals(503,response.getStatus());
- test.nodeHealthcheck();
- Assert.assertFalse(true);
- }*/
+ }
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
index a62f42af5a..75cd360663 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/notify/SDNCNotifyResourceTest.java
@@ -24,6 +24,9 @@ import org.junit.Test;
import org.mockito.Mock;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
+
+import static org.junit.Assert.assertEquals;
public class SDNCNotifyResourceTest {
@@ -31,16 +34,19 @@ public class SDNCNotifyResourceTest {
HttpServletRequest httpServletRequest;
SDNCNotifyResource test = new SDNCNotifyResource();
-//These tests need a recheck for the class cast exception
- /* @Test(expected = ClassFormatError.class)
- public void testPrintMessageException() {
- test.printMessage();
- test.printMessageParam("msg");
- }
- @Test(expected = ClassFormatError.class)
- public void testSDNCNotifyException() {
- test.SDNCNotify("reqXML", httpServletRequest);
+ @Test
+ public void testPrintMessage() {
+
+ Response response = test.printMessage();
+ assertEquals(200, response.getStatus());
- }*/
+ response = test.printMessageParam("msg");
+ assertEquals(200, response.getStatus());
+
+ String reqXML = "<xml>test</xml>";
+ response = test.SDNCNotify(reqXML, httpServletRequest);
+ assertEquals(400, response.getStatus());
+
+ }
}