TableRule { int findActualTableIndex(final String dataSourceName, final String actualTableName) { return dataNodeIndexMap.getOrDefault(new DataNode(dataSourceName, actualTableName), -1); } TableRule(final Collection<String> dataSourceNames, final String logicTableName);  TableRule(final ShardingTableRuleConfiguration tableRuleConfig, final Collection<String> dataSourceNames, 
                     final ShardingAlgorithm databaseShardingAlgorithm, final ShardingAlgorithm tableShardingAlgorithm, final String defaultGenerateKeyColumn);  TableRule(final ShardingAutoTableRuleConfiguration tableRuleConfig, 
                     final Collection<String> dataSourceNames, final ShardingAlgorithm shardingAlgorithm, final String defaultGenerateKeyColumn); Map<String, List<DataNode>> getDataNodeGroups(); Collection<String> getActualDatasourceNames(); Collection<String> getActualTableNames(final String targetDataSource); Optional<String> getGenerateKeyColumn();  }
@Test public void assertFindActualTableIndex() { TableRule actual = new TableRule(new ShardingTableRuleConfiguration("LOGIC_TABLE", "ds${0..1}.table_${0..2}"), Arrays.asList("ds0", "ds1"), null, null, null); assertThat(actual.findActualTableIndex("ds1", "table_1"), is(4)); }
@Test public void assertNotFindActualTableIndex() { TableRule actual = new TableRule(new ShardingTableRuleConfiguration("LOGIC_TABLE", "ds${0..1}.table_${0..2}"), Arrays.asList("ds0", "ds1"), null, null, null); assertThat(actual.findActualTableIndex("ds2", "table_2"), is(-1)); }