### Question:
QueryStatus { @Override public int hashCode() { int result = message != null ? message.hashCode() : 0; result = 31 * result + (status != null ? status.hashCode() : 0); return result; } 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);  }### Answer:
@Test public void testHashCode() throws Exception { String testMessage = "Message for Unit Test"; QueryStatus.QueryStatusEnum testStatus = QueryStatus.QueryStatusEnum.WARNING; QueryStatus one = new QueryStatus(testStatus, testMessage); Assert.assertEquals("A QueryStatus object should have the same hashcode as itself.", one.hashCode(), one.hashCode()); QueryStatus other = new QueryStatus(testStatus, testMessage); Assert.assertEquals("Two QueryStatus objects created with the same parameters should have same hashcodes.", one.hashCode(), other.hashCode()); other.setMessage("A different message"); Assert.assertNotEquals("QueryStatus objects with different messages should have different hashcodes.", one.hashCode(), other.hashCode()); other.setMessage(testMessage); Assert.assertEquals("QueryStatus objects should have the same hashcode after setting message back to same value", one.hashCode(), other.hashCode()); other.setStatus(QueryStatus.QueryStatusEnum.ERROR); Assert.assertNotEquals("QueryStatusObjects with different statuses should have different hashcodes.", one.hashCode(), other.hashCode()); }