SecondaryMarketplaceComparator implements Comparator<ParticipationDescriptor> { @Override public int compare(final ParticipationDescriptor p1, final ParticipationDescriptor p2) { return comparator.compare(p1.item(), p2.item()); } SecondaryMarketplaceComparator(Comparator<Rating> ratingByDemandComparator); @Override int compare(final ParticipationDescriptor p1, final ParticipationDescriptor p2);  }
@Test void sortByRating() { final Loan l1 = new MockLoanBuilder() .set(LoanImpl::setRating, Rating.D) .build(); final Loan l2 = new MockLoanBuilder() .set(LoanImpl::setRating, Rating.A) .build(); final ParticipationDescriptor pd1 = mockParticipationDescriptor(l1), pd2 = mockParticipationDescriptor(l2); assertSoftly(softly -> { softly.assertThat(c.compare(pd1, pd2)) .isGreaterThan(0); softly.assertThat(c.compare(pd2, pd1)) .isLessThan(0); softly.assertThat(c.compare(pd1, pd1)) .isEqualTo(0); }); }