NotAuthorizedExceptionMapper extends CandlepinExceptionMapper implements ExceptionMapper<NotAuthorizedException> { @Override public Response toResponse(NotAuthorizedException exception) { return getDefaultBuilder(exception, Response.Status.UNAUTHORIZED, determineBestMediaType()).build(); }  @Override Response toResponse(NotAuthorizedException exception);  }
@Test public void handleException() { NotAuthorizedException nae = new NotAuthorizedException( "Not Authorized", "Negotiate", "Basic realm=candlepin"); NotAuthorizedExceptionMapper naem = injector.getInstance(NotAuthorizedExceptionMapper.class); Response r = naem.toResponse(nae); assertEquals(401, r.getStatus()); verifyMessage(r, rtmsg("Not Authorized")); }