Search in sources :

Example 1 with ReaderException

use of org.jboss.resteasy.spi.ReaderException in project candlepin by candlepin.

the class ReaderExceptionMapperTest method handleExceptionWithoutResponse.

@Test
public void handleExceptionWithoutResponse() {
    ReaderException nfe = new ReaderException("unacceptable");
    ReaderExceptionMapper nfem = injector.getInstance(ReaderExceptionMapper.class);
    Response r = nfem.toResponse(nfe);
    assertEquals(500, r.getStatus());
    verifyMessage(r, rtmsg("unacceptable"));
}
Also used : Response(javax.ws.rs.core.Response) ReaderException(org.jboss.resteasy.spi.ReaderException) Test(org.junit.Test)

Example 2 with ReaderException

use of org.jboss.resteasy.spi.ReaderException in project candlepin by candlepin.

the class ReaderExceptionMapperTest method handleJsonMappingExceptionWithResponse.

@Test
public void handleJsonMappingExceptionWithResponse() {
    Response mockr = mock(Response.class);
    when(mockr.getStatus()).thenReturn(400);
    ReaderException nfe = new ReaderException("kaboom", new JsonMappingException("nope"));
    ReaderExceptionMapper nfem = injector.getInstance(ReaderExceptionMapper.class);
    Response r = nfem.toResponse(nfe);
    assertEquals(400, r.getStatus());
    verifyMessage(r, rtmsg("kaboom"));
}
Also used : Response(javax.ws.rs.core.Response) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) ReaderException(org.jboss.resteasy.spi.ReaderException) Test(org.junit.Test)

Example 3 with ReaderException

use of org.jboss.resteasy.spi.ReaderException in project candlepin by candlepin.

the class ReaderExceptionMapperTest method handleExceptionWithResponse.

@Test
public void handleExceptionWithResponse() {
    Response mockr = mock(Response.class);
    when(mockr.getStatus()).thenReturn(400);
    ReaderException nfe = new ReaderException("unacceptable", mockr);
    ReaderExceptionMapper nfem = injector.getInstance(ReaderExceptionMapper.class);
    Response r = nfem.toResponse(nfe);
    assertEquals(400, r.getStatus());
    verifyMessage(r, rtmsg("unacceptable"));
}
Also used : Response(javax.ws.rs.core.Response) ReaderException(org.jboss.resteasy.spi.ReaderException) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)3 ReaderException (org.jboss.resteasy.spi.ReaderException)3 Test (org.junit.Test)3 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1