@Test
public void testVisitCube() throws Exception {

    RawScan rawScan = mockFullScan(gtInfo, getTestConfig());
    CoprocessorEnvironment env = PowerMockito.mock(RegionCoprocessorEnvironment.class);
    PowerMockito.when(env, "getRegion").thenReturn(region);
    final CubeVisitService service = new CubeVisitService();
    service.start(env);
    CubeVisitProtos.CubeVisitRequest request = mockFullScanRequest(gtInfo, Lists.newArrayList(rawScan));
    RpcCallback<CubeVisitProtos.CubeVisitResponse> done = new RpcCallback<CubeVisitProtos.CubeVisitResponse>() {
        @Override
        public void run(CubeVisitProtos.CubeVisitResponse result) {
            CubeVisitProtos.CubeVisitResponse.Stats stats = result.getStats();
            Assert.assertEquals(0L, stats.getAggregatedRowCount());
            Assert.assertEquals(0L, stats.getFilteredRowCount());
            Assert.assertEquals(dateList.size() * userList.size(), stats.getScannedRowCount());
            try {
                byte[] rawData = CompressionUtils
                        .decompress(HBaseZeroCopyByteString.zeroCopyGetBytes(result.getCompressedRows()));
                PartitionResultIterator iterator = new PartitionResultIterator(rawData, gtInfo, setOf(0, 1, 2, 3));
                int nReturn = 0;
                while (iterator.hasNext()) {
                    iterator.next();
                    nReturn++;
                }
                Assert.assertEquals(dateList.size() * userList.size(), nReturn);
            } catch (Exception e) {
                Assert.fail("Fail due to " + e);
            }
        }
    };
    service.visitCube(null, request, done);
}