FileUtils { @NotNull public static MerkleTree buildMerkleTree( @NotNull IndexService indexService, @NotNull File blob, @NotNull Partition partition ) { SortedMap<Long, Block> blocks = readBlob(indexService, blob, partition); MerkleTree tree = new MerkleTree(indexService.getMinMaxRange(partition), MAX_LEVEL); MerkleTree.fillTree(tree, blocks); tree.calculate(); return tree; } private  FileUtils(); static boolean isFileEmpty(@NotNull File file, @NotNull IndexElt elt); static long getCrc(byte[] data); static long getCrc(@NotNull File file); static java.io.File getDiskPathByDisk(@NotNull FileConfiguration configuration, int disk); static java.io.File getFilePathByPartition(@NotNull FileConfiguration configuration, int disk, int partition); static java.io.File getFilePathByPartition(@NotNull FileConfiguration configuration, @NotNull Partition partition); static File getOrCreateFile(@NotNull FileConfiguration configuration, @NotNull Partition partition); static ByteBuffer readFile(@NotNull File file, long offset, long length); static int writeFile(@NotNull File file, byte[] bytes, long offset); @NotNull static ByteBuffer readFile(@NotNull java.io.File javaFile); @NotNull static String readFileToString(@NotNull java.io.File javaFile); @NotNull static SortedMap<Long, Block> readBlob(@NotNull IndexService indexService, @NotNull File blob, @NotNull Partition partition); @NotNull static MerkleTree buildMerkleTree(
            @NotNull IndexService indexService,
            @NotNull File blob,
            @NotNull Partition partition
    ); static int getPercentOfDeleted(
            @NotNull FileConfiguration configuration,
            @NotNull IndexService indexService,
            @NotNull Partition partition
    );  }
@Test public void buildMerkleTree() throws IOException { java.io.File dataFile1 = getFilePathByPartition(configuration, 0, 0); Files.touch(dataFile1); partitionService.setActive(new Partition(0, 0)); File file = fileListService.getFile(0, 0); byte[] data = new byte[128]; for (int i = 0; i < 128; i++) { data[i] = 0x1; } file.getFileChannel().write(ByteBuffer.wrap(data), 0); IndexElt expected = new IndexElt.IndexEltBuilder() .id(214803434770010112L) .type(1) .partition(new Partition(0, 0)) .offset(0L) .length(128L) .metadata(ImmutableMap.of("key", "value")) .crc(FileUtils.getCrc(data)) .build(); indexService.add(expected); MerkleTree tree = FileUtils.buildMerkleTree(indexService, file, new Partition(0, 0)); assertEquals(tree.getLeafNodes().get(0).getRange(), Range.openClosed(214803434770010111L, 214803434770010112L)); assertEquals(tree.getLeafNodes().get(0).getHash(), new byte[]{2, -5, 34, -107, -6, 0, 16, 0, 0, 0, 0, 1}); file.close(); }