JavaScopeReader { public void read(Map parameters) { String baseDirName = (String) parameters.get(BASE_DIR_KEY); if (StringUtils.isEmpty(baseDirName)) { LOGGER.warn("{} missing - no files will be read!", BASE_DIR_KEY); } else { File baseDir = new File(baseDirName); if (!baseDir.exists()) { LOGGER.warn("baseDir {} missing - no files will be read!", baseDir.getAbsolutePath()); } else if (baseDir.isDirectory()) { readDirectory(baseDir, parameters); } else { readJarFile(baseDir, parameters); } } } JavaScopeReader(DependencyGraph dependencyGraph, boolean collapseInnerClasses); void read(Map parameters); static final String BASE_DIR_KEY; }
@Test public void testReadNoRootDirs() { dependencyGraph = DependencyGraphFactory.createGraph(); new JavaScopeReader(dependencyGraph, true).read(Maps.newHashMap()); assertThat(dependencyGraph.getAllNodes().size(), is(0)); }
@Test public void testWrongInputDir() { dependencyGraph = DependencyGraphFactory.createGraph(); Map<String, String> parameters = Maps.newHashMap(); parameters.put("baseDir", "not-existing"); new JavaScopeReader(dependencyGraph, true).read(parameters); assertThat(dependencyGraph.getAllNodes(), hasSize(0)); }
@Test public void testNoInputDir() { dependencyGraph = DependencyGraphFactory.createGraph(); Map<String, String> parameters = Maps.newHashMap(); parameters.put("baseDir", "src/test/resources/something.txt"); new JavaScopeReader(dependencyGraph, true).read(parameters); assertThat(dependencyGraph.getAllNodes(), hasSize(0)); }