@Test public void compareSameWarningTypeDifferentSeverity() { final Comparator<MedicationsWarningDto> comparator = therapyWarningsProvider.getMedicationsWarningDtoComparator(); final MedicationsWarningDto o1 = getMedicationsWarningDto(WarningType.DUPLICATE, WarningSeverity.LOW); final MedicationsWarningDto o2 = getMedicationsWarningDto(WarningType.DUPLICATE, WarningSeverity.SIGNIFICANT); final int compare = Objects.compare(o1, o2, comparator); final int reverseCompare = Objects.compare(o2, o1, comparator); assertTrue(compare > 0); assertEquals(0, compare + reverseCompare); }
Comparator<MedicationsWarningDto> getMedicationsWarningDtoComparator() { return Comparator .comparing((MedicationsWarningDto w) -> w.getType() != WarningType.UNMATCHED) .thenComparing(MedicationsWarningDto::getSeverity, Comparator.nullsLast(Comparator.naturalOrder())) .thenComparing(MedicationsWarningDto::getType); }
TherapyWarningsProvider { Comparator<MedicationsWarningDto> getMedicationsWarningDtoComparator() { return Comparator .comparing((MedicationsWarningDto w) -> w.getType() != WarningType.UNMATCHED) .thenComparing(MedicationsWarningDto::getSeverity, Comparator.nullsLast(Comparator.naturalOrder())) .thenComparing(MedicationsWarningDto::getType); } }
TherapyWarningsProvider { Comparator<MedicationsWarningDto> getMedicationsWarningDtoComparator() { return Comparator .comparing((MedicationsWarningDto w) -> w.getType() != WarningType.UNMATCHED) .thenComparing(MedicationsWarningDto::getSeverity, Comparator.nullsLast(Comparator.naturalOrder())) .thenComparing(MedicationsWarningDto::getType); }  }
TherapyWarningsProvider { Comparator<MedicationsWarningDto> getMedicationsWarningDtoComparator() { return Comparator .comparing((MedicationsWarningDto w) -> w.getType() != WarningType.UNMATCHED) .thenComparing(MedicationsWarningDto::getSeverity, Comparator.nullsLast(Comparator.naturalOrder())) .thenComparing(MedicationsWarningDto::getType); }  @Required void setMedicationsDao(final MedicationsDao medicationsDao); @Required void setMedicationsExternalService(final MedicationsExternalService medicationsExternalService); @Required void setMentalHealthWarningsHandler(final MentalHealthWarningsHandler mentalHealthWarningsHandler); MedicationWarningsDto findMedicationWarnings(
      final String patientId,
      final long patientAgeInDays,
      final Double patientWeightInKg,
      final Double bsaInM2,
      final boolean isFemale,
      final List<ExternalCatalogDto> patientDiseasesList,
      final List<NamedExternalDto> patientAllergiesList,
      final List<MedicationForWarningsSearchDto> medicationSummaries,
      final Set<WarningSeverity> severityFilterValues,
      final boolean loadCustomWarnings,
      final DateTime when); }
TherapyWarningsProvider { Comparator<MedicationsWarningDto> getMedicationsWarningDtoComparator() { return Comparator .comparing((MedicationsWarningDto w) -> w.getType() != WarningType.UNMATCHED) .thenComparing(MedicationsWarningDto::getSeverity, Comparator.nullsLast(Comparator.naturalOrder())) .thenComparing(MedicationsWarningDto::getType); }  @Required void setMedicationsDao(final MedicationsDao medicationsDao); @Required void setMedicationsExternalService(final MedicationsExternalService medicationsExternalService); @Required void setMentalHealthWarningsHandler(final MentalHealthWarningsHandler mentalHealthWarningsHandler); MedicationWarningsDto findMedicationWarnings(
      final String patientId,
      final long patientAgeInDays,
      final Double patientWeightInKg,
      final Double bsaInM2,
      final boolean isFemale,
      final List<ExternalCatalogDto> patientDiseasesList,
      final List<NamedExternalDto> patientAllergiesList,
      final List<MedicationForWarningsSearchDto> medicationSummaries,
      final Set<WarningSeverity> severityFilterValues,
      final boolean loadCustomWarnings,
      final DateTime when);  }