### Question:
User { @Override public boolean equals(Object o){ if (this == o) { return true; } if (o == null || !getClass().equals(o.getClass())) { return false; } User that = (User) o; return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(email, that.email) && Objects.equals(userId, that.userId); } User();  User(String userId, String name, String email); @Id @GeneratedValue Long getId(); User setId(Long id); String getName(); User setName(String name); String getEmail(); User setEmail(String email); String getUserId(); User setUserId(String userId); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testEquals(){ Long id = 1L; String userId = "dudes"; String userName = "The Dude"; String userEmail = "TheDude@email.com"; User user = new User(userId, userName, userEmail); user.setId(id); User user2 = user; User user3 = new User(userId, userName, userEmail); user3.setId(id); Assert.assertEquals("Same address space", user, user2); Assert.assertEquals("Different Objects same values", user, user3); Assert.assertNotEquals("Different Object Types", user, "Hello World"); Assert.assertNotEquals("Different ids", user.setId(2L), user3); user.setId(id); Assert.assertNotEquals("Different name", user.setUserId(""), user3); user.setUserId(userName); Assert.assertNotEquals("Different application", user.setName(""), user3); user.setName(userEmail); Assert.assertNotEquals("Different instance Id", user.setEmail(""), user3); user.setEmail(userEmail); }