test_class.declarator: DATASOURCE_NAME = "ds"
test_class.modifier: private static final
test_class.original_string: private static final String DATASOURCE_NAME = "ds";
test_class.type: String
test_class.var_name: DATASOURCE_NAME
test_class.declarator: NON_PRIMARY_REPLICA_DATASOURCE_NAME = "nonPrDatasource"
test_class.modifier: private static final
test_class.original_string: private static final String NON_PRIMARY_REPLICA_DATASOURCE_NAME = "nonPrDatasource";
test_class.type: String
test_class.var_name: NON_PRIMARY_REPLICA_DATASOURCE_NAME
test_class.declarator: PRIMARY_DATASOURCE = "primary"
test_class.modifier: private static final
test_class.original_string: private static final String PRIMARY_DATASOURCE = "primary";
test_class.type: String
test_class.var_name: PRIMARY_DATASOURCE
test_class.declarator: REPLICA_DATASOURCE = "query"
test_class.modifier: private static final
test_class.original_string: private static final String REPLICA_DATASOURCE = "query";
test_class.type: String
test_class.var_name: REPLICA_DATASOURCE
test_class.declarator: rule
test_class.modifier: private
test_class.original_string: private PrimaryReplicaReplicationRule rule;
test_class.type: PrimaryReplicaReplicationRule
test_class.var_name: rule
test_class.declarator: sqlStatementContext
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private SQLStatementContext<SQLStatement> sqlStatementContext;
test_class.type: SQLStatementContext<SQLStatement>
test_class.var_name: sqlStatementContext
test_class.declarator: sqlRouter
test_class.modifier: private
test_class.original_string: private PrimaryReplicaReplicationSQLRouter sqlRouter;
test_class.type: PrimaryReplicaReplicationSQLRouter
test_class.var_name: sqlRouter
test_class.file: shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-route/src/test/java/org/apache/shardingsphere/replication/primaryreplica/route/engine/PrimaryReplicaReplicationSQLRouterTest.java
test_class.identifier: PrimaryReplicaReplicationSQLRouterTest
test_case.body: @Test
      public void assertDecorateRouteContextToPrimaryDataSourceWithLock() {
          RouteContext actual = mockRouteContext();
          MySQLSelectStatement selectStatement = mock(MySQLSelectStatement.class);
          when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
          when(selectStatement.getLock()).thenReturn(Optional.of(mock(LockSegment.class)));
          ShardingSphereSchema schema = new ShardingSphereSchema("logic_schema", Collections.emptyList(), Collections.singleton(rule), Collections.emptyMap(), mock(ShardingSphereMetaData.class));
          LogicSQL logicSQL = new LogicSQL(schema, sqlStatementContext, "", Collections.emptyList());
          sqlRouter.decorateRouteContext(actual, logicSQL, rule, new ConfigurationProperties(new Properties()));
          Iterator<String> routedDataSourceNames = actual.getActualDataSourceNames().iterator();
          assertThat(routedDataSourceNames.next(), is(NON_PRIMARY_REPLICA_DATASOURCE_NAME));
          assertThat(routedDataSourceNames.next(), is(PRIMARY_DATASOURCE));
      }
test_case.class_method_signature: PrimaryReplicaReplicationSQLRouterTest.assertDecorateRouteContextToPrimaryDataSourceWithLock()
test_case.full_signature: @Test public void assertDecorateRouteContextToPrimaryDataSourceWithLock()
test_case.identifier: assertDecorateRouteContextToPrimaryDataSourceWithLock
test_case.invocations: mockRouteContext mock thenReturn when getSqlStatement thenReturn when getLock of mock emptyList singleton emptyMap mock emptyList decorateRouteContext iterator getActualDataSourceNames assertThat next is assertThat next is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void assertDecorateRouteContextToPrimaryDataSourceWithLock()
focal_class.file: shardingsphere-features/shardingsphere-primary-replica-replication/shardingsphere-primary-replica-replication-route/src/main/java/org/apache/shardingsphere/replication/primaryreplica/route/engine/PrimaryReplicaReplicationSQLRouter.java
focal_class.identifier: PrimaryReplicaReplicationSQLRouter
focal_class.interfaces: implements SQLRouter<PrimaryReplicaReplicationRule>
focal_class.class_method_signature: PrimaryReplicaReplicationSQLRouter.createRouteContext(final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.full_signature: @Override public RouteContext createRouteContext(final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.identifier: createRouteContext
focal_class.modifiers: @Override public
focal_class.parameters: (final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.return: RouteContext
focal_class.signature: RouteContext createRouteContext(final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.class_method_signature: PrimaryReplicaReplicationSQLRouter.decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.full_signature: @Override public void decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.identifier: decorateRouteContext
focal_class.modifiers: @Override public
focal_class.parameters: (final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.return: void
focal_class.signature: void decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_class.class_method_signature: PrimaryReplicaReplicationSQLRouter.getOrder()
focal_class.full_signature: @Override public int getOrder()
focal_class.identifier: getOrder
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getOrder()
focal_class.class_method_signature: PrimaryReplicaReplicationSQLRouter.getTypeClass()
focal_class.full_signature: @Override public Class<PrimaryReplicaReplicationRule> getTypeClass()
focal_class.identifier: getTypeClass
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Class<PrimaryReplicaReplicationRule>
focal_class.signature: Class<PrimaryReplicaReplicationRule> getTypeClass()
focal_method.body: @Override
      public void decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props) {
          Collection<RouteUnit> toBeRemoved = new LinkedList<>();
          Collection<RouteUnit> toBeAdded = new LinkedList<>();
          for (RouteUnit each : routeContext.getRouteUnits()) {
              String dataSourceName = each.getDataSourceMapper().getLogicName();
              Optional<PrimaryReplicaReplicationDataSourceRule> dataSourceRule = rule.findDataSourceRule(dataSourceName);
              if (dataSourceRule.isPresent() && dataSourceRule.get().getName().equalsIgnoreCase(each.getDataSourceMapper().getActualName())) {
                  toBeRemoved.add(each);
                  String actualDataSourceName = new PrimaryReplicaReplicationDataSourceRouter(dataSourceRule.get()).route(logicSQL.getSqlStatementContext().getSqlStatement());
                  toBeAdded.add(new RouteUnit(new RouteMapper(each.getDataSourceMapper().getLogicName(), actualDataSourceName), each.getTableMappers()));
              }
          }
          routeContext.getRouteUnits().removeAll(toBeRemoved);
          routeContext.getRouteUnits().addAll(toBeAdded);
      }
focal_method.class_method_signature: PrimaryReplicaReplicationSQLRouter.decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_method.full_signature: @Override public void decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_method.identifier: decorateRouteContext
focal_method.invocations: getRouteUnits getLogicName getDataSourceMapper findDataSourceRule isPresent equalsIgnoreCase getName get getActualName getDataSourceMapper add route get getSqlStatement getSqlStatementContext add getLogicName getDataSourceMapper getTableMappers removeAll getRouteUnits addAll getRouteUnits
focal_method.modifiers: @Override public
focal_method.parameters: (final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)
focal_method.return: void
focal_method.signature: void decorateRouteContext(final RouteContext routeContext, final LogicSQL logicSQL, final PrimaryReplicaReplicationRule rule, final ConfigurationProperties props)