private Answer<Boolean> createMockScanner() throws IOException {
    AtomicInteger callCount = new AtomicInteger(0);
    return invocation -> {
      List<Cell> results = (List<Cell>) invocation.getArguments()[0];
      int call = callCount.getAndIncrement();
      if (call < NUM_ROWS) {
        Cell cell = mock(Cell.class);
        when(cell.getRowArray()).thenReturn(Bytes.toBytes("row" + (call + 1)));
        when(cell.getRowOffset()).thenReturn(0);
        when(cell.getRowLength()).thenReturn((short) 4);

        when(cell.getValueArray()).thenReturn(Bytes.toBytes((long) call + 1));
        when(cell.getValueOffset()).thenReturn(0);
        when(cell.getValueLength()).thenReturn(8);
        results.add(cell);
        return call < NUM_ROWS - 1;
      } else {
        // No more rows
        return false;
      }
    };
  }
Test AggregateImplementation with throttling and partial results
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestAggregateImplementation.java