private Answer<OperationQuota> createMockQuota() throws IOException {
    OperationQuota mockQuota = mock(OperationQuota.class);

    final AtomicInteger rowCount = new AtomicInteger(0);

    return invocation -> {
      int count = rowCount.incrementAndGet();
      if (count == THROTTLE_AT_ROW) {
        RpcThrottlingException throttlingEx =
          new RpcThrottlingException(ReadSizeExceeded, 1000, "Throttled for testing");
        throw throttlingEx;
      }
      return mockQuota;
    };
  }
Test AggregateImplementation with throttling and partial results
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestAggregateImplementation.java