ResourceException extends RuntimeException { public Object getData() { return data; } ResourceException(int code);  ResourceException(int code, Object data); static String codeToString(int code); int getCode(); Object getData(); T getData(Class<T> cl); final static int OK; final static int CREATED; final static int ACCEPTED; final static int NO_CONTENT; final static int MOVED_PERMANENTLY; final static int FOUND; final static int SEE_OTHER; final static int NOT_MODIFIED; final static int TEMPORARY_REDIRECT; final static int BAD_REQUEST; final static int UNAUTHORIZED; final static int FORBIDDEN; final static int NOT_FOUND; final static int CONFLICT; final static int GONE; final static int PRECONDITION_FAILED; final static int UNSUPPORTED_MEDIA_TYPE; final static int PRECONDITION_REQUIRED; final static int TOO_MANY_REQUESTS; final static int REQUEST_HEADER_FIELDS_TOO_LARGE; final static int INTERNAL_SERVER_ERROR; final static int NOT_IMPLEMENTED; final static int SERVICE_UNAVAILABLE; final static int GATEWAY_TIMEOUT; final static int NETWORK_AUTHENTICATION_REQUIRED; }
@Test public void testCodeOnly() { ResourceException exc = new ResourceException(400); assertEquals(exc.getData().toString(), "{code: 400, message: \"Bad Request\"}"); }
@Test public void testGetData() { ResourceException exc = new ResourceException(400, "Invalid domain name"); assertEquals(exc.getData(), "Invalid domain name"); }
@Test public void testGetDataCast() { ResourceException exc = new ResourceException(400, 5000); assertEquals(exc.getData(Integer.class), new Integer(5000)); }