@Test public void controlFileHasPath() { AbstractMessageReport report = new DummyMessageReport(); ReportStats reportStats = new SimpleReportStats(); Source source = new JobSource(null); Mockito.when(entry.getFileName()).thenReturn(path + fileName); fileEntries.add(entry); boolean isValid = controlFileValidator.isValid(controlFile, report, reportStats, source, null); Assert.assertTrue(reportStats.hasErrors()); Assert.assertFalse(isValid); }
@Override public boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { Set<String> zipFileEntries = null; Map<String, Object> localParameters = (parameters == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(parameters); List<IngestionFileEntry> entries = controlFile.getFileEntries(); if (entries.size() < 1) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0003); return false; } try { zipFileEntries = ZipFileUtil.getZipFileEntries(controlFile.getParentZipFileOrDirectory()); } catch (IOException e) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0020, controlFile.getParentZipFileOrDirectory()); return false; } if (zipFileEntries != null) { localParameters.put(ZIPFILE_ENTRIES, zipFileEntries); } boolean isValid = true; for (IngestionFileEntry entry : entries) { if (!isValid(entry, report, reportStats, source, localParameters)) { entry.setValid(false); isValid = false; } } if (!isValid && !reportStats.hasErrors()) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0002); return false; } return isValid; }
ControlFileValidator implements Validator<ControlFile> { @Override public boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { Set<String> zipFileEntries = null; Map<String, Object> localParameters = (parameters == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(parameters); List<IngestionFileEntry> entries = controlFile.getFileEntries(); if (entries.size() < 1) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0003); return false; } try { zipFileEntries = ZipFileUtil.getZipFileEntries(controlFile.getParentZipFileOrDirectory()); } catch (IOException e) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0020, controlFile.getParentZipFileOrDirectory()); return false; } if (zipFileEntries != null) { localParameters.put(ZIPFILE_ENTRIES, zipFileEntries); } boolean isValid = true; for (IngestionFileEntry entry : entries) { if (!isValid(entry, report, reportStats, source, localParameters)) { entry.setValid(false); isValid = false; } } if (!isValid && !reportStats.hasErrors()) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0002); return false; } return isValid; } }
ControlFileValidator implements Validator<ControlFile> { @Override public boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { Set<String> zipFileEntries = null; Map<String, Object> localParameters = (parameters == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(parameters); List<IngestionFileEntry> entries = controlFile.getFileEntries(); if (entries.size() < 1) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0003); return false; } try { zipFileEntries = ZipFileUtil.getZipFileEntries(controlFile.getParentZipFileOrDirectory()); } catch (IOException e) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0020, controlFile.getParentZipFileOrDirectory()); return false; } if (zipFileEntries != null) { localParameters.put(ZIPFILE_ENTRIES, zipFileEntries); } boolean isValid = true; for (IngestionFileEntry entry : entries) { if (!isValid(entry, report, reportStats, source, localParameters)) { entry.setValid(false); isValid = false; } } if (!isValid && !reportStats.hasErrors()) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0002); return false; } return isValid; }  }
ControlFileValidator implements Validator<ControlFile> { @Override public boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { Set<String> zipFileEntries = null; Map<String, Object> localParameters = (parameters == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(parameters); List<IngestionFileEntry> entries = controlFile.getFileEntries(); if (entries.size() < 1) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0003); return false; } try { zipFileEntries = ZipFileUtil.getZipFileEntries(controlFile.getParentZipFileOrDirectory()); } catch (IOException e) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0020, controlFile.getParentZipFileOrDirectory()); return false; } if (zipFileEntries != null) { localParameters.put(ZIPFILE_ENTRIES, zipFileEntries); } boolean isValid = true; for (IngestionFileEntry entry : entries) { if (!isValid(entry, report, reportStats, source, localParameters)) { entry.setValid(false); isValid = false; } } if (!isValid && !reportStats.hasErrors()) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0002); return false; } return isValid; }  List<Validator<IngestionFileEntry>> getIngestionFileValidators(); void setIngestionFileValidators(List<Validator<IngestionFileEntry>> ingestionFileValidators); @Override boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats,
            Source source, Map<String, Object> parameters); @Override String getStageName(); }
ControlFileValidator implements Validator<ControlFile> { @Override public boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats, Source source, Map<String, Object> parameters) { Set<String> zipFileEntries = null; Map<String, Object> localParameters = (parameters == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(parameters); List<IngestionFileEntry> entries = controlFile.getFileEntries(); if (entries.size() < 1) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0003); return false; } try { zipFileEntries = ZipFileUtil.getZipFileEntries(controlFile.getParentZipFileOrDirectory()); } catch (IOException e) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0020, controlFile.getParentZipFileOrDirectory()); return false; } if (zipFileEntries != null) { localParameters.put(ZIPFILE_ENTRIES, zipFileEntries); } boolean isValid = true; for (IngestionFileEntry entry : entries) { if (!isValid(entry, report, reportStats, source, localParameters)) { entry.setValid(false); isValid = false; } } if (!isValid && !reportStats.hasErrors()) { report.error(reportStats, new ControlFileSource(source.getResourceId(), controlFile), BaseMessageCode.BASE_0002); return false; } return isValid; }  List<Validator<IngestionFileEntry>> getIngestionFileValidators(); void setIngestionFileValidators(List<Validator<IngestionFileEntry>> ingestionFileValidators); @Override boolean isValid(ControlFile controlFile, AbstractMessageReport report, ReportStats reportStats,
            Source source, Map<String, Object> parameters); @Override String getStageName(); static final String ZIPFILE_ENTRIES; }