JsonApiResponse { public static BuildableException createExceptionResponse(Response.Status code) { assertIsValidErrCode(code.getStatusCode()); return new Builder(new JsonApiResponse(code)); } private  JsonApiResponse(UriInfo uriInfo, Response.StatusType statusCode); private  JsonApiResponse(Response.StatusType statusCode); static RequiredEntity createGetResponse(UriInfo uriInfo); static RequiredEntity createPostResponse(UriInfo uriInfo); static RequiredEntity createPutResponse(UriInfo uriInfo); static BuildableException createExceptionResponse(Response.Status code); static final String JSONAPI_TYPE; }
@Test public void testExceptionResponse() { Response result = JsonApiResponse .createExceptionResponse(Response.Status.fromStatusCode(ERRCODE_VALID)) .message(MESSAGE) .build(); Assert.assertEquals(ERRCODE_VALID, result.getStatus()); assertIsValidJsonApiErrorResponse(result); assertExceptionResponseHasValues(result, COMBINED_MESSAGE, ERRCODE_VALID); }
@Test public void testExceptionResponseWithoutMessage() { Response result = JsonApiResponse .createExceptionResponse(Response.Status.fromStatusCode(ERRCODE_VALID)) .build(); Assert.assertEquals(ERRCODE_VALID, result.getStatus()); assertIsValidJsonApiErrorResponse(result); assertExceptionResponseHasValues(result, VALID_ERRMSG, ERRCODE_VALID); }
@Test(expected = IllegalArgumentException.class) public void testExceptionResponseInvalidCode() { JsonApiResponse .createExceptionResponse(Response.Status.fromStatusCode(ERRCODE_INVALID)) .message(MESSAGE) .build(); }