From 04436cbfd38b0b021d4b25287a540b31146ec209 Mon Sep 17 00:00:00 2001 From: Varun Gudisena Date: Tue, 3 Oct 2017 19:01:37 -0500 Subject: Add unit test cases Add unit test cases Issue-Id: DMAAP-151 Change-Id: I55df6f71f58ae7c52aa7931056647c165eb5aa48 Signed-off-by: Varun Gudisena --- .../nsa/dmaap/DMaaPCambriaExceptionMapperTest.java | 42 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src/test') 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 -- cgit 1.2.3-korg