### Question:
OzoneFSInputStream extends FSInputStream implements ByteBufferReadable { @Override public int read() throws IOException { int byteRead = inputStream.read(); if (statistics != null && byteRead >= 0) { statistics.incrementBytesRead(1); } return byteRead; } OzoneFSInputStream(InputStream inputStream, Statistics statistics); @Override int read(); @Override int read(byte[] b, int off, int len); @Override synchronized void close(); @Override void seek(long pos); @Override long getPos(); @Override boolean seekToNewSource(long targetPos); @Override int available(); @Override int read(ByteBuffer buf);  }### Answer:
@Test public void readEmptyStreamToByteBuffer() throws IOException { for (IntFunction<ByteBuffer> constructor : BUFFER_CONSTRUCTORS) { final OzoneFSInputStream subject = createTestSubject(emptyStream()); final ByteBuffer buf = constructor.apply(1); final int bytesRead = subject.read(buf); assertEquals(-1, bytesRead); assertEquals(0, buf.position()); } }
@Test public void bufferPositionUnchangedOnEOF() throws IOException { for (IntFunction<ByteBuffer> constructor : BUFFER_CONSTRUCTORS) { final OzoneFSInputStream subject = createTestSubject(eofStream()); final ByteBuffer buf = constructor.apply(123); final int bytesRead = subject.read(buf); assertEquals(-1, bytesRead); assertEquals(0, buf.position()); } }