summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarun Gudisena <vg411h@att.com>2017-10-03 18:18:12 -0500
committerVarun Gudisena <vg411h@att.com>2017-10-03 18:18:28 -0500
commit82627283fd017062439d6d898afba9127d224b1d (patch)
tree6da1191b99cccffce1b566580c104239e9a27467
parent7b7d8beca8298ee55f79596fe8fd694cde248eb4 (diff)
Add unit test cases
Add unit test cases Issue-Id: DMAAP-151 Change-Id: I5f70774ad35aef71aa6f00b2433224d113f4f85b Signed-off-by: Varun Gudisena <vg411h@att.com>
-rw-r--r--src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java b/src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java
index 22c31c9..cb1edb5 100644
--- a/src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java
+++ b/src/test/java/com/att/nsa/dmaap/DMaaPWebExceptionMapperTest.java
@@ -32,9 +32,22 @@ import javax.ws.rs.ServiceUnavailableException;
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.exception.DMaaPErrorMessages;
+@RunWith(PowerMockRunner.class)
public class DMaaPWebExceptionMapperTest {
+ @InjectMocks
+ DMaaPWebExceptionMapper mapper;
+
+ @Mock
+ DMaaPErrorMessages msgs;
+
@Before
public void setUp() throws Exception {
}
@@ -46,8 +59,6 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponse() {
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
try {
mapper.toResponse(null);
} catch (NullPointerException e) {
@@ -58,9 +69,7 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponseNotFoundException() {
-
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
try {
mapper.toResponse(new NotFoundException());
} catch (NullPointerException e) {
@@ -71,9 +80,7 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponseInternalServerErrorException() {
-
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
try {
mapper.toResponse(new InternalServerErrorException());
@@ -85,9 +92,7 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponseNotAuthorizedException() {
-
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
try {
mapper.toResponse(new NotAuthorizedException("Error", "Error"));
@@ -99,9 +104,7 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponseBadRequestException() {
-
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
try {
mapper.toResponse(new BadRequestException());
@@ -113,9 +116,7 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponseNotAllowedException() {
-
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
try {
mapper.toResponse(new NotAllowedException("Not Allowed"));
@@ -127,9 +128,7 @@ public class DMaaPWebExceptionMapperTest {
@Test
public void testToResponseServiceUnavailableException() {
-
- DMaaPWebExceptionMapper mapper = new DMaaPWebExceptionMapper();
-
+ PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
try {
mapper.toResponse(new ServiceUnavailableException());