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



##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/ShadowPredicateColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,41 @@
+package org.apache.shardingsphere.shadow.rewrite.token.generator;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.shadow.rewrite.token.generator.impl.ShadowPredicateColumnTokenGenerator;
+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;
+
+/**
+ * test for ShadowPredicateColumnTokenGenerator
+ */
+public class ShadowPredicateColumnTokenGeneratorTest {

Review comment:
       All the test classes are expected to be defined as the final classes.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rewrite/token/generator/impl/ShadowInsertValuesTokenGenerator.java
##########
@@ -102,15 +102,15 @@ private void removeValueToken(final InsertValue 
insertValueToken, final InsertSt
     }
     
     private int getStartIndex(final Collection<InsertValuesSegment> segments) {
-        int result = segments.iterator().next().getStartIndex();
+        int result = Integer.MAX_VALUE;
         for (InsertValuesSegment each : segments) {
             result = Math.min(result, each.getStartIndex());
         }
         return result;
     }
     
     private int getStopIndex(final Collection<InsertValuesSegment> segments) {
-        int result = segments.iterator().next().getStopIndex();
+        int result = Integer.MIN_VALUE;

Review comment:
       Why is it changed to `MIN_VALUE`?

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/ShadowPredicateColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,41 @@
+package org.apache.shardingsphere.shadow.rewrite.token.generator;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.shadow.rewrite.token.generator.impl.ShadowPredicateColumnTokenGenerator;
+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;
+
+/**
+ * test for ShadowPredicateColumnTokenGenerator

Review comment:
       Please capitalize the first letter and check other classes in the same 
place.

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rewrite/parameter/impl/ShadowInsertValueParameterRewriter.java
##########
@@ -33,7 +33,7 @@
 public final class ShadowInsertValueParameterRewriter extends 
ShadowParameterRewriter<InsertStatementContext> {
     
     @Override
-    protected boolean isNeedRewriteForShadow(final SQLStatementContext 
sqlStatementContext) {
+    public boolean isNeedRewriteForShadow(final SQLStatementContext 
sqlStatementContext) {

Review comment:
       Why do you use `public`?

##########
File path: 
shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/rewrite/token/generator/ShadowPredicateColumnTokenGeneratorTest.java
##########
@@ -0,0 +1,41 @@
+package org.apache.shardingsphere.shadow.rewrite.token.generator;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.shadow.rewrite.token.generator.impl.ShadowPredicateColumnTokenGenerator;
+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;
+
+/**
+ * test for ShadowPredicateColumnTokenGenerator
+ */
+public class ShadowPredicateColumnTokenGeneratorTest {
+
+    private static final ShadowPredicateColumnTokenGenerator 
shadowPredicateColumnTokenGenerator = new ShadowPredicateColumnTokenGenerator();
+
+    private SQLStatementContext <? extends SQLStatement> sqlStatementContext;
+
+    @Before
+    public void  mockSQLStatementContext(){
+        sqlStatementContext = mock(SQLStatementContext.class);
+    }
+
+    @Test
+    public void isGenerateSQLTokenForShadow(){
+        boolean generateSQLTokenForShadow = 
shadowPredicateColumnTokenGenerator.isGenerateSQLTokenForShadow(sqlStatementContext);
+        Assert.assertFalse(generateSQLTokenForShadow);
+    }
+
+    @Test(expected = ClassCastException.class)
+    public void generateSQLTokensTest(){
+        
shadowPredicateColumnTokenGenerator.generateSQLTokens(sqlStatementContext);
+    }
+
+
+
+

Review comment:
       Please remove all the redundant blank lines.




-- 
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