@Test public void testEquals() throws Exception { String testMessage = "Message for Unit Test"; QueryStatus one = new QueryStatus(QueryStatus.QueryStatusEnum.WARNING, testMessage); Assert.assertEquals("A QueryStatus object should be equal to itself.", one, one); QueryStatus other = new QueryStatus(QueryStatus.QueryStatusEnum.WARNING, testMessage); Assert.assertEquals("Two QueryStatus objects created with the same parameters should be equal.", one, other); other.setMessage("A different message"); Assert.assertNotEquals("QueryStatus objects with different messages should not be equal.", one, other); other.setMessage(testMessage); Assert.assertEquals("QueryStatus objects should be equal after setting message back to same value", one, other); other.setStatus(QueryStatus.QueryStatusEnum.ERROR); Assert.assertNotEquals("QueryStatusObjects with different statuses should not be equal.", one, other); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryStatus that = (QueryStatus) o; if (message != null ? !message.equals(that.message) : that.message != null) return false; if (status != that.status) return false; return true; }
QueryStatus { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryStatus that = (QueryStatus) o; if (message != null ? !message.equals(that.message) : that.message != null) return false; if (status != that.status) return false; return true; } }
QueryStatus { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryStatus that = (QueryStatus) o; if (message != null ? !message.equals(that.message) : that.message != null) return false; if (status != that.status) return false; return true; } QueryStatus();  QueryStatus(QueryStatusEnum status, String message); }
QueryStatus { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryStatus that = (QueryStatus) o; if (message != null ? !message.equals(that.message) : that.message != null) return false; if (status != that.status) return false; return true; } QueryStatus();  QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int hashCode(); QueryStatusEnum getStatus(); void setStatus(QueryStatusEnum status); String getMessage(); void setMessage(String message); }
QueryStatus { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryStatus that = (QueryStatus) o; if (message != null ? !message.equals(that.message) : that.message != null) return false; if (status != that.status) return false; return true; } QueryStatus();  QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int hashCode(); QueryStatusEnum getStatus(); void setStatus(QueryStatusEnum status); String getMessage(); void setMessage(String message);  }