@Test public void inputDataIsFoundInStream() { final byte[] inputStreamBytes = ("TRY1" + System.lineSeparator()).getBytes(); final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(inputStreamBytes); final PasswordReader passwordReader = new InputStreamPasswordReader(byteArrayInputStream); final char[] password = passwordReader.readPasswordFromConsole(); assertThat(String.valueOf(password)).isEqualTo("TRY1"); }
@Override public char[] readPasswordFromConsole() { if (this.inputStream.hasNextLine()) { return this.inputStream.nextLine().toCharArray(); } else { return new char[0]; } }
InputStreamPasswordReader implements PasswordReader { @Override public char[] readPasswordFromConsole() { if (this.inputStream.hasNextLine()) { return this.inputStream.nextLine().toCharArray(); } else { return new char[0]; } } }
InputStreamPasswordReader implements PasswordReader { @Override public char[] readPasswordFromConsole() { if (this.inputStream.hasNextLine()) { return this.inputStream.nextLine().toCharArray(); } else { return new char[0]; } } InputStreamPasswordReader(final InputStream inputStream); }
InputStreamPasswordReader implements PasswordReader { @Override public char[] readPasswordFromConsole() { if (this.inputStream.hasNextLine()) { return this.inputStream.nextLine().toCharArray(); } else { return new char[0]; } } InputStreamPasswordReader(final InputStream inputStream); @Override char[] readPasswordFromConsole(); }
InputStreamPasswordReader implements PasswordReader { @Override public char[] readPasswordFromConsole() { if (this.inputStream.hasNextLine()) { return this.inputStream.nextLine().toCharArray(); } else { return new char[0]; } } InputStreamPasswordReader(final InputStream inputStream); @Override char[] readPasswordFromConsole();  }