@Test public void notEqualWithDifferentId() { final int newId = 2; final Customer otherCustomer = new Customer(newId, FIRSTNAME, LASTNAME); assertNotEquals(customer, otherCustomer); assertNotEquals(customer.hashCode(), otherCustomer.hashCode()); }
@Override public int hashCode() { return getId(); }
Customer { @Override public int hashCode() { return getId(); } }
Customer { @Override public int hashCode() { return getId(); } Customer(final int id, final String firstName, final String lastName); }
Customer { @Override public int hashCode() { return getId(); } Customer(final int id, final String firstName, final String lastName); int getId(); void setId(final int id); String getFirstName(); void setFirstName(final String firstName); String getLastName(); void setLastName(final String lastName); @Override String toString(); @Override boolean equals(final Object that); @Override int hashCode(); }
Customer { @Override public int hashCode() { return getId(); } Customer(final int id, final String firstName, final String lastName); int getId(); void setId(final int id); String getFirstName(); void setFirstName(final String firstName); String getLastName(); void setLastName(final String lastName); @Override String toString(); @Override boolean equals(final Object that); @Override int hashCode();  }