TeslaCN commented on a change in pull request #11060:
URL: https://github.com/apache/shardingsphere/pull/11060#discussion_r661182219



##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowInsertValueParameterRewriterTest.java
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.parameter.impl;
+
+import com.google.common.collect.Lists;
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import 
org.apache.shardingsphere.infra.rewrite.parameter.builder.impl.GroupedParameterBuilder;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ShadowInsertValueParameterRewriterTest {
+
+    private ShadowInsertValueParameterRewriter 
shadowInsertValueParameterRewriter;
+
+    private InsertStatementContext insertStatementContext;
+
+    @Before
+    public void init() {
+        String shadowColumn = "shadow_column";
+        initShadowInsertValueParameterRewriter(shadowColumn);
+        mockInsertStatementContext(shadowColumn);
+    }
+
+    private void mockInsertStatementContext(final String shadowColumn) {
+        insertStatementContext = mock(InsertStatementContext.class);
+        
when(insertStatementContext.getInsertColumnNames()).thenReturn(Lists.newArrayList(shadowColumn));
+    }
+
+    private void initShadowInsertValueParameterRewriter(final String 
shadowColumn) {
+        shadowInsertValueParameterRewriter = new 
ShadowInsertValueParameterRewriter();
+        
shadowInsertValueParameterRewriter.setShadowRule(mockShadowRule(shadowColumn));
+    }
+
+    private ShadowRule mockShadowRule(final String shadowColumn) {
+        ShadowRule shadowRule = mock(ShadowRule.class);
+        when(shadowRule.getColumn()).thenReturn(shadowColumn);
+        return shadowRule;
+    }
+
+    @Test
+    public void isNeedRewriteForShadowTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/context/ShadowSQLRewriteContextDecoratorTest.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.context;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public final class ShadowSQLRewriteContextDecoratorTest {
+
+    private ShadowSQLRewriteContextDecorator shadowSQLRewriteContextDecorator;
+
+    @Before
+    public void init() {
+        shadowSQLRewriteContextDecorator = new 
ShadowSQLRewriteContextDecorator();
+    }
+
+    @Test
+    public void getOrderTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/context/ShadowSQLRewriteContextDecoratorTest.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.context;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+public final class ShadowSQLRewriteContextDecoratorTest {
+
+    private ShadowSQLRewriteContextDecorator shadowSQLRewriteContextDecorator;
+
+    @Before
+    public void init() {
+        shadowSQLRewriteContextDecorator = new 
ShadowSQLRewriteContextDecorator();
+    }
+
+    @Test
+    public void getOrderTest() {
+        assertThat(shadowSQLRewriteContextDecorator.getOrder(), is(60));
+    }
+
+    @Test
+    public void getTypeClassTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowInsertValuesTokenGeneratorTest.java
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.generator.impl;
+
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ShadowInsertValuesTokenGeneratorTest {
+
+    private ShadowInsertValuesTokenGenerator shadowInsertValuesTokenGenerator;
+
+    private InsertStatementContext insertStatementContext;
+
+    @Before
+    public void init() {
+        String shadowColumn = "shadow_column";
+        initShadowInsertValuesTokenGenerator(shadowColumn);
+        mockInsertStatementContext(shadowColumn);
+    }
+
+    private void mockInsertStatementContext(final String shadowColumn) {
+        InsertStatement insertStatement = mock(InsertStatement.class);
+        when(insertStatement.getValues()).thenReturn(createValues());
+        insertStatementContext = mock(InsertStatementContext.class);
+        
when(insertStatementContext.getSqlStatement()).thenReturn(insertStatement);
+        
when(insertStatementContext.getInsertColumnNames()).thenReturn(createInsertColumnNames(shadowColumn));
+    }
+
+    private Collection<InsertValuesSegment> createValues() {
+        List<InsertValuesSegment> values = new LinkedList<>();
+        values.add(mock(InsertValuesSegment.class));
+        return values;
+    }
+
+    private List<String> createInsertColumnNames(final String shadowColumn) {
+        List<String> insertColumnNames = new LinkedList<>();
+        insertColumnNames.add(shadowColumn);
+        insertColumnNames.add("aaa");
+        return insertColumnNames;
+    }
+
+    private void initShadowInsertValuesTokenGenerator(final String 
shadowColumn) {
+        shadowInsertValuesTokenGenerator = new 
ShadowInsertValuesTokenGenerator();
+        
shadowInsertValuesTokenGenerator.setShadowRule(mockShadowRule(shadowColumn));
+        shadowInsertValuesTokenGenerator.setPreviousSQLTokens(new 
LinkedList<>());
+    }
+
+    private ShadowRule mockShadowRule(final String shadowColumn) {
+        ShadowRule shadowRule = mock(ShadowRule.class);
+        when(shadowRule.getColumn()).thenReturn(shadowColumn);
+        return shadowRule;
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadowTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/ShadowTokenGenerateBuilderTest.java
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token;
+
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class ShadowTokenGenerateBuilderTest {
+
+    private ShadowTokenGenerateBuilder shadowTokenGenerateBuilder;
+
+    @Before
+    public void init() {
+        shadowTokenGenerateBuilder = new 
ShadowTokenGenerateBuilder(mock(ShadowRule.class));
+    }
+
+    @Test
+    public void getSQLTokenGeneratorsTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/parameter/ShadowParameterRewriterBuilderTest.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.parameter;
+
+import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.mockito.Mockito.mock;
+import static org.junit.Assert.assertThat;
+
+public final class ShadowParameterRewriterBuilderTest {
+
+    private ShadowParameterRewriterBuilder shadowParameterRewriterBuilder;
+
+    @Before
+    public void init() {
+        shadowParameterRewriterBuilder = new 
ShadowParameterRewriterBuilder(mock(ShadowRule.class));
+    }
+    
+    @Test
+    public void getParameterRewritersTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowInsertValuesTokenGeneratorTest.java
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.generator.impl;
+
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ShadowInsertValuesTokenGeneratorTest {
+
+    private ShadowInsertValuesTokenGenerator shadowInsertValuesTokenGenerator;
+
+    private InsertStatementContext insertStatementContext;
+
+    @Before
+    public void init() {
+        String shadowColumn = "shadow_column";
+        initShadowInsertValuesTokenGenerator(shadowColumn);
+        mockInsertStatementContext(shadowColumn);
+    }
+
+    private void mockInsertStatementContext(final String shadowColumn) {
+        InsertStatement insertStatement = mock(InsertStatement.class);
+        when(insertStatement.getValues()).thenReturn(createValues());
+        insertStatementContext = mock(InsertStatementContext.class);
+        
when(insertStatementContext.getSqlStatement()).thenReturn(insertStatement);
+        
when(insertStatementContext.getInsertColumnNames()).thenReturn(createInsertColumnNames(shadowColumn));
+    }
+
+    private Collection<InsertValuesSegment> createValues() {
+        List<InsertValuesSegment> values = new LinkedList<>();
+        values.add(mock(InsertValuesSegment.class));
+        return values;
+    }
+
+    private List<String> createInsertColumnNames(final String shadowColumn) {
+        List<String> insertColumnNames = new LinkedList<>();
+        insertColumnNames.add(shadowColumn);
+        insertColumnNames.add("aaa");
+        return insertColumnNames;
+    }
+
+    private void initShadowInsertValuesTokenGenerator(final String 
shadowColumn) {
+        shadowInsertValuesTokenGenerator = new 
ShadowInsertValuesTokenGenerator();
+        
shadowInsertValuesTokenGenerator.setShadowRule(mockShadowRule(shadowColumn));
+        shadowInsertValuesTokenGenerator.setPreviousSQLTokens(new 
LinkedList<>());
+    }
+
+    private ShadowRule mockShadowRule(final String shadowColumn) {
+        ShadowRule shadowRule = mock(ShadowRule.class);
+        when(shadowRule.getColumn()).thenReturn(shadowColumn);
+        return shadowRule;
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadowTest() {
+        
Assert.assertTrue(shadowInsertValuesTokenGenerator.isGenerateSQLTokenForShadow(insertStatementContext));
+    }
+
+    @Test
+    public void generateSQLTokenTest() {
+        
Assert.assertNotNull(shadowInsertValuesTokenGenerator.generateSQLToken(insertStatementContext));

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowPredicateParameterRewriterTest.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.parameter.impl;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.infra.rewrite.parameter.builder.ParameterBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class ShadowPredicateParameterRewriterTest {
+
+    private ShadowPredicateParameterRewriter shadowPredicateParameterRewriter;
+
+    @Before
+    public void init() {
+        shadowPredicateParameterRewriter = new 
ShadowPredicateParameterRewriter();
+    }
+
+    @Test
+    public void isNeedRewriteForShadowTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowPredicateColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.generator.impl;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+
+public class ShadowPredicateColumnTokenGeneratorTest {
+
+    private ShadowPredicateColumnTokenGenerator 
shadowPredicateColumnTokenGenerator;
+
+    private SQLStatementContext<? extends SQLStatement> sqlStatementContext;
+
+    @Before
+    public void init() {
+        shadowPredicateColumnTokenGenerator = new 
ShadowPredicateColumnTokenGenerator();
+        sqlStatementContext = mock(SQLStatementContext.class);
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadow() {
+        
Assert.assertFalse(shadowPredicateColumnTokenGenerator.isGenerateSQLTokenForShadow(sqlStatementContext));
+    }
+
+    @Test(expected = ClassCastException.class)
+    public void generateSQLTokensTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/RemoveShadowColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.generator.impl;
+
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.InsertColumnsSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class RemoveShadowColumnTokenGeneratorTest {
+
+    private RemoveShadowColumnTokenGenerator removeShadowColumnTokenGenerator;
+
+    private InsertStatementContext insertStatementContext;
+
+    @Before
+    public void init() {
+        String shadowColumn = "shadow_column";
+        initRemoveShadowColumnTokenGenerator(shadowColumn);
+        mockInsertStatementContext(shadowColumn);
+    }
+
+    private void mockInsertStatementContext(final String shadowColumn) {
+        InsertStatement insertStatement = mock(InsertStatement.class);
+        InsertColumnsSegment insertColumnsSegment = 
mockInsertColumnsSegment(shadowColumn);
+        insertStatement.setInsertColumns(insertColumnsSegment);
+        
when(insertStatement.getInsertColumns()).thenReturn(Optional.of(insertColumnsSegment));
+        insertStatementContext = mock(InsertStatementContext.class);
+        
when(insertStatementContext.getSqlStatement()).thenReturn(insertStatement);
+    }
+
+    private InsertColumnsSegment mockInsertColumnsSegment(final String 
shadowColumn) {
+        InsertColumnsSegment insertColumnsSegment = 
mock(InsertColumnsSegment.class);
+        
when(insertColumnsSegment.getColumns()).thenReturn(initColumns(shadowColumn));
+        return insertColumnsSegment;
+    }
+
+    private Collection<ColumnSegment> initColumns(final String shadowColumn) {
+        Collection<ColumnSegment> columns = new LinkedList<>();
+        columns.add(new ColumnSegment(1, 6, new 
IdentifierValue(shadowColumn)));
+        columns.add(new ColumnSegment(7, 8, new IdentifierValue("a")));
+        return columns;
+    }
+
+    private void initRemoveShadowColumnTokenGenerator(final String 
shadowColumn) {
+        removeShadowColumnTokenGenerator = new 
RemoveShadowColumnTokenGenerator();
+        
removeShadowColumnTokenGenerator.setShadowRule(mockShadowRule(shadowColumn));
+    }
+
+    private ShadowRule mockShadowRule(final String shadowColumn) {
+        ShadowRule shadowRule = mock(ShadowRule.class);
+        when(shadowRule.getColumn()).thenReturn(shadowColumn);
+        return shadowRule;
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadowTest() {
+        
assertTrue(removeShadowColumnTokenGenerator.isGenerateSQLTokenForShadow(insertStatementContext));
+    }
+
+    @Test
+    public void generateSQLTokensTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/RemoveShadowColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.generator.impl;
+
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.InsertColumnsSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class RemoveShadowColumnTokenGeneratorTest {
+
+    private RemoveShadowColumnTokenGenerator removeShadowColumnTokenGenerator;
+
+    private InsertStatementContext insertStatementContext;
+
+    @Before
+    public void init() {
+        String shadowColumn = "shadow_column";
+        initRemoveShadowColumnTokenGenerator(shadowColumn);
+        mockInsertStatementContext(shadowColumn);
+    }
+
+    private void mockInsertStatementContext(final String shadowColumn) {
+        InsertStatement insertStatement = mock(InsertStatement.class);
+        InsertColumnsSegment insertColumnsSegment = 
mockInsertColumnsSegment(shadowColumn);
+        insertStatement.setInsertColumns(insertColumnsSegment);
+        
when(insertStatement.getInsertColumns()).thenReturn(Optional.of(insertColumnsSegment));
+        insertStatementContext = mock(InsertStatementContext.class);
+        
when(insertStatementContext.getSqlStatement()).thenReturn(insertStatement);
+    }
+
+    private InsertColumnsSegment mockInsertColumnsSegment(final String 
shadowColumn) {
+        InsertColumnsSegment insertColumnsSegment = 
mock(InsertColumnsSegment.class);
+        
when(insertColumnsSegment.getColumns()).thenReturn(initColumns(shadowColumn));
+        return insertColumnsSegment;
+    }
+
+    private Collection<ColumnSegment> initColumns(final String shadowColumn) {
+        Collection<ColumnSegment> columns = new LinkedList<>();
+        columns.add(new ColumnSegment(1, 6, new 
IdentifierValue(shadowColumn)));
+        columns.add(new ColumnSegment(7, 8, new IdentifierValue("a")));
+        return columns;
+    }
+
+    private void initRemoveShadowColumnTokenGenerator(final String 
shadowColumn) {
+        removeShadowColumnTokenGenerator = new 
RemoveShadowColumnTokenGenerator();
+        
removeShadowColumnTokenGenerator.setShadowRule(mockShadowRule(shadowColumn));
+    }
+
+    private ShadowRule mockShadowRule(final String shadowColumn) {
+        ShadowRule shadowRule = mock(ShadowRule.class);
+        when(shadowRule.getColumn()).thenReturn(shadowColumn);
+        return shadowRule;
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadowTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowInsertValueParameterRewriterTest.java
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.parameter.impl;
+
+import com.google.common.collect.Lists;
+import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import 
org.apache.shardingsphere.infra.rewrite.parameter.builder.impl.GroupedParameterBuilder;
+import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ShadowInsertValueParameterRewriterTest {
+
+    private ShadowInsertValueParameterRewriter 
shadowInsertValueParameterRewriter;
+
+    private InsertStatementContext insertStatementContext;
+
+    @Before
+    public void init() {
+        String shadowColumn = "shadow_column";
+        initShadowInsertValueParameterRewriter(shadowColumn);
+        mockInsertStatementContext(shadowColumn);
+    }
+
+    private void mockInsertStatementContext(final String shadowColumn) {
+        insertStatementContext = mock(InsertStatementContext.class);
+        
when(insertStatementContext.getInsertColumnNames()).thenReturn(Lists.newArrayList(shadowColumn));
+    }
+
+    private void initShadowInsertValueParameterRewriter(final String 
shadowColumn) {
+        shadowInsertValueParameterRewriter = new 
ShadowInsertValueParameterRewriter();
+        
shadowInsertValueParameterRewriter.setShadowRule(mockShadowRule(shadowColumn));
+    }
+
+    private ShadowRule mockShadowRule(final String shadowColumn) {
+        ShadowRule shadowRule = mock(ShadowRule.class);
+        when(shadowRule.getColumn()).thenReturn(shadowColumn);
+        return shadowRule;
+    }
+
+    @Test
+    public void isNeedRewriteForShadowTest() {
+        
assertTrue(shadowInsertValueParameterRewriter.isNeedRewriteForShadow(insertStatementContext));
+    }
+
+    @Test
+    public void rewriteTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/pojo/ShadowInsertValuesTokenTest.java
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.pojo;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ShadowInsertValuesTokenTest {
+
+    private ShadowInsertValuesToken shadowInsertValuesToken;
+
+    @Before
+    public void init() {
+        shadowInsertValuesToken = new ShadowInsertValuesToken(0, 10);
+    }
+
+    @Test
+    public void toStringTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowPredicateParameterRewriterTest.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.parameter.impl;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.infra.rewrite.parameter.builder.ParameterBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class ShadowPredicateParameterRewriterTest {
+
+    private ShadowPredicateParameterRewriter shadowPredicateParameterRewriter;
+
+    @Before
+    public void init() {
+        shadowPredicateParameterRewriter = new 
ShadowPredicateParameterRewriter();
+    }
+
+    @Test
+    public void isNeedRewriteForShadowTest() {
+        
assertTrue(shadowPredicateParameterRewriter.isNeedRewriteForShadow(mock(SQLStatementContext.class)));
+    }
+
+    @Test
+    public void rewriteTest() {

Review comment:
       Name the test methods like `assertXXX`.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowPredicateColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.shadow.rewrite.token.generator.impl;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+
+public class ShadowPredicateColumnTokenGeneratorTest {
+
+    private ShadowPredicateColumnTokenGenerator 
shadowPredicateColumnTokenGenerator;
+
+    private SQLStatementContext<? extends SQLStatement> sqlStatementContext;
+
+    @Before
+    public void init() {
+        shadowPredicateColumnTokenGenerator = new 
ShadowPredicateColumnTokenGenerator();
+        sqlStatementContext = mock(SQLStatementContext.class);
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadow() {

Review comment:
       Name the test methods like `assertXXX`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to