JSONResponse { public static Response createErrorResponse(Response.StatusType status, String errormessage) { return createResponse(status, null, errormessage); } private  JSONResponse(); static Response createErrorResponse(Response.StatusType status, String errormessage); static Response createResponse(Response.StatusType status, Object entity, String errormessage);  }
@Test public void creatErrorShouldCreateErrorResponse() { Response errorResponse = JSONResponse.createErrorResponse(Status.INTERNAL_SERVER_ERROR, "error"); assertThat(errorResponse.getMediaType(), is(equalTo(MediaType.APPLICATION_JSON_TYPE))); assertThat(errorResponse.getStatus(), is(500)); JsonObject entity = ((JsonObject) errorResponse.getEntity()).get(JSONResponse.JSON_KEY_ERROR).getAsJsonObject(); assertThat(entity.get(JSONResponse.JSON_KEY_ERROR_MESSAGE).getAsString(), is("error")); assertThat(entity.get(JSONResponse.JSON_KEY_HTTPCODE).getAsInt(), is(500)); }