### Question:
ShardCleaner { @VisibleForTesting void deleteOldShards() { while (!Thread.currentThread().isInterrupted()) { List<UUID> shards = dao.getOldCreatedShardsBatch(); if (shards.isEmpty()) { break; } dao.insertDeletedShards(shards); dao.deleteCreatedShards(shards); backupShardsQueued.update(shards.size()); } } @Inject  ShardCleaner(
            DaoSupplier<ShardDao> shardDaoSupplier,
            Ticker ticker,
            NodeManager nodeManager,
            StorageService storageService,
            Optional<BackupStore> backupStore,
            ShardCleanerConfig config);  ShardCleaner(
            DaoSupplier<ShardDao> shardDaoSupplier,
            String currentNode,
            boolean coordinator,
            Ticker ticker,
            StorageService storageService,
            Optional<BackupStore> backupStore,
            Duration maxTransactionAge,
            Duration transactionCleanerInterval,
            Duration localCleanerInterval,
            Duration localCleanTime,
            Duration backupCleanerInterval,
            Duration backupCleanTime,
            int backupDeletionThreads,
            Duration maxCompletedTransactionAge); @PostConstruct void start(); @PreDestroy void shutdown(); @Managed @Nested CounterStat getTransactionJobErrors(); @Managed @Nested CounterStat getBackupJobErrors(); @Managed @Nested CounterStat getLocalJobErrors(); @Managed @Nested CounterStat getBackupShardsQueued(); @Managed @Nested CounterStat getBackupShardsCleaned(); @Managed @Nested CounterStat getLocalShardsCleaned(); @Managed void startBackupCleanup(); @Managed void startLocalCleanup(); @Managed void startLocalCleanupImmediately();  }### Answer:
@Test public void testDeleteOldShards() { assertEquals(cleaner.getBackupShardsQueued().getTotalCount(), 0); ShardDao dao = dbi.onDemand(ShardDao.class); UUID shard1 = randomUUID(); UUID shard2 = randomUUID(); UUID shard3 = randomUUID(); long txn1 = dao.insertTransaction(); assertEquals(dao.finalizeTransaction(txn1, false), 1); dao.insertCreatedShard(shard1, txn1); dao.insertCreatedShard(shard2, txn1); long txn2 = dao.insertTransaction(); dao.insertCreatedShard(shard3, txn2); assertQuery("SELECT shard_uuid, transaction_id FROM created_shards", row(shard1, txn1), row(shard2, txn1), row(shard3, txn2)); assertQuery("SELECT shard_uuid FROM deleted_shards"); cleaner.deleteOldShards(); assertEquals(cleaner.getBackupShardsQueued().getTotalCount(), 2); assertQuery("SELECT shard_uuid, transaction_id FROM created_shards", row(shard3, txn2)); assertQuery("SELECT shard_uuid FROM deleted_shards", row(shard1), row(shard2)); }