@Test
public void testDeleteAllDataAndHasData() throws Exception {

    KeySpace root = new KeySpace(
            new KeySpaceDirectory("root", KeyType.LONG, Math.abs(random.nextLong()))
                    .addSubdirectory(new KeySpaceDirectory("dir1", KeyType.STRING, "a")
                            .addSubdirectory(new KeySpaceDirectory("dir1_1", KeyType.LONG)))
                    .addSubdirectory(new KeySpaceDirectory("dir2", KeyType.STRING, "b")
                            .addSubdirectory(new KeySpaceDirectory("dir2_1", KeyType.LONG)))
                    .addSubdirectory(new KeySpaceDirectory("dir3", KeyType.STRING, "c")
                            .addSubdirectory(new KeySpaceDirectory("dir3_1", KeyType.LONG))));
    final FDBDatabase database = FDBDatabaseFactory.instance().getDatabase();
    try (FDBRecordContext context = database.openContext()) {
        Transaction tr = context.ensureActive();
        for (int i = 0; i < 5; i++) {
            tr.set(root.path("root").add("dir1").add("dir1_1", i).toTuple(context).pack(), Tuple.from(i).pack());
            tr.set(root.path("root").add("dir2").add("dir2_1", i).toTuple(context).pack(), Tuple.from(i).pack());
            tr.set(root.path("root").add("dir3").add("dir3_1", i).toTuple(context).pack(), Tuple.from(i).pack());
        }
        context.commit();
    }
    try (FDBRecordContext context = database.openContext()) {
        // All directories hava data?
        for (int i = 1; i <= 3; i++) {
            assertTrue(root.path("root").add("dir" + i).hasData(context), "dir" + i + " is empty!");
        }
        // Clear out dir2
        root.path("root").add("dir2").deleteAllData(context);
        context.commit();
    }
    try (FDBRecordContext context = database.openContext()) {
        assertTrue(root.path("root").add("dir1").hasData(context), "dir1 is empty!");
        assertFalse(root.path("root").add("dir2").hasData(context), "dir2 has data!");
        assertTrue(root.path("root").add("dir3").hasData(context), "dir3 is empty!");
    }
}