ShardingRule implements DataNodeRoutedRule { public boolean isAllBindingTables(final Collection<String> logicTableNames) { if (logicTableNames.isEmpty()) { return false; } Optional<BindingTableRule> bindingTableRule = findBindingTableRule(logicTableNames); if (!bindingTableRule.isPresent()) { return false; } Collection<String> result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); result.addAll(bindingTableRule.get().getAllLogicTables()); return !result.isEmpty() && result.containsAll(logicTableNames); } ShardingRule(final ShardingRuleConfiguration config, final Collection<String> dataSourceNames);  ShardingRule(final AlgorithmProvidedShardingRuleConfiguration config, final Collection<String> dataSourceNames); Optional<TableRule> findTableRule(final String logicTableName); Optional<TableRule> findTableRuleByActualTable(final String actualTableName); TableRule getTableRule(final String logicTableName); ShardingStrategy getDatabaseShardingStrategy(final TableRule tableRule); ShardingStrategy getTableShardingStrategy(final TableRule tableRule); boolean isAllBindingTables(final Collection<String> logicTableNames); Optional<BindingTableRule> findBindingTableRule(final String logicTableName); boolean isAllBroadcastTables(final Collection<String> logicTableNames); boolean isBroadcastTable(final String logicTableName); boolean tableRuleExists(final Collection<String> logicTableNames); boolean isShardingColumn(final String columnName, final String tableName); boolean isGenerateKeyColumn(final String columnName, final String tableName); Optional<String> findGenerateKeyColumnName(final String logicTableName); Comparable<?> generateKey(final String logicTableName); DataNode getDataNode(final String logicTableName); DataNode getDataNode(final String dataSourceName, final String logicTableName); Collection<String> getShardingLogicTableNames(final Collection<String> logicTableNames); Map<String, String> getLogicAndActualTablesFromBindingTable(final String dataSourceName,
                                                                       final String logicTable, final String actualTable, final Collection<String> availableLogicBindingTables); @Override Map<String, Collection<DataNode>> getAllDataNodes(); @Override Collection<String> getAllActualTables(); @Override Optional<String> findFirstActualTable(final String logicTable); @Override boolean isNeedAccumulate(final Collection<String> tables); @Override Optional<String> findLogicTableByActualTable(final String actualTable);  }
@Test public void assertIsAllBindingTableWhenLogicTablesIsEmpty() { assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.emptyList())); }
@Test public void assertIsNotAllBindingTable() { assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.singletonList("new_Table"))); assertFalse(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_Table", "new_Table"))); }
@Test public void assertIsAllBindingTable() { assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singletonList("logic_Table"))); assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singletonList("logic_table"))); assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singletonList("sub_Logic_Table"))); assertTrue(createMaximumShardingRule().isAllBindingTables(Collections.singletonList("sub_logic_table"))); assertTrue(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_Table", "sub_Logic_Table"))); assertTrue(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_table", "sub_logic_Table"))); assertFalse(createMaximumShardingRule().isAllBindingTables(Arrays.asList("logic_table", "sub_logic_Table", "new_table"))); assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.emptyList())); assertFalse(createMaximumShardingRule().isAllBindingTables(Collections.singletonList("new_Table"))); }