2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package com.att.nsa.dmaap;
\r
23 import static org.junit.Assert.*;
\r
25 import javax.ws.rs.BadRequestException;
\r
26 import javax.ws.rs.InternalServerErrorException;
\r
27 import javax.ws.rs.NotAllowedException;
\r
28 import javax.ws.rs.NotAuthorizedException;
\r
29 import javax.ws.rs.NotFoundException;
\r
30 import javax.ws.rs.ServiceUnavailableException;
\r
32 import org.junit.After;
\r
33 import org.junit.Before;
\r
34 import org.junit.Test;
\r
35 import org.junit.runner.RunWith;
\r
36 import org.mockito.InjectMocks;
\r
37 import org.mockito.Mock;
\r
38 import org.powermock.api.mockito.PowerMockito;
\r
39 import org.powermock.modules.junit4.PowerMockRunner;
\r
41 import com.att.dmf.mr.exception.DMaaPErrorMessages;
\r
42 @RunWith(PowerMockRunner.class)
\r
43 public class DMaaPWebExceptionMapperTest {
\r
46 DMaaPWebExceptionMapper mapper;
\r
49 DMaaPErrorMessages msgs;
\r
52 public void setUp() throws Exception {
\r
56 public void tearDown() throws Exception {
\r
60 public void testToResponse() {
\r
63 mapper.toResponse(null);
\r
64 } catch (NullPointerException e) {
\r
71 public void testToResponseNotFoundException() {
\r
72 PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
\r
74 mapper.toResponse(new NotFoundException());
\r
75 } catch (NullPointerException e) {
\r
82 public void testToResponseInternalServerErrorException() {
\r
83 PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
\r
85 mapper.toResponse(new InternalServerErrorException());
\r
87 } catch (NullPointerException e) {
\r
94 public void testToResponseNotAuthorizedException() {
\r
95 PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
\r
97 mapper.toResponse(new NotAuthorizedException("Error", "Error"));
\r
99 } catch (NullPointerException e) {
\r
106 public void testToResponseBadRequestException() {
\r
107 PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
\r
109 mapper.toResponse(new BadRequestException());
\r
111 } catch (NullPointerException e) {
\r
118 public void testToResponseNotAllowedException() {
\r
119 PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
\r
121 mapper.toResponse(new NotAllowedException("Not Allowed"));
\r
123 } catch (NullPointerException e) {
\r
130 public void testToResponseServiceUnavailableException() {
\r
131 PowerMockito.when(msgs.getNotFound()).thenReturn("Not found");
\r
133 mapper.toResponse(new ServiceUnavailableException());
\r
135 } catch (NullPointerException e) {
\r