@Test public void parsePluginTxtFileTest() throws URISyntaxException { List<Plugin> noFilePluginList = pluginList.parsePluginTxtFile(null); assertThat(noFilePluginList).isEmpty(); File pluginTxtFile = new File(this.getClass().getResource("PluginListParserTest/plugins.txt").toURI()); List<Plugin> pluginsFromFile = pluginList.parsePluginTxtFile(pluginTxtFile); List<String> pluginInfo = new ArrayList<>(); for (Plugin p : pluginsFromFile) { pluginInfo.add(p.toString()); } assertThat(pluginInfo).containsExactlyInAnyOrder(expectedPluginInfo); }
public List<Plugin> parsePluginTxtFile(File pluginTxtFile) { List<Plugin> pluginsFromTxt = new ArrayList<>(); if (fileExists(pluginTxtFile)) { try (BufferedReader bufferedReader = Files.newBufferedReader(pluginTxtFile.toPath(), StandardCharsets.UTF_8)) { List<Plugin> pluginsFromFile = bufferedReader.lines() .map(line -> line.replaceAll("\\s#+.*", "")) .map(line -> line.replaceAll("\\s", "")) .filter(line -> !line.startsWith("#")) .filter(line -> line.length() > 0) .map(this::parsePluginLine) .collect(toList()); pluginsFromTxt.addAll(pluginsFromFile); } catch (IOException e) { System.out.println("Unable to open " + pluginTxtFile); } } return pluginsFromTxt; }
PluginListParser { public List<Plugin> parsePluginTxtFile(File pluginTxtFile) { List<Plugin> pluginsFromTxt = new ArrayList<>(); if (fileExists(pluginTxtFile)) { try (BufferedReader bufferedReader = Files.newBufferedReader(pluginTxtFile.toPath(), StandardCharsets.UTF_8)) { List<Plugin> pluginsFromFile = bufferedReader.lines() .map(line -> line.replaceAll("\\s#+.*", "")) .map(line -> line.replaceAll("\\s", "")) .filter(line -> !line.startsWith("#")) .filter(line -> line.length() > 0) .map(this::parsePluginLine) .collect(toList()); pluginsFromTxt.addAll(pluginsFromFile); } catch (IOException e) { System.out.println("Unable to open " + pluginTxtFile); } } return pluginsFromTxt; } }
PluginListParser { public List<Plugin> parsePluginTxtFile(File pluginTxtFile) { List<Plugin> pluginsFromTxt = new ArrayList<>(); if (fileExists(pluginTxtFile)) { try (BufferedReader bufferedReader = Files.newBufferedReader(pluginTxtFile.toPath(), StandardCharsets.UTF_8)) { List<Plugin> pluginsFromFile = bufferedReader.lines() .map(line -> line.replaceAll("\\s#+.*", "")) .map(line -> line.replaceAll("\\s", "")) .filter(line -> !line.startsWith("#")) .filter(line -> line.length() > 0) .map(this::parsePluginLine) .collect(toList()); pluginsFromTxt.addAll(pluginsFromFile); } catch (IOException e) { System.out.println("Unable to open " + pluginTxtFile); } } return pluginsFromTxt; } PluginListParser(boolean verbose); }
PluginListParser { public List<Plugin> parsePluginTxtFile(File pluginTxtFile) { List<Plugin> pluginsFromTxt = new ArrayList<>(); if (fileExists(pluginTxtFile)) { try (BufferedReader bufferedReader = Files.newBufferedReader(pluginTxtFile.toPath(), StandardCharsets.UTF_8)) { List<Plugin> pluginsFromFile = bufferedReader.lines() .map(line -> line.replaceAll("\\s#+.*", "")) .map(line -> line.replaceAll("\\s", "")) .filter(line -> !line.startsWith("#")) .filter(line -> line.length() > 0) .map(this::parsePluginLine) .collect(toList()); pluginsFromTxt.addAll(pluginsFromFile); } catch (IOException e) { System.out.println("Unable to open " + pluginTxtFile); } } return pluginsFromTxt; } PluginListParser(boolean verbose); List<Plugin> parsePluginsFromCliOption(String[] plugins); List<Plugin> parsePluginTxtFile(File pluginTxtFile); List<Plugin> parsePluginYamlFile(File pluginYamlFile); boolean fileExists(File pluginFile); static boolean isURL(String url); }
PluginListParser { public List<Plugin> parsePluginTxtFile(File pluginTxtFile) { List<Plugin> pluginsFromTxt = new ArrayList<>(); if (fileExists(pluginTxtFile)) { try (BufferedReader bufferedReader = Files.newBufferedReader(pluginTxtFile.toPath(), StandardCharsets.UTF_8)) { List<Plugin> pluginsFromFile = bufferedReader.lines() .map(line -> line.replaceAll("\\s#+.*", "")) .map(line -> line.replaceAll("\\s", "")) .filter(line -> !line.startsWith("#")) .filter(line -> line.length() > 0) .map(this::parsePluginLine) .collect(toList()); pluginsFromTxt.addAll(pluginsFromFile); } catch (IOException e) { System.out.println("Unable to open " + pluginTxtFile); } } return pluginsFromTxt; } PluginListParser(boolean verbose); List<Plugin> parsePluginsFromCliOption(String[] plugins); List<Plugin> parsePluginTxtFile(File pluginTxtFile); List<Plugin> parsePluginYamlFile(File pluginYamlFile); boolean fileExists(File pluginFile); static boolean isURL(String url);  }