@Nullable
    public abstract DirectoryStateHandle completeSnapshotAndGetHandle() throws IOException;
@Test
    void completeSnapshotAndGetHandle() throws Exception {
        File folderRoot = temporaryFolder.toFile();
        File folderA = new File(folderRoot, String.valueOf(UUID.randomUUID()));
        assertThat(folderA.mkdirs()).isTrue();
        Path folderAPath = folderA.toPath();

        SnapshotDirectory snapshotDirectory = SnapshotDirectory.permanent(folderAPath);

        // check that completed checkpoint dirs are not deleted as incomplete.
        DirectoryStateHandle handle = snapshotDirectory.completeSnapshotAndGetHandle();
        assertThat(handle).isNotNull();
        assertThat(snapshotDirectory.cleanup()).isTrue();
        assertThat(folderA).isDirectory();
        assertThat(handle.getDirectory()).isEqualTo(folderAPath);
        handle.discardState();

        assertThat(folderA).doesNotExist();
        assertThat(folderA.mkdirs()).isTrue();

        SnapshotDirectory newSnapshotDirectory = SnapshotDirectory.permanent(folderAPath);
        assertThat(newSnapshotDirectory.cleanup()).isTrue();
        assertThatThrownBy(newSnapshotDirectory::completeSnapshotAndGetHandle)
                .isInstanceOf(IOException.class);
    }