ShardingUnconfiguredTablesRoutingEngine implements ShardingRouteEngine { @Override public void route(final RouteContext routeContext, final ShardingRule shardingRule) { Optional<String> dataSourceName = findDataSourceName(); if (!dataSourceName.isPresent()) { throw new ShardingSphereException("Can not route tables for `%s`, please make sure the tables are in same schema.", logicTables); } List<RouteMapper> routingTables = logicTables.stream().map(table -> new RouteMapper(table, table)).collect(Collectors.toList()); routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper(dataSourceName.get(), dataSourceName.get()), routingTables)); }  @Override void route(final RouteContext routeContext, final ShardingRule shardingRule);  }
@Test public void assertRoute() { ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration(); ShardingRule shardingRule = new ShardingRule(shardingRuleConfig, Arrays.asList("ds_0", "ds_1")); RouteContext routeContext = new RouteContext(); shardingDefaultDatabaseRoutingEngine.route(routeContext, shardingRule); List<RouteUnit> routeUnits = new ArrayList<>(routeContext.getRouteUnits()); assertThat(routeContext.getRouteUnits().size(), is(1)); assertThat(routeUnits.get(0).getDataSourceMapper().getActualName(), is("ds_0")); assertThat(routeUnits.get(0).getTableMappers().size(), is(2)); Iterator<RouteMapper> tableMappers = routeUnits.get(0).getTableMappers().iterator(); RouteMapper tableMapper0 = tableMappers.next(); assertThat(tableMapper0.getActualName(), is("t_order")); assertThat(tableMapper0.getLogicName(), is("t_order")); RouteMapper tableMapper1 = tableMappers.next(); assertThat(tableMapper1.getActualName(), is("t_order_item")); assertThat(tableMapper1.getLogicName(), is("t_order_item")); }