RestApiResponseHandler { public static Response getResponseError(Exception e) { logger.error(e.getMessage(),e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(getErrorJsonString(e.getMessage())).build(); }  static Response getResponseOk(); static Response getResponseOk(String msg); static Response getResponseOk(JSONObject jsonObj); static Response getResponseCreatedOk(String msg); static Response getResponse200Ok(String msg); static Response getResponse204Ok(); static Response getResponseJsonOk(String jsonString); static Response getResponseJsonCreatedOk(String jsonString); static Response getResponseError(Exception e); static Response getResponseInternalServerError(String msg); static Response getResponseUnauthorized(String msg); static Response getResponseBadRequest(String msg); static Response getResponseNotFound(String msg); static Response getResponseJsonBuildError(Throwable t, Locale locale); static Response getResponseJsonParseError(Throwable t, Locale locale); static Response getResponseAppNotFound(AppNotFoundException e, Locale locale); static Response getResponseAppInfoNotFound(AppInfoNotFoundException e, Locale locale); static Response getResponseCloudError(CloudException e, Locale locale); static Response getResponseServiceNotFound(ServiceNotFoundException e, Locale locale); static Response getResponseInternalServerError(InternalServerErrorException e, Locale locale); static Response getResponseInputJsonParseError(InputJSONParseErrorException e, Locale locale); static Response getResponseInputJsonFormatError(InputJSONFormatErrorException e, Locale locale); static Response getResponseOutputJsonParseError(OutputJSONParseErrorException e, Locale locale); static Response getResponseOutputJsonFormatError(OutputJSONFormatErrorException e, Locale locale); static Response getResponseInternalAuthenticationFail(InternalAuthenticationException e, Locale locale); static Response getResponsePolicyNotExistError(PolicyNotFoundException e, Locale locale); static String getErrorJsonString(String errDesc); static String getErrorMessage(Exception e, Locale locale); static final String CLASS_NAME; static final Logger logger; }
@Test public void getResponseErrorTest() { assertEquals(RestApiResponseHandler.getResponseError(new Exception("Internal Server error")).getEntity().toString(), "{\"error\" : \""+"Internal Server error"+"\"}"); }