@Test
  public void testMedianThrottleWithNoResults() throws Exception {
    AggregateRequest request = AggregateRequest.newBuilder().setScan(ProtobufUtil.toScan(scan))
      .setInterpreterClassName(LongColumnInterpreter.class.getName())
      .setClientSupportsPartialResult(true).build();

    when(env.checkScanQuota(any(), anyLong(), anyLong()))
      .thenThrow(new RpcThrottlingException(ReadSizeExceeded, 1000, "Throttled for testing"));

    ArgumentCaptor<AggregateResponse> responseCaptor =
      ArgumentCaptor.forClass(AggregateResponse.class);
    RpcCallback<AggregateResponse> callback = mock(RpcCallback.class);

    // call gets no results, and response should contain the same start row as the request, because
    // no progress in the scan was made
    aggregate.getMedian(controller, request, callback);

    verify(callback).run(responseCaptor.capture());

    AggregateResponse response = responseCaptor.getValue();

    assertTrue("Response should indicate there are more rows", response.hasNextChunkStartRow());
    assertEquals("response should contain the same start row as the request",
      request.getScan().getStartRow(), response.getNextChunkStartRow());
  }
Test AggregateImplementation with throttling and partial results
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestAggregateImplementation.java