### Question:
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();  }### Answer:
@Test public void testNoLineFoundInStream() { final byte[] inputStreamBytes = new byte[0]; final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(inputStreamBytes); final PasswordReader passwordReader = new InputStreamPasswordReader(byteArrayInputStream); final char[] password = passwordReader.readPasswordFromConsole(); assertThat(String.valueOf(password)).isEmpty(); }
@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"); }