### Question:
ShardPrunableZipHashCalculator { public void tryRecalculatePrunableArchiveHashes(int time) { if (time > lastPruningTime) { log.debug("Recalculate prunable archive hashes at {}", time); lastPruningTime = time; recalculatePrunableArchiveHashes(); } } @Inject  ShardPrunableZipHashCalculator(Event<ChunkedFileOps> fileChangedEvent, DerivedTablesRegistry registry, Zip zip, DatabaseManager databaseManager, ShardDao shardDao, BlockchainConfig blockchainConfig, DirProvider dirProvider, CsvEscaper translator); void tryRecalculatePrunableArchiveHashes(int time); int getLastPruningTime();  }### Answer:
@Test void testTryRecalculatePrunableArchiveHashes() throws IOException { Path dataExportDir = tempFolder.newFolder().toPath(); DerivedTableInterface derivedTable = mock(DerivedTableInterface.class); doReturn(50).when(blockchainConfig).getMinPrunableLifetime(); mockChain(); doReturn(dataExportDir).when(dirProvider).getDataExportDir(); doReturn(List.of(shard1, shard2, shard3)).when(shardDao).getAllCompletedShards(); doReturn(List.of(prunableMessageTable, derivedTable)).when(registry).getDerivedTables(); Path secondZipPath = dataExportDir.resolve("apl-blockchain-shardprun-2-chain-" + chainId.toString() + ".zip"); Path thirdZipPath = dataExportDir.resolve("apl-blockchain-shardprun-3-chain-" + chainId.toString() + ".zip"); Files.createFile(secondZipPath); Files.createFile(thirdZipPath); prunableZipHashCalculator.tryRecalculatePrunableArchiveHashes(250); assertFalse(Files.exists(secondZipPath)); assertTrue(Files.exists(thirdZipPath)); zip.extract(thirdZipPath.toAbsolutePath().toString(), dataExportDir.toAbsolutePath().toString(), true); assertEquals(2, FileUtils.countElementsOfDirectory(dataExportDir)); assertTrue(Files.exists(dataExportDir.resolve("prunable_message.csv"))); assertNull(shard2.getPrunableZipHash()); ChunkedFileOps ops = new ChunkedFileOps(thirdZipPath.toAbsolutePath().toString()); assertArrayEquals(ops.getFileHash(), shard3.getPrunableZipHash()); assertEquals(250, prunableZipHashCalculator.getLastPruningTime()); }
@Test void testSkipRecalculationWhenTimeIsNotGreaterThanPrevPruningTime() { prunableZipHashCalculator.tryRecalculatePrunableArchiveHashes(0); verifyZeroInteractions(shardDao, zip, dirProvider); }