### Question:
BaseException extends Exception { @Override public int hashCode() { int hashCode = 31 * (getMessage() != null ? getMessage().hashCode() : 0); hashCode += 31 * (getCause() != null ? getCause().hashCode() : 0); hashCode += 31 * (getErrorCode() != null ? getErrorCode().hashCode() : 0); return hashCode; } BaseException(String message, Throwable cause, String errorCode); String getErrorCode(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void hashCodeIsEqualForSameObject() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); assertEquals(base.hashCode(), base.hashCode()); }
@Test public void hashCodeIsEqualForEquivalentObject() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(MESSAGE, CAUSE, CODE); assertEquals(base.hashCode(), other.hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentMessage() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(null, CAUSE, CODE); assertNotEquals(base.hashCode(), other.hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentCause() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(MESSAGE, null, CODE); assertNotEquals(base.hashCode(), other.hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentErrorCode() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(MESSAGE, CAUSE, null); assertNotEquals(base.hashCode(), other.hashCode()); }