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

    OperationQuota nonThrottlingQuota = mock(OperationQuota.class);
    when(env.checkScanQuota(any(), anyLong(), anyLong())).thenReturn(nonThrottlingQuota);

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

    // Call should complete without throttling
    aggregate.getStd(controller, noPartialRequest, callback);

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

    AggregateResponse response = responseCaptor.getValue();

    assertFalse("Response should not indicate there are more rows",
      response.hasNextChunkStartRow());
    assertEquals("sum should be 15", 15L, (long) LONG_COLUMN_INTERPRETER.getPromotedValueFromProto(
      getParsedGenericInstance(LONG_COLUMN_INTERPRETER.getClass(), 3, response.getFirstPart(0))));
    assertEquals("sumSq should be 55", 55L,
      (long) LONG_COLUMN_INTERPRETER.getPromotedValueFromProto(
        getParsedGenericInstance(LONG_COLUMN_INTERPRETER.getClass(), 3, response.getFirstPart(1))));
    assertEquals("count should be 5", NUM_ROWS,
      response.getSecondPart().asReadOnlyByteBuffer().getLong());
  }
Test AggregateImplementation with throttling and partial results
hbase-endpoint/src/test/java/org/apache/hadoop/hbase/coprocessor/TestAggregateImplementation.java