DefaultOptionsMethodExceptionMapper extends
    CandlepinExceptionMapper implements
    ExceptionMapper<DefaultOptionsMethodException> { @Override public Response toResponse(DefaultOptionsMethodException exception) { Response resp = exception.getResponse(); return (resp != null) ? resp : getDefaultBuilder(exception, null, determineBestMediaType()).build(); }  @Override Response toResponse(DefaultOptionsMethodException exception);  }
@Test public void exceptionWithResponse() { Response mockr = mock(Response.class); when(mockr.getStatus()).thenReturn(500); DefaultOptionsMethodException dome = new DefaultOptionsMethodException("oops", mockr); DefaultOptionsMethodExceptionMapper domem = injector.getInstance(DefaultOptionsMethodExceptionMapper.class); Response r = domem.toResponse(dome); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus()); assertEquals(mockr, r); assertEquals("oops", dome.getMessage()); }
@Test public void verifyResponse() { DefaultOptionsMethodException dome = new DefaultOptionsMethodException("oops", null); DefaultOptionsMethodExceptionMapper domem = injector.getInstance(DefaultOptionsMethodExceptionMapper.class); Response r = domem.toResponse(dome); assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), r.getStatus()); verifyMessage(r, rtmsg("oops")); }