@Test public void testValidatorInValid() throws IOException, NoSuchFieldException, IllegalAccessException { Resource xmlResource = new ClassPathResource("emptyXml/InterchangeStudent.xml"); File xmlFile = xmlResource.getFile(); IngestionFileEntry ife = new IngestionFileEntry(xmlFile.getParentFile().getAbsolutePath(), FileFormat.EDFI_XML, FileType.XML_STUDENT_PARENT_ASSOCIATION, xmlFile.getName(), ""); List<IngestionFileEntry> fileEntries = new ArrayList<IngestionFileEntry>(); fileEntries.add(ife); ControlFile cfl = Mockito.mock(ControlFile.class); Mockito.when(cfl.getFileEntries()).thenReturn(fileEntries); AbstractMessageReport messageReport = Mockito.mock(AbstractMessageReport.class); PrivateAccessor.setField(validationController, "messageReport", messageReport); ReportStats reportStats = Mockito.mock(ReportStats.class); Mockito.when(reportStats.hasErrors()).thenReturn(true); validationController.processValidators(cfl, reportStats); Mockito.verify(messageReport, Mockito.atLeastOnce()).info(Matchers.any(ReportStats.class), Matchers.any(Source.class), Matchers.eq(ValidationMessageCode.VALIDATION_0003), Matchers.eq(xmlFile.getName())); }
public void processValidators(ControlFile cfile, ReportStats reportStats) { boolean isValid = false; for (IngestionFileEntry ife : cfile.getFileEntries()) { if (ife.isValid()) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0002, ife.getFileName()); isValid = complexValidator.isValid(ife, messageReport, reportStats, new XmlFileSource(ife), null); if (!isValid) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0003, ife.getFileName()); continue; } messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0004, ife.getFileName()); } } }
ValidationController { public void processValidators(ControlFile cfile, ReportStats reportStats) { boolean isValid = false; for (IngestionFileEntry ife : cfile.getFileEntries()) { if (ife.isValid()) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0002, ife.getFileName()); isValid = complexValidator.isValid(ife, messageReport, reportStats, new XmlFileSource(ife), null); if (!isValid) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0003, ife.getFileName()); continue; } messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0004, ife.getFileName()); } } } }
ValidationController { public void processValidators(ControlFile cfile, ReportStats reportStats) { boolean isValid = false; for (IngestionFileEntry ife : cfile.getFileEntries()) { if (ife.isValid()) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0002, ife.getFileName()); isValid = complexValidator.isValid(ife, messageReport, reportStats, new XmlFileSource(ife), null); if (!isValid) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0003, ife.getFileName()); continue; } messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0004, ife.getFileName()); } } }  }
ValidationController { public void processValidators(ControlFile cfile, ReportStats reportStats) { boolean isValid = false; for (IngestionFileEntry ife : cfile.getFileEntries()) { if (ife.isValid()) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0002, ife.getFileName()); isValid = complexValidator.isValid(ife, messageReport, reportStats, new XmlFileSource(ife), null); if (!isValid) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0003, ife.getFileName()); continue; } messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0004, ife.getFileName()); } } }  void doValidation(File path); void processValidators(ControlFile cfile, ReportStats reportStats); void processZip(File zipFile, ReportStats reportStats); void processControlFile(File parentDirectoryOrZipFile, String ctlFile, ReportStats reportStats); Handler<Resource, String> getZipFileHandler(); void setZipFileHandler(Handler<Resource, String> zipFileHandler); ComplexValidator<IngestionFileEntry> getComplexValidator(); void setComplexValidator(ComplexValidator<IngestionFileEntry> complexValidator); Validator<ControlFile> getControlFilevalidator(); void setControlFilevalidator(Validator<ControlFile> controlFilevalidator); AbstractMessageReport getMessageReport(); void setMessageReport(AbstractMessageReport messageReport); }
ValidationController { public void processValidators(ControlFile cfile, ReportStats reportStats) { boolean isValid = false; for (IngestionFileEntry ife : cfile.getFileEntries()) { if (ife.isValid()) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0002, ife.getFileName()); isValid = complexValidator.isValid(ife, messageReport, reportStats, new XmlFileSource(ife), null); if (!isValid) { messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0003, ife.getFileName()); continue; } messageReport.info(reportStats, new XmlFileSource(ife), ValidationMessageCode.VALIDATION_0004, ife.getFileName()); } } }  void doValidation(File path); void processValidators(ControlFile cfile, ReportStats reportStats); void processZip(File zipFile, ReportStats reportStats); void processControlFile(File parentDirectoryOrZipFile, String ctlFile, ReportStats reportStats); Handler<Resource, String> getZipFileHandler(); void setZipFileHandler(Handler<Resource, String> zipFileHandler); ComplexValidator<IngestionFileEntry> getComplexValidator(); void setComplexValidator(ComplexValidator<IngestionFileEntry> complexValidator); Validator<ControlFile> getControlFilevalidator(); void setControlFilevalidator(Validator<ControlFile> controlFilevalidator); AbstractMessageReport getMessageReport(); void setMessageReport(AbstractMessageReport messageReport);  }