You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/02 15:06:25 UTC

[shardingsphere] branch master updated: Use static import for @Parameterized.Parameters (#17274)

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

duanzhengqiang 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 de4738a5813 Use static import for @Parameterized.Parameters (#17274)
de4738a5813 is described below

commit de4738a58137aec6de9e8d7763b44c071da14d45
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon May 2 23:06:19 2022 +0800

    Use static import for @Parameterized.Parameters (#17274)
    
    * Use static import for @Parameterized.Parameters
    
    * Use static import for @Parameterized.Parameters
---
 .../bind/protocol/PostgreSQLByteConverterTest.java |  3 +-
 .../PostgreSQLNumericBinaryProtocolValueTest.java  |  3 +-
 .../cosid/CosIdIntervalShardingAlgorithmTest.java  | 45 ++++++++--------------
 .../cosid/CosIdModShardingAlgorithmTest.java       | 10 ++---
 ...osIdSnowflakeIntervalShardingAlgorithmTest.java | 25 +++++-------
 .../util/ColumnExtractorParameterizedTest.java     |  3 +-
 6 files changed, 34 insertions(+), 55 deletions(-)

diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverterTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverterTest.java
index 05520d7df0b..982ccaca262 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverterTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLByteConverterTest.java
@@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.math.BigDecimal;
 import java.util.Arrays;
@@ -36,7 +37,7 @@ public final class PostgreSQLByteConverterTest {
     
     private final byte[] expected;
     
-    @Parameterized.Parameters(name = "{0}")
+    @Parameters(name = "{0}")
     public static Iterable<Object[]> textValues() {
         return Arrays.asList(
                 new Object[]{new BigDecimal("0"), new byte[]{0, 0, -1, -1, 0, 0, 0, 0}},
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java
index d849a9c85f6..f6f21f1d8ef 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLNumericBinaryProtocolValueTest.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacket
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.math.BigDecimal;
 import java.nio.charset.StandardCharsets;
@@ -42,7 +43,7 @@ public final class PostgreSQLNumericBinaryProtocolValueTest {
     
     private final byte[] expected;
     
-    @Parameterized.Parameters(name = "{0}")
+    @Parameters(name = "{0}")
     public static Iterable<Object[]> textValues() {
         return Arrays.asList(
                 new Object[]{new BigDecimal("0"), new byte[]{0, 0, -1, -1, 0, 0, 0, 0}},
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdIntervalShardingAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdIntervalShardingAlgorithmTest.java
index 9bd18ca3809..ed0e767592f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdIntervalShardingAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdIntervalShardingAlgorithmTest.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.sharding.algorithm.sharding.cosid;
 
 import com.google.common.collect.Range;
+import lombok.RequiredArgsConstructor;
 import me.ahoo.cosid.sharding.ExactCollection;
 import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
 import org.apache.shardingsphere.sharding.algorithm.constant.CosIdAlgorithmConstants;
@@ -179,7 +180,7 @@ public final class CosIdIntervalShardingAlgorithmTest {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return preciseArgsProviderAsLocalDateTime();
         }
@@ -211,7 +212,7 @@ public final class CosIdIntervalShardingAlgorithmTest {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return rangeArgsProviderAsLocalDateTime();
         }
@@ -243,7 +244,7 @@ public final class CosIdIntervalShardingAlgorithmTest {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return preciseArgsProviderAsString();
         }
@@ -275,7 +276,7 @@ public final class CosIdIntervalShardingAlgorithmTest {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return rangeArgsProviderAsString();
         }
@@ -307,7 +308,7 @@ public final class CosIdIntervalShardingAlgorithmTest {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return preciseArgsProviderAsDate();
         }
@@ -321,25 +322,21 @@ public final class CosIdIntervalShardingAlgorithmTest {
     }
     
     @RunWith(Parameterized.class)
+    @RequiredArgsConstructor
     public static class DateRangeValueDoShardingTest {
         
-        private CosIdIntervalShardingAlgorithm shardingAlgorithm;
-        
         private final Range<Date> rangeValue;
         
         private final Collection<String> expected;
         
-        public DateRangeValueDoShardingTest(final Range<Date> rangeValue, final Collection<String> expected) {
-            this.rangeValue = rangeValue;
-            this.expected = expected;
-        }
+        private CosIdIntervalShardingAlgorithm shardingAlgorithm;
         
         @Before
         public void init() {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return rangeArgsProviderAsDate();
         }
@@ -347,31 +344,26 @@ public final class CosIdIntervalShardingAlgorithmTest {
         @Test
         public void assertDoSharding() {
             RangeShardingValue shardingValue = new RangeShardingValue<>(LOGIC_NAME, COLUMN_NAME, new DataNodeInfo(LOGIC_NAME_PREFIX, 6, '0'), rangeValue);
-            Collection<String> actual = shardingAlgorithm.doSharding(ALL_NODES, shardingValue);
-            assertThat(actual, is(expected));
+            assertThat(shardingAlgorithm.doSharding(ALL_NODES, shardingValue), is(expected));
         }
     }
     
     @RunWith(Parameterized.class)
+    @RequiredArgsConstructor
     public static class TimestampPreciseValueDoShardingTest {
         
-        private CosIdIntervalShardingAlgorithm shardingAlgorithm;
-        
         private final Long value;
         
         private final String expected;
         
-        public TimestampPreciseValueDoShardingTest(final Long value, final String expected) {
-            this.value = value;
-            this.expected = expected;
-        }
+        private CosIdIntervalShardingAlgorithm shardingAlgorithm;
         
         @Before
         public void init() {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return preciseArgsProviderAsTimestamp();
         }
@@ -379,24 +371,19 @@ public final class CosIdIntervalShardingAlgorithmTest {
         @Test
         public void assertDoSharding() {
             PreciseShardingValue shardingValue = new PreciseShardingValue<>(LOGIC_NAME, COLUMN_NAME, new DataNodeInfo(LOGIC_NAME_PREFIX, 6, '0'), value);
-            String actual = shardingAlgorithm.doSharding(ALL_NODES, shardingValue);
-            assertThat(actual, is(expected));
+            assertThat(shardingAlgorithm.doSharding(ALL_NODES, shardingValue), is(expected));
         }
     }
     
     @RunWith(Parameterized.class)
+    @RequiredArgsConstructor
     public static class TimestampRangeValueDoShardingTest {
         
-        private CosIdIntervalShardingAlgorithm shardingAlgorithm;
-        
         private final Range<Long> rangeValue;
         
         private final Collection<String> expected;
         
-        public TimestampRangeValueDoShardingTest(final Range<Long> rangeValue, final Collection<String> expected) {
-            this.rangeValue = rangeValue;
-            this.expected = expected;
-        }
+        private CosIdIntervalShardingAlgorithm shardingAlgorithm;
         
         @Before
         public void init() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdModShardingAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdModShardingAlgorithmTest.java
index 4c7afaa4d81..da98d6b314c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdModShardingAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdModShardingAlgorithmTest.java
@@ -71,7 +71,7 @@ public final class CosIdModShardingAlgorithmTest {
             shardingAlgorithm = createShardingAlgorithm();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Number[] argsProvider() {
             return Arguments.of(1L, 2L, 3L, 4L, 5L, 6L);
         }
@@ -86,18 +86,14 @@ public final class CosIdModShardingAlgorithmTest {
     }
     
     @RunWith(Parameterized.class)
+    @RequiredArgsConstructor
     public static class RangeValueDoShardingTest {
         
-        private CosIdModShardingAlgorithm<Long> shardingAlgorithm;
-        
         private final Range<Long> rangeValue;
         
         private final Collection<String> expected;
         
-        public RangeValueDoShardingTest(final Range<Long> rangeValue, final Collection<String> expected) {
-            this.rangeValue = rangeValue;
-            this.expected = expected;
-        }
+        private CosIdModShardingAlgorithm<Long> shardingAlgorithm;
         
         @Before
         public void init() {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdSnowflakeIntervalShardingAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdSnowflakeIntervalShardingAlgorithmTest.java
index fac9d442393..915182172a6 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdSnowflakeIntervalShardingAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/cosid/CosIdSnowflakeIntervalShardingAlgorithmTest.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.sharding.algorithm.sharding.cosid;
 
 import com.google.common.collect.Range;
+import lombok.RequiredArgsConstructor;
 import me.ahoo.cosid.snowflake.MillisecondSnowflakeId;
 import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
 import org.apache.shardingsphere.sharding.algorithm.constant.CosIdAlgorithmConstants;
@@ -28,6 +29,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.time.LocalDateTime;
 import java.util.Collection;
@@ -70,25 +72,21 @@ public final class CosIdSnowflakeIntervalShardingAlgorithmTest {
     }
     
     @RunWith(Parameterized.class)
+    @RequiredArgsConstructor
     public static class SnowflakeIdPreciseValueDoShardingTest {
         
-        private CosIdSnowflakeIntervalShardingAlgorithm shardingAlgorithm;
-        
         private final Long snowflakeId;
         
         private final String expected;
         
-        public SnowflakeIdPreciseValueDoShardingTest(final Long snowflakeId, final String expected) {
-            this.snowflakeId = snowflakeId;
-            this.expected = expected;
-        }
+        private CosIdSnowflakeIntervalShardingAlgorithm shardingAlgorithm;
         
         @Before
         public void init() {
             shardingAlgorithm = createShardingAlg();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return preciseArgsProviderAsSnowflakeId();
         }
@@ -103,25 +101,21 @@ public final class CosIdSnowflakeIntervalShardingAlgorithmTest {
     }
     
     @RunWith(Parameterized.class)
+    @RequiredArgsConstructor
     public static class SnowflakeIdRangeValueDoShardingTest {
         
-        private CosIdSnowflakeIntervalShardingAlgorithm shardingAlgorithm;
-        
         private final Range<Long> rangeValue;
         
         private final Collection<String> expected;
         
-        public SnowflakeIdRangeValueDoShardingTest(final Range<Long> rangeValue, final Collection<String> expected) {
-            this.rangeValue = rangeValue;
-            this.expected = expected;
-        }
+        private CosIdSnowflakeIntervalShardingAlgorithm shardingAlgorithm;
         
         @Before
         public void init() {
             shardingAlgorithm = createShardingAlg();
         }
         
-        @Parameterized.Parameters
+        @Parameters
         public static Iterable<Object[]> argsProvider() {
             return rangeArgsProviderAsSnowflakeId();
         }
@@ -130,8 +124,7 @@ public final class CosIdSnowflakeIntervalShardingAlgorithmTest {
         public void assertDoSharding() {
             RangeShardingValue shardingValue = new RangeShardingValue<>(CosIdIntervalShardingAlgorithmTest.LOGIC_NAME,
                     CosIdIntervalShardingAlgorithmTest.COLUMN_NAME, new DataNodeInfo(CosIdIntervalShardingAlgorithmTest.LOGIC_NAME_PREFIX, 6, '0'), rangeValue);
-            Collection<String> actual = shardingAlgorithm.doSharding(CosIdIntervalShardingAlgorithmTest.ALL_NODES, shardingValue);
-            assertThat(actual, is(expected));
+            assertThat(shardingAlgorithm.doSharding(CosIdIntervalShardingAlgorithmTest.ALL_NODES, shardingValue), is(expected));
         }
     }
 }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java
index 98bd7bd6ef7..ae8ded6a2e1 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorParameterizedTest.java
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.Identifi
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -50,7 +51,7 @@ public final class ColumnExtractorParameterizedTest {
     
     private final ExpressionSegment expression;
     
-    @Parameterized.Parameters(name = "{0}")
+    @Parameters(name = "{0}")
     public static Collection<ExpressionSegment> getTestParameters() {
         return testUnits;
     }