DiagnosticResponse implements Serializable { @Override public int hashCode() { return Objects.hash(body, errorType, errorStack); } DiagnosticResponse(T body);  DiagnosticResponse(T body, Throwable error); @JsonCreator  DiagnosticResponse(@JsonProperty("body") T body,
                     @JsonProperty("errorType") String errorType,
                     @JsonProperty("errorMessage") String errorMessage,
                     @JsonProperty("errorStack") String errorStack); Optional<String> getErrorType(); Optional<String> getErrorMessage(); Optional<String> getErrorStack(); @JsonIgnore Optional<String> getError(); @JsonIgnore boolean hasError(); T getBody(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void test_hashCode_considers_everything() { DiagnosticResponse<String> request1 = new DiagnosticResponse<>("foo"); DiagnosticResponse<String> request2 = new DiagnosticResponse<>("foo"); Throwable error = new Throwable(""); DiagnosticResponse<String> request3 = new DiagnosticResponse<>(null, error); DiagnosticResponse<String> request4 = new DiagnosticResponse<>(null, error); assertThat(request1.hashCode(), is(equalTo(request2.hashCode()))); assertThat(request3.hashCode(), is(equalTo(request4.hashCode()))); }