### Question:
Stock { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Stock)) { return false; } Stock that = (Stock) o; return this.symbol.equals(that.symbol) && this.date.equals(that.date) && this.value.equals(that.value); } @JsonCreator  Stock(
      @NonNull @JsonProperty("symbol") String symbol,
      @NonNull @JsonProperty("date") Instant date,
      @NonNull @JsonProperty("value") BigDecimal value); @NonNull String getSymbol(); @NonNull Instant getDate(); @NonNull BigDecimal getValue(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test void should_return_true_when_two_instances_same() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i, value); @SuppressWarnings({"EqualsWithItself", "SelfEquals"}) boolean actual = stock1.equals(stock1); assertThat(actual).isTrue(); }
@Test void should_return_true_when_two_instances_equal() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i, value); var stock2 = new Stock("ABC", i, value); boolean actual = stock1.equals(stock2); assertThat(actual).isTrue(); }
@Test void should_return_false_when_two_instances_have_different_symbols() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i, value); var stock2 = new Stock("DEF", i, value); boolean actual = stock1.equals(stock2); assertThat(actual).isFalse(); }
@Test void should_return_false_when_two_instances_have_different_dates() { var i1 = Instant.parse("2019-01-01T12:34:56.789Z"); var i2 = LocalDateTime.of(2020, Month.MAY, 4, 10, 48, 47, 123_000_000).toInstant(ZoneOffset.UTC); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i1, value); var stock2 = new Stock("ABC", i2, value); boolean actual = stock1.equals(stock2); assertThat(actual).isFalse(); }
@Test void should_return_false_when_two_instances_have_different_values() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value1 = BigDecimal.valueOf(42); BigDecimal value2 = BigDecimal.valueOf(43); var stock1 = new Stock("ABC", i, value1); var stock2 = new Stock("ABC", i, value2); boolean actual = stock1.equals(stock2); assertThat(actual).isFalse(); }
@Test void should_return_false_when_two_instances_not_same_class() { var i = Instant.parse("2019-01-01T12:34:56.789Z"); BigDecimal value = BigDecimal.valueOf(42); var stock1 = new Stock("ABC", i, value); boolean actual = stock1.equals(new Object()); assertThat(actual).isFalse(); }