@Test
  public void testTransferWindowFiles() throws IOException, InterruptedException {
    testMeta.checkpointManager.setup(testMeta.managedStateContext);

    Map<Long, Map<Slice, Bucket.BucketedValue>> buckets5 =
        ManagedStateTestUtils.getTestData(0, 5, 0);
    testMeta.checkpointManager.save(buckets5, 10, false);
    // Need to synchronously call transfer window files so shutting down the other thread.
    testMeta.checkpointManager.teardown();
    Thread.sleep(500);

    testMeta.checkpointManager.committed(10);
    testMeta.checkpointManager.transferWindowFiles();

    for (int i = 0; i < 5; i++) {
      ManagedStateTestUtils.transferBucketHelper(
          testMeta.managedStateContext.getFileAccess(), i, buckets5.get((long) i), 1);
    }
  }
  @Test
  public void testCommitted() throws IOException, InterruptedException {
    CountDownLatch latch = new CountDownLatch(5);
    MockBucketsFileSystem mockBucketsFileSystem = new MockBucketsFileSystem(latch);

    testMeta.managedStateContext.setBucketsFileSystem(mockBucketsFileSystem);

    mockBucketsFileSystem.setup(testMeta.managedStateContext);
    testMeta.checkpointManager.setup(testMeta.managedStateContext);

    Map<Long, Map<Slice, Bucket.BucketedValue>> data = ManagedStateTestUtils.getTestData(0, 5, 0);
    testMeta.checkpointManager.save(data, 10, false);
    testMeta.checkpointManager.committed(10);
    latch.await();
    testMeta.checkpointManager.teardown();
    Thread.sleep(500);

    for (int i = 0; i < 5; i++) {
      ManagedStateTestUtils.transferBucketHelper(
          testMeta.managedStateContext.getFileAccess(), i, data.get((long) i), 1);
    }
  }
    @Override
    protected void starting(Description description) {
      TestUtils.deleteTargetTestClassFolder(description);
      applicationPath = "target/" + description.getClassName() + "/" + description.getMethodName();

      Context.OperatorContext operatorContext =
          ManagedStateTestUtils.getOperatorContext(operatorId, applicationPath);
      managedStateContext = new MockManagedStateContext(operatorContext);

      ((FileAccessFSImpl) managedStateContext.getFileAccess())
          .setBasePath(applicationPath + "/" + "bucket_data");
      managedStateContext.getFileAccess().init();

      checkpointManager = new IncrementalCheckpointManager();

      managedStateContext.getTimeBucketAssigner().setup(managedStateContext);
      managedStateContext.getBucketsFileSystem().setup(managedStateContext);
    }
  @Test
  public void testSave() throws IOException {
    testMeta.checkpointManager.setup(testMeta.managedStateContext);
    Map<Long, Map<Slice, Bucket.BucketedValue>> buckets5 =
        ManagedStateTestUtils.getTestData(0, 5, 0);
    testMeta.checkpointManager.save(buckets5, 10, false);
    testMeta.checkpointManager.teardown();

    KryoCloneUtils<IncrementalCheckpointManager> cloneUtils =
        KryoCloneUtils.createCloneUtils(testMeta.checkpointManager);
    testMeta.checkpointManager = cloneUtils.getClone();
    testMeta.checkpointManager.setup(testMeta.managedStateContext);
    @SuppressWarnings("unchecked")
    Map<Long, Map<Slice, Bucket.BucketedValue>> buckets5After =
        (Map<Long, Map<Slice, Bucket.BucketedValue>>) testMeta.checkpointManager.retrieve(10);

    Assert.assertEquals("saved", buckets5, buckets5After);
    testMeta.checkpointManager.teardown();
  }