@Test public void whenSearchByNameThenResultOneLineInLogFile() { String[] argsSearchByName = {"-d", "c:/temp/", "-n", "2.txt", "-f", "-o", "log.txt"}; FileSearch.main(argsSearchByName); StringBuilder sb = new StringBuilder(); try (Scanner sc = new Scanner(this.logFile)) { while (sc.hasNext()) { sb.append(sc.nextLine()); } } catch (IOException ioe) { ioe.printStackTrace(); } assertThat(sb.toString(), is("c:\\temp\\2.txt")); }
public static void main(String[] args) { FileSearch fs = new FileSearch(args); if (fs.isValid()) { fs.setLogFile(fs.get(Arg.PATH.ordinal()), fs.get(Arg.LOG_FILE.ordinal())); fs.recursiveSearch(new File(fs.get(Arg.PATH.ordinal())), fs.get(Arg.NAME.ordinal()), fs.get(Arg.FIND_KEY.ordinal())); } else if (args.length == 1 && args[0].equals("/help")) { fs.showHelp(); } else { System.out.println("Wrong arguments\r\nTo show help - execute program with key /help"); } }
FileSearch { public static void main(String[] args) { FileSearch fs = new FileSearch(args); if (fs.isValid()) { fs.setLogFile(fs.get(Arg.PATH.ordinal()), fs.get(Arg.LOG_FILE.ordinal())); fs.recursiveSearch(new File(fs.get(Arg.PATH.ordinal())), fs.get(Arg.NAME.ordinal()), fs.get(Arg.FIND_KEY.ordinal())); } else if (args.length == 1 && args[0].equals("/help")) { fs.showHelp(); } else { System.out.println("Wrong arguments\r\nTo show help - execute program with key /help"); } } }
FileSearch { public static void main(String[] args) { FileSearch fs = new FileSearch(args); if (fs.isValid()) { fs.setLogFile(fs.get(Arg.PATH.ordinal()), fs.get(Arg.LOG_FILE.ordinal())); fs.recursiveSearch(new File(fs.get(Arg.PATH.ordinal())), fs.get(Arg.NAME.ordinal()), fs.get(Arg.FIND_KEY.ordinal())); } else if (args.length == 1 && args[0].equals("/help")) { fs.showHelp(); } else { System.out.println("Wrong arguments\r\nTo show help - execute program with key /help"); } } FileSearch(String[] args); }
FileSearch { public static void main(String[] args) { FileSearch fs = new FileSearch(args); if (fs.isValid()) { fs.setLogFile(fs.get(Arg.PATH.ordinal()), fs.get(Arg.LOG_FILE.ordinal())); fs.recursiveSearch(new File(fs.get(Arg.PATH.ordinal())), fs.get(Arg.NAME.ordinal()), fs.get(Arg.FIND_KEY.ordinal())); } else if (args.length == 1 && args[0].equals("/help")) { fs.showHelp(); } else { System.out.println("Wrong arguments\r\nTo show help - execute program with key /help"); } } FileSearch(String[] args); static void main(String[] args); }
FileSearch { public static void main(String[] args) { FileSearch fs = new FileSearch(args); if (fs.isValid()) { fs.setLogFile(fs.get(Arg.PATH.ordinal()), fs.get(Arg.LOG_FILE.ordinal())); fs.recursiveSearch(new File(fs.get(Arg.PATH.ordinal())), fs.get(Arg.NAME.ordinal()), fs.get(Arg.FIND_KEY.ordinal())); } else if (args.length == 1 && args[0].equals("/help")) { fs.showHelp(); } else { System.out.println("Wrong arguments\r\nTo show help - execute program with key /help"); } } FileSearch(String[] args); static void main(String[] args);  }