You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/03/03 02:55:14 UTC

[shardingsphere] branch master updated: Polish test code. (#24357)

This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 1b015b7488a Polish test code. (#24357)
1b015b7488a is described below

commit 1b015b7488a91f84a3db1659387fc89a339f67d4
Author: gongzhongqiang <76...@qq.com>
AuthorDate: Fri Mar 3 10:55:06 2023 +0800

    Polish test code. (#24357)
    
    * Polish test code.
    
    * Polish test code.
    
    ---------
    
    Co-authored-by: gongzhongqiang <go...@gigacloudtech.com>
    Co-authored-by: Liang Zhang <zh...@apache.org>
---
 .../strategy/KeyGenerateStrategySegment.java       |  2 +-
 .../segment/select/orderby/OrderByItemTest.java    |  4 ++--
 .../RowNumberPaginationContextEngineTest.java      |  2 +-
 .../infra/datanode/DataNodeTest.java               |  4 ++--
 .../datasource/props/DataSourcePropertiesTest.java |  4 ++--
 .../infra/metadata/user/GranteeTest.java           | 10 ++++----
 .../infra/util/yaml/YamlEngineTest.java            |  7 +++---
 .../transaction/utils/AutoCommitUtils.java         |  5 +---
 .../watcher/GlobalRuleChangedWatcherTest.java      |  2 +-
 .../sql/parser/mysql/MySQLFormatTest.java          | 27 +++++++++++-----------
 .../sql/parser/mysql/MySQLParameterizedTest.java   | 18 +++++++--------
 .../sql/parser/mysql/MySQLTableVisitorTest.java    | 16 ++++++-------
 .../sql/parser/mysql/MySQLXAVisitorTest.java       | 18 +++++++--------
 .../util/ColumnExtractorParameterizedTest.java     | 10 ++++----
 .../scenario/authority/AuthorityEnvironment.java   |  2 +-
 .../entity/RewriteAssertionsRootEntity.java        |  2 +-
 16 files changed, 65 insertions(+), 68 deletions(-)

diff --git a/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/strategy/KeyGenerateStrategySegment.java b/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/strategy/KeyGenerateStrategySegment.java
index e5292302ba9..04907577af2 100644
--- a/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/strategy/KeyGenerateStrategySegment.java
+++ b/features/sharding/distsql/statement/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/segment/strategy/KeyGenerateStrategySegment.java
@@ -31,7 +31,7 @@ public final class KeyGenerateStrategySegment implements ASTNode {
     
     private final String keyGenerateColumn;
     
-    private Optional<String> keyGenerateAlgorithmName;
+    private final Optional<String> keyGenerateAlgorithmName;
     
     private AlgorithmSegment keyGenerateAlgorithmSegment;
     
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/orderby/OrderByItemTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/orderby/OrderByItemTest.java
index 050c0b156b5..3420be3c2fa 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/orderby/OrderByItemTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/orderby/OrderByItemTest.java
@@ -20,13 +20,13 @@ package org.apache.shardingsphere.infra.binder.segment.select.orderby;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.item.OrderByItemSegment;
 import org.junit.Test;
 
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.mockito.Mockito.mock;
 
 public final class OrderByItemTest {
     
     @Test
     public void assertEqualsWhenObjIsNull() {
-        assertFalse(new OrderByItem(mock(OrderByItemSegment.class)).equals(null));
+        assertNotEquals(null, new OrderByItem(mock(OrderByItemSegment.class)));
     }
 }
diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
index efd02954a5d..a14b5d0d86d 100644
--- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
+++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
@@ -91,7 +91,7 @@ public final class RowNumberPaginationContextEngineTest {
         AndPredicate andPredicate = new AndPredicate();
         ColumnSegment left = new ColumnSegment(0, 10, new IdentifierValue(ROW_NUMBER_COLUMN_NAME));
         BinaryOperationExpression predicateSegment = new BinaryOperationExpression(0, 0, left, null, null, null);
-        andPredicate.getPredicates().addAll(Collections.singleton(predicateSegment));
+        andPredicate.getPredicates().add(predicateSegment);
         PaginationContext paginationContext = new RowNumberPaginationContextEngine().createPaginationContext(Collections.emptyList(), projectionsContext, Collections.emptyList());
         assertFalse(paginationContext.getOffsetSegment().isPresent());
         assertFalse(paginationContext.getRowCountSegment().isPresent());
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
index dc3108ec74f..f00069274bc 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
@@ -23,7 +23,7 @@ import org.junit.Test;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 
 public final class DataNodeTest {
     
@@ -55,7 +55,7 @@ public final class DataNodeTest {
         assertThat(dataNode, is(new DataNode("ds_0.tbl_0")));
         assertThat(dataNode, is(dataNode));
         assertThat(dataNode, not(new DataNode("ds_0.tbl_1")));
-        assertFalse(dataNode.equals(null));
+        assertNotEquals(null, dataNode);
     }
     
     @Test
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
index 9e3f232857b..20a7ea300c0 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/datasource/props/DataSourcePropertiesTest.java
@@ -31,7 +31,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
@@ -99,7 +99,7 @@ public final class DataSourcePropertiesTest {
     
     @Test
     public void assertNotEqualsWithNullValue() {
-        assertFalse(new DataSourceProperties(MockedDataSource.class.getName(), new HashMap<>()).equals(null));
+        assertNotEquals(null, new DataSourceProperties(MockedDataSource.class.getName(), new HashMap<>()));
     }
     
     @Test
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/user/GranteeTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/user/GranteeTest.java
index 0bc7cfcf055..f3a436fd76a 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/user/GranteeTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/user/GranteeTest.java
@@ -17,13 +17,13 @@
 
 package org.apache.shardingsphere.infra.metadata.user;
 
+import org.junit.Assert;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertFalse;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
 
 public final class GranteeTest {
     
@@ -46,9 +46,9 @@ public final class GranteeTest {
         Grantee grantee = new Grantee("name", "%");
         Grantee grantee1 = new Grantee("name", "");
         Grantee grantee2 = new Grantee("name", "127.0.0.1");
-        assertTrue(grantee.equals(grantee1));
-        assertTrue(grantee.equals(grantee2));
-        assertFalse(grantee.equals(new Object()));
+        Assert.assertEquals(grantee, grantee1);
+        Assert.assertEquals(grantee, grantee2);
+        assertNotEquals(grantee, new Object());
     }
     
     @Test
diff --git a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java
index 79cbad24d56..e3c1743ccf8 100644
--- a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java
+++ b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/YamlEngineTest.java
@@ -109,9 +109,8 @@ public final class YamlEngineTest {
         actual.setName("test");
         YamlShortcutsConfigurationFixture actualAnother = new YamlShortcutsConfigurationFixture();
         actualAnother.setName("test");
-        StringBuilder res = new StringBuilder("- !FIXTURE");
-        res.append(System.lineSeparator()).append("  name: test").append(System.lineSeparator()).append("- !FIXTURE")
-                .append(System.lineSeparator()).append("  name: test").append(System.lineSeparator());
-        assertThat(YamlEngine.marshal(Arrays.asList(actual, actualAnother)), is(res.toString()));
+        String res = "- !FIXTURE" + System.lineSeparator() + "  name: test" + System.lineSeparator() + "- !FIXTURE"
+                + System.lineSeparator() + "  name: test" + System.lineSeparator();
+        assertThat(YamlEngine.marshal(Arrays.asList(actual, actualAnother)), is(res));
     }
 }
diff --git a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/utils/AutoCommitUtils.java b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/utils/AutoCommitUtils.java
index 8f1975b5564..a7ef96bb918 100644
--- a/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/utils/AutoCommitUtils.java
+++ b/kernel/transaction/core/src/main/java/org/apache/shardingsphere/transaction/utils/AutoCommitUtils.java
@@ -37,9 +37,6 @@ public final class AutoCommitUtils {
         if (sqlStatement instanceof SelectStatement && null == ((SelectStatement) sqlStatement).getFrom()) {
             return false;
         }
-        if (sqlStatement instanceof DDLStatement || sqlStatement instanceof DMLStatement) {
-            return true;
-        }
-        return false;
+        return sqlStatement instanceof DDLStatement || sqlStatement instanceof DMLStatement;
     }
 }
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/GlobalRuleChangedWatcherTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/GlobalRuleChangedWatcherTest.java
index ae7476df34d..dc26abfbbc9 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/GlobalRuleChangedWatcherTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/registry/config/watcher/GlobalRuleChangedWatcherTest.java
@@ -44,7 +44,7 @@ public final class GlobalRuleChangedWatcherTest {
     }
     
     @SneakyThrows({IOException.class, URISyntaxException.class})
-    protected String readYAML() {
+    private String readYAML() {
         return Files.readAllLines(Paths.get(ClassLoader.getSystemResource("yaml/authority-rule.yaml").toURI())).stream().map(each -> each + System.lineSeparator()).collect(Collectors.joining());
     }
 }
diff --git a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java
index 7507eb39d4c..5d4d0fcfb0b 100644
--- a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java
+++ b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLFormatTest.java
@@ -43,20 +43,20 @@ import static org.hamcrest.MatcherAssert.assertThat;
 @RequiredArgsConstructor
 public final class MySQLFormatTest {
     
-    private static Collection<String[]> testUnits = new LinkedList<>();
+    private static final Collection<String[]> TEST_UNITS = new LinkedList<>();
     
     static {
-        testUnits.add(new String[]{"select_with_union", "select a+1 as b, name n from table1 join table2 where id=1 and name='lu';", "SELECT a + 1 AS b, name n\n"
+        TEST_UNITS.add(new String[]{"select_with_union", "select a+1 as b, name n from table1 join table2 where id=1 and name='lu';", "SELECT a + 1 AS b, name n\n"
                 + "FROM table1 JOIN table2\n"
                 + "WHERE \n"
                 + "\tid = 1\n"
                 + "\tand name = 'lu';"});
-        testUnits.add(new String[]{"select_item_nums", "select id, name, age, sex, ss, yy from table1 where id=1", "SELECT id , name , age , \n"
+        TEST_UNITS.add(new String[]{"select_item_nums", "select id, name, age, sex, ss, yy from table1 where id=1", "SELECT id , name , age , \n"
                 + "\tsex , ss , yy \n"
                 + "FROM table1\n"
                 + "WHERE \n"
                 + "\tid = 1;"});
-        testUnits.add(new String[]{"select_with_subquery", "select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1", "SELECT id ,"
+        TEST_UNITS.add(new String[]{"select_with_subquery", "select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1", "SELECT id ,"
                 + " name , age , \n"
                 + "\tCOUNT(*) AS n, \n"
                 + "\t(\n"
@@ -69,7 +69,7 @@ public final class MySQLFormatTest {
                 + "FROM table1\n"
                 + "WHERE \n"
                 + "\tid = 1;"});
-        testUnits.add(new String[]{"select_where_num", "select id, name, age, sex, ss, yy from table1 where id=1 and name=1 and a=1 and b=2 and c=4 and d=3", "SELECT id , name , age , \n"
+        TEST_UNITS.add(new String[]{"select_where_num", "select id, name, age, sex, ss, yy from table1 where id=1 and name=1 and a=1 and b=2 and c=4 and d=3", "SELECT id , name , age , \n"
                 + "\tsex , ss , yy \n"
                 + "FROM table1\n"
                 + "WHERE \n"
@@ -79,7 +79,7 @@ public final class MySQLFormatTest {
                 + "\tand b = 2\n"
                 + "\tand c = 4\n"
                 + "\tand d = 3;"});
-        testUnits.add(new String[]{"alter_table", "ALTER TABLE t_order ADD column4 DATE, ADD column5 DATETIME, engine ss max_rows 10,min_rows 2, ADD column6 TIMESTAMP, ADD column7 TIME;", ""
+        TEST_UNITS.add(new String[]{"alter_table", "ALTER TABLE t_order ADD column4 DATE, ADD column5 DATETIME, engine ss max_rows 10,min_rows 2, ADD column6 TIMESTAMP, ADD column7 TIME;", ""
                 + "ALTER TABLE t_order\n"
                 + "\tADD column4 DATE,\n"
                 + "\tADD column5 DATETIME,\n"
@@ -88,7 +88,7 @@ public final class MySQLFormatTest {
                 + "\tMIN_ROWS 2,\n"
                 + "\tADD column6 TIMESTAMP,\n"
                 + "\tADD column7 TIME"});
-        testUnits.add(new String[]{"create_table", "CREATE TABLE IF NOT EXISTS `runoob_tbl`(\n"
+        TEST_UNITS.add(new String[]{"create_table", "CREATE TABLE IF NOT EXISTS `runoob_tbl`(\n"
                 + "`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
                 + "`runoob_title` VARCHAR(100) NOT NULL,\n"
                 + "`runoob_author` VARCHAR(40) NOT NULL,\n"
@@ -104,28 +104,29 @@ public final class MySQLFormatTest {
                         + "\t`submission_date` DATE,\n"
                         + "\tPRIMARY KEY (`runoob_id`)\n"
                         + ") ENGINE = InnoDB DEFAULT CHARSET = utf8"});
-        testUnits.add(new String[]{"insert_with_muti_value", "INSERT INTO t_order_item(order_id, user_id, status, creation_date) values (1, 1, 'insert', '2017-08-08'), (2, 2, 'insert', '2017-08-08') "
+        TEST_UNITS.add(new String[]{"insert_with_muti_value", "INSERT INTO t_order_item(order_id, user_id, status, creation_date) values (1, 1, 'insert', '2017-08-08'), "
+                + "(2, 2, 'insert', '2017-08-08') "
                 + "ON DUPLICATE KEY UPDATE status = 'init'",
                 "INSERT  INTO t_order_item (order_id , user_id , status , creation_date)\n"
                         + "VALUES\n"
                         + "\t(1, 1, 'insert', '2017-08-08'),\n"
                         + "\t(2, 2, 'insert', '2017-08-08')\n"
                         + "ON DUPLICATE KEY UPDATE status = 'init'"});
-        testUnits.add(new String[]{"insert_with_muti_set", "INSERT INTO t_order SET order_id = 1, user_id = 1, status = convert(to_base64(aes_encrypt(1, 'key')) USING utf8) "
+        TEST_UNITS.add(new String[]{"insert_with_muti_set", "INSERT INTO t_order SET order_id = 1, user_id = 1, status = convert(to_base64(aes_encrypt(1, 'key')) USING utf8) "
                 + "ON DUPLICATE KEY UPDATE status = VALUES(status)",
                 "INSERT  INTO t_order "
                         + "SET order_id = 1,\n"
                         + "\tuser_id = 1,\n"
                         + "\tstatus = CONVERT(to_base64(aes_encrypt(1 , 'key')) USING utf8)\n"
                         + "ON DUPLICATE KEY UPDATE status = VALUES(status)"});
-        testUnits.add(new String[]{"insert_with_select", "INSERT INTO t_order (order_id, user_id, status) SELECT order_id, user_id, status FROM t_order WHERE order_id = 1", "INSERT  INTO t_order "
+        TEST_UNITS.add(new String[]{"insert_with_select", "INSERT INTO t_order (order_id, user_id, status) SELECT order_id, user_id, status FROM t_order WHERE order_id = 1", "INSERT  INTO t_order "
                 + "(order_id , user_id , status) \n"
                 + "SELECT order_id , user_id , status \n"
                 + "FROM t_order\n"
                 + "WHERE \n"
                 + "\torder_id = 1;"});
-        testUnits.add(new String[]{"only_comment", "/* c_zz_xdba_test_4 login */", ""});
-        testUnits.add(new String[]{"select_with_Variable", "SELECT @@SESSION.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, "
+        TEST_UNITS.add(new String[]{"only_comment", "/* c_zz_xdba_test_4 login */", ""});
+        TEST_UNITS.add(new String[]{"select_with_Variable", "SELECT @@SESSION.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, "
                 + "@@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, "
                 + "@@collation_server AS collation_server, @@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, "
                 + "@@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, "
@@ -149,7 +150,7 @@ public final class MySQLFormatTest {
     
     @Parameters(name = "{0}")
     public static Collection<String[]> getTestParameters() {
-        return testUnits;
+        return TEST_UNITS;
     }
     
     @Test
diff --git a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java
index 855187b0ced..4c842de75ba 100644
--- a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java
+++ b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLParameterizedTest.java
@@ -43,20 +43,20 @@ import static org.hamcrest.MatcherAssert.assertThat;
 @RequiredArgsConstructor
 public final class MySQLParameterizedTest {
     
-    private static Collection<String[]> testUnits = new LinkedList<>();
+    private static final Collection<String[]> TEST_UNITS = new LinkedList<>();
     
     static {
-        testUnits.add(new String[]{"select_with_union", "select a+1 as b, name n from table1 join table2 where id=1 and name='lu';", "SELECT a + ? AS b, name n\n"
+        TEST_UNITS.add(new String[]{"select_with_union", "select a+1 as b, name n from table1 join table2 where id=1 and name='lu';", "SELECT a + ? AS b, name n\n"
                 + "FROM table1 JOIN table2\n"
                 + "WHERE \n"
                 + "\tid = ?\n"
                 + "\tand name = ?;"});
-        testUnits.add(new String[]{"select_item_nums", "select id, name, age, sex, ss, yy from table1 where id=1", "SELECT id , name , age , \n"
+        TEST_UNITS.add(new String[]{"select_item_nums", "select id, name, age, sex, ss, yy from table1 where id=1", "SELECT id , name , age , \n"
                 + "\tsex , ss , yy \n"
                 + "FROM table1\n"
                 + "WHERE \n"
                 + "\tid = ?;"});
-        testUnits.add(new String[]{"select_with_subquery", "select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1", "SELECT id ,"
+        TEST_UNITS.add(new String[]{"select_with_subquery", "select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1", "SELECT id ,"
                 + " name , age , \n"
                 + "\tCOUNT(*) AS n, \n"
                 + "\t(\n"
@@ -69,7 +69,7 @@ public final class MySQLParameterizedTest {
                 + "FROM table1\n"
                 + "WHERE \n"
                 + "\tid = ?;"});
-        testUnits.add(new String[]{"select_where_num", "select id, name, age, sex, ss, yy from table1 where id=1 and name=1 and a=1 and b=2 and c=4 and d=3", "SELECT id , name , age , \n"
+        TEST_UNITS.add(new String[]{"select_where_num", "select id, name, age, sex, ss, yy from table1 where id=1 and name=1 and a=1 and b=2 and c=4 and d=3", "SELECT id , name , age , \n"
                 + "\tsex , ss , yy \n"
                 + "FROM table1\n"
                 + "WHERE \n"
@@ -79,7 +79,7 @@ public final class MySQLParameterizedTest {
                 + "\tand b = ?\n"
                 + "\tand c = ?\n"
                 + "\tand d = ?;"});
-        testUnits.add(new String[]{"alter_table", "ALTER TABLE t_order ADD column4 DATE, ADD column5 DATETIME, engine ss max_rows 10,min_rows 2, ADD column6 TIMESTAMP, ADD column7 TIME;", ""
+        TEST_UNITS.add(new String[]{"alter_table", "ALTER TABLE t_order ADD column4 DATE, ADD column5 DATETIME, engine ss max_rows 10,min_rows 2, ADD column6 TIMESTAMP, ADD column7 TIME;", ""
                 + "ALTER TABLE t_order\n"
                 + "\tADD column4 DATE,\n"
                 + "\tADD column5 DATETIME,\n"
@@ -88,7 +88,7 @@ public final class MySQLParameterizedTest {
                 + "\tMIN_ROWS 2,\n"
                 + "\tADD column6 TIMESTAMP,\n"
                 + "\tADD column7 TIME"});
-        testUnits.add(new String[]{"create_table", "CREATE TABLE IF NOT EXISTS `runoob_tbl`(\n"
+        TEST_UNITS.add(new String[]{"create_table", "CREATE TABLE IF NOT EXISTS `runoob_tbl`(\n"
                 + "`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
                 + "`runoob_title` VARCHAR(100) NOT NULL,\n"
                 + "`runoob_author` VARCHAR(40) NOT NULL,\n"
@@ -104,7 +104,7 @@ public final class MySQLParameterizedTest {
                         + "\t`submission_date` DATE,\n"
                         + "\tPRIMARY KEY (`runoob_id`)\n"
                         + ") ENGINE = InnoDB DEFAULT CHARSET = utf8"});
-        testUnits.add(new String[]{"select_with_column",
+        TEST_UNITS.add(new String[]{"select_with_column",
                 "select id, name, age, count(table1.id) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1",
                 "SELECT id ,"
                         + " name , age , \n"
@@ -129,7 +129,7 @@ public final class MySQLParameterizedTest {
     
     @Parameters(name = "{0}")
     public static Collection<String[]> getTestParameters() {
-        return testUnits;
+        return TEST_UNITS;
     }
     
     @Test
diff --git a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVisitorTest.java b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVisitorTest.java
index e0f87023c51..cfdff5e98cb 100644
--- a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVisitorTest.java
+++ b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLTableVisitorTest.java
@@ -43,15 +43,15 @@ import static org.hamcrest.MatcherAssert.assertThat;
 @RequiredArgsConstructor
 public final class MySQLTableVisitorTest {
     
-    private static Collection<Object[]> testUnits = new LinkedList<>();
+    private static final Collection<Object[]> TEST_UNITS = new LinkedList<>();
     
     static {
-        testUnits.add(new Object[]{"select_with_union", "select a+1 as b, name n from table1 join table2 where id=1 and name='lu';", 2, 3});
-        testUnits.add(new Object[]{"select_item_nums", "select id, name, age, sex, ss, yy from table1 where id=1", 1, 6});
-        testUnits.add(new Object[]{"select_with_subquery", "select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1", 2, 5});
-        testUnits.add(new Object[]{"select_where_num", "select id, name, age, sex, ss, yy from table1 where id=1 and name=1 and a=1 and b=2 and c=4 and d=3", 1, 10});
-        testUnits.add(new Object[]{"alter_table", "ALTER TABLE t_order ADD column4 DATE, ADD column5 DATETIME, engine ss max_rows 10,min_rows 2, ADD column6 TIMESTAMP, ADD column7 TIME;", 1, 4});
-        testUnits.add(new Object[]{"create_table", "CREATE TABLE IF NOT EXISTS `runoob_tbl`(\n"
+        TEST_UNITS.add(new Object[]{"select_with_union", "select a+1 as b, name n from table1 join table2 where id=1 and name='lu';", 2, 3});
+        TEST_UNITS.add(new Object[]{"select_item_nums", "select id, name, age, sex, ss, yy from table1 where id=1", 1, 6});
+        TEST_UNITS.add(new Object[]{"select_with_subquery", "select id, name, age, count(*) as n, (select id, name, age, sex from table2 where id=2) as sid, yyyy from table1 where id=1", 2, 5});
+        TEST_UNITS.add(new Object[]{"select_where_num", "select id, name, age, sex, ss, yy from table1 where id=1 and name=1 and a=1 and b=2 and c=4 and d=3", 1, 10});
+        TEST_UNITS.add(new Object[]{"alter_table", "ALTER TABLE t_order ADD column4 DATE, ADD column5 DATETIME, engine ss max_rows 10,min_rows 2, ADD column6 TIMESTAMP, ADD column7 TIME;", 1, 4});
+        TEST_UNITS.add(new Object[]{"create_table", "CREATE TABLE IF NOT EXISTS `runoob_tbl`(\n"
                 + "`runoob_id` INT UNSIGNED AUTO_INCREMENT,\n"
                 + "`runoob_title` VARCHAR(100) NOT NULL,\n"
                 + "`runoob_author` VARCHAR(40) NOT NULL,\n"
@@ -72,7 +72,7 @@ public final class MySQLTableVisitorTest {
     
     @Parameters(name = "{0}")
     public static Collection<Object[]> getTestParameters() {
-        return testUnits;
+        return TEST_UNITS;
     }
     
     @Test
diff --git a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLXAVisitorTest.java b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLXAVisitorTest.java
index e6645565e50..f3d0ea648ca 100644
--- a/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLXAVisitorTest.java
+++ b/sql-parser/dialect/mysql/src/test/java/org/apache/shardingsphere/sql/parser/mysql/MySQLXAVisitorTest.java
@@ -41,16 +41,16 @@ import static org.hamcrest.MatcherAssert.assertThat;
 @RequiredArgsConstructor
 public final class MySQLXAVisitorTest {
     
-    private static Collection<Object[]> testUnits = new LinkedList<>();
+    private static final Collection<Object[]> TEST_UNITS = new LinkedList<>();
     
     static {
-        testUnits.add(new Object[]{"xa_start", "XA START 0x6262,b'000',7", "START", "0x6262,b'000',7"});
-        testUnits.add(new Object[]{"xa_begin", "XA BEGIN 0x6262,b'000',7", "BEGIN", "0x6262,b'000',7"});
-        testUnits.add(new Object[]{"xa_end", "XA END 0x6262,b'000',7", "END", "0x6262,b'000',7"});
-        testUnits.add(new Object[]{"xa_prepare", "XA PREPARE 0x6262,b'000',7", "PREPARE", "0x6262,b'000',7"});
-        testUnits.add(new Object[]{"xa_commit", "XA COMMIT 0x6262,b'000',7", "COMMIT", "0x6262,b'000',7"});
-        testUnits.add(new Object[]{"xa_rollback", "XA ROLLBACK 0x6262,b'000',7", "ROLLBACK", "0x6262,b'000',7"});
-        testUnits.add(new Object[]{"xa_recover", "XA RECOVER", "RECOVER", null});
+        TEST_UNITS.add(new Object[]{"xa_start", "XA START 0x6262,b'000',7", "START", "0x6262,b'000',7"});
+        TEST_UNITS.add(new Object[]{"xa_begin", "XA BEGIN 0x6262,b'000',7", "BEGIN", "0x6262,b'000',7"});
+        TEST_UNITS.add(new Object[]{"xa_end", "XA END 0x6262,b'000',7", "END", "0x6262,b'000',7"});
+        TEST_UNITS.add(new Object[]{"xa_prepare", "XA PREPARE 0x6262,b'000',7", "PREPARE", "0x6262,b'000',7"});
+        TEST_UNITS.add(new Object[]{"xa_commit", "XA COMMIT 0x6262,b'000',7", "COMMIT", "0x6262,b'000',7"});
+        TEST_UNITS.add(new Object[]{"xa_rollback", "XA ROLLBACK 0x6262,b'000',7", "ROLLBACK", "0x6262,b'000',7"});
+        TEST_UNITS.add(new Object[]{"xa_recover", "XA RECOVER", "RECOVER", null});
     }
     
     private final String caseId;
@@ -63,7 +63,7 @@ public final class MySQLXAVisitorTest {
     
     @Parameters(name = "{0}")
     public static Collection<Object[]> getTestParameters() {
-        return testUnits;
+        return TEST_UNITS;
     }
     
     @Test
diff --git a/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java b/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java
index dbc5cab55f4..2376d4a29c4 100644
--- a/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java
+++ b/sql-parser/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java
@@ -39,21 +39,21 @@ import static org.hamcrest.MatcherAssert.assertThat;
 @RequiredArgsConstructor
 public final class ColumnExtractorParameterizedTest {
     
-    private static Collection<ExpressionSegment> testUnits = new LinkedList<>();
+    private static final Collection<ExpressionSegment> TEST_UNITS = new LinkedList<>();
     
     private static final ColumnSegment COLUMN_SEGMENT = new ColumnSegment(35, 42, new IdentifierValue("order_item_id"));
     
     static {
-        testUnits.add(new BinaryOperationExpression(0, 0, COLUMN_SEGMENT, null, null, null));
-        testUnits.add(new InExpression(0, 0, COLUMN_SEGMENT, null, false));
-        testUnits.add(new BetweenExpression(0, 0, COLUMN_SEGMENT, null, null, false));
+        TEST_UNITS.add(new BinaryOperationExpression(0, 0, COLUMN_SEGMENT, null, null, null));
+        TEST_UNITS.add(new InExpression(0, 0, COLUMN_SEGMENT, null, false));
+        TEST_UNITS.add(new BetweenExpression(0, 0, COLUMN_SEGMENT, null, null, false));
     }
     
     private final ExpressionSegment expression;
     
     @Parameters(name = "{0}")
     public static Collection<ExpressionSegment> getTestParameters() {
-        return testUnits;
+        return TEST_UNITS;
     }
     
     @Test
diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/authority/AuthorityEnvironment.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/authority/AuthorityEnvironment.java
index 958eba268a5..b0ac14f7a47 100644
--- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/authority/AuthorityEnvironment.java
+++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/runtime/scenario/authority/AuthorityEnvironment.java
@@ -31,7 +31,7 @@ import java.util.LinkedList;
 public final class AuthorityEnvironment {
     
     @XmlElement(name = "sqlset")
-    private Collection<AuthoritySQLSet> sqlSets = new LinkedList<>();
+    private final Collection<AuthoritySQLSet> sqlSets = new LinkedList<>();
     
     /**
      * Get init SQLs of this database type.
diff --git a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/entity/RewriteAssertionsRootEntity.java b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/entity/RewriteAssertionsRootEntity.java
index 27ff0d218bb..f8acec92542 100644
--- a/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/entity/RewriteAssertionsRootEntity.java
+++ b/test/it/rewriter/src/test/java/org/apache/shardingsphere/test/it/rewrite/entity/RewriteAssertionsRootEntity.java
@@ -36,5 +36,5 @@ public final class RewriteAssertionsRootEntity {
     private String yamlRule;
     
     @XmlElement(name = "rewrite-assertion")
-    private Collection<RewriteAssertionEntity> assertions = new LinkedList<>();
+    private final Collection<RewriteAssertionEntity> assertions = new LinkedList<>();
 }