NotFoundExceptionMapper extends CandlepinExceptionMapper implements ExceptionMapper<NotFoundException> { @Override public final Response toResponse(final NotFoundException exception) { if (badQueryParamHandler.canHandle(exception)) { return badQueryParamHandler.getResponse(exception); } return getDefaultBuilder(exception, Response.Status.NOT_FOUND, determineBestMediaType()).build(); }  @Override final Response toResponse(final NotFoundException exception);  }
@Test public void handleNotFoundQueryParameterException() { NotFoundExceptionMapper nfem = injector.getInstance(NotFoundExceptionMapper.class); String foo = "javax.ws.rs.SomeThing(\"paramName\") value is 'strVal' for"; NotFoundException bre = new NotFoundException(foo); Response r = nfem.toResponse(bre); assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus()); verifyMessage(r, "strVal is not a valid value for paramName"); }
@Test public void handleNotFoundException() { NotFoundException nfe = new NotFoundException("unacceptable"); NotFoundExceptionMapper nfem = injector.getInstance(NotFoundExceptionMapper.class); Response r = nfem.toResponse(nfe); assertEquals(404, r.getStatus()); verifyMessage(r, rtmsg("unacceptable")); }