ErrorMessage { @Override public boolean equals(Object o) { if (!(o instanceof ErrorMessage)) return false; ErrorMessage other = (ErrorMessage) o; if (this.code != other.code) return false; if (!this.message.equals(other.message)) return false; if (this.detailedMessage==null) return other.detailedMessage==null; if (other.detailedMessage==null) return false; return this.detailedMessage.equals(other.detailedMessage); } ErrorMessage();  ErrorMessage(int code, String message);  ErrorMessage(int code, String message, String detailedMessage);  ErrorMessage(int code, String message, String detailedMessage, Throwable cause); int getCode(); String getMessage(); String getDetailedMessage(); void setCause(Throwable cause); Throwable getCause(); int hashCode(); @Override boolean equals(Object o); @Override String toString();  }
@Test public void testErrorMessageEquality() { assertEquals(new ErrorMessage(17,"Message"),new ErrorMessage(17,"Message")); assertFalse(new ErrorMessage(16,"Message").equals(new ErrorMessage(17,"Message"))); assertFalse(new ErrorMessage(17,"Message").equals(new ErrorMessage(17,"Other message"))); assertFalse(new ErrorMessage(17,"Message").equals(new ErrorMessage(17,"Message","Detail"))); assertFalse(new ErrorMessage(17,"Message","Detail").equals(new ErrorMessage(17,"Message"))); assertEquals(new ErrorMessage(17,"Message","Detail"),new ErrorMessage(17,"Message","Detail",new Exception())); assertTrue(new ErrorMessage(17,"Message","Detail").equals(new ErrorMessage(17,"Message","Detail"))); assertFalse(new ErrorMessage(17,"Message","Detail").equals(new ErrorMessage(17,"Message","Other detail"))); }