@Test public void whenWrongArgumentsThenResultErrorMessage() { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { System.setOut(new PrintStream(output)); String[] wrongArgs = {"-d", "-m", "-n"}; FileSearch.main(wrongArgs); assertThat(output.toString(), is("Wrong arguments\r\nTo show help - execute program with key /help\r\n")); } catch (IOException ioe) { ioe.printStackTrace(); } }
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);  }