@Test public void createFailureAlertWithTranslation() { HttpHeaders headers = HeaderUtil.createFailureAlert("myApp", true, "User", "404", "Failed to find user"); assertThat(headers.getFirst("X-myApp-error")).isEqualTo("error.404"); assertThat(headers.getFirst("X-myApp-params")).isEqualTo("User"); }
public static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage) { log.error("Entity processing failed, {}", defaultMessage); String message = enableTranslation ? "error." + errorKey : defaultMessage; HttpHeaders headers = new HttpHeaders(); headers.add("X-" + applicationName + "-error", message); headers.add("X-" + applicationName + "-params", entityName); return headers; }
HeaderUtil { public static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage) { log.error("Entity processing failed, {}", defaultMessage); String message = enableTranslation ? "error." + errorKey : defaultMessage; HttpHeaders headers = new HttpHeaders(); headers.add("X-" + applicationName + "-error", message); headers.add("X-" + applicationName + "-params", entityName); return headers; } }
HeaderUtil { public static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage) { log.error("Entity processing failed, {}", defaultMessage); String message = enableTranslation ? "error." + errorKey : defaultMessage; HttpHeaders headers = new HttpHeaders(); headers.add("X-" + applicationName + "-error", message); headers.add("X-" + applicationName + "-params", entityName); return headers; } private  HeaderUtil(); }
HeaderUtil { public static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage) { log.error("Entity processing failed, {}", defaultMessage); String message = enableTranslation ? "error." + errorKey : defaultMessage; HttpHeaders headers = new HttpHeaders(); headers.add("X-" + applicationName + "-error", message); headers.add("X-" + applicationName + "-params", entityName); return headers; } private  HeaderUtil(); static HttpHeaders createAlert(String applicationName, String message, String param); static HttpHeaders createEntityCreationAlert(String applicationName, boolean enableTranslation, String entityName, String param); static HttpHeaders createEntityUpdateAlert(String applicationName, boolean enableTranslation, String entityName, String param); static HttpHeaders createEntityDeletionAlert(String applicationName, boolean enableTranslation, String entityName, String param); static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage); }
HeaderUtil { public static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage) { log.error("Entity processing failed, {}", defaultMessage); String message = enableTranslation ? "error." + errorKey : defaultMessage; HttpHeaders headers = new HttpHeaders(); headers.add("X-" + applicationName + "-error", message); headers.add("X-" + applicationName + "-params", entityName); return headers; } private  HeaderUtil(); static HttpHeaders createAlert(String applicationName, String message, String param); static HttpHeaders createEntityCreationAlert(String applicationName, boolean enableTranslation, String entityName, String param); static HttpHeaders createEntityUpdateAlert(String applicationName, boolean enableTranslation, String entityName, String param); static HttpHeaders createEntityDeletionAlert(String applicationName, boolean enableTranslation, String entityName, String param); static HttpHeaders createFailureAlert(String applicationName, boolean enableTranslation, String entityName, String errorKey, String defaultMessage);  }