### Question:
RadiologyReportValidator implements Validator { @Override public void validate(Object obj, Errors errors) { final RadiologyReport radiologyReport = (RadiologyReport) obj; if (radiologyReport == null) { errors.reject("error.general"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "principalResultsInterpreter", "error.null", "Provider cannot be null"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "body", "error.null", "Diagnosis cannot be null"); } }  @Override boolean supports(Class clazz); @Override void validate(Object obj, Errors errors);  }### Answer:
@Test public void shouldFailValidationIfRadiologyReportIsNull() throws Exception { radiologyReportValidator.validate(null, errors); assertSingleGeneralError(errors); }
@Test public void shouldFailValidationIfPrincipalResultsInterpreterIsNull() throws Exception { radiologyReport.setPrincipalResultsInterpreter(null); radiologyReportValidator.validate(radiologyReport, errors); assertSingleNullErrorInField(errors, "principalResultsInterpreter"); }
@Test public void shouldFailValidationIfReportBodyIsNull() throws Exception { radiologyReport.setBody(null); radiologyReportValidator.validate(radiologyReport, errors); assertSingleNullErrorInField(errors, "body"); }
@Test public void shouldFailValidationIfReportBodyIsEmpty() throws Exception { radiologyReport.setBody(""); radiologyReportValidator.validate(radiologyReport, errors); assertSingleNullErrorInField(errors, "body"); }
@Test public void shouldFailValidationIfReportBodyIsWhitespacesOnly() throws Exception { radiologyReport.setBody(" "); radiologyReportValidator.validate(radiologyReport, errors); assertSingleNullErrorInField(errors, "body"); }
@Test public void shouldPassValidationIfAllFieldsAreCorrect() throws Exception { radiologyReportValidator.validate(radiologyReport, errors); assertFalse(errors.hasErrors()); }