diff options
author | Varun Gudisena <vg411h@att.com> | 2017-10-03 19:01:37 -0500 |
---|---|---|
committer | Varun Gudisena <vg411h@att.com> | 2017-10-03 19:02:56 -0500 |
commit | 04436cbfd38b0b021d4b25287a540b31146ec209 (patch) | |
tree | 6bd07428934ff0394a0ec7c9397aab287fe6a9d6 /src/test | |
parent | 82627283fd017062439d6d898afba9127d224b1d (diff) |
Add unit test cases
Add unit test cases
Issue-Id: DMAAP-151
Change-Id: I55df6f71f58ae7c52aa7931056647c165eb5aa48
Signed-off-by: Varun Gudisena <vg411h@att.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java b/src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java index eeeca29..9294e4d 100644 --- a/src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java +++ b/src/test/java/com/att/nsa/dmaap/DMaaPCambriaExceptionMapperTest.java @@ -20,14 +20,40 @@ package com.att.nsa.dmaap;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
+import org.json.JSONObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.modules.junit4.PowerMockRunner;
+import com.att.nsa.cambria.CambriaApiException;
+import com.att.nsa.cambria.exception.DMaaPErrorMessages;
+import com.att.nsa.cambria.exception.ErrorResponse;
+@RunWith(PowerMockRunner.class)
public class DMaaPCambriaExceptionMapperTest {
+ @InjectMocks
+ DMaaPCambriaExceptionMapper mapper;
+
+ @Mock
+ private ErrorResponse errRes;
+
+ @Mock
+ private DMaaPErrorMessages msgs;
+
+ @Mock
+ CambriaApiException exc;
+
+ @Mock
+ JSONObject json;
+
+
@Before
public void setUp() throws Exception {
}
@@ -38,9 +64,6 @@ public class DMaaPCambriaExceptionMapperTest { @Test
public void testToResponse() {
-
- DMaaPCambriaExceptionMapper mapper = new DMaaPCambriaExceptionMapper();
-
try {
mapper.toResponse(null);
} catch (NullPointerException e) {
@@ -49,4 +72,15 @@ public class DMaaPCambriaExceptionMapperTest { }
+
+ @Test
+ public void testToResponseCambriaApiException2() {
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
+ try {
+ mapper.toResponse(new CambriaApiException(404,"Not found"));
+ } catch (NullPointerException e) {
+ assertTrue(true);
+ }
+ assertTrue(true);
+ }
}
\ No newline at end of file |