InvestmentDescriptor implements Descriptor<RecommendedInvestment, InvestmentDescriptor, Investment> { @Override public boolean equals(final Object o) { if (this == o) { return true; } if (o == null || !Objects.equals(getClass(), o.getClass())) { return false; } final InvestmentDescriptor that = (InvestmentDescriptor) o; return Objects.equals(investment, that.investment); } InvestmentDescriptor(final Investment investment, final Supplier<Loan> related); @Override Investment item(); @Override Loan related(); Optional<RecommendedInvestment> recommend(); @Override Optional<RecommendedInvestment> recommend(final Money amount); @Override boolean equals(final Object o); @Override String toString(); @Override int hashCode();  }
@Test void equals() { final Investment i = mockInvestment(BigDecimal.TEN); final InvestmentDescriptor id = new InvestmentDescriptor(i, () -> LOAN); assertSoftly(softly -> { softly.assertThat(id) .isNotEqualTo(null); softly.assertThat(id) .isNotEqualTo(UUID.randomUUID() .toString()); softly.assertThat(id) .isEqualTo(id); }); final InvestmentDescriptor id2 = new InvestmentDescriptor(i, () -> LOAN); assertSoftly(softly -> { softly.assertThat(id) .isEqualTo(id2); softly.assertThat(id2) .isEqualTo(id); }); final InvestmentDescriptor id3 = new InvestmentDescriptor(mockInvestment(BigDecimal.ONE), () -> LOAN); assertThat(id).isNotEqualTo(id3); }