@Test
public void testReadAheadManagerForSuccessfulReadAhead() throws Exception {

  // Mock failure for client.read()
  AbfsClient client = getMockAbfsClient();
  // Success operation mock
  AbfsRestOperation op = getMockRestOp();
  // Stub :
  // Pass all readAheads and fail the post eviction request to
  // prove ReadAhead buffer is used
  doReturn(op)
      .doReturn(op)
      .doReturn(op)
      .doThrow(new TimeoutException("Internal Server error for RAH-X")) // for post eviction request
      .doThrow(new TimeoutException("Internal Server error for RAH-Y"))
      .doThrow(new TimeoutException("Internal Server error for RAH-Z"))
      .when(client)
      .read(any(String.class), any(Long.class), any(byte[].class),
          any(Integer.class), any(Integer.class), any(String.class),
          any(String.class));
  AbfsInputStream inputStream = getAbfsInputStream(client, "testSuccessfulReadAhead.txt");
  queueReadAheads(inputStream);
  // AbfsInputStream Read would have waited for the read-ahead for the requested offset
  // as we are testing from ReadAheadManager directly, sleep for a sec to
  // get the read ahead threads to complete
  Thread.sleep(1000);
  // Only the 3 readAhead threads should have triggered client.read
  verifyReadCallCount(client, 3);
  // getBlock for a new read should return the buffer read-ahead
  int bytesRead = ReadBufferManager.getBufferManager().getBlock(
      inputStream,
      ONE_KB,
      ONE_KB,
      new byte[ONE_KB]);
  Assert.assertTrue("bytesRead should be non-zero from the "
      + "buffer that was read-ahead", bytesRead > 0);
  // Once created, mock will remember all interactions.
  // As the above read should not have triggered any server calls, total
  // number of read calls made at this point will be same as last.
  verifyReadCallCount(client, 3);
  // Stub will throw exception for client.read() for 4th and later calls
  // if not using the read-ahead buffer exception will be thrown on read
  checkEvictedStatus(inputStream, 0, true);
}