test_class.declarator: shardingRule
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      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/validator/impl/ShardingInsertStatementValidatorTest.java
test_class.identifier: ShardingInsertStatementValidatorTest
test_case.body: @Test(expected = ShardingSphereException.class)
      public void assertValidateOnDuplicateKeyWithShardingKey() {
          when(shardingRule.isShardingColumn("id", "user")).thenReturn(true);
          SQLStatementContext<InsertStatement> sqlStatementContext = new InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), Collections.singletonList(1), createInsertStatement());
          new ShardingInsertStatementValidator().preValidate(shardingRule, sqlStatementContext, Collections.emptyList(), mock(ShardingSphereMetaData.class));
      }
test_case.class_method_signature: ShardingInsertStatementValidatorTest.assertValidateOnDuplicateKeyWithShardingKey()
test_case.full_signature: @Test(expected = ShardingSphereException.class) public void assertValidateOnDuplicateKeyWithShardingKey()
test_case.identifier: assertValidateOnDuplicateKeyWithShardingKey
test_case.invocations: thenReturn when isShardingColumn emptyMap singletonList createInsertStatement preValidate emptyList mock
test_case.modifiers: @Test(expected = ShardingSphereException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void assertValidateOnDuplicateKeyWithShardingKey()
focal_class.file: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidator.java
focal_class.identifier: ShardingInsertStatementValidator
focal_class.interfaces: implements ShardingStatementValidator<InsertStatement>
focal_class.class_method_signature: ShardingInsertStatementValidator.preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_class.full_signature: @Override public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_class.identifier: preValidate
focal_class.modifiers: @Override public
focal_class.parameters: (final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_class.return: void
focal_class.signature: void preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_class.class_method_signature: ShardingInsertStatementValidator.isUpdateShardingKey(final ShardingRule shardingRule, final OnDuplicateKeyColumnsSegment onDuplicateKeyColumnsSegment, final String tableName)
focal_class.full_signature: private boolean isUpdateShardingKey(final ShardingRule shardingRule, final OnDuplicateKeyColumnsSegment onDuplicateKeyColumnsSegment, final String tableName)
focal_class.identifier: isUpdateShardingKey
focal_class.modifiers: private
focal_class.parameters: (final ShardingRule shardingRule, final OnDuplicateKeyColumnsSegment onDuplicateKeyColumnsSegment, final String tableName)
focal_class.return: boolean
focal_class.signature: boolean isUpdateShardingKey(final ShardingRule shardingRule, final OnDuplicateKeyColumnsSegment onDuplicateKeyColumnsSegment, final String tableName)
focal_class.class_method_signature: ShardingInsertStatementValidator.isContainsKeyGenerateStrategy(final ShardingRule shardingRule, final String tableName)
focal_class.full_signature: private boolean isContainsKeyGenerateStrategy(final ShardingRule shardingRule, final String tableName)
focal_class.identifier: isContainsKeyGenerateStrategy
focal_class.modifiers: private
focal_class.parameters: (final ShardingRule shardingRule, final String tableName)
focal_class.return: boolean
focal_class.signature: boolean isContainsKeyGenerateStrategy(final ShardingRule shardingRule, final String tableName)
focal_class.class_method_signature: ShardingInsertStatementValidator.isContainsKeyGenerateColumn(final ShardingRule shardingRule, final Collection<ColumnSegment> columns, final String tableName)
focal_class.full_signature: private boolean isContainsKeyGenerateColumn(final ShardingRule shardingRule, final Collection<ColumnSegment> columns, final String tableName)
focal_class.identifier: isContainsKeyGenerateColumn
focal_class.modifiers: private
focal_class.parameters: (final ShardingRule shardingRule, final Collection<ColumnSegment> columns, final String tableName)
focal_class.return: boolean
focal_class.signature: boolean isContainsKeyGenerateColumn(final ShardingRule shardingRule, final Collection<ColumnSegment> columns, final String tableName)
focal_class.class_method_signature: ShardingInsertStatementValidator.isAllSameTables(final Collection<String> tableNames)
focal_class.full_signature: private boolean isAllSameTables(final Collection<String> tableNames)
focal_class.identifier: isAllSameTables
focal_class.modifiers: private
focal_class.parameters: (final Collection<String> tableNames)
focal_class.return: boolean
focal_class.signature: boolean isAllSameTables(final Collection<String> tableNames)
focal_class.class_method_signature: ShardingInsertStatementValidator.postValidate(final InsertStatement sqlStatement, final RouteContext routeContext)
focal_class.full_signature: @Override public void postValidate(final InsertStatement sqlStatement, final RouteContext routeContext)
focal_class.identifier: postValidate
focal_class.modifiers: @Override public
focal_class.parameters: (final InsertStatement sqlStatement, final RouteContext routeContext)
focal_class.return: void
focal_class.signature: void postValidate(final InsertStatement sqlStatement, final RouteContext routeContext)
focal_method.body: @Override
      public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData) {
          if (null == ((InsertStatementContext) sqlStatementContext).getInsertSelectContext() && 1 != ((TableAvailable) sqlStatementContext).getTablesContext().getTables().size()) {
              throw new ShardingSphereException("Cannot support Multiple-Table for '%s'.", sqlStatementContext.getSqlStatement());
          }
          InsertStatement sqlStatement = sqlStatementContext.getSqlStatement();
          Optional<OnDuplicateKeyColumnsSegment> onDuplicateKeyColumnsSegment = InsertStatementHandler.getOnDuplicateKeyColumnsSegment(sqlStatement);
          String tableName = sqlStatement.getTable().getTableName().getIdentifier().getValue();
          if (onDuplicateKeyColumnsSegment.isPresent() && isUpdateShardingKey(shardingRule, onDuplicateKeyColumnsSegment.get(), tableName)) {
              throw new ShardingSphereException("INSERT INTO ... ON DUPLICATE KEY UPDATE can not support update for sharding column.");
          }
          Optional<SubquerySegment> insertSelectSegment = sqlStatement.getInsertSelect();
          if (insertSelectSegment.isPresent() && isContainsKeyGenerateStrategy(shardingRule, tableName)
                  && !isContainsKeyGenerateColumn(shardingRule, sqlStatement.getColumns(), tableName)) {
              throw new ShardingSphereException("INSERT INTO ... SELECT can not support applying keyGenerator to absent generateKeyColumn.");
          }
          TablesContext tablesContext = sqlStatementContext.getTablesContext();
          if (insertSelectSegment.isPresent() && !isAllSameTables(tablesContext.getTableNames()) && !shardingRule.isAllBindingTables(tablesContext.getTableNames())) {
              throw new ShardingSphereException("The table inserted and the table selected must be the same or bind tables.");
          }
      }
focal_method.class_method_signature: ShardingInsertStatementValidator.preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_method.full_signature: @Override public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_method.identifier: preValidate
focal_method.invocations: getInsertSelectContext size getTables getTablesContext getSqlStatement getSqlStatement getOnDuplicateKeyColumnsSegment getValue getIdentifier getTableName getTable isPresent isUpdateShardingKey get getInsertSelect isPresent isContainsKeyGenerateStrategy isContainsKeyGenerateColumn getColumns getTablesContext isPresent isAllSameTables getTableNames isAllBindingTables getTableNames
focal_method.modifiers: @Override public
focal_method.parameters: (final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)
focal_method.return: void
focal_method.signature: void preValidate(final ShardingRule shardingRule, final SQLStatementContext<InsertStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData)