PatientValidator { @NotNull @VisibleForTesting static List<ValidationFinding> validatePreTreatmentData(@NotNull String patientIdentifier, @NotNull PreTreatmentData preTreatmentData) { String preTreatmentGiven = preTreatmentData.treatmentGiven(); String preRadioTreatmentGiven = preTreatmentData.radiotherapyGiven(); List<ValidationFinding> findings = Lists.newArrayList(); if (preTreatmentGiven == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Pre systemic treatment given empty", preTreatmentData.formStatus())); } if (preRadioTreatmentGiven == null) { findings.add(ValidationFinding.of(ECRF_LEVEL, patientIdentifier, "Pre radio treatment given empty", preTreatmentData.formStatus())); } return findings; }  @NotNull static List<ValidationFinding> validatePatient(@NotNull Patient patient);  }
@Test public void canValidatePreTreatmentData() { PreTreatmentData emptyData = ImmutablePreTreatmentData.builder().formStatus(FormStatus.undefined()).build(); assertEquals(2, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, emptyData).size()); PreTreatmentData actualData = ImmutablePreTreatmentData.builder() .radiotherapyGiven("Yes") .treatmentGiven("No") .formStatus(FormStatus.undefined()) .build(); assertEquals(0, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, actualData).size()); PreTreatmentData onlyRadioTherapyPresent = ImmutablePreTreatmentData.builder().radiotherapyGiven("Yes").formStatus(FormStatus.undefined()).build(); assertEquals(1, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, onlyRadioTherapyPresent).size()); PreTreatmentData onlyTreatmentPresent = ImmutablePreTreatmentData.builder().treatmentGiven("Yes").formStatus(FormStatus.undefined()).build(); assertEquals(1, PatientValidator.validatePreTreatmentData(PATIENT_IDENTIFIER, onlyTreatmentPresent).size()); }