### Question:
Device { @Override public int hashCode() { int result = getId() != null ? getId().hashCode() : 0; result = 31 * result + (getName() != null ? getName().hashCode() : 0); result = 31 * result + (getStatus() != null ? getStatus().hashCode() : 0); result = 31 * result + (getType() != null ? getType().hashCode() : 0); result = 31 * result + (getCreated() != null ? getCreated().hashCode() : 0); result = 31 * result + (getUpdated() != null ? getUpdated().hashCode() : 0); return result; } Device(String id, String name, DeviceStatus status, String type, Date created, Date updated); String getId(); String getName(); DeviceStatus getStatus(); String getType(); Date getCreated(); Date getUpdated(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void hashCodeIsEqualForSameObject() throws Exception { assertEquals(device.hashCode(), device.hashCode()); }
@Test public void hashCodeIsEqualForEquivalentObject() throws Exception { assertEquals(device.hashCode(), new Device(ID, NAME, DeviceStatus.LINKED, TYPE, CREATED, UPDATED).hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentName() throws Exception { assertNotEquals(device.hashCode(), new Device(ID, null, DeviceStatus.LINKED, TYPE, CREATED, UPDATED).hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentStatus() throws Exception { assertNotEquals(device.hashCode(), new Device(ID, NAME, DeviceStatus.UNLINK_PENDING, TYPE, CREATED, UPDATED).hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentType() throws Exception { assertNotEquals(device.hashCode(), new Device(ID, NAME, DeviceStatus.LINKED, null, CREATED, UPDATED).hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentDateCreated() throws Exception { assertNotEquals(device.hashCode(), new Device(ID, NAME, DeviceStatus.LINKED, TYPE, null, UPDATED).hashCode()); }
@Test public void hashCodeIsNotEqualForDifferentDateUpdated() throws Exception { assertNotEquals(device.hashCode(), new Device(ID, NAME, DeviceStatus.LINKED, TYPE, CREATED, null).hashCode()); }