@Test public void whenEnterStopAndOtherWordsThenResultNoAnswer() { String stopKey = String.format("stop%stest%stest2", sep, sep); System.setIn(new ByteArrayInputStream(stopKey.getBytes())); try { new ConsoleChat(this.filePathPhrase, this.filePathLog).init(); } catch (IOException ioe) { ioe.printStackTrace(); } assertThat(this.out.toString().isEmpty(), is(true)); }
public void init() throws IOException { fillPhrasesList(); try (Scanner sc = new Scanner(System.in); BufferedWriter writer = new BufferedWriter(new FileWriter(this.logFile))) { while (!isExit && sc.hasNext()) { String line = sc.nextLine(); checkConsoleChatStatus(line); writer.write(String.format("User: %s\r\n", line)); if (!isPaused && !isExit) { writer.write(String.format("PC: %s\r\n", getNextRandomPhrase())); } } } }
ConsoleChat { public void init() throws IOException { fillPhrasesList(); try (Scanner sc = new Scanner(System.in); BufferedWriter writer = new BufferedWriter(new FileWriter(this.logFile))) { while (!isExit && sc.hasNext()) { String line = sc.nextLine(); checkConsoleChatStatus(line); writer.write(String.format("User: %s\r\n", line)); if (!isPaused && !isExit) { writer.write(String.format("PC: %s\r\n", getNextRandomPhrase())); } } } } }
ConsoleChat { public void init() throws IOException { fillPhrasesList(); try (Scanner sc = new Scanner(System.in); BufferedWriter writer = new BufferedWriter(new FileWriter(this.logFile))) { while (!isExit && sc.hasNext()) { String line = sc.nextLine(); checkConsoleChatStatus(line); writer.write(String.format("User: %s\r\n", line)); if (!isPaused && !isExit) { writer.write(String.format("PC: %s\r\n", getNextRandomPhrase())); } } } } ConsoleChat();  ConsoleChat(String pathToDictionary, String pathToLogFile); }
ConsoleChat { public void init() throws IOException { fillPhrasesList(); try (Scanner sc = new Scanner(System.in); BufferedWriter writer = new BufferedWriter(new FileWriter(this.logFile))) { while (!isExit && sc.hasNext()) { String line = sc.nextLine(); checkConsoleChatStatus(line); writer.write(String.format("User: %s\r\n", line)); if (!isPaused && !isExit) { writer.write(String.format("PC: %s\r\n", getNextRandomPhrase())); } } } } ConsoleChat();  ConsoleChat(String pathToDictionary, String pathToLogFile); void init(); }
ConsoleChat { public void init() throws IOException { fillPhrasesList(); try (Scanner sc = new Scanner(System.in); BufferedWriter writer = new BufferedWriter(new FileWriter(this.logFile))) { while (!isExit && sc.hasNext()) { String line = sc.nextLine(); checkConsoleChatStatus(line); writer.write(String.format("User: %s\r\n", line)); if (!isPaused && !isExit) { writer.write(String.format("PC: %s\r\n", getNextRandomPhrase())); } } } } ConsoleChat();  ConsoleChat(String pathToDictionary, String pathToLogFile); void init();  }