private static void testDataInMemoryWithoutWAL(HRegion region, Put originalPut, final Put addPut,
    long delta) throws IOException {
    final long initSize = region.getDataInMemoryWithoutWAL();
    // save normalCPHost and replaced by mockedCPHost
    RegionCoprocessorHost normalCPHost = region.getCoprocessorHost();
    RegionCoprocessorHost mockedCPHost = mock(RegionCoprocessorHost.class);
    // Because the preBatchMutate returns void, we can't do usual Mockito when...then form. Must
    // do below format (from Mockito doc).
    doAnswer(new Answer<Void>() {
      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        MiniBatchOperationInProgress<Mutation> mb = invocation.getArgument(0);
        mb.addOperationsFromCP(0, new Mutation[] { addPut });
        return null;
      }
    }).when(mockedCPHost).preBatchMutate(isA(MiniBatchOperationInProgress.class));
    ColumnFamilyDescriptorBuilder builder =
      ColumnFamilyDescriptorBuilder.newBuilder(COLUMN_FAMILY_BYTES);
    ScanInfo info = new ScanInfo(CONF, builder.build(), Long.MAX_VALUE, Long.MAX_VALUE,
      region.getCellComparator());
    when(mockedCPHost.preFlushScannerOpen(any(HStore.class), any())).thenReturn(info);

    when(mockedCPHost.preFlush(any(), any(StoreScanner.class), any()))
      .thenAnswer(i -> i.getArgument(1));
    region.setCoprocessorHost(mockedCPHost);

    region.put(originalPut);
    region.setCoprocessorHost(normalCPHost);
    final long finalSize = region.getDataInMemoryWithoutWAL();
    assertEquals("finalSize:" + finalSize + ", initSize:" + initSize + ", delta:" + delta,
      finalSize, initSize + delta);
  }
Tests that there is server-side filtering for invalid timestamp upper bound. Note that the
timestamp lower bound is automatically handled for us by the TTL field.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java