@Test public void parseErrorType_ErrorTypeInHeadersTakesPrecedence_NoSuffix() { String actualErrorType = parser.parseErrorCode( httpResponseWithHeaders(JsonErrorCodeParser.X_AMZN_ERROR_TYPE, HEADER_ERROR_TYPE), toJsonContent(JSON_ERROR_TYPE)); assertEquals(HEADER_ERROR_TYPE, actualErrorType); }
public String parseErrorCode(HttpResponse response, JsonContent jsonContent) { String errorCodeFromHeader = parseErrorCodeFromHeader(response.getHeaders()); if (errorCodeFromHeader != null) { return errorCodeFromHeader; } else if (jsonContent != null) { return parseErrorCodeFromContents(jsonContent.getJsonNode()); } else { return null; } }
JsonErrorCodeParser implements ErrorCodeParser { public String parseErrorCode(HttpResponse response, JsonContent jsonContent) { String errorCodeFromHeader = parseErrorCodeFromHeader(response.getHeaders()); if (errorCodeFromHeader != null) { return errorCodeFromHeader; } else if (jsonContent != null) { return parseErrorCodeFromContents(jsonContent.getJsonNode()); } else { return null; } } }
JsonErrorCodeParser implements ErrorCodeParser { public String parseErrorCode(HttpResponse response, JsonContent jsonContent) { String errorCodeFromHeader = parseErrorCodeFromHeader(response.getHeaders()); if (errorCodeFromHeader != null) { return errorCodeFromHeader; } else if (jsonContent != null) { return parseErrorCodeFromContents(jsonContent.getJsonNode()); } else { return null; } } JsonErrorCodeParser();  JsonErrorCodeParser(String errorCodeFieldName); }
JsonErrorCodeParser implements ErrorCodeParser { public String parseErrorCode(HttpResponse response, JsonContent jsonContent) { String errorCodeFromHeader = parseErrorCodeFromHeader(response.getHeaders()); if (errorCodeFromHeader != null) { return errorCodeFromHeader; } else if (jsonContent != null) { return parseErrorCodeFromContents(jsonContent.getJsonNode()); } else { return null; } } JsonErrorCodeParser();  JsonErrorCodeParser(String errorCodeFieldName); String parseErrorCode(HttpResponse response, JsonContent jsonContent); }
JsonErrorCodeParser implements ErrorCodeParser { public String parseErrorCode(HttpResponse response, JsonContent jsonContent) { String errorCodeFromHeader = parseErrorCodeFromHeader(response.getHeaders()); if (errorCodeFromHeader != null) { return errorCodeFromHeader; } else if (jsonContent != null) { return parseErrorCodeFromContents(jsonContent.getJsonNode()); } else { return null; } } JsonErrorCodeParser();  JsonErrorCodeParser(String errorCodeFieldName); String parseErrorCode(HttpResponse response, JsonContent jsonContent);  }