@Test public void testGetErrorResponse() throws Exception { String idString = "ID String"; int status = 404; String messageString = "Message String"; String contextString = "Context String"; Response subject = Utils.getErrorResponse(idString, status, messageString, contextString); Assert.assertEquals("Status of created response should match method argument", status, subject.getStatus()); String stringEntity = (String) subject.getEntity(); Assert.assertTrue("Error entity should contain message string.", stringEntity.contains(messageString)); Assert.assertTrue("Error entity should contain context string.", stringEntity.contains(contextString)); Assert.assertTrue("Error entity should contain ID string.", stringEntity.contains(idString)); }
public static Response getErrorResponse(String id, int status, String message, String context) { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.id = id; errorResponse.errorSource = context; errorResponse.errorMessage = message; String jsonErrorResponse = jsonStringFromObject(errorResponse); return Response.status(status) .entity(jsonErrorResponse) .build(); }
Utils { public static Response getErrorResponse(String id, int status, String message, String context) { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.id = id; errorResponse.errorSource = context; errorResponse.errorMessage = message; String jsonErrorResponse = jsonStringFromObject(errorResponse); return Response.status(status) .entity(jsonErrorResponse) .build(); } }
Utils { public static Response getErrorResponse(String id, int status, String message, String context) { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.id = id; errorResponse.errorSource = context; errorResponse.errorMessage = message; String jsonErrorResponse = jsonStringFromObject(errorResponse); return Response.status(status) .entity(jsonErrorResponse) .build(); } private  Utils(); }
Utils { public static Response getErrorResponse(String id, int status, String message, String context) { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.id = id; errorResponse.errorSource = context; errorResponse.errorMessage = message; String jsonErrorResponse = jsonStringFromObject(errorResponse); return Response.status(status) .entity(jsonErrorResponse) .build(); } private  Utils(); static Map<String, Object> makeError(String errorMessage, String errorCause, String errorPart); static Response getErrorResponse(String id, int status,
                                            String message, String context); static String createUuid(); static long parseDate(String value); static long parseDuration(String v); static String jsonStringFromObject(Object object); static ObjectMapper getObjectMapper(); }
Utils { public static Response getErrorResponse(String id, int status, String message, String context) { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.id = id; errorResponse.errorSource = context; errorResponse.errorMessage = message; String jsonErrorResponse = jsonStringFromObject(errorResponse); return Response.status(status) .entity(jsonErrorResponse) .build(); } private  Utils(); static Map<String, Object> makeError(String errorMessage, String errorCause, String errorPart); static Response getErrorResponse(String id, int status,
                                            String message, String context); static String createUuid(); static long parseDate(String value); static long parseDuration(String v); static String jsonStringFromObject(Object object); static ObjectMapper getObjectMapper(); static final String NOW; static final String DEFAULT_START_TIME; static final String DEFAULT_END_TIME; static final String NOT_SPECIFIED; static final String CLIENT_ID; static final String ERRORS; static final String ERROR_MESSAGE; static final String ERROR_CAUSE; static final String ERROR_PART; static final String START; static final String END; static final String COUNT; static final double DEFAULT_DOWNSAMPLE_MULTIPLIER; static final int DAYS_PER_YEAR; static final int DAYS_PER_WEEK; static final int HOURS_PER_DAY; static final int MINUTES_PER_HOUR; static final int SECONDS_PER_MINUTE; static final int SECONDS_PER_HOUR; static final int SECONDS_PER_DAY; static final int SECONDS_PER_WEEK; static final int SECONDS_PER_YEAR; }