You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/01 12:45:41 UTC

[GitHub] [shardingsphere] fwhdzh opened a new pull request #12159: Issue10968

fwhdzh opened a new pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159


   For #10968.
   
   Changes proposed in this pull request:
   -Add unit test of RowCountTokenGenerator and ShardingInsertValuesTokenGenerator.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-911217284


   @fwhdzh Hi, welcome here.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fwhdzh commented on a change in pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
fwhdzh commented on a change in pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#discussion_r702537464



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ProjectionsTokenGeneratorTest.java
##########
@@ -59,27 +59,25 @@
 
     private static final String TEST_DERIVED_PROJECTION_ALIAS = "TEST_DERIVED_PROJECTION_ALIAS";
 
-    private static final int TEST_STOP_INDEX = 2;
-
     private static final String TEST_LOGIC_TABLE_NAME = "TEST_LOGIC_TABLE_NAME";
 
-    private static final String TEST_ACTUAL_TABLE_NAME = "TEST_ACTUAL_TABLE_NAME";
-
     private static final String TEST_ACTUAL_TABLE_NAME_WRAPPED = "TEST_ACTUAL_TABLE_NAME_WRAPPED";
 
     private static final String TEST_OTHER_DERIVED_PROJECTION_ALIAS = "TEST_OTHER_DERIVED_PROJECTION_ALIAS";
 
     private static final String TEST_OTHER_DERIVED_PROJECTION_EXPRESSION = "TEST_OTHER_DERIVED_PROJECTION_EXPRESSION";
 
-    private RouteUnit routeUnit = mock(RouteUnit.class);
+    private RouteUnit routeUnit;
 
     @Before
     public void setup() {
         RouteMapper routeMapper = mock(RouteMapper.class);
         when(routeMapper.getLogicName()).thenReturn(TEST_LOGIC_TABLE_NAME);
-        when(routeMapper.getActualName()).thenReturn(TEST_ACTUAL_TABLE_NAME);
+        final String testActualTableName = "TEST_ACTUAL_TABLE_NAME";
+        when(routeMapper.getActualName()).thenReturn(testActualTableName);

Review comment:
       Okay, I will fix it. 
   If the variable is a int instead of a string, should I also use it directly?




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fwhdzh commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
fwhdzh commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-914811496


   I have fixed these issues and check for all the pr to recorrect them.
   For now : 
   - If a variable is only used in one method, I use local variables instead of static variables.
   - If a variable of String type is only used once, I use the content of the String directly instead of a variable.
   - If a variable of Int or Long type is only used once, I still use a local variables in afraid of confusion of magic number.
   - If a variable is used in many method, I use it as static variable.
   I also merge those recent commits from master.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-913094287


   Hi @fwhdzh Thanks for your continuous tweaks, @soulasuna Do you think it's ready to merge?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-911716651


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#12159](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7df2c55) into [master](https://codecov.io/gh/apache/shardingsphere/commit/bf812c0e85afa392c4013cb71fd2945f75189f81?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bf812c0) will **increase** coverage by `0.09%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12159/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #12159      +/-   ##
   ============================================
   + Coverage     63.74%   63.83%   +0.09%     
   - Complexity     1261     1271      +10     
   ============================================
     Files          2351     2363      +12     
     Lines         35746    35867     +121     
     Branches       6210     6232      +22     
   ============================================
   + Hits          22785    22896     +111     
   + Misses        11135    11130       -5     
   - Partials       1826     1841      +15     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ere/scaling/core/config/WorkflowConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9jb25maWcvV29ya2Zsb3dDb25maWd1cmF0aW9uLmphdmE=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [...rdingsphere/scaling/core/util/ScalingTaskUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS91dGlsL1NjYWxpbmdUYXNrVXRpbC5qYXZh) | `5.88% <0.00%> (-60.79%)` | :arrow_down: |
   | [.../manager/cluster/ClusterContextManagerBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9DbHVzdGVyQ29udGV4dE1hbmFnZXJCdWlsZGVyLmphdmE=) | `52.63% <0.00%> (-19.62%)` | :arrow_down: |
   | [...rdingsphere/scaling/core/job/FinishedCheckJob.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvRmluaXNoZWRDaGVja0pvYi5qYXZh) | `32.50% <0.00%> (-18.79%)` | :arrow_down: |
   | [.../scaling/core/job/preparer/ScalingJobPreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvcHJlcGFyZXIvU2NhbGluZ0pvYlByZXBhcmVyLmphdmE=) | `68.08% <0.00%> (-16.13%)` | :arrow_down: |
   | [...nd/text/admin/mysql/MySQLAdminExecutorFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2FkbWluL215c3FsL015U1FMQWRtaW5FeGVjdXRvckZhY3RvcnkuamF2YQ==) | `40.54% <0.00%> (-15.02%)` | :arrow_down: |
   | [...phere/scaling/core/config/HandleConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9jb25maWcvSGFuZGxlQ29uZmlndXJhdGlvbi5qYXZh) | `0.00% <0.00%> (-12.50%)` | :arrow_down: |
   | [...fra/config/datasource/DataSourceConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9jb25maWcvZGF0YXNvdXJjZS9EYXRhU291cmNlQ29uZmlndXJhdGlvbi5qYXZh) | `65.21% <0.00%> (-10.13%)` | :arrow_down: |
   | [...resql/component/PostgreSQLPositionInitializer.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc2NhbGluZy1wb3N0Z3Jlc3FsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zY2FsaW5nL3Bvc3RncmVzcWwvY29tcG9uZW50L1Bvc3RncmVTUUxQb3NpdGlvbkluaXRpYWxpemVyLmphdmE=) | `67.34% <0.00%> (-6.57%)` | :arrow_down: |
   | [...sphere/scaling/core/job/schedule/JobScheduler.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2Ivc2NoZWR1bGUvSm9iU2NoZWR1bGVyLmphdmE=) | `46.66% <0.00%> (-5.19%)` | :arrow_down: |
   | ... and [37 more](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bf812c0...7df2c55](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fwhdzh commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
fwhdzh commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-913309420


   @soulasuna I will fixed these issues soon. In this pull request, there are also other code having problem like this. (for example, AggregationDistinctTokenGeneratorTest.TEST_ALIAS). Should I fixed all of them?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-911716651


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#12159](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (07f2eb7) into [master](https://codecov.io/gh/apache/shardingsphere/commit/cfec4481a7a41615956ce6640bce11621c190284?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (cfec448) will **increase** coverage by `0.11%`.
   > The diff coverage is `76.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12159/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #12159      +/-   ##
   ============================================
   + Coverage     63.72%   63.83%   +0.11%     
   - Complexity     1255     1262       +7     
   ============================================
     Files          2326     2327       +1     
     Lines         35401    35413      +12     
     Branches       6160     6161       +1     
   ============================================
   + Hits          22560    22607      +47     
   + Misses        11027    10990      -37     
   - Partials       1814     1816       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ql/parser/core/EncryptDistSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWRpc3RzcWwvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC1kaXN0c3FsLXBhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZW5jcnlwdC9kaXN0c3FsL3BhcnNlci9jb3JlL0VuY3J5cHREaXN0U1FMU3RhdGVtZW50VmlzaXRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...resql/tcl/PostgreSQLStartTransactionStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvcG9zdGdyZXNxbC90Y2wvUG9zdGdyZVNRTFN0YXJ0VHJhbnNhY3Rpb25TdGF0ZW1lbnQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...egment/impl/distsql/rdl/ExpectedEncryptColumn.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvamF4Yi9jYXNlcy9kb21haW4vc2VnbWVudC9pbXBsL2Rpc3RzcWwvcmRsL0V4cGVjdGVkRW5jcnlwdENvbHVtbi5qYXZh) | `100.00% <ø> (ø)` | |
   | [...acket/generic/PostgreSQLCommandCompletePacket.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wvc2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGIvcHJvdG9jb2wvcG9zdGdyZXNxbC9wYWNrZXQvZ2VuZXJpYy9Qb3N0Z3JlU1FMQ29tbWFuZENvbXBsZXRlUGFja2V0LmphdmE=) | `55.55% <25.00%> (+5.55%)` | :arrow_up: |
   | [...ndler/converter/EncryptRuleStatementConverter.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWRpc3RzcWwvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvZGlzdHNxbC9oYW5kbGVyL2NvbnZlcnRlci9FbmNyeXB0UnVsZVN0YXRlbWVudENvbnZlcnRlci5qYXZh) | `94.73% <100.00%> (+0.29%)` | :arrow_up: |
   | [...nd/postgresql/command/query/PostgreSQLCommand.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvcG9zdGdyZXNxbC9jb21tYW5kL3F1ZXJ5L1Bvc3RncmVTUUxDb21tYW5kLmphdmE=) | `100.00% <100.00%> (ø)` | |
   | [...y/binary/execute/PostgreSQLComExecuteExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvcG9zdGdyZXNxbC9jb21tYW5kL3F1ZXJ5L2JpbmFyeS9leGVjdXRlL1Bvc3RncmVTUUxDb21FeGVjdXRlRXhlY3V0b3IuamF2YQ==) | `97.29% <100.00%> (ø)` | |
   | [...command/query/text/PostgreSQLComQueryExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQvc2hhcmRpbmdzcGhlcmUtcHJveHktZnJvbnRlbmQtcG9zdGdyZXNxbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvcG9zdGdyZXNxbC9jb21tYW5kL3F1ZXJ5L3RleHQvUG9zdGdyZVNRTENvbVF1ZXJ5RXhlY3V0b3IuamF2YQ==) | `82.14% <100.00%> (ø)` | |
   | [...atement/impl/PostgreSQLTCLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1wb3N0Z3Jlc3FsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zcWwvcGFyc2VyL3Bvc3RncmVzcWwvdmlzaXRvci9zdGF0ZW1lbnQvaW1wbC9Qb3N0Z3JlU1FMVENMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `81.81% <100.00%> (+0.86%)` | :arrow_up: |
   | [...l/parser/core/database/visitor/SQLVisitorRule.java](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWVuZ2luZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9jb3JlL2RhdGFiYXNlL3Zpc2l0b3IvU1FMVmlzaXRvclJ1bGUuamF2YQ==) | `100.00% <100.00%> (ø)` | |
   | ... and [13 more](https://codecov.io/gh/apache/shardingsphere/pull/12159/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [17fa0cf...07f2eb7](https://codecov.io/gh/apache/shardingsphere/pull/12159?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fwhdzh edited a comment on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
fwhdzh edited a comment on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-914811496


   I have fixed these issues and check for all the pr to recorrect them.
   
   For now : 
   - If a variable is only used in one method, I use local variables instead of static variables.
   - If a variable of String type is only used once, I use the content of the String directly instead of a variable.
   - If a variable of Int or Long type is only used once, I still use a local variables in afraid of confusion of magic number.
   - If a variable is used in many method, I use it as static variable.
   
   I also merge those recent commits from master.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero merged pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fwhdzh commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
fwhdzh commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-911476461


   > Thank you very much for your contribution. Here are a few minor issues, please modify them.
   
   I have fixed these issues.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] soulasuna commented on a change in pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
soulasuna commented on a change in pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#discussion_r702530186



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ProjectionsTokenGeneratorTest.java
##########
@@ -59,27 +59,25 @@
 
     private static final String TEST_DERIVED_PROJECTION_ALIAS = "TEST_DERIVED_PROJECTION_ALIAS";
 
-    private static final int TEST_STOP_INDEX = 2;
-
     private static final String TEST_LOGIC_TABLE_NAME = "TEST_LOGIC_TABLE_NAME";
 
-    private static final String TEST_ACTUAL_TABLE_NAME = "TEST_ACTUAL_TABLE_NAME";
-
     private static final String TEST_ACTUAL_TABLE_NAME_WRAPPED = "TEST_ACTUAL_TABLE_NAME_WRAPPED";
 
     private static final String TEST_OTHER_DERIVED_PROJECTION_ALIAS = "TEST_OTHER_DERIVED_PROJECTION_ALIAS";
 
     private static final String TEST_OTHER_DERIVED_PROJECTION_EXPRESSION = "TEST_OTHER_DERIVED_PROJECTION_EXPRESSION";
 
-    private RouteUnit routeUnit = mock(RouteUnit.class);
+    private RouteUnit routeUnit;
 
     @Before
     public void setup() {
         RouteMapper routeMapper = mock(RouteMapper.class);
         when(routeMapper.getLogicName()).thenReturn(TEST_LOGIC_TABLE_NAME);
-        when(routeMapper.getActualName()).thenReturn(TEST_ACTUAL_TABLE_NAME);
+        final String testActualTableName = "TEST_ACTUAL_TABLE_NAME";
+        when(routeMapper.getActualName()).thenReturn(testActualTableName);

Review comment:
       If the variable is only used once, it can be used directly.
   Refactored to ‘ when(routeMapper.getActualName()).thenReturn("TEST_ACTUAL_TABLE_NAME")’.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/RowCountTokenGeneratorTest.java
##########
@@ -0,0 +1,74 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.segment.select.pagination.PaginationContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.RowCountTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.RowCountToken;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.NumberLiteralPaginationValueSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.NumberLiteralLimitValueSegment;
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class RowCountTokenGeneratorTest {
+
+    private static final int TEST_OFFSET_SEGMENT_VALUE = 12;
+
+    private static final int TEST_ROW_COUNT_SEGMENT_VALUE = 8;

Review comment:
       Minimize the use of variables.
   The life cycle of the constant defined in the class is bound to the bytecode file.
   If `TEST_OFFSET_SEGMENT_VALUE `, `TEST_ROW_COUNT_SEGMENT_VALUE `  is only used in methods, use local variables. The life cycle of the variable is bound to the method.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingInsertValuesTokenGeneratorTest.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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.apache.shardingsphere.infra.rewrite.sql.token.pojo.generic.InsertValuesToken;
+import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.ShardingInsertValuesTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.ShardingInsertValue;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ShardingInsertValuesTokenGeneratorTest {
+
+    private static final String TEST_DATASOURCE = "testDatasource";
+
+    private static final String TEST_TABLE = "testTable";

Review comment:
       Minimize the use of variables.
   The life cycle of the constant defined in the class is bound to the bytecode file.
   If `TEST_DATASOURCE ` , `TEST_TABLE ` is only used in methods, use local variables. The life cycle of the variable is bound to the method.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ConstraintTokenGeneratorTest.java
##########
@@ -72,6 +71,6 @@ public void assertGenerateSQLTokens() {
         constraintTokenGenerator.setShardingRule(shardingRule);
         Collection<ConstraintToken> result = constraintTokenGenerator.generateSQLTokens(alterTableStatementContext);
         assertThat(result.size(), is(1));
-        assertThat(result.stream().collect(Collectors.toList()).get(0).getStartIndex(), is(TEST_START_INDEX));
+        assertThat((new LinkedList<>(result)).get(0).getStartIndex(), is(TEST_START_INDEX));

Review comment:
       Minimize the use of variables.
   The life cycle of the constant defined in the class is bound to the bytecode file.
   If `TEST_START_INDEX` is only used in methods, use local variables. The life cycle of the variable is bound to the method.




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] soulasuna commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
soulasuna commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-913317275


   > @soulasuna I will fixed these issues soon. In this pull request, there are also other code having problem like this. (for example, AggregationDistinctTokenGeneratorTest.TEST_ALIAS). Should I fixed all of them?
   
   @fwhdzh Thank you very much for your contribution. If other codes have such problems, please fix them together.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] soulasuna commented on a change in pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
soulasuna commented on a change in pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#discussion_r700808368



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/DistinctProjectionPrefixTokenGeneratorTest.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationDistinctProjection;
+import org.apache.shardingsphere.infra.binder.statement.ddl.CreateDatabaseStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.DistinctProjectionPrefixTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.DistinctProjectionPrefixToken;
+import org.junit.Test;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class DistinctProjectionPrefixTokenGeneratorTest {
+
+    private static final int TEST_START_INDEX = 1;
+
+    @Test
+    public void assertIsGenerateSQLToken() {
+        CreateDatabaseStatementContext createDatabaseStatementContext = mock(CreateDatabaseStatementContext.class);
+        DistinctProjectionPrefixTokenGenerator distinctProjectionPrefixTokenGenerator = new DistinctProjectionPrefixTokenGenerator();
+        assertFalse(distinctProjectionPrefixTokenGenerator.isGenerateSQLToken(createDatabaseStatementContext));
+        SelectStatementContext selectStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+        List<AggregationDistinctProjection> aggregationDistinctProjectionList = new LinkedList<>();
+        when(selectStatementContext.getProjectionsContext().getAggregationDistinctProjections()).thenReturn(aggregationDistinctProjectionList);
+        assertFalse(distinctProjectionPrefixTokenGenerator.isGenerateSQLToken(selectStatementContext));
+        aggregationDistinctProjectionList.add(mock(AggregationDistinctProjection.class));
+        assertTrue(distinctProjectionPrefixTokenGenerator.isGenerateSQLToken(selectStatementContext));
+    }
+
+    @Test
+    public void assertGenerateSQLToken() {
+        SelectStatementContext selectStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+        when(selectStatementContext.getProjectionsContext().getStartIndex()).thenReturn(TEST_START_INDEX);

Review comment:
       If `TEST_START_INDEX` are used in only one method, please use local variable substitution.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ConstraintTokenGeneratorTest.java
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.statement.ddl.AlterTableStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.ddl.CreateDatabaseStatementContext;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.ConstraintTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.ConstraintToken;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.constraint.ConstraintSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+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 ConstraintTokenGeneratorTest {
+
+    private static final int TEST_START_INDEX = 1;
+
+    private static final int TEST_STOP_INDEX = 3;
+
+    @Test
+    public void assertIsGenerateSQLToken() {
+        CreateDatabaseStatementContext createDatabaseStatementContext = mock(CreateDatabaseStatementContext.class);
+        ConstraintTokenGenerator constraintTokenGenerator = new ConstraintTokenGenerator();
+        assertFalse(constraintTokenGenerator.isGenerateSQLToken(createDatabaseStatementContext));
+        AlterTableStatementContext alterTableStatementContext = mock(AlterTableStatementContext.class);
+        Collection<ConstraintSegment> constraintSegmentCollection = new LinkedList<>();
+        when(alterTableStatementContext.getConstraints()).thenReturn(constraintSegmentCollection);
+        assertFalse(constraintTokenGenerator.isGenerateSQLToken(alterTableStatementContext));
+        constraintSegmentCollection.add(mock(ConstraintSegment.class));
+        assertTrue(constraintTokenGenerator.isGenerateSQLToken(alterTableStatementContext));
+    }
+
+    @Test
+    public void assertGenerateSQLTokens() {
+        ConstraintSegment constraintSegment = mock(ConstraintSegment.class);
+        when(constraintSegment.getStartIndex()).thenReturn(TEST_START_INDEX);
+        when(constraintSegment.getStopIndex()).thenReturn(TEST_STOP_INDEX);
+        IdentifierValue constraintIdentifier = mock(IdentifierValue.class);
+        when(constraintSegment.getIdentifier()).thenReturn(constraintIdentifier);
+        Collection<ConstraintSegment> constraintSegmentCollection = new LinkedList<>();
+        constraintSegmentCollection.add(constraintSegment);
+        AlterTableStatementContext alterTableStatementContext = mock(AlterTableStatementContext.class);
+        when(alterTableStatementContext.getConstraints()).thenReturn(constraintSegmentCollection);
+        ShardingRule shardingRule = mock(ShardingRule.class);
+        ConstraintTokenGenerator constraintTokenGenerator = new ConstraintTokenGenerator();
+        constraintTokenGenerator.setShardingRule(shardingRule);
+        Collection<ConstraintToken> result = constraintTokenGenerator.generateSQLTokens(alterTableStatementContext);
+        assertThat(result.size(), is(1));
+        assertThat(result.stream().collect(Collectors.toList()).get(0).getStartIndex(), is(TEST_START_INDEX));

Review comment:
       `result.stream().collect(Collectors.toList())` can be replaced with `new ArrayList()`

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ProjectionsTokenGeneratorTest.java
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.segment.select.projection.Projection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationDistinctProjection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationProjection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.DerivedProjection;
+import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.infra.route.context.RouteMapper;
+import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.ProjectionsTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.ProjectionsToken;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.OrderDirection;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ColumnOrderByItemSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ProjectionsTokenGeneratorTest {
+
+    private static final String TEST_AGGREGATION_DISTINCT_PROJECTION_DISTINCT_INNER_EXPRESSION = "TEST_AGGREGATION_DISTINCT_PROJECTION_DISTINCT_INNER_EXPRESSION";
+
+    private static final String TEST_AGGREGATION_DISTINCT_PROJECTION_ALIAS = "TEST_AGGREGATION_DISTINCT_PROJECTION_ALIAS";
+
+    private static final String TEST_DERIVED_PROJECTION_ALIAS = "TEST_DERIVED_PROJECTION_ALIAS";
+
+    private static final int TEST_STOP_INDEX = 2;
+
+    private static final String TEST_LOGIC_TABLE_NAME = "TEST_LOGIC_TABLE_NAME";
+
+    private static final String TEST_ACTUAL_TABLE_NAME = "TEST_ACTUAL_TABLE_NAME";
+
+    private static final String TEST_ACTUAL_TABLE_NAME_WRAPPED = "TEST_ACTUAL_TABLE_NAME_WRAPPED";
+
+    private static final String TEST_OTHER_DERIVED_PROJECTION_ALIAS = "TEST_OTHER_DERIVED_PROJECTION_ALIAS";
+
+    private static final String TEST_OTHER_DERIVED_PROJECTION_EXPRESSION = "TEST_OTHER_DERIVED_PROJECTION_EXPRESSION";
+
+    private RouteUnit routeUnit = mock(RouteUnit.class);
+
+    @Before
+    public void setup() {
+        RouteMapper routeMapper = mock(RouteMapper.class);
+        when(routeMapper.getLogicName()).thenReturn(TEST_LOGIC_TABLE_NAME);
+        when(routeMapper.getActualName()).thenReturn(TEST_ACTUAL_TABLE_NAME);

Review comment:
       If `TEST_ACTUAL_TABLE_NAME ` is used in only one method, please use local variable substitution.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ProjectionsTokenGeneratorTest.java
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.segment.select.projection.Projection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationDistinctProjection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationProjection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.DerivedProjection;
+import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.infra.route.context.RouteMapper;
+import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.ProjectionsTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.ProjectionsToken;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.OrderDirection;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ColumnOrderByItemSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ProjectionsTokenGeneratorTest {
+
+    private static final String TEST_AGGREGATION_DISTINCT_PROJECTION_DISTINCT_INNER_EXPRESSION = "TEST_AGGREGATION_DISTINCT_PROJECTION_DISTINCT_INNER_EXPRESSION";
+
+    private static final String TEST_AGGREGATION_DISTINCT_PROJECTION_ALIAS = "TEST_AGGREGATION_DISTINCT_PROJECTION_ALIAS";
+
+    private static final String TEST_DERIVED_PROJECTION_ALIAS = "TEST_DERIVED_PROJECTION_ALIAS";
+
+    private static final int TEST_STOP_INDEX = 2;
+
+    private static final String TEST_LOGIC_TABLE_NAME = "TEST_LOGIC_TABLE_NAME";
+
+    private static final String TEST_ACTUAL_TABLE_NAME = "TEST_ACTUAL_TABLE_NAME";
+
+    private static final String TEST_ACTUAL_TABLE_NAME_WRAPPED = "TEST_ACTUAL_TABLE_NAME_WRAPPED";
+
+    private static final String TEST_OTHER_DERIVED_PROJECTION_ALIAS = "TEST_OTHER_DERIVED_PROJECTION_ALIAS";
+
+    private static final String TEST_OTHER_DERIVED_PROJECTION_EXPRESSION = "TEST_OTHER_DERIVED_PROJECTION_EXPRESSION";
+
+    private RouteUnit routeUnit = mock(RouteUnit.class);

Review comment:
       The initialization of the `RouteUnit `object can be placed in the setup method.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/IndexTokenGeneratorTest.java
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.statement.ddl.AlterIndexStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.ddl.CreateDatabaseStatementContext;
+import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.IndexTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.IndexToken;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+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 IndexTokenGeneratorTest {
+
+    private static final int TEST_START_INDEX = 1;
+
+    private static final int TEST_STOP_INDEX = 3;
+
+    @Test
+    public void assertIsGenerateSQLToken() {
+        CreateDatabaseStatementContext createDatabaseStatementContext = mock(CreateDatabaseStatementContext.class);
+        IndexTokenGenerator indexTokenGenerator = new IndexTokenGenerator();
+        assertFalse(indexTokenGenerator.isGenerateSQLToken(createDatabaseStatementContext));
+        AlterIndexStatementContext alterIndexStatementContext = mock(AlterIndexStatementContext.class);
+        Collection<IndexSegment> indexSegmentCollection = new LinkedList<>();
+        when(alterIndexStatementContext.getIndexes()).thenReturn(indexSegmentCollection);
+        assertFalse(indexTokenGenerator.isGenerateSQLToken(alterIndexStatementContext));
+        indexSegmentCollection.add(mock(IndexSegment.class));
+        assertTrue(indexTokenGenerator.isGenerateSQLToken(alterIndexStatementContext));
+    }
+
+    @Test
+    public void assertGenerateSQLTokens() {
+        IndexSegment indexSegment = mock(IndexSegment.class);
+        when(indexSegment.getStartIndex()).thenReturn(TEST_START_INDEX);
+        when(indexSegment.getStopIndex()).thenReturn(TEST_STOP_INDEX);
+        IdentifierValue identifierValue = mock(IdentifierValue.class);
+        when(indexSegment.getIdentifier()).thenReturn(identifierValue);
+        Collection<IndexSegment> indexSegmentCollection = new LinkedList<>();
+        indexSegmentCollection.add(indexSegment);
+        AlterIndexStatementContext alterIndexStatementContext = mock(AlterIndexStatementContext.class);
+        when(alterIndexStatementContext.getIndexes()).thenReturn(indexSegmentCollection);
+        IndexTokenGenerator indexTokenGenerator = new IndexTokenGenerator();
+        ShardingRule shardingRule = mock(ShardingRule.class);
+        indexTokenGenerator.setShardingRule(shardingRule);
+        ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
+        indexTokenGenerator.setSchema(schema);
+        Collection<IndexToken> result = indexTokenGenerator.generateSQLTokens(alterIndexStatementContext);
+        assertThat(result.size(), is(1));
+        assertThat(result.stream().collect(Collectors.toList()).get(0).getStartIndex(), is(TEST_START_INDEX));

Review comment:
       `result.stream().collect(Collectors.toList())` can be replaced with `new ArrayList()`

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/IndexTokenGeneratorTest.java
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.statement.ddl.AlterIndexStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.ddl.CreateDatabaseStatementContext;
+import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.IndexTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.IndexToken;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+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 IndexTokenGeneratorTest {
+
+    private static final int TEST_START_INDEX = 1;
+
+    private static final int TEST_STOP_INDEX = 3;
+
+    @Test
+    public void assertIsGenerateSQLToken() {
+        CreateDatabaseStatementContext createDatabaseStatementContext = mock(CreateDatabaseStatementContext.class);
+        IndexTokenGenerator indexTokenGenerator = new IndexTokenGenerator();
+        assertFalse(indexTokenGenerator.isGenerateSQLToken(createDatabaseStatementContext));
+        AlterIndexStatementContext alterIndexStatementContext = mock(AlterIndexStatementContext.class);
+        Collection<IndexSegment> indexSegmentCollection = new LinkedList<>();
+        when(alterIndexStatementContext.getIndexes()).thenReturn(indexSegmentCollection);
+        assertFalse(indexTokenGenerator.isGenerateSQLToken(alterIndexStatementContext));
+        indexSegmentCollection.add(mock(IndexSegment.class));
+        assertTrue(indexTokenGenerator.isGenerateSQLToken(alterIndexStatementContext));
+    }
+
+    @Test
+    public void assertGenerateSQLTokens() {
+        IndexSegment indexSegment = mock(IndexSegment.class);
+        when(indexSegment.getStartIndex()).thenReturn(TEST_START_INDEX);
+        when(indexSegment.getStopIndex()).thenReturn(TEST_STOP_INDEX);

Review comment:
       If `TEST_START_INDEX` and `TEST_STOP_INDEX` are used in only one method, please use local variable substitution.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ProjectionsTokenGeneratorTest.java
##########
@@ -0,0 +1,165 @@
+/*
+ * 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.sharding.rewrite.token;
+
+import org.apache.shardingsphere.infra.binder.segment.select.projection.Projection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationDistinctProjection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.AggregationProjection;
+import org.apache.shardingsphere.infra.binder.segment.select.projection.impl.DerivedProjection;
+import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
+import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.infra.route.context.RouteMapper;
+import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.ProjectionsTokenGenerator;
+import org.apache.shardingsphere.sharding.rewrite.token.pojo.ProjectionsToken;
+import org.apache.shardingsphere.sql.parser.sql.common.constant.OrderDirection;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.ColumnOrderByItemSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OwnerSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public final class ProjectionsTokenGeneratorTest {
+
+    private static final String TEST_AGGREGATION_DISTINCT_PROJECTION_DISTINCT_INNER_EXPRESSION = "TEST_AGGREGATION_DISTINCT_PROJECTION_DISTINCT_INNER_EXPRESSION";
+
+    private static final String TEST_AGGREGATION_DISTINCT_PROJECTION_ALIAS = "TEST_AGGREGATION_DISTINCT_PROJECTION_ALIAS";
+
+    private static final String TEST_DERIVED_PROJECTION_ALIAS = "TEST_DERIVED_PROJECTION_ALIAS";
+
+    private static final int TEST_STOP_INDEX = 2;
+
+    private static final String TEST_LOGIC_TABLE_NAME = "TEST_LOGIC_TABLE_NAME";
+
+    private static final String TEST_ACTUAL_TABLE_NAME = "TEST_ACTUAL_TABLE_NAME";
+
+    private static final String TEST_ACTUAL_TABLE_NAME_WRAPPED = "TEST_ACTUAL_TABLE_NAME_WRAPPED";
+
+    private static final String TEST_OTHER_DERIVED_PROJECTION_ALIAS = "TEST_OTHER_DERIVED_PROJECTION_ALIAS";
+
+    private static final String TEST_OTHER_DERIVED_PROJECTION_EXPRESSION = "TEST_OTHER_DERIVED_PROJECTION_EXPRESSION";
+
+    private RouteUnit routeUnit = mock(RouteUnit.class);
+
+    @Before
+    public void setup() {
+        RouteMapper routeMapper = mock(RouteMapper.class);
+        when(routeMapper.getLogicName()).thenReturn(TEST_LOGIC_TABLE_NAME);
+        when(routeMapper.getActualName()).thenReturn(TEST_ACTUAL_TABLE_NAME);
+        Collection<RouteMapper> routeMapperCollection = new LinkedList<>();
+        routeMapperCollection.add(routeMapper);
+        when(routeUnit.getTableMappers()).thenReturn(routeMapperCollection);
+    }
+
+    @Test
+    public void assertIsGenerateSQLToken() {
+        ProjectionsTokenGenerator projectionsTokenGenerator = getProjectionsTokenGenerator();
+        InsertStatementContext insertStatementContext = mock(InsertStatementContext.class);
+        assertFalse(projectionsTokenGenerator.isGenerateSQLToken(insertStatementContext));
+        SelectStatementContext selectStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+        when(selectStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.emptyList());
+        assertFalse(projectionsTokenGenerator.isGenerateSQLToken(selectStatementContext));
+        AggregationProjection aggregationProjection = getAggregationProjection();
+        Collection<Projection> projectionCollection = new LinkedList<>();
+        projectionCollection.add(aggregationProjection);
+        when(selectStatementContext.getProjectionsContext().getProjections()).thenReturn(projectionCollection);
+        assertTrue(projectionsTokenGenerator.isGenerateSQLToken(selectStatementContext));
+    }
+
+    @Test
+    public void assertGenerateSQLToken() {
+        Collection<Projection> projectionCollection = new LinkedList<>();
+        AggregationProjection aggregationProjection = getAggregationProjection();
+        projectionCollection.add(aggregationProjection);
+        DerivedProjection derivedProjection = getDerivedProjection();
+        projectionCollection.add(derivedProjection);
+        DerivedProjection otherDerivedProjection = getOtherDerivedProjection();
+        projectionCollection.add(otherDerivedProjection);
+        SelectStatementContext selectStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+        when(selectStatementContext.getProjectionsContext().getProjections()).thenReturn(projectionCollection);
+        when(selectStatementContext.getProjectionsContext().getStopIndex()).thenReturn(TEST_STOP_INDEX);

Review comment:
       If `TEST_STOP_INDEX ` is used in only one method, please use local variable substitution.




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fwhdzh commented on pull request #12159: Issue10968

Posted by GitBox <gi...@apache.org>.
fwhdzh commented on pull request #12159:
URL: https://github.com/apache/shardingsphere/pull/12159#issuecomment-912453699


   I have added unit test of TableTokenGenerator to this pull request. It is also a task of issue 10968.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org