PatientValidator { @NotNull @VisibleForTesting static List<ValidationFinding> validateBiopsies(@NotNull String patientIdentifier, @NotNull List<BiopsyData> biopsies) { List<ValidationFinding> findings = Lists.newArrayList(); for (BiopsyData biopsy : biopsies) { if (biopsy.sampleId() != null) { if (biopsy.date() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Biopsy date empty or in wrong format", biopsy.formStatus())); } if (biopsy.site() == null && biopsy.location() == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Biopsy site and biopsy location are empty", biopsy.formStatus())); } } } return findings; }  @NotNull static List<ValidationFinding> validatePatient(@NotNull Patient patient);  }
@Test public void reportsOnMatchedBiopsiesWithMissingFields() { List<ValidationFinding> findings = PatientValidator.validateBiopsies(PATIENT_IDENTIFIER, Lists.newArrayList(BIOPSY_NULL, BIOPSY_FEB_WITH_SITE, BIOPSY_FEB_WITH_LOCATION)); assertEquals(2, findings.size()); findings.stream().map(ValidationFinding::patientIdentifier).forEach(id -> assertEquals(PATIENT_IDENTIFIER, id)); }