@SuppressWarnings("unchecked") @Test public void testProcessZip() throws IOException, NoSuchFieldException, IllegalAccessException { Handler<org.slc.sli.ingestion.Resource, String> handler = Mockito.mock(Handler.class); ReportStats rs = Mockito.mock(ReportStats.class); Mockito.when(rs.hasErrors()).thenReturn(false); AbstractMessageReport messageReport = Mockito.mock(AbstractMessageReport.class); PrivateAccessor.setField(validationController, "messageReport", messageReport); File zipFile = (new ClassPathResource(zipFileName)).getFile(); FileResource zipFileResource = new FileResource(zipFile.getAbsolutePath()); ValidationController vc = Mockito.spy(validationController); Mockito.doNothing().when(vc).processControlFile(Mockito.any(FileResource.class), Mockito.any(String.class), Mockito.any(ReportStats.class)); Mockito.doReturn(zipFile.getName()).when(handler).handle(zipFileResource, messageReport, rs); vc.setZipFileHandler(handler); vc.processZip(zipFileResource, rs); Mockito.verify(handler, Mockito.atLeastOnce()).handle(zipFileResource, messageReport, rs); }
public void processZip(File zipFile, ReportStats reportStats) { messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0005, zipFile.getAbsolutePath()); FileResource zipFileResource = new FileResource(zipFile.getAbsolutePath()); String ctlFile = zipFileHandler.handle(zipFileResource, messageReport, reportStats); if (!reportStats.hasErrors()) { processControlFile(zipFile, ctlFile, reportStats); } messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0006, zipFile.getAbsolutePath()); }
ValidationController { public void processZip(File zipFile, ReportStats reportStats) { messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0005, zipFile.getAbsolutePath()); FileResource zipFileResource = new FileResource(zipFile.getAbsolutePath()); String ctlFile = zipFileHandler.handle(zipFileResource, messageReport, reportStats); if (!reportStats.hasErrors()) { processControlFile(zipFile, ctlFile, reportStats); } messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0006, zipFile.getAbsolutePath()); } }
ValidationController { public void processZip(File zipFile, ReportStats reportStats) { messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0005, zipFile.getAbsolutePath()); FileResource zipFileResource = new FileResource(zipFile.getAbsolutePath()); String ctlFile = zipFileHandler.handle(zipFileResource, messageReport, reportStats); if (!reportStats.hasErrors()) { processControlFile(zipFile, ctlFile, reportStats); } messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0006, zipFile.getAbsolutePath()); }  }
ValidationController { public void processZip(File zipFile, ReportStats reportStats) { messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0005, zipFile.getAbsolutePath()); FileResource zipFileResource = new FileResource(zipFile.getAbsolutePath()); String ctlFile = zipFileHandler.handle(zipFileResource, messageReport, reportStats); if (!reportStats.hasErrors()) { processControlFile(zipFile, ctlFile, reportStats); } messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0006, zipFile.getAbsolutePath()); }  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 processZip(File zipFile, ReportStats reportStats) { messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0005, zipFile.getAbsolutePath()); FileResource zipFileResource = new FileResource(zipFile.getAbsolutePath()); String ctlFile = zipFileHandler.handle(zipFileResource, messageReport, reportStats); if (!reportStats.hasErrors()) { processControlFile(zipFile, ctlFile, reportStats); } messageReport.info(reportStats, new FileSource(zipFile.getName()), ValidationMessageCode.VALIDATION_0006, zipFile.getAbsolutePath()); }  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);  }