test_class.declarator: shardingRule
test_class.modifier: private
test_class.original_string: private ShardingRule shardingRule;
test_class.type: ShardingRule
test_class.var_name: shardingRule
test_class.file: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngineTest.java
test_class.identifier: ShardingUnicastRoutingEngineTest
test_case.body: @Test
      public void assertRoutingForTableWithoutTableRule() {
          ShardingUnicastRoutingEngine unicastRoutingEngine = new ShardingUnicastRoutingEngine(Collections.singleton("t_other"));
          RouteContext routeContext = new RouteContext();
          unicastRoutingEngine.route(routeContext, shardingRule);
          assertThat(routeContext.getRouteUnits().size(), is(1));
      }
test_case.class_method_signature: ShardingUnicastRoutingEngineTest.assertRoutingForTableWithoutTableRule()
test_case.full_signature: @Test public void assertRoutingForTableWithoutTableRule()
test_case.identifier: assertRoutingForTableWithoutTableRule
test_case.invocations: singleton route assertThat size getRouteUnits is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void assertRoutingForTableWithoutTableRule()
focal_class.declarator: logicTables
focal_class.modifier: private final
focal_class.original_string: private final Collection<String> logicTables;
focal_class.type: Collection<String>
focal_class.var_name: logicTables
focal_class.file: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngine.java
focal_class.identifier: ShardingUnicastRoutingEngine
focal_class.interfaces: implements ShardingRouteEngine
focal_class.class_method_signature: ShardingUnicastRoutingEngine.route(final RouteContext routeContext, final ShardingRule shardingRule)
focal_class.full_signature: @Override public void route(final RouteContext routeContext, final ShardingRule shardingRule)
focal_class.identifier: route
focal_class.modifiers: @Override public
focal_class.parameters: (final RouteContext routeContext, final ShardingRule shardingRule)
focal_class.return: void
focal_class.signature: void route(final RouteContext routeContext, final ShardingRule shardingRule)
focal_class.class_method_signature: ShardingUnicastRoutingEngine.getRandomDataSourceName(final Collection<String> dataSourceNames)
focal_class.full_signature: private String getRandomDataSourceName(final Collection<String> dataSourceNames)
focal_class.identifier: getRandomDataSourceName
focal_class.modifiers: private
focal_class.parameters: (final Collection<String> dataSourceNames)
focal_class.return: String
focal_class.signature: String getRandomDataSourceName(final Collection<String> dataSourceNames)
focal_method.body: @Override
      public void route(final RouteContext routeContext, final ShardingRule shardingRule) {
          String dataSourceName = getRandomDataSourceName(shardingRule.getDataSourceNames());
          RouteMapper dataSourceMapper = new RouteMapper(dataSourceName, dataSourceName);
          if (shardingRule.isAllBroadcastTables(logicTables)) {
              List<RouteMapper> tableMappers = new ArrayList<>(logicTables.size());
              for (String each : logicTables) {
                  tableMappers.add(new RouteMapper(each, each));
              }
              routeContext.getRouteUnits().add(new RouteUnit(dataSourceMapper, tableMappers));
          } else if (logicTables.isEmpty()) {
              routeContext.getRouteUnits().add(new RouteUnit(dataSourceMapper, Collections.emptyList()));
          } else if (1 == logicTables.size()) {
              String logicTableName = logicTables.iterator().next();
              if (!shardingRule.findTableRule(logicTableName).isPresent()) {
                  routeContext.getRouteUnits().add(new RouteUnit(dataSourceMapper, Collections.emptyList()));
                  return;
              }
              DataNode dataNode = shardingRule.getDataNode(logicTableName);
              routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper(dataNode.getDataSourceName(), dataNode.getDataSourceName()),
                      Collections.singletonList(new RouteMapper(logicTableName, dataNode.getTableName()))));
          } else {
              List<RouteMapper> tableMappers = new ArrayList<>(logicTables.size());
              Set<String> availableDatasourceNames = null;
              boolean first = true;
              for (String each : logicTables) {
                  TableRule tableRule = shardingRule.getTableRule(each);
                  DataNode dataNode = tableRule.getActualDataNodes().get(0);
                  tableMappers.add(new RouteMapper(each, dataNode.getTableName()));
                  Set<String> currentDataSourceNames = new HashSet<>(tableRule.getActualDatasourceNames().size());
                  for (DataNode eachDataNode : tableRule.getActualDataNodes()) {
                      currentDataSourceNames.add(eachDataNode.getDataSourceName());
                  }
                  if (first) {
                      availableDatasourceNames = currentDataSourceNames;
                      first = false;
                  } else {
                      availableDatasourceNames = Sets.intersection(availableDatasourceNames, currentDataSourceNames);
                  }
              }
              if (availableDatasourceNames.isEmpty()) {
                  throw new ShardingSphereConfigurationException("Cannot find actual datasource intersection for logic tables: %s", logicTables);
              }
              dataSourceName = getRandomDataSourceName(availableDatasourceNames);
              routeContext.getRouteUnits().add(new RouteUnit(new RouteMapper(dataSourceName, dataSourceName), tableMappers));
          }
      }
focal_method.class_method_signature: ShardingUnicastRoutingEngine.route(final RouteContext routeContext, final ShardingRule shardingRule)
focal_method.full_signature: @Override public void route(final RouteContext routeContext, final ShardingRule shardingRule)
focal_method.identifier: route
focal_method.invocations: getRandomDataSourceName getDataSourceNames isAllBroadcastTables size add add getRouteUnits isEmpty add getRouteUnits emptyList size next iterator isPresent findTableRule add getRouteUnits emptyList getDataNode add getRouteUnits getDataSourceName getDataSourceName singletonList getTableName size getTableRule get getActualDataNodes add getTableName size getActualDatasourceNames getActualDataNodes add getDataSourceName intersection isEmpty getRandomDataSourceName add getRouteUnits
focal_method.modifiers: @Override public
focal_method.parameters: (final RouteContext routeContext, final ShardingRule shardingRule)
focal_method.return: void
focal_method.signature: void route(final RouteContext routeContext, final ShardingRule shardingRule)