User { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof User)) { return false; } User other = (User) obj; return Objects.equals(this.email, other.email) && Objects.equals(this.password, other.password) && Objects.equals(this.properties, other.properties); } @JsonCreator  User(@JsonProperty("email") Email email,
              @JsonProperty("password") String password,
              @JsonProperty("properties") Map<String, Object> properties); Email getEmail(); String getPassword(); @JsonAnyGetter Map<String, Object> getProperties(); @JsonAnySetter void setProperty(String name, Object value); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test @SuppressWarnings({"ConstantConditions", "ObjectEqualsNull"}) void testEquals() { assertAll("Basic equals properties", () -> assertTrue(!emptyPropertiesUser.equals(null), "User must not be equal to null"), () -> assertTrue(!emptyPropertiesUser.equals(new Object()), "User must not be equal to another type"), () -> assertEquals(emptyPropertiesUser, emptyPropertiesUser, "User must be equal to itself")); User differentEmail = new User(new Email("bad@test.com", false, "token"), PASSWORD, Collections.emptyMap()); User differentPassword = new User(EMAIL, "54321", Collections.emptyMap()); User differentProperties = new User(EMAIL, PASSWORD, Collections.singletonMap("Test", "Map")); User sameUser = new User(EMAIL, PASSWORD, Collections.emptyMap()); assertAll("Verify against other created objects", () -> assertNotEquals(differentEmail, emptyPropertiesUser), () -> assertNotEquals(differentPassword, emptyPropertiesUser), () -> assertNotEquals(differentProperties, emptyPropertiesUser), () -> assertEquals(sameUser, emptyPropertiesUser)); }