### Question:
ShardOrganizationManager { @VisibleForTesting Set<Long> discoverAndInitializeTablesToOrganize() { Set<Long> enabledTableIds = metadataDao.getOrganizationEligibleTables(); Set<TableOrganizationInfo> tableOrganizationInfo = organizerDao.getNodeTableOrganizationInfo(currentNodeIdentifier); Map<Long, TableOrganizationInfo> organizationInfos = Maps.uniqueIndex(tableOrganizationInfo, TableOrganizationInfo::getTableId); difference(enabledTableIds, organizationInfos.keySet()) .forEach(tableId -> organizerDao.insertNode(currentNodeIdentifier, tableId)); ImmutableSet.Builder<Long> tableIds = ImmutableSet.builder(); for (Long tableId : enabledTableIds) { TableOrganizationInfo info = organizationInfos.get(tableId); if (info == null || shouldRunOrganization(info)) { tableIds.add(tableId); } } return tableIds.build(); } @Inject  ShardOrganizationManager(
            @ForMetadata IDBI dbi,
            NodeManager nodeManager,
            ShardManager shardManager,
            ShardOrganizer organizer,
            StorageManagerConfig config);  ShardOrganizationManager(
            IDBI dbi,
            String currentNodeIdentifier,
            ShardManager shardManager,
            ShardOrganizer organizer,
            boolean enabled,
            Duration organizationInterval,
            Duration organizationDiscoveryInterval); @PostConstruct void start(); @PreDestroy void shutdown();  }### Answer:
@Test public void testTableDiscovery() throws Exception { long table1 = metadataDao.insertTable("schema", "table1", false, true, null, 0); metadataDao.insertColumn(table1, 1, "foo", 1, "bigint", 1, null); long table2 = metadataDao.insertTable("schema", "table2", false, true, null, 0); metadataDao.insertColumn(table2, 1, "foo", 1, "bigint", 1, null); metadataDao.insertTable("schema", "table3", false, false, null, 0); long intervalMillis = 100; ShardOrganizationManager organizationManager = createShardOrganizationManager(intervalMillis); Set<Long> actual = organizationManager.discoverAndInitializeTablesToOrganize(); assertEquals(actual, ImmutableSet.of(table1, table2)); long updateTime = System.currentTimeMillis(); organizerDao.updateLastStartTime("node1", table1, updateTime); organizerDao.updateLastStartTime("node1", table2, updateTime); long start = System.nanoTime(); while (organizationManager.discoverAndInitializeTablesToOrganize().isEmpty() && nanosSince(start).toMillis() < intervalMillis + 1000) { MILLISECONDS.sleep(10); } assertEquals(organizationManager.discoverAndInitializeTablesToOrganize(), ImmutableSet.of(table1, table2)); }