### Question:
BaseException extends Exception { @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof BaseException)) return false; BaseException that = (BaseException) o; if (getMessage() != null ? !getMessage().equals(that.getMessage()) : that.getMessage() != null) return false; if (getCause() != null ? !getCause().equals(that.getCause()) : that.getCause() != null) return false; return (getErrorCode() != null ? getErrorCode().equals(that.getErrorCode()) : that.getErrorCode() == null); } BaseException(String message, Throwable cause, String errorCode); String getErrorCode(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void equalsIsTrueForSameObject() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); assertTrue(base.equals(base)); }
@Test public void equalsIsTrueForEquivalentObject() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(MESSAGE, CAUSE, CODE); assertTrue(base.equals(other)); }
@Test public void equalsIsFalseForDifferentMessage() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(null, CAUSE, CODE); assertFalse(base.equals(other)); }
@Test public void equalsIsFalseForDifferentCause() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(MESSAGE, null, CODE); assertFalse(base.equals(other)); }
@Test public void equalsIsFalseForDifferentErrorCode() throws Exception { BaseException base = new BaseException(MESSAGE, CAUSE, CODE); BaseException other = new BaseException(MESSAGE, CAUSE, null); assertFalse(base.equals(other)); }