### Question:
Session { @Override public int hashCode() { int result = serviceId != null ? serviceId.hashCode() : 0; result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0); result = 31 * result + (serviceIcon != null ? serviceIcon.hashCode() : 0); result = 31 * result + (authRequest != null ? authRequest.hashCode() : 0); result = 31 * result + (created != null ? created.hashCode() : 0); return result; } Session(UUID serviceId, String serviceName, URI serviceIcon, UUID authRequest, Date created); UUID getServiceId(); String getServiceName(); URI getServiceIcon(); UUID getAuthRequest(); Date getCreated(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void hashCodeEqualForSameValues() throws Exception { UUID id = UUID.randomUUID(); UUID auth = UUID.randomUUID(); URI icon = URI.create("http: Date created = new Date(123456L); assertEquals(new Session(id, "Name", icon, auth, created).hashCode(), new Session(id, "Name", icon, auth, created).hashCode()); }
@Test public void hashCodeNotEqualForDifferentServiceId() throws Exception { UUID id = UUID.randomUUID(); UUID auth = UUID.randomUUID(); URI icon = URI.create("http: Date created = new Date(123456L); assertNotEquals(new Session(id, "Name", icon, auth, created).hashCode(), new Session(UUID.randomUUID(), "Name", icon, auth, created).hashCode()); }
@Test public void hashCodeNotEqualForDifferentServiceName() throws Exception { UUID id = UUID.randomUUID(); UUID auth = UUID.randomUUID(); URI icon = URI.create("http: Date created = new Date(123456L); assertNotEquals(new Session(id, "Name", icon, auth, created).hashCode(), new Session(id, "Other", icon, auth, created).hashCode()); }
@Test public void hashCodeNotEqualForDifferentServiceIcon() throws Exception { UUID id = UUID.randomUUID(); UUID auth = UUID.randomUUID(); URI icon = URI.create("http: Date created = new Date(123456L); assertNotEquals(new Session(id, "Name", icon, auth, created).hashCode(), new Session(id, "Name", URI.create("http: }
@Test public void hashCodeNotEqualForDifferentAuthRequest() throws Exception { UUID id = UUID.randomUUID(); UUID auth = UUID.randomUUID(); URI icon = URI.create("http: Date created = new Date(123456L); assertNotEquals(new Session(id, "Name", icon, auth, created).hashCode(), new Session(id, "Name", icon, UUID.randomUUID(), created).hashCode()); }
@Test public void hashCodeNotEqualForDifferentCreated() throws Exception { UUID id = UUID.randomUUID(); UUID auth = UUID.randomUUID(); URI icon = URI.create("http: Date created = new Date(123456L); assertNotEquals(new Session(id, "Name", icon, auth, created).hashCode(), new Session(id, "Name", icon, auth, new Date(654321L)).hashCode()); }