@Test public void testDirectory() throws NoSuchFieldException, IllegalAccessException, IOException { File ctlFile = Mockito.mock(File.class); Mockito.when(ctlFile.getName()).thenReturn("Test"); Mockito.when(ctlFile.isFile()).thenReturn(false); AbstractMessageReport messageReport = Mockito.mock(AbstractMessageReport.class); PrivateAccessor.setField(validationController, "messageReport", messageReport); validationController.doValidation(ctlFile); Mockito.verify(messageReport, Mockito.atLeastOnce()).error(Matchers.any(ReportStats.class), Matchers.any(Source.class), Matchers.eq(ValidationMessageCode.VALIDATION_0015)); }
public void doValidation(File path) { ReportStats reportStats = new SimpleReportStats(); if (path.isFile()) { if (path.getName().endsWith(".ctl")) { processControlFile(path.getParentFile().getAbsoluteFile(), path.getName(), reportStats); } else if (path.getName().endsWith(".zip")) { processZip(path, reportStats); } else { messageReport.error(reportStats, new FileSource(path.getName()), ValidationMessageCode.VALIDATION_0001); } } else { messageReport.error(reportStats, new DirectorySource(path.getPath(), path.getName()), ValidationMessageCode.VALIDATION_0015); } }
ValidationController { public void doValidation(File path) { ReportStats reportStats = new SimpleReportStats(); if (path.isFile()) { if (path.getName().endsWith(".ctl")) { processControlFile(path.getParentFile().getAbsoluteFile(), path.getName(), reportStats); } else if (path.getName().endsWith(".zip")) { processZip(path, reportStats); } else { messageReport.error(reportStats, new FileSource(path.getName()), ValidationMessageCode.VALIDATION_0001); } } else { messageReport.error(reportStats, new DirectorySource(path.getPath(), path.getName()), ValidationMessageCode.VALIDATION_0015); } } }
ValidationController { public void doValidation(File path) { ReportStats reportStats = new SimpleReportStats(); if (path.isFile()) { if (path.getName().endsWith(".ctl")) { processControlFile(path.getParentFile().getAbsoluteFile(), path.getName(), reportStats); } else if (path.getName().endsWith(".zip")) { processZip(path, reportStats); } else { messageReport.error(reportStats, new FileSource(path.getName()), ValidationMessageCode.VALIDATION_0001); } } else { messageReport.error(reportStats, new DirectorySource(path.getPath(), path.getName()), ValidationMessageCode.VALIDATION_0015); } }  }
ValidationController { public void doValidation(File path) { ReportStats reportStats = new SimpleReportStats(); if (path.isFile()) { if (path.getName().endsWith(".ctl")) { processControlFile(path.getParentFile().getAbsoluteFile(), path.getName(), reportStats); } else if (path.getName().endsWith(".zip")) { processZip(path, reportStats); } else { messageReport.error(reportStats, new FileSource(path.getName()), ValidationMessageCode.VALIDATION_0001); } } else { messageReport.error(reportStats, new DirectorySource(path.getPath(), path.getName()), ValidationMessageCode.VALIDATION_0015); } }  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 doValidation(File path) { ReportStats reportStats = new SimpleReportStats(); if (path.isFile()) { if (path.getName().endsWith(".ctl")) { processControlFile(path.getParentFile().getAbsoluteFile(), path.getName(), reportStats); } else if (path.getName().endsWith(".zip")) { processZip(path, reportStats); } else { messageReport.error(reportStats, new FileSource(path.getName()), ValidationMessageCode.VALIDATION_0001); } } else { messageReport.error(reportStats, new DirectorySource(path.getPath(), path.getName()), ValidationMessageCode.VALIDATION_0015); } }  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);  }