ReservationComparator implements Comparator<ReservationDescriptor> { @Override public int compare(final ReservationDescriptor loan1, final ReservationDescriptor loan2) { return comparator.compare(loan1.item(), loan2.item()); } ReservationComparator(Comparator<Rating> ratingByDemandComparator); @Override int compare(final ReservationDescriptor loan1, final ReservationDescriptor loan2);  }
@Test void sortByRating() { final Reservation l1 = new MockReservationBuilder() .set(ReservationImpl::setRating, Rating.D) .build(); final Reservation l2 = new MockReservationBuilder() .set(ReservationImpl::setRating, Rating.A) .build(); final ReservationDescriptor ld1 = new ReservationDescriptor(l1, () -> null), ld2 = new ReservationDescriptor(l2, () -> null); assertSoftly(softly -> { softly.assertThat(c.compare(ld1, ld2)) .isGreaterThan(0); softly.assertThat(c.compare(ld2, ld1)) .isLessThan(0); softly.assertThat(c.compare(ld1, ld1)) .isEqualTo(0); }); }