@Test public void testHashCode() { String exception = "NullPointerOfCourse"; String message = "because why not!"; CrashStackTrace st = new CrashStackTrace(exception, message); CrashStackTrace st2 = new CrashStackTrace(exception, message); assertThat("Hash codes generated on the same objects should be equal!", st.hashCode(), equalTo(st.hashCode())); assertThat("Hash codes generated on equal objects should be equal!", st.hashCode(), equalTo(st2.hashCode())); assertThat("Hash codes generated on non equal objects should be different!", st.hashCode(), not(new CrashStackTrace(exception, message, st2).hashCode())); st.addFrame(new Frame("clazz", "method")); st.addFrame(new Frame("clazz2", "method2")); assertThat("Hash codes generated on the same objects should be equal!", st.hashCode(), equalTo(st.hashCode())); assertThat("Hash codes generated on non equal objects should be different!", st.hashCode(), not(st2.hashCode())); st2.addFrame(new Frame("clazz", "method")); st2.addFrame(new Frame("clazz2", "method2")); assertThat("Hash codes generated on the same objects should be equal!", st.hashCode(), equalTo(st.hashCode())); assertThat("Hash codes generated on equal objects should be equal!", st.hashCode(), equalTo(st2.hashCode())); st.setCause(new CrashStackTrace("except", message)); assertThat("Hash codes generated on the same objects should be equal!", st.hashCode(), equalTo(st.hashCode())); assertThat("Hash codes generated on non equal objects should be different!", st.hashCode(), not(st2.hashCode())); st2.setCause(new CrashStackTrace("except", message)); assertThat("Hash codes generated on the same objects should be equal!", st.hashCode(), equalTo(st.hashCode())); assertThat("Hash codes generated on equal objects should be equal!", st.hashCode(), equalTo(st2.hashCode())); }
@Override public int hashCode() { return Objects.hash(exceptionClass, errorMessage, frames, cause); }
CrashStackTrace implements Iterable<Frame> { @Override public int hashCode() { return Objects.hash(exceptionClass, errorMessage, frames, cause); } }
CrashStackTrace implements Iterable<Frame> { @Override public int hashCode() { return Objects.hash(exceptionClass, errorMessage, frames, cause); } CrashStackTrace();  CrashStackTrace(String exceptionClass, String errorMessage);  CrashStackTrace(String exceptionClass, String errorMessage, CrashStackTrace cause); }
CrashStackTrace implements Iterable<Frame> { @Override public int hashCode() { return Objects.hash(exceptionClass, errorMessage, frames, cause); } CrashStackTrace();  CrashStackTrace(String exceptionClass, String errorMessage);  CrashStackTrace(String exceptionClass, String errorMessage, CrashStackTrace cause); String getExceptionClass(); void setExceptionClass(String exceptionClass); String getErrorMessage(); void setErrorMessage(String errorMessage); CrashStackTrace getCause(); void setCause(CrashStackTrace stackTrace); @Override Iterator<Frame> iterator(); Frame removeFrame(int level); void addFrame(Frame frame); int highestFrameLevel(); Frame getFrame(int level); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); }
CrashStackTrace implements Iterable<Frame> { @Override public int hashCode() { return Objects.hash(exceptionClass, errorMessage, frames, cause); } CrashStackTrace();  CrashStackTrace(String exceptionClass, String errorMessage);  CrashStackTrace(String exceptionClass, String errorMessage, CrashStackTrace cause); String getExceptionClass(); void setExceptionClass(String exceptionClass); String getErrorMessage(); void setErrorMessage(String errorMessage); CrashStackTrace getCause(); void setCause(CrashStackTrace stackTrace); @Override Iterator<Frame> iterator(); Frame removeFrame(int level); void addFrame(Frame frame); int highestFrameLevel(); Frame getFrame(int level); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }