private MetricsReplicationGlobalSourceSource createMockGlobalMetrics() {
    MetricsReplicationGlobalSourceSource globalMetrics =
      Mockito.mock(MetricsReplicationGlobalSourceSource.class);
    final AtomicLong bufferUsedCounter = new AtomicLong(0);
    Mockito.doAnswer((invocationOnMock) -> {
      bufferUsedCounter.set(invocationOnMock.getArgument(0, Long.class));
      return null;
    }).when(globalMetrics).setWALReaderEditsBufferBytes(Mockito.anyLong());
    when(globalMetrics.getWALReaderEditsBufferBytes())
      .then(invocationOnMock -> bufferUsedCounter.get());
    return globalMetrics;
  }
Tests that if we stop before hitting the end of a stream, we can continue where we left off
using the last position
hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestBasicWALEntryStream.java