@Test public void testMultipleInputFilesNotFound() { QAvalidatorConfig config = new QAvalidatorConfig(); config.setAnalysisFilename("/not/existing/file"); try { new QAvalidator().selectAnalysisFilename(config); fail("IllegalArgumentException expected"); } catch(IllegalArgumentException e) { assertThat(e.getMessage(), startsWith("Can not find analysis file ")); assertThat(e.getMessage().replaceAll("\\\\", "/"), endsWith("/not/existing/file")); } }
protected String selectAnalysisFilename(QAvalidatorConfig config) { if (StringUtils.isNotBlank(config.getAnalysisFilename())) { if (FileSystemUtil.checkFileOrResourceExists(config.getAnalysisFilename())) { return config.getAnalysisFilename(); } else { throw new IllegalArgumentException("Can not find analysis file " + config.getAnalysisFilename()); } } else { return findFirstExistingDefault(); } }
QAvalidator { protected String selectAnalysisFilename(QAvalidatorConfig config) { if (StringUtils.isNotBlank(config.getAnalysisFilename())) { if (FileSystemUtil.checkFileOrResourceExists(config.getAnalysisFilename())) { return config.getAnalysisFilename(); } else { throw new IllegalArgumentException("Can not find analysis file " + config.getAnalysisFilename()); } } else { return findFirstExistingDefault(); } } }
QAvalidator { protected String selectAnalysisFilename(QAvalidatorConfig config) { if (StringUtils.isNotBlank(config.getAnalysisFilename())) { if (FileSystemUtil.checkFileOrResourceExists(config.getAnalysisFilename())) { return config.getAnalysisFilename(); } else { throw new IllegalArgumentException("Can not find analysis file " + config.getAnalysisFilename()); } } else { return findFirstExistingDefault(); } }  }
QAvalidator { protected String selectAnalysisFilename(QAvalidatorConfig config) { if (StringUtils.isNotBlank(config.getAnalysisFilename())) { if (FileSystemUtil.checkFileOrResourceExists(config.getAnalysisFilename())) { return config.getAnalysisFilename(); } else { throw new IllegalArgumentException("Can not find analysis file " + config.getAnalysisFilename()); } } else { return findFirstExistingDefault(); } }  @SuppressWarnings({"squid:S2221","squid:S1166"}) // catching Exception (instead of specific subtypes) because there could also be runtime exceptions. // Their messages will all be properly logged. QAvalidatorResult runAnalysis(QAvalidatorConfig config); }
QAvalidator { protected String selectAnalysisFilename(QAvalidatorConfig config) { if (StringUtils.isNotBlank(config.getAnalysisFilename())) { if (FileSystemUtil.checkFileOrResourceExists(config.getAnalysisFilename())) { return config.getAnalysisFilename(); } else { throw new IllegalArgumentException("Can not find analysis file " + config.getAnalysisFilename()); } } else { return findFirstExistingDefault(); } }  @SuppressWarnings({"squid:S2221","squid:S1166"}) // catching Exception (instead of specific subtypes) because there could also be runtime exceptions. // Their messages will all be properly logged. QAvalidatorResult runAnalysis(QAvalidatorConfig config);  }