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 edfa978c0c7 Use Collections.singleton to instead of
Collections.singletonList (#28278)
edfa978c0c7 is described below
commit edfa978c0c7e1f5b9041d4ec39f6ecba1a21a20a
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 28 00:19:01 2023 +0800
Use Collections.singleton to instead of Collections.singletonList (#28278)
* Refactor NacosRepository
* Use Collections.singleton to instead of Collections.singletonList
* Use Collections.singleton to instead of Collections.singletonList
---
.../command/query/PostgreSQLDataRowPacketTest.java | 16 ++++-----
.../query/PostgreSQLRowDescriptionPacketTest.java | 2 +-
.../EncryptIndexColumnTokenGenerator.java | 2 +-
.../EncryptPredicateColumnTokenGenerator.java | 2 +-
.../EncryptRuleConfigurationCheckerTest.java | 16 ++++-----
...ecoratedEncryptShowColumnsMergedResultTest.java | 2 +-
...atedEncryptShowCreateTableMergedResultTest.java | 6 ++--
.../MergedEncryptShowColumnsMergedResultTest.java | 2 +-
...rgedEncryptShowCreateTableMergedResultTest.java | 6 ++--
.../EncryptParameterRewriterBuilderTest.java | 4 +--
.../EncryptPredicateEqualRightValueTokenTest.java | 2 +-
.../EncryptPredicateInRightValueTokenTest.java | 2 +-
.../token/EncryptTokenGenerateBuilderTest.java | 4 +--
.../EncryptCreateTableTokenGeneratorTest.java | 2 +-
.../EncryptProjectionTokenGeneratorTest.java | 12 +++----
.../rule/builder/EncryptRuleBuilderTest.java | 2 +-
...patibleEncryptRuleConfigurationSwapperTest.java | 2 +-
.../YamlEncryptRuleConfigurationSwapperTest.java | 2 +-
.../mask/merge/dql/MaskAlgorithmMetaDataTest.java | 2 +-
.../YamlMaskRuleConfigurationSwapperTest.java | 2 +-
...writeSplittingRuleConfigurationCheckerTest.java | 5 +--
.../route/ReadwriteSplittingSQLRouterTest.java | 2 +-
.../builder/ReadwriteSplittingRuleBuilderTest.java | 6 ++--
...writeSplittingRuleConfigurationSwapperTest.java | 2 +-
.../HintShadowAlgorithmDeterminerTest.java | 2 +-
.../ShadowNonDMLStatementRoutingEngineTest.java | 4 +--
.../shardingsphere/shadow/rule/ShadowRuleTest.java | 4 +--
.../distsql/query/ShowShadowRuleExecutorTest.java | 4 +--
.../AlterShadowRuleStatementUpdaterTest.java | 8 ++---
.../CreateShadowRuleStatementUpdaterTest.java | 6 ++--
.../ShardingStandardRoutingEngineTest.java | 12 +++----
.../standard/assertion/ShardingRouteAssert.java | 2 +-
.../unicast/ShardingUnicastRoutingEngineTest.java | 2 +-
.../ShardingDropTableStatementValidatorTest.java | 10 +++---
.../sharding/rule/ShardingRuleTest.java | 4 +--
.../checker/ShardingRuleStatementCheckerTest.java | 38 +++++++++++-----------
.../query/CountShardingRuleExecutorTest.java | 2 +-
...dingTableReferenceRuleStatementUpdaterTest.java | 2 +-
...AlterShardingTableRuleStatementUpdaterTest.java | 2 +-
...reateShardingTableRuleStatementUpdaterTest.java | 4 +--
.../DropShardingAuditorStatementUpdaterTest.java | 4 +--
...opShardingKeyGeneratorStatementUpdaterTest.java | 2 +-
.../batch/BatchPreparedStatementExecutorTest.java | 8 ++---
.../ShardingSphereDatabaseMetaDataTest.java | 4 +--
.../repository/cluster/nacos/NacosRepository.java | 5 ++-
.../standalone/StandaloneModeContextManager.java | 2 +-
.../type/OpenGaussDDLStatementVisitor.java | 4 +--
.../type/PostgreSQLDDLStatementVisitor.java | 4 +--
.../statement/type/SQL92DDLStatementVisitor.java | 3 +-
.../sql/common/util/ExpressionExtractUtils.java | 6 ++--
.../sql/common/util/ColumnExtractorTest.java | 2 +-
.../common/util/ExpressionExtractUtilsTest.java | 6 ++--
.../ral/updatable/RefreshTableMetaDataUpdater.java | 2 +-
53 files changed, 130 insertions(+), 133 deletions(-)
diff --git
a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
index b03f99b72c2..012a0ddf475 100644
---
a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
+++
b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLDataRowPacketTest.java
@@ -59,14 +59,14 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteWithNull() {
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList(null));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(null));
actual.write(payload);
verify(payload).writeInt4(0xFFFFFFFF);
}
@Test
void assertWriteWithBytes() {
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList(new byte[]{'a'}));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(new byte[]{'a'}));
actual.write(payload);
verify(payload).writeInt4(new byte[]{'a'}.length);
verify(payload).writeBytes(new byte[]{'a'});
@@ -75,7 +75,7 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteWithSQLXML() throws SQLException {
when(sqlxml.getString()).thenReturn("value");
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList(sqlxml));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(sqlxml));
actual.write(payload);
byte[] valueBytes = "value".getBytes(StandardCharsets.UTF_8);
verify(payload).writeInt4(valueBytes.length);
@@ -84,8 +84,8 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteWithString() {
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList("value"));
- assertThat(actual.getData(), is(Collections.singletonList("value")));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton("value"));
+ assertThat(actual.getData(), is(Collections.singleton("value")));
actual.write(payload);
byte[] valueBytes = "value".getBytes(StandardCharsets.UTF_8);
verify(payload).writeInt4(valueBytes.length);
@@ -95,14 +95,14 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteWithSQLXML4Error() throws SQLException {
when(sqlxml.getString()).thenThrow(new SQLException("mock"));
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList(sqlxml));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(sqlxml));
assertThrows(RuntimeException.class, () -> actual.write(payload));
verify(payload, times(0)).writeStringEOF(any());
}
@Test
void assertWriteBinaryNull() {
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList(new
BinaryCell(PostgreSQLColumnType.INT4, null)));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(new
BinaryCell(PostgreSQLColumnType.INT4, null)));
actual.write(payload);
verify(payload).writeInt2(1);
verify(payload).writeInt4(0xFFFFFFFF);
@@ -111,7 +111,7 @@ class PostgreSQLDataRowPacketTest {
@Test
void assertWriteBinaryInt4() {
final int value = 12345678;
- PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singletonList(new
BinaryCell(PostgreSQLColumnType.INT4, value)));
+ PostgreSQLDataRowPacket actual = new
PostgreSQLDataRowPacket(Collections.singleton(new
BinaryCell(PostgreSQLColumnType.INT4, value)));
actual.write(payload);
verify(payload).writeInt2(1);
verify(payload).writeInt4(4);
diff --git
a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLRowDescriptionPacketTest.java
b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLRowDescriptionPacketTest.java
index e11ce624ac0..85647e81864 100644
---
a/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLRowDescriptionPacketTest.java
+++
b/db-protocol/postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/PostgreSQLRowDescriptionPacketTest.java
@@ -41,7 +41,7 @@ class PostgreSQLRowDescriptionPacketTest {
@Test
void assertWrite() {
PostgreSQLColumnDescription description = new
PostgreSQLColumnDescription("name", 1, Types.VARCHAR, 4, null);
- PostgreSQLRowDescriptionPacket packet = new
PostgreSQLRowDescriptionPacket(Collections.singletonList(description));
+ PostgreSQLRowDescriptionPacket packet = new
PostgreSQLRowDescriptionPacket(Collections.singleton(description));
packet.write(payload);
verify(payload, times(2)).writeInt2(1);
verify(payload).writeStringNul("name");
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
index 8a3219cbfed..05c23e2b20b 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptIndexColumnTokenGenerator.java
@@ -89,6 +89,6 @@ public final class EncryptIndexColumnTokenGenerator
implements CollectionSQLToke
}
private Collection<Projection> getColumnProjections(final String
columnName, final QuoteCharacter quoteCharacter) {
- return Collections.singletonList(new ColumnProjection(null, new
IdentifierValue(columnName, quoteCharacter), null, databaseType));
+ return Collections.singleton(new ColumnProjection(null, new
IdentifierValue(columnName, quoteCharacter), null, databaseType));
}
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
index dcedd90a791..0d8f6e7653b 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateColumnTokenGenerator.java
@@ -142,6 +142,6 @@ public final class EncryptPredicateColumnTokenGenerator
implements CollectionSQL
}
private Collection<Projection> createColumnProjections(final String
columnName, final QuoteCharacter quoteCharacter) {
- return Collections.singletonList(new ColumnProjection(null, new
IdentifierValue(columnName, quoteCharacter), null, databaseType));
+ return Collections.singleton(new ColumnProjection(null, new
IdentifierValue(columnName, quoteCharacter), null, databaseType));
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
index 8168f8848ce..170d57dcfb5 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
@@ -48,8 +48,8 @@ class EncryptRuleConfigurationCheckerTest {
EncryptRuleConfiguration result = mock(EncryptRuleConfiguration.class);
when(result.getEncryptors()).thenReturn(Collections.singletonMap("aes_encryptor",
mock(AlgorithmConfiguration.class)));
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_cipher", "aes_encryptor"));
- Collection<EncryptColumnRuleConfiguration> columns =
Collections.singletonList(columnRuleConfig);
- when(result.getTables()).thenReturn(Collections.singletonList(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
+ Collection<EncryptColumnRuleConfiguration> columns =
Collections.singleton(columnRuleConfig);
+ when(result.getTables()).thenReturn(Collections.singleton(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
return result;
}
@@ -65,8 +65,8 @@ class EncryptRuleConfigurationCheckerTest {
EncryptRuleConfiguration result = mock(EncryptRuleConfiguration.class);
when(result.getEncryptors()).thenReturn(Collections.emptyMap());
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_cipher", "aes_encryptor"));
- Collection<EncryptColumnRuleConfiguration> columns =
Collections.singletonList(columnRuleConfig);
- when(result.getTables()).thenReturn(Collections.singletonList(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
+ Collection<EncryptColumnRuleConfiguration> columns =
Collections.singleton(columnRuleConfig);
+ when(result.getTables()).thenReturn(Collections.singleton(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
return result;
}
@@ -82,9 +82,9 @@ class EncryptRuleConfigurationCheckerTest {
EncryptRuleConfiguration result = mock(EncryptRuleConfiguration.class);
when(result.getEncryptors()).thenReturn(Collections.emptyMap());
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_cipher", "aes_encryptor"));
- Collection<EncryptColumnRuleConfiguration> columns =
Collections.singletonList(columnRuleConfig);
+ Collection<EncryptColumnRuleConfiguration> columns =
Collections.singleton(columnRuleConfig);
columnRuleConfig.setAssistedQuery(new
EncryptColumnItemRuleConfiguration("user_assisted", "aes_assisted_encryptor"));
- when(result.getTables()).thenReturn(Collections.singletonList(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
+ when(result.getTables()).thenReturn(Collections.singleton(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
return result;
}
@@ -100,9 +100,9 @@ class EncryptRuleConfigurationCheckerTest {
EncryptRuleConfiguration result = mock(EncryptRuleConfiguration.class);
when(result.getEncryptors()).thenReturn(Collections.emptyMap());
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_cipher", "aes_encryptor"));
- Collection<EncryptColumnRuleConfiguration> columns =
Collections.singletonList(columnRuleConfig);
+ Collection<EncryptColumnRuleConfiguration> columns =
Collections.singleton(columnRuleConfig);
columnRuleConfig.setLikeQuery(new
EncryptColumnItemRuleConfiguration("user_like", "like_cn_encryptor"));
- when(result.getTables()).thenReturn(Collections.singletonList(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
+ when(result.getTables()).thenReturn(Collections.singleton(new
EncryptTableRuleConfiguration("t_encrypt", columns)));
return result;
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResultTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResultTest.java
index 3bf8ebb1451..03df83117bb 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResultTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResultTest.java
@@ -135,7 +135,7 @@ class DecoratedEncryptShowColumnsMergedResultTest {
private DecoratedEncryptShowColumnsMergedResult
createDecoratedEncryptShowColumnsMergedResult(final MergedResult mergedResult,
final EncryptRule encryptRule) {
ShowColumnsStatementContext showColumnsStatementContext =
mock(ShowColumnsStatementContext.class);
-
when(showColumnsStatementContext.getAllTables()).thenReturn(Collections.singletonList(new
SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt")))));
+
when(showColumnsStatementContext.getAllTables()).thenReturn(Collections.singleton(new
SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt")))));
return new DecoratedEncryptShowColumnsMergedResult(mergedResult,
showColumnsStatementContext, encryptRule);
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowCreateTableMergedResultTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowCreateTableMergedResultTest.java
index 32a1849f9d4..52b3075670a 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowCreateTableMergedResultTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowCreateTableMergedResultTest.java
@@ -72,7 +72,7 @@ class DecoratedEncryptShowCreateTableMergedResultTest {
+ "`user_id_assisted` VARCHAR(100) NOT NULL,
`order_id` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT
CHARSET=utf8mb4;");
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_id_cipher", "foo_encryptor"));
columnRuleConfig.setAssistedQuery(new
EncryptColumnItemRuleConfiguration("user_id_assisted",
"foo_assist_query_encryptor"));
- DecoratedEncryptShowCreateTableMergedResult actual =
createDecoratedEncryptShowCreateTableMergedResult(mergedResult,
mockEncryptRule(Collections.singletonList(columnRuleConfig)));
+ DecoratedEncryptShowCreateTableMergedResult actual =
createDecoratedEncryptShowCreateTableMergedResult(mergedResult,
mockEncryptRule(Collections.singleton(columnRuleConfig)));
assertTrue(actual.next());
assertThat(actual.getValue(2, String.class),
is("CREATE TABLE `t_encrypt` (`id` INT NOT NULL, `user_id`
VARCHAR(100) NOT NULL, `order_id` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"));
@@ -86,7 +86,7 @@ class DecoratedEncryptShowCreateTableMergedResultTest {
+ "`user_id_like` VARCHAR(100) NOT NULL, `order_id`
VARCHAR(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT
CHARSET=utf8mb4;");
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_id_cipher", "foo_encryptor"));
columnRuleConfig.setLikeQuery(new
EncryptColumnItemRuleConfiguration("user_id_like", "foo_like_encryptor"));
- DecoratedEncryptShowCreateTableMergedResult actual =
createDecoratedEncryptShowCreateTableMergedResult(mergedResult,
mockEncryptRule(Collections.singletonList(columnRuleConfig)));
+ DecoratedEncryptShowCreateTableMergedResult actual =
createDecoratedEncryptShowCreateTableMergedResult(mergedResult,
mockEncryptRule(Collections.singleton(columnRuleConfig)));
assertTrue(actual.next());
assertThat(actual.getValue(2, String.class),
is("CREATE TABLE `t_encrypt` (`id` INT NOT NULL, `user_id`
VARCHAR(100) NOT NULL, `order_id` VARCHAR(30) NOT NULL,"
@@ -129,7 +129,7 @@ class DecoratedEncryptShowCreateTableMergedResultTest {
IdentifierValue identifierValue = new IdentifierValue("t_encrypt");
TableNameSegment tableNameSegment = new TableNameSegment(1, 4,
identifierValue);
SimpleTableSegment simpleTableSegment = new
SimpleTableSegment(tableNameSegment);
-
when(sqlStatementContext.getAllTables()).thenReturn(Collections.singletonList(simpleTableSegment));
+
when(sqlStatementContext.getAllTables()).thenReturn(Collections.singleton(simpleTableSegment));
when(sqlStatementContext.getDatabaseType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"MySQL"));
return new DecoratedEncryptShowCreateTableMergedResult(mergedResult,
sqlStatementContext, encryptRule);
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowColumnsMergedResultTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowColumnsMergedResultTest.java
index e1c746a8538..dd71bc219a9 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowColumnsMergedResultTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowColumnsMergedResultTest.java
@@ -135,7 +135,7 @@ class MergedEncryptShowColumnsMergedResultTest {
private MergedEncryptShowColumnsMergedResult
createMergedEncryptColumnsMergedResult(final QueryResult queryResult, final
EncryptRule encryptRule) {
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class);
-
when(sqlStatementContext.getAllTables()).thenReturn(Collections.singletonList(new
SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt")))));
+
when(sqlStatementContext.getAllTables()).thenReturn(Collections.singleton(new
SimpleTableSegment(new TableNameSegment(0, 0, new
IdentifierValue("t_encrypt")))));
return new MergedEncryptShowColumnsMergedResult(queryResult,
sqlStatementContext, encryptRule);
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowCreateTableMergedResultTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowCreateTableMergedResultTest.java
index d4c7809b355..3d16057d715 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowCreateTableMergedResultTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/MergedEncryptShowCreateTableMergedResultTest.java
@@ -71,7 +71,7 @@ class MergedEncryptShowCreateTableMergedResultTest {
+ "`user_id_assisted` VARCHAR(100) NOT NULL,
`order_id` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT
CHARSET=utf8mb4;");
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_id_cipher", "foo_encryptor"));
columnRuleConfig.setAssistedQuery(new
EncryptColumnItemRuleConfiguration("user_id_assisted",
"foo_assist_query_encryptor"));
- MergedEncryptShowCreateTableMergedResult actual =
createMergedEncryptShowCreateTableMergedResult(queryResult,
mockEncryptRule(Collections.singletonList(columnRuleConfig)));
+ MergedEncryptShowCreateTableMergedResult actual =
createMergedEncryptShowCreateTableMergedResult(queryResult,
mockEncryptRule(Collections.singleton(columnRuleConfig)));
assertTrue(actual.next());
assertThat(actual.getValue(2, String.class),
is("CREATE TABLE `t_encrypt` (`id` INT NOT NULL, `user_id`
VARCHAR(100) NOT NULL, `order_id` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"));
@@ -85,7 +85,7 @@ class MergedEncryptShowCreateTableMergedResultTest {
+ "`user_id_like` VARCHAR(100) NOT NULL, `order_id`
VARCHAR(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT
CHARSET=utf8mb4;");
EncryptColumnRuleConfiguration columnRuleConfig = new
EncryptColumnRuleConfiguration("user_id", new
EncryptColumnItemRuleConfiguration("user_id_cipher", "foo_encryptor"));
columnRuleConfig.setLikeQuery(new
EncryptColumnItemRuleConfiguration("user_id_like", "foo_like_encryptor"));
- MergedEncryptShowCreateTableMergedResult actual =
createMergedEncryptShowCreateTableMergedResult(queryResult,
mockEncryptRule(Collections.singletonList(columnRuleConfig)));
+ MergedEncryptShowCreateTableMergedResult actual =
createMergedEncryptShowCreateTableMergedResult(queryResult,
mockEncryptRule(Collections.singleton(columnRuleConfig)));
assertTrue(actual.next());
assertThat(actual.getValue(2, String.class),
is("CREATE TABLE `t_encrypt` (`id` INT NOT NULL, `user_id`
VARCHAR(100) NOT NULL, `order_id` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"));
@@ -108,7 +108,7 @@ class MergedEncryptShowCreateTableMergedResultTest {
IdentifierValue identifierValue = new IdentifierValue("t_encrypt");
TableNameSegment tableNameSegment = new TableNameSegment(1, 4,
identifierValue);
SimpleTableSegment simpleTableSegment = new
SimpleTableSegment(tableNameSegment);
-
when(sqlStatementContext.getAllTables()).thenReturn(Collections.singletonList(simpleTableSegment));
+
when(sqlStatementContext.getAllTables()).thenReturn(Collections.singleton(simpleTableSegment));
when(sqlStatementContext.getDatabaseType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"MySQL"));
return new MergedEncryptShowCreateTableMergedResult(queryResult,
sqlStatementContext, encryptRule);
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
index 69001363c49..ead6110bab7 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
@@ -44,7 +44,7 @@ class EncryptParameterRewriterBuilderTest {
EncryptRule encryptRule = mock(EncryptRule.class, RETURNS_DEEP_STUBS);
when(encryptRule.findEncryptTable("t_order").isPresent()).thenReturn(true);
SQLStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_order"));
Collection<ParameterRewriter> actual = new
EncryptParameterRewriterBuilder(
encryptRule, DefaultDatabase.LOGIC_NAME,
Collections.singletonMap("test", mock(ShardingSphereSchema.class)),
sqlStatementContext, Collections.emptyList()).getParameterRewriters();
assertThat(actual.size(), is(1));
@@ -55,7 +55,7 @@ class EncryptParameterRewriterBuilderTest {
void assertGetParameterRewritersWhenPredicateIsNotNeedRewrite() {
EncryptRule encryptRule = mock(EncryptRule.class, RETURNS_DEEP_STUBS);
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_order"));
when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.emptyList());
assertTrue(new EncryptParameterRewriterBuilder(encryptRule,
DefaultDatabase.LOGIC_NAME, Collections.singletonMap("test",
mock(ShardingSphereSchema.class)), sqlStatementContext,
Collections.emptyList()).getParameterRewriters().isEmpty());
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateEqualRightValueTokenTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateEqualRightValueTokenTest.java
index 9436de9412c..d5167977753 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateEqualRightValueTokenTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateEqualRightValueTokenTest.java
@@ -39,7 +39,7 @@ class EncryptPredicateEqualRightValueTokenTest {
@Test
void assertToStringWithPlaceholderWithoutTableOwnerWithEqual() {
- EncryptPredicateEqualRightValueToken actual = new
EncryptPredicateEqualRightValueToken(0, 0, Collections.emptyMap(),
Collections.singletonList(0));
+ EncryptPredicateEqualRightValueToken actual = new
EncryptPredicateEqualRightValueToken(0, 0, Collections.emptyMap(),
Collections.singleton(0));
assertThat(actual.toString(), is("?"));
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateInRightValueTokenTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateInRightValueTokenTest.java
index 3d69de125fd..77f6205d94f 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateInRightValueTokenTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/pojo/EncryptPredicateInRightValueTokenTest.java
@@ -40,7 +40,7 @@ class EncryptPredicateInRightValueTokenTest {
@Test
void assertToStringWithPlaceholderWithoutTableOwnerWithIn() {
- EncryptPredicateInRightValueToken actual = new
EncryptPredicateInRightValueToken(0, 0, Collections.emptyMap(),
Collections.singletonList(0));
+ EncryptPredicateInRightValueToken actual = new
EncryptPredicateInRightValueToken(0, 0, Collections.emptyMap(),
Collections.singleton(0));
assertThat(actual.toString(), is("(?)"));
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
index b8313c24810..6b7430269ae 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
@@ -55,8 +55,8 @@ class EncryptTokenGenerateBuilderTest {
void assertGetSQLTokenGenerators() {
SelectStatementContext selectStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(selectStatementContext.getAllTables().isEmpty()).thenReturn(false);
-
when(selectStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("table"));
-
when(selectStatementContext.getOrderByContext().getItems()).thenReturn(Collections.singletonList(mock(OrderByItem.class)));
+
when(selectStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("table"));
+
when(selectStatementContext.getOrderByContext().getItems()).thenReturn(Collections.singleton(mock(OrderByItem.class)));
when(selectStatementContext.getGroupByContext().getItems()).thenReturn(Collections.emptyList());
when(selectStatementContext.getWhereSegments()).thenReturn(Collections.emptyList());
EncryptTokenGenerateBuilder encryptTokenGenerateBuilder = new
EncryptTokenGenerateBuilder(encryptRule, selectStatementContext,
Collections.emptyList(), DefaultDatabase.LOGIC_NAME);
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGeneratorTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGeneratorTest.java
index 60b83bf41d9..c1110657335 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGeneratorTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptCreateTableTokenGeneratorTest.java
@@ -103,7 +103,7 @@ class EncryptCreateTableTokenGeneratorTest {
CreateTableStatementContext result =
mock(CreateTableStatementContext.class, RETURNS_DEEP_STUBS);
when(result.getSqlStatement().getTable().getTableName().getIdentifier().getValue()).thenReturn("t_encrypt");
ColumnDefinitionSegment segment = new ColumnDefinitionSegment(25, 78,
new ColumnSegment(25, 42, new IdentifierValue("certificate_number")), new
DataTypeSegment(), false, false);
-
when(result.getSqlStatement().getColumnDefinitions()).thenReturn(Collections.singletonList(segment));
+
when(result.getSqlStatement().getColumnDefinitions()).thenReturn(Collections.singleton(segment));
return result;
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
index 712e5fffcee..346af625002 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptProjectionTokenGeneratorTest.java
@@ -88,7 +88,7 @@ class EncryptProjectionTokenGeneratorTest {
new IdentifierValue("mobile")));
column.setOwner(new OwnerSegment(0, 0, new IdentifierValue("a")));
ProjectionsSegment projections = mock(ProjectionsSegment.class);
-
when(projections.getProjections()).thenReturn(Collections.singletonList(new
ColumnProjectionSegment(column)));
+
when(projections.getProjections()).thenReturn(Collections.singleton(new
ColumnProjectionSegment(column)));
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getSubqueryType()).thenReturn(null);
when(sqlStatementContext.getDatabaseType()).thenReturn(databaseType);
@@ -96,7 +96,7 @@ class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment doctorOneTable = new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("doctor1")));
when(sqlStatementContext.getTablesContext()).thenReturn(new
TablesContext(Arrays.asList(doctorTable, doctorOneTable), databaseType));
-
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
ColumnProjection("a", "mobile", null, databaseType)));
+
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singleton(new
ColumnProjection("a", "mobile", null, databaseType)));
Collection<SQLToken> actual =
generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
}
@@ -110,7 +110,7 @@ class EncryptProjectionTokenGeneratorTest {
new IdentifierValue("mobile")));
column.setOwner(new OwnerSegment(0, 0, new IdentifierValue("a")));
ProjectionsSegment projections = mock(ProjectionsSegment.class);
-
when(projections.getProjections()).thenReturn(Collections.singletonList(new
ColumnProjectionSegment(column)));
+
when(projections.getProjections()).thenReturn(Collections.singleton(new
ColumnProjectionSegment(column)));
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getSubqueryType()).thenReturn(null);
when(sqlStatementContext.getDatabaseType()).thenReturn(databaseType);
@@ -118,7 +118,7 @@ class EncryptProjectionTokenGeneratorTest {
when(sqlStatementContext.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
SimpleTableSegment sameDoctorTable = new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("doctor")));
when(sqlStatementContext.getTablesContext()).thenReturn(new
TablesContext(Arrays.asList(doctorTable, sameDoctorTable), databaseType));
-
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
ColumnProjection("a", "mobile", null, databaseType)));
+
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singleton(new
ColumnProjection("a", "mobile", null, databaseType)));
Collection<SQLToken> actual =
generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
}
@@ -128,7 +128,7 @@ class EncryptProjectionTokenGeneratorTest {
ColumnSegment column = new ColumnSegment(0, 0, new
IdentifierValue("mobile"));
column.setOwner(new OwnerSegment(0, 0, new IdentifierValue("doctor")));
ProjectionsSegment projections = mock(ProjectionsSegment.class);
-
when(projections.getProjections()).thenReturn(Collections.singletonList(new
ColumnProjectionSegment(column)));
+
when(projections.getProjections()).thenReturn(Collections.singleton(new
ColumnProjectionSegment(column)));
SelectStatementContext sqlStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getSubqueryType()).thenReturn(null);
when(sqlStatementContext.getDatabaseType()).thenReturn(databaseType);
@@ -137,7 +137,7 @@ class EncryptProjectionTokenGeneratorTest {
SimpleTableSegment doctorTable = new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("doctor")));
SimpleTableSegment doctorOneTable = new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("doctor1")));
when(sqlStatementContext.getTablesContext()).thenReturn(new
TablesContext(Arrays.asList(doctorTable, doctorOneTable), databaseType));
-
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singletonList(new
ColumnProjection("doctor", "mobile", null, databaseType)));
+
when(sqlStatementContext.getProjectionsContext().getProjections()).thenReturn(Collections.singleton(new
ColumnProjection("doctor", "mobile", null, databaseType)));
Collection<SQLToken> actual =
generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
index 08b0e568074..e002840e9a4 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
@@ -36,7 +36,7 @@ class EncryptRuleBuilderTest {
@Test
void assertBuild() {
EncryptRuleConfiguration ruleConfig =
mock(EncryptRuleConfiguration.class);
- DatabaseRuleBuilder builder =
OrderedSPILoader.getServices(DatabaseRuleBuilder.class,
Collections.singletonList(ruleConfig)).get(ruleConfig);
+ DatabaseRuleBuilder builder =
OrderedSPILoader.getServices(DatabaseRuleBuilder.class,
Collections.singleton(ruleConfig)).get(ruleConfig);
assertThat(builder.build(ruleConfig, "", Collections.emptyMap(),
Collections.emptyList(), mock(InstanceContext.class)),
instanceOf(EncryptRule.class));
}
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlCompatibleEncryptRuleConfigurationSwapperTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlCompatibleEncryptRuleConfigurationSwapperTest.java
index 2b2bada136e..8043e93c938 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlCompatibleEncryptRuleConfigurationSwapperTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlCompatibleEncryptRuleConfigurationSwapperTest.java
@@ -47,7 +47,7 @@ class YamlCompatibleEncryptRuleConfigurationSwapperTest {
}
private CompatibleEncryptRuleConfiguration
createEncryptRuleConfiguration() {
- Collection<EncryptTableRuleConfiguration> tables =
Collections.singletonList(new EncryptTableRuleConfiguration("tbl",
Collections.emptyList()));
+ Collection<EncryptTableRuleConfiguration> tables =
Collections.singleton(new EncryptTableRuleConfiguration("tbl",
Collections.emptyList()));
Map<String, AlgorithmConfiguration> encryptors =
Collections.singletonMap("myEncryptor", new AlgorithmConfiguration("FIXTURE",
new Properties()));
return new CompatibleEncryptRuleConfiguration(tables, encryptors);
}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
index f40bed1fb0c..415877df021 100644
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
+++
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
@@ -46,7 +46,7 @@ class YamlEncryptRuleConfigurationSwapperTest {
}
private EncryptRuleConfiguration createEncryptRuleConfiguration() {
- Collection<EncryptTableRuleConfiguration> tables =
Collections.singletonList(new EncryptTableRuleConfiguration("tbl",
Collections.emptyList()));
+ Collection<EncryptTableRuleConfiguration> tables =
Collections.singleton(new EncryptTableRuleConfiguration("tbl",
Collections.emptyList()));
Map<String, AlgorithmConfiguration> encryptors =
Collections.singletonMap("myEncryptor", new AlgorithmConfiguration("FIXTURE",
new Properties()));
return new EncryptRuleConfiguration(tables, encryptors);
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
index eae75d2a29c..df4475a287d 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/dql/MaskAlgorithmMetaDataTest.java
@@ -60,7 +60,7 @@ class MaskAlgorithmMetaDataTest {
columnProjection.setOriginalColumn(new IdentifierValue("order_id"));
columnProjection.setOriginalTable(new IdentifierValue("t_order"));
when(selectStatementContext.getProjectionsContext().getExpandProjections()).thenReturn(Collections.singletonList(columnProjection));
-
when(selectStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
+
when(selectStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_order"));
Optional<MaskAlgorithm> actual = new MaskAlgorithmMetaData(database,
maskRule, selectStatementContext).findMaskAlgorithmByColumnIndex(1);
assertTrue(actual.isPresent());
assertThat(actual.get().getType(), is("MD5"));
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
index 3aaa6bafaf6..fd6a697947c 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
@@ -46,7 +46,7 @@ class YamlMaskRuleConfigurationSwapperTest {
}
private MaskRuleConfiguration createMaskRuleConfiguration() {
- Collection<MaskTableRuleConfiguration> tables =
Collections.singletonList(new MaskTableRuleConfiguration("tbl",
Collections.emptyList()));
+ Collection<MaskTableRuleConfiguration> tables =
Collections.singleton(new MaskTableRuleConfiguration("tbl",
Collections.emptyList()));
Map<String, AlgorithmConfiguration> encryptors =
Collections.singletonMap("myMaskAlgorithm", new AlgorithmConfiguration("MD5",
new Properties()));
return new MaskRuleConfiguration(tables, encryptors);
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
index 5a4c6d4903f..b7bf0b0fe1c 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
@@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -87,7 +88,7 @@ class ReadwriteSplittingRuleConfigurationCheckerTest {
@Test
void assertCheckWeightLoadBalanceInvalidDataSourceName() {
ReadwriteSplittingRuleConfiguration config =
mock(ReadwriteSplittingRuleConfiguration.class);
- List<ReadwriteSplittingDataSourceRuleConfiguration> configs =
Collections.singletonList(createDataSourceRuleConfig("write_ds_0",
Arrays.asList("read_ds_0", "read_ds_1")));
+ Collection<ReadwriteSplittingDataSourceRuleConfiguration> configs =
Collections.singleton(createDataSourceRuleConfig("write_ds_0",
Arrays.asList("read_ds_0", "read_ds_1")));
when(config.getDataSources()).thenReturn(configs);
AlgorithmConfiguration algorithm = new
AlgorithmConfiguration("WEIGHT", PropertiesBuilder.build(new
Property("read_ds_2", "1"), new Property("read_ds_1", "2")));
when(config.getLoadBalancers()).thenReturn(Collections.singletonMap("weight_ds",
algorithm));
@@ -111,7 +112,7 @@ class ReadwriteSplittingRuleConfigurationCheckerTest {
when(dataSourceConfig.getName()).thenReturn("readwrite_ds");
when(dataSourceConfig.getWriteDataSourceName()).thenReturn("otherDatasourceName");
when(dataSourceConfig.getReadDataSourceNames()).thenReturn(Arrays.asList("read_ds_0",
"read_ds_1"));
-
when(result.getDataSources()).thenReturn(Collections.singletonList(dataSourceConfig));
+
when(result.getDataSources()).thenReturn(Collections.singleton(dataSourceConfig));
return result;
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
index 07386968eb9..d3bbe56e33c 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/route/ReadwriteSplittingSQLRouterTest.java
@@ -235,7 +235,7 @@ class ReadwriteSplittingSQLRouterTest {
private RouteContext mockRouteContext() {
RouteContext result = new RouteContext();
- RouteUnit routeUnit = new RouteUnit(new RouteMapper(DATASOURCE_NAME,
DATASOURCE_NAME), Collections.singletonList(new RouteMapper("table",
"table_0")));
+ RouteUnit routeUnit = new RouteUnit(new RouteMapper(DATASOURCE_NAME,
DATASOURCE_NAME), Collections.singleton(new RouteMapper("table", "table_0")));
result.getRouteUnits().add(routeUnit);
result.getRouteUnits().add(new RouteUnit(new
RouteMapper(NONE_READWRITE_SPLITTING_DATASOURCE_NAME,
NONE_READWRITE_SPLITTING_DATASOURCE_NAME), Collections.emptyList()));
return result;
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
index 0b1ba3ac2dc..8aa3af15ada 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
@@ -36,10 +36,8 @@ class ReadwriteSplittingRuleBuilderTest {
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
void assertBuild() {
- ReadwriteSplittingRuleConfiguration ruleConfig = new
ReadwriteSplittingRuleConfiguration(
- Collections.singletonList(new
ReadwriteSplittingDataSourceRuleConfiguration("name", "writeDataSourceName",
- Collections.singletonList("readDataSourceName"),
"loadBalancerName")),
- Collections.emptyMap());
+ ReadwriteSplittingRuleConfiguration ruleConfig = new
ReadwriteSplittingRuleConfiguration(Collections.singleton(
+ new ReadwriteSplittingDataSourceRuleConfiguration("name",
"writeDataSourceName", Collections.singletonList("readDataSourceName"),
"loadBalancerName")), Collections.emptyMap());
DatabaseRuleBuilder builder =
OrderedSPILoader.getServices(DatabaseRuleBuilder.class,
Collections.singleton(ruleConfig)).get(ruleConfig);
assertThat(builder.build(ruleConfig, "", Collections.emptyMap(),
Collections.emptyList(), mock(InstanceContext.class)),
instanceOf(ReadwriteSplittingRule.class));
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
index 4f229d916d3..1ece80c0f5c 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
@@ -60,7 +60,7 @@ class YamlReadwriteSplittingRuleConfigurationSwapperTest {
}
private ReadwriteSplittingRuleConfiguration
creatReadwriteSplittingRuleConfiguration() {
- Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources
= Collections.singletonList(
+ Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources
= Collections.singleton(
new ReadwriteSplittingDataSourceRuleConfiguration("readwrite",
"write_ds", Arrays.asList("read_ds_0", "read_ds_1"), "random"));
Map<String, AlgorithmConfiguration> loadBalancers =
Collections.singletonMap("myLoadBalancer", new AlgorithmConfiguration("RANDOM",
new Properties()));
return new ReadwriteSplittingRuleConfiguration(dataSources,
loadBalancers);
diff --git
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminerTest.java
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminerTest.java
index cfc97b652b7..8084c10b64c 100644
---
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminerTest.java
+++
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/determiner/HintShadowAlgorithmDeterminerTest.java
@@ -48,7 +48,7 @@ class HintShadowAlgorithmDeterminerTest {
private ShadowRuleConfiguration createShadowRuleConfiguration() {
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
result.setDataSources(createDataSources());
- result.setTables(Collections.singletonMap("t_order", new
ShadowTableConfiguration(Collections.singletonList("shadow-data-source-0"),
Collections.singleton("sql-hint-algorithm"))));
+ result.setTables(Collections.singletonMap("t_order", new
ShadowTableConfiguration(Collections.singleton("shadow-data-source-0"),
Collections.singleton("sql-hint-algorithm"))));
result.setShadowAlgorithms(Collections.singletonMap("sql-hint-algorithm", new
AlgorithmConfiguration("SQL_HINT", new Properties())));
return result;
}
diff --git
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngineTest.java
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngineTest.java
index ca2385a7a33..dce38affae3 100644
---
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngineTest.java
+++
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/engine/impl/ShadowNonDMLStatementRoutingEngineTest.java
@@ -83,8 +83,8 @@ class ShadowNonDMLStatementRoutingEngineTest {
private ShadowRuleConfiguration createShadowRuleConfiguration() {
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
- result.setDataSources(Collections.singletonList(new
ShadowDataSourceConfiguration("shadow-data-source", "ds", "ds_shadow")));
- result.setTables(Collections.singletonMap("t_order", new
ShadowTableConfiguration(Collections.singletonList("shadow-data-source"),
Collections.singleton("sql-hint-algorithm"))));
+ result.setDataSources(Collections.singleton(new
ShadowDataSourceConfiguration("shadow-data-source", "ds", "ds_shadow")));
+ result.setTables(Collections.singletonMap("t_order", new
ShadowTableConfiguration(Collections.singleton("shadow-data-source"),
Collections.singleton("sql-hint-algorithm"))));
result.setShadowAlgorithms(createShadowAlgorithms());
return result;
}
diff --git
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/ShadowRuleTest.java
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/ShadowRuleTest.java
index 7841be2b449..274fd09233c 100644
---
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/ShadowRuleTest.java
+++
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/ShadowRuleTest.java
@@ -68,8 +68,8 @@ class ShadowRuleTest {
private Map<String, ShadowTableConfiguration> createTables() {
Map<String, ShadowTableConfiguration> result = new LinkedHashMap<>();
- result.put("t_user", new
ShadowTableConfiguration(Collections.singletonList("shadow-data-source-0"),
createShadowAlgorithmNames("t_user")));
- result.put("t_order", new
ShadowTableConfiguration(Collections.singletonList("shadow-data-source-1"),
createShadowAlgorithmNames("t_order")));
+ result.put("t_user", new
ShadowTableConfiguration(Collections.singleton("shadow-data-source-0"),
createShadowAlgorithmNames("t_user")));
+ result.put("t_order", new
ShadowTableConfiguration(Collections.singleton("shadow-data-source-1"),
createShadowAlgorithmNames("t_order")));
return result;
}
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
index dc768654bc5..e69a58a74d9 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
@@ -92,8 +92,8 @@ class ShowShadowRuleExecutorTest {
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
result.getDataSources().add(new
ShadowDataSourceConfiguration("shadow_rule", "source", "shadow"));
result.getShadowAlgorithms().put("user_id_select_match_algorithm", new
AlgorithmConfiguration("REGEX_MATCH", new Properties()));
- result.getTables().put("t_order", new
ShadowTableConfiguration(Collections.singletonList("shadow_rule"),
Collections.singletonList("user_id_select_match_algorithm")));
- result.getTables().put("t_order_item", new
ShadowTableConfiguration(Collections.singletonList("shadow_rule"),
Collections.singletonList("user_id_select_match_algorithm")));
+ result.getTables().put("t_order", new
ShadowTableConfiguration(Collections.singleton("shadow_rule"),
Collections.singleton("user_id_select_match_algorithm")));
+ result.getTables().put("t_order_item", new
ShadowTableConfiguration(Collections.singleton("shadow_rule"),
Collections.singleton("user_id_select_match_algorithm")));
return result;
}
}
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
index 925451e04d8..c241960af47 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterShadowRuleStatementUpdaterTest.java
@@ -107,7 +107,7 @@ class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new
ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name",
PropertiesBuilder.build(new Property("type", "value"))));
AlterShadowRuleStatement sqlStatement = new
AlterShadowRuleStatement(Arrays.asList(
new ShadowRuleSegment("initRuleName1", "ds", null,
Collections.singletonMap("t_order", Collections.singleton(segment))),
- new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singletonList(segment)))));
+ new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment)))));
assertThrows(AlgorithmInUsedException.class, () ->
updater.checkSQLStatement(database, sqlStatement, currentConfig));
}
@@ -116,7 +116,7 @@ class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new
ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name",
PropertiesBuilder.build(new Property("type", "value"))));
AlterShadowRuleStatement sqlStatement = new
AlterShadowRuleStatement(Arrays.asList(
new ShadowRuleSegment("initRuleName1", "ds", null,
Collections.singletonMap("t_order", Collections.singleton(segment))),
- new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singletonList(segment)))));
+ new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment)))));
assertThrows(AlgorithmInUsedException.class, () ->
updater.checkSQLStatement(database, sqlStatement, currentConfig));
}
@@ -127,7 +127,7 @@ class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment2 = new
ShadowAlgorithmSegment("algorithmName2", new AlgorithmSegment("SQL_HINT",
props));
AlterShadowRuleStatement sqlStatement = new
AlterShadowRuleStatement(Arrays.asList(
new ShadowRuleSegment("initRuleName1", "ds", null,
Collections.singletonMap("t_order", Collections.singleton(segment1))),
- new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singletonList(segment2)))));
+ new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment2)))));
updater.checkSQLStatement(database, sqlStatement, currentConfig);
}
@@ -137,7 +137,7 @@ class AlterShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment2 = new
ShadowAlgorithmSegment("algorithmName2", new AlgorithmSegment("SQL_HINT",
null));
AlterShadowRuleStatement sqlStatement = new
AlterShadowRuleStatement(Arrays.asList(
new ShadowRuleSegment("initRuleName1", "ds", null,
Collections.singletonMap("t_order", Collections.singleton(segment1))),
- new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singletonList(segment2)))));
+ new ShadowRuleSegment("initRuleName2", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment2)))));
updater.checkSQLStatement(database, sqlStatement, currentConfig);
}
}
diff --git
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
index c601ab1c17b..1c68f0fd951 100644
---
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
+++
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
@@ -81,7 +81,7 @@ class CreateShadowRuleStatementUpdaterTest {
@Test
void assertExecuteWithDuplicateRuleNameInMetaData() {
-
when(currentConfig.getDataSources()).thenReturn(Collections.singletonList(new
ShadowDataSourceConfiguration("ruleName", "ds", "ds_shadow")));
+
when(currentConfig.getDataSources()).thenReturn(Collections.singleton(new
ShadowDataSourceConfiguration("ruleName", "ds", "ds_shadow")));
ShadowRuleSegment ruleSegment = new ShadowRuleSegment("ruleName",
null, null, null);
assertThrows(DuplicateRuleException.class, () ->
updater.checkSQLStatement(database, new CreateShadowRuleStatement(false,
Collections.singleton(ruleSegment)), currentConfig));
}
@@ -107,7 +107,7 @@ class CreateShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new
ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name",
PropertiesBuilder.build(new Property("type", "value"))));
CreateShadowRuleStatement sqlStatement = new
CreateShadowRuleStatement(false, Arrays.asList(
new ShadowRuleSegment("ruleName", "ds", null,
Collections.singletonMap("t_order", Collections.singleton(segment))),
- new ShadowRuleSegment("ruleName", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singletonList(segment)))));
+ new ShadowRuleSegment("ruleName", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment)))));
assertThrows(DuplicateRuleException.class, () ->
updater.checkSQLStatement(database, sqlStatement, currentConfig));
}
@@ -116,7 +116,7 @@ class CreateShadowRuleStatementUpdaterTest {
ShadowAlgorithmSegment segment = new
ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name",
PropertiesBuilder.build(new Property("type", "value"))));
CreateShadowRuleStatement sqlStatement = new
CreateShadowRuleStatement(false, Arrays.asList(
new ShadowRuleSegment("ruleName", "ds", null,
Collections.singletonMap("t_order", Collections.singleton(segment))),
- new ShadowRuleSegment("ruleName1", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singletonList(segment)))));
+ new ShadowRuleSegment("ruleName1", "ds1", null,
Collections.singletonMap("t_order_1", Collections.singleton(segment)))));
assertThrows(DuplicateRuleException.class, () ->
updater.checkSQLStatement(database, sqlStatement, null));
}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
index fb53ca620e8..ba64c8f7f4c 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/ShardingStandardRoutingEngineTest.java
@@ -97,7 +97,7 @@ class ShardingStandardRoutingEngineTest {
@Test
void assertRouteByHint() {
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_hint_test"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_hint_test"));
ShardingStandardRoutingEngine standardRoutingEngine =
createShardingStandardRoutingEngine("t_hint_test",
new ShardingConditions(Collections.emptyList(),
sqlStatementContext, mock(ShardingRule.class)), sqlStatementContext, new
HintValueContext());
HintManager hintManager = HintManager.getInstance();
@@ -115,7 +115,7 @@ class ShardingStandardRoutingEngineTest {
@Test
void assertRouteByMixedWithHintDataSource() {
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_hint_ds_test"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_hint_ds_test"));
ShardingStandardRoutingEngine standardRoutingEngine =
createShardingStandardRoutingEngine("t_hint_ds_test",
ShardingRoutingEngineFixtureBuilder.createShardingConditions("t_hint_ds_test"),
sqlStatementContext, new HintValueContext());
HintManager hintManager = HintManager.getInstance();
@@ -132,7 +132,7 @@ class ShardingStandardRoutingEngineTest {
@Test
void assertRouteByMixedWithHintDataSourceOnly() {
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_hint_ds_test"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_hint_ds_test"));
ShardingStandardRoutingEngine standardRoutingEngine =
createShardingStandardRoutingEngine("t_hint_ds_test",
new ShardingConditions(Collections.emptyList(),
sqlStatementContext, mock(ShardingRule.class)), sqlStatementContext, new
HintValueContext());
HintManager hintManager = HintManager.getInstance();
@@ -153,7 +153,7 @@ class ShardingStandardRoutingEngineTest {
@Test
void assertRouteByMixedWithHintTable() {
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_hint_table_test"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_hint_table_test"));
ShardingStandardRoutingEngine standardRoutingEngine =
createShardingStandardRoutingEngine("t_hint_table_test",
ShardingRoutingEngineFixtureBuilder.createShardingConditions("t_hint_table_test"),
sqlStatementContext, new HintValueContext());
HintManager hintManager = HintManager.getInstance();
@@ -170,7 +170,7 @@ class ShardingStandardRoutingEngineTest {
@Test
void assertRouteByMixedWithHintTableOnly() {
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_hint_table_test"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_hint_table_test"));
ShardingStandardRoutingEngine standardRoutingEngine =
createShardingStandardRoutingEngine("t_hint_table_test",
new ShardingConditions(Collections.emptyList(),
sqlStatementContext, mock(ShardingRule.class)), sqlStatementContext, new
HintValueContext());
HintManager hintManager = HintManager.getInstance();
@@ -191,7 +191,7 @@ class ShardingStandardRoutingEngineTest {
@Test
void assertRouteByIntervalTableShardingStrategyOnly() {
SQLStatementContext sqlStatementContext =
mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
-
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_interval_test"));
+
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singleton("t_interval_test"));
ShardingStandardRoutingEngine standardRoutingEngine =
createShardingStandardRoutingEngine("t_interval_test",
ShardingRoutingEngineFixtureBuilder.createIntervalShardingConditions("t_interval_test"),
sqlStatementContext, new HintValueContext());
RouteContext routeContext =
standardRoutingEngine.route(ShardingRoutingEngineFixtureBuilder.createIntervalTableShardingRule());
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
index c10251fc83b..1375141f36f 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/standard/assertion/ShardingRouteAssert.java
@@ -70,7 +70,7 @@ public final class ShardingRouteAssert {
public static RouteContext assertRoute(final String sql, final
List<Object> params) {
DatabaseType databaseType =
TypedSPILoader.getService(DatabaseType.class, "MySQL");
ShardingRule shardingRule =
ShardingRoutingEngineFixtureBuilder.createAllShardingRule();
- SingleRule singleRule =
ShardingRoutingEngineFixtureBuilder.createSingleRule(Collections.singletonList(shardingRule));
+ SingleRule singleRule =
ShardingRoutingEngineFixtureBuilder.createSingleRule(Collections.singleton(shardingRule));
TimestampServiceRule timestampServiceRule =
ShardingRoutingEngineFixtureBuilder.createTimeServiceRule();
Map<String, ShardingSphereSchema> schemas = buildSchemas();
ConfigurationProperties props = new ConfigurationProperties(new
Properties());
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngineTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngineTest.java
index 5f90242ea4e..64f67966fa1 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngineTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/unicast/ShardingUnicastRoutingEngineTest.java
@@ -90,7 +90,7 @@ class ShardingUnicastRoutingEngineTest {
@Test
void assertRoutingForBroadcastTableWithPreferredDataSource() {
- ConnectionContext connectionContext = new ConnectionContext(() ->
Collections.singletonList("ds_1"));
+ ConnectionContext connectionContext = new ConnectionContext(() ->
Collections.singleton("ds_1"));
RouteContext actual = new
ShardingUnicastRoutingEngine(mock(SelectStatementContext.class),
Collections.singleton("t_config"), connectionContext).route(shardingRule);
assertThat(actual.getRouteUnits().size(), is(1));
assertThat(actual.getRouteUnits().iterator().next().getDataSourceMapper().getActualName(),
is("ds_1"));
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
index e8cfeef86e9..20e25dff97a 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
@@ -127,8 +127,8 @@ class ShardingDropTableStatementValidatorTest {
when(shardingRule.isShardingTable("t_order")).thenReturn(true);
when(shardingRule.getTableRule("t_order")).thenReturn(new
TableRule(Arrays.asList("ds_0", "ds_1"), "t_order"));
Collection<RouteUnit> routeUnits = new LinkedList<>();
- routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
- routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
+ routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
+ routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"),
Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
assertDoesNotThrow(() -> new
ShardingDropTableStatementValidator().postValidate(
shardingRule, new DropTableStatementContext(sqlStatement), new
HintValueContext(), Collections.emptyList(),
@@ -142,7 +142,7 @@ class ShardingDropTableStatementValidatorTest {
when(shardingRule.isShardingTable("t_order")).thenReturn(true);
when(shardingRule.getTableRule("t_order")).thenReturn(new
TableRule(Arrays.asList("ds_0", "ds_1"), "t_order"));
Collection<RouteUnit> routeUnits = new LinkedList<>();
- routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_order", "t_order_0"))));
+ routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
assertThrows(ShardingDDLRouteException.class,
() -> new
ShardingDropTableStatementValidator().postValidate(shardingRule, new
DropTableStatementContext(sqlStatement), new HintValueContext(),
@@ -155,8 +155,8 @@ class ShardingDropTableStatementValidatorTest {
sqlStatement.getTables().add(new SimpleTableSegment(new
TableNameSegment(0, 0, new IdentifierValue("t_config"))));
when(shardingRule.getTableRule("t_config")).thenReturn(new
TableRule(Arrays.asList("ds_0", "ds_1"), "t_config"));
Collection<RouteUnit> routeUnits = new LinkedList<>();
- routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singletonList(new RouteMapper("t_config", "t_config"))));
- routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"),
Collections.singletonList(new RouteMapper("t_config", "t_config"))));
+ routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"),
Collections.singleton(new RouteMapper("t_config", "t_config"))));
+ routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"),
Collections.singleton(new RouteMapper("t_config", "t_config"))));
when(routeContext.getRouteUnits()).thenReturn(routeUnits);
assertDoesNotThrow(() -> new
ShardingDropTableStatementValidator().postValidate(
shardingRule, new DropTableStatementContext(sqlStatement), new
HintValueContext(),
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index a75c4e5b115..2281e541c40 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -486,7 +486,7 @@ class ShardingRuleTest {
shardingRuleConfig.setDefaultTableShardingStrategy(new
StandardShardingStrategyConfiguration("table_id", "standard"));
shardingRuleConfig.setDefaultShardingColumn("table_id");
shardingRuleConfig.setDefaultKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "default"));
- shardingRuleConfig.setDefaultAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singletonList("audit_algorithm"),
false));
+ shardingRuleConfig.setDefaultAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singleton("audit_algorithm"),
false));
shardingRuleConfig.getShardingAlgorithms().put("core_standard_fixture", new
AlgorithmConfiguration("CORE.STANDARD.FIXTURE", new Properties()));
shardingRuleConfig.getKeyGenerators().put("uuid", new
AlgorithmConfiguration("UUID", new Properties()));
shardingRuleConfig.getKeyGenerators().put("default", new
AlgorithmConfiguration("UUID", new Properties()));
@@ -635,7 +635,7 @@ class ShardingRuleTest {
when(sqlStatementContext.isContainsJoinQuery()).thenReturn(true);
when(sqlStatementContext.getDatabaseType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"FIXTURE"));
when(sqlStatementContext.getTablesContext().getSchemaName()).thenReturn(Optional.empty());
-
when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.singletonList(new
WhereSegment(0, 0, condition)));
+
when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.singleton(new
WhereSegment(0, 0, condition)));
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
when(sqlStatementContext.getTablesContext().findTableNamesByColumnSegment(Arrays.asList(leftDatabaseJoin,
rightDatabaseJoin), schema)).thenReturn(createColumnTableNameMap());
when(sqlStatementContext.getTablesContext().findTableNamesByColumnSegment(Arrays.asList(leftTableJoin,
rightTableJoin), schema)).thenReturn(createColumnTableNameMap());
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index a3db153fd65..6748fc914ea 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -127,19 +127,19 @@ class ShardingRuleStatementCheckerTest {
@Test
void assertCheckCreationWithIdentical() {
- List<AbstractTableRuleSegment> rules = Collections.singletonList(new
AutoTableRuleSegment("t_order", Arrays.asList("ds_0", "ds_1")));
+ Collection<AbstractTableRuleSegment> rules = Collections.singleton(new
AutoTableRuleSegment("t_order", Arrays.asList("ds_0", "ds_1")));
assertThrows(DuplicateRuleException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@Test
void assertCheckAlterationWithRuleRequiredMissed() {
- List<AbstractTableRuleSegment> rules = Collections.singletonList(new
AutoTableRuleSegment("t_order_required_missed", Arrays.asList("ds_0", "ds_1")));
+ Collection<AbstractTableRuleSegment> rules = Collections.singleton(new
AutoTableRuleSegment("t_order_required_missed", Arrays.asList("ds_0", "ds_1")));
assertThrows(MissingRequiredRuleException.class, () ->
ShardingTableRuleStatementChecker.checkAlteration(database, rules,
shardingRuleConfig));
}
@Test
void assertCheckCreationWithResourceRequiredMissed() {
- List<AbstractTableRuleSegment> rules = Collections.singletonList(new
AutoTableRuleSegment("t_product", Arrays.asList("ds_required_missed", "ds_1")));
+ Collection<AbstractTableRuleSegment> rules = Collections.singleton(new
AutoTableRuleSegment("t_product", Arrays.asList("ds_required_missed", "ds_1")));
assertThrows(MissingRequiredStorageUnitsException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -154,7 +154,7 @@ class ShardingRuleStatementCheckerTest {
@Test
void assertCheckCreationWithInvalidAuditAlgorithm() {
AutoTableRuleSegment autoTableRuleSegment = new
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
- autoTableRuleSegment.setAuditStrategySegment(new
AuditStrategySegment(Collections.singletonList(new
ShardingAuditorSegment("sharding_key_required_auditor",
+ autoTableRuleSegment.setAuditStrategySegment(new
AuditStrategySegment(Collections.singleton(new
ShardingAuditorSegment("sharding_key_required_auditor",
new AlgorithmSegment("invalid", new Properties()))), true));
assertThrows(ServiceProviderNotFoundException.class,
() ->
ShardingTableRuleStatementChecker.checkCreation(database,
Collections.singleton(autoTableRuleSegment), false, shardingRuleConfig));
@@ -165,7 +165,7 @@ class ShardingRuleStatementCheckerTest {
AutoTableRuleSegment autoTableRuleSegment = new
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
autoTableRuleSegment.setShardingColumn("product_id");
autoTableRuleSegment.setShardingAlgorithmSegment(new
AlgorithmSegment("not_exist", PropertiesBuilder.build(new Property("", ""))));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(autoTableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(autoTableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -174,7 +174,7 @@ class ShardingRuleStatementCheckerTest {
AutoTableRuleSegment autoTableRuleSegment = new
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
autoTableRuleSegment.setShardingColumn("product_id");
autoTableRuleSegment.setShardingAlgorithmSegment(new
AlgorithmSegment("complex", PropertiesBuilder.build(new Property("", ""))));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(autoTableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(autoTableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -183,7 +183,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("invalid", "product_id", null));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(UnsupportedSQLOperationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -192,7 +192,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("complex", "product_id", null));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -201,7 +201,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("standard", "product_id,user_id", null));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -211,7 +211,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("standard", "user_id", databaseAlgorithmSegment));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -220,7 +220,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("hint", "product_id", null));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -229,7 +229,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("hint", "product_id", null));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false, null));
}
@@ -239,7 +239,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("standard", "product_id", databaseAlgorithmSegment));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
ShardingTableRuleStatementChecker.checkCreation(database, rules,
false, shardingRuleConfig);
}
@@ -248,7 +248,7 @@ class ShardingRuleStatementCheckerTest {
KeyGenerateStrategySegment keyGenerateStrategy = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TableRuleSegment tableRuleSegment = new TableRuleSegment("t_product",
Arrays.asList("ds_0", "ds_1"), keyGenerateStrategy, null);
tableRuleSegment.setTableStrategySegment(new
ShardingStrategySegment("standard", "product_id", null));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(tableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(tableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -256,7 +256,7 @@ class ShardingRuleStatementCheckerTest {
void assertCheckAutoTableRuleWithStandardShardingAlgorithm() {
AutoTableRuleSegment autoTableRuleSegment = new
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
autoTableRuleSegment.setShardingAlgorithmSegment(new
AlgorithmSegment("INLINE", PropertiesBuilder.build(new
Property("algorithm-expression", "ds_${product_id % 2}"))));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(autoTableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(autoTableRuleSegment);
assertThrows(InvalidAlgorithmConfigurationException.class, () ->
ShardingTableRuleStatementChecker.checkCreation(database, rules, false,
shardingRuleConfig));
}
@@ -264,7 +264,7 @@ class ShardingRuleStatementCheckerTest {
void assertCheckAutoTableRuleWithAutoShardingAlgorithm() {
AutoTableRuleSegment autoTableRuleSegment = new
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
autoTableRuleSegment.setShardingAlgorithmSegment(new
AlgorithmSegment("CORE.AUTO.FIXTURE", PropertiesBuilder.build(new
Property("sharding-count", "4"))));
- List<AbstractTableRuleSegment> rules =
Collections.singletonList(autoTableRuleSegment);
+ Collection<AbstractTableRuleSegment> rules =
Collections.singleton(autoTableRuleSegment);
ShardingTableRuleStatementChecker.checkCreation(database, rules,
false, shardingRuleConfig);
}
@@ -323,7 +323,7 @@ class ShardingRuleStatementCheckerTest {
private TableRuleSegment createCompleteTableRule() {
Properties props = new Properties();
KeyGenerateStrategySegment keyGenerator = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", props));
- TableRuleSegment result = new TableRuleSegment("t_product_1",
Collections.singletonList("ds_${0..1}.t_order${0..1}"), keyGenerator, null);
+ TableRuleSegment result = new TableRuleSegment("t_product_1",
Collections.singleton("ds_${0..1}.t_order${0..1}"), keyGenerator, null);
result.setTableStrategySegment(new ShardingStrategySegment("hint",
null, new AlgorithmSegment("CORE.HINT.FIXTURE", props)));
result.setDatabaseStrategySegment(new ShardingStrategySegment("hint",
null, new AlgorithmSegment("CORE.HINT.FIXTURE", props)));
return result;
@@ -332,7 +332,7 @@ class ShardingRuleStatementCheckerTest {
private TableRuleSegment createWrongTableRuleWithNoneTypeStrategy() {
Properties props = new Properties();
KeyGenerateStrategySegment keyGenerator = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", props));
- TableRuleSegment result = new TableRuleSegment("t_product_1",
Collections.singletonList("ds_${0..1}.t_order${0..1}"), keyGenerator, null);
+ TableRuleSegment result = new TableRuleSegment("t_product_1",
Collections.singleton("ds_${0..1}.t_order${0..1}"), keyGenerator, null);
result.setDatabaseStrategySegment(new ShardingStrategySegment("none",
null, null));
result.setTableStrategySegment(new ShardingStrategySegment("none",
null, null));
return result;
@@ -341,7 +341,7 @@ class ShardingRuleStatementCheckerTest {
private TableRuleSegment createCompleteTableRuleWithNoneTypeStrategy() {
Properties props = PropertiesBuilder.build(new
Property("algorithm-expression", "t_order_${order_id % 2}"));
KeyGenerateStrategySegment keyGenerator = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", props));
- TableRuleSegment result = new TableRuleSegment("t_product_1",
Collections.singletonList("ds_0.t_order${0..1}"), keyGenerator, null);
+ TableRuleSegment result = new TableRuleSegment("t_product_1",
Collections.singleton("ds_0.t_order${0..1}"), keyGenerator, null);
result.setDatabaseStrategySegment(new ShardingStrategySegment("none",
null, null));
result.setTableStrategySegment(new ShardingStrategySegment("standard",
"order_id", new AlgorithmSegment("inline", props)));
return result;
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/CountShardingRuleExecutorTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/CountShardingRuleExecutorTest.java
index 296478c5fcf..93510757b5d 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/CountShardingRuleExecutorTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/CountShardingRuleExecutorTest.java
@@ -70,7 +70,7 @@ class CountShardingRuleExecutorTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
when(result.getName()).thenReturn("db_1");
- RuleMetaData ruleMetaData = new
RuleMetaData(Collections.singletonList(mockShardingRule()));
+ RuleMetaData ruleMetaData = new
RuleMetaData(Collections.singleton(mockShardingRule()));
when(result.getRuleMetaData()).thenReturn(ruleMetaData);
return result;
}
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableReferenceRuleStatementUpdaterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableReferenceRuleStatementUpdaterTest.java
index b7679142446..da8e9c74203 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableReferenceRuleStatementUpdaterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableReferenceRuleStatementUpdaterTest.java
@@ -71,7 +71,7 @@ class AlterShardingTableReferenceRuleStatementUpdaterTest {
}
private AlterShardingTableReferenceRuleStatement createSQLStatement(final
String name, final String reference) {
- return new
AlterShardingTableReferenceRuleStatement(Collections.singletonList(new
TableReferenceRuleSegment(name, reference)));
+ return new
AlterShardingTableReferenceRuleStatement(Collections.singleton(new
TableReferenceRuleSegment(name, reference)));
}
private ShardingRuleConfiguration createCurrentRuleConfiguration() {
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
index 299c9e1a219..421ea0ead08 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/AlterShardingTableRuleStatementUpdaterTest.java
@@ -159,7 +159,7 @@ class AlterShardingTableRuleStatementUpdaterTest {
private TableRuleSegment createCompleteTableRule(final String
logicTableName) {
KeyGenerateStrategySegment keyGenerator = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
- TableRuleSegment result = new TableRuleSegment(logicTableName,
Collections.singletonList("ds_${0..1}.t_order${0..1}"), keyGenerator, null);
+ TableRuleSegment result = new TableRuleSegment(logicTableName,
Collections.singleton("ds_${0..1}.t_order${0..1}"), keyGenerator, null);
result.setTableStrategySegment(new ShardingStrategySegment("standard",
"product_id", new AlgorithmSegment("CORE.STANDARD.FIXTURE", new Properties())));
AlgorithmSegment databaseAlgorithmSegment = new
AlgorithmSegment("inline", PropertiesBuilder.build(new
Property("algorithm-expression", "ds_${user_id % 2}")));
result.setDatabaseStrategySegment(new
ShardingStrategySegment("standard", "product_id", databaseAlgorithmSegment));
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
index c47e90169b2..1a88ef4819a 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/CreateShardingTableRuleStatementUpdaterTest.java
@@ -240,7 +240,7 @@ class CreateShardingTableRuleStatementUpdaterTest {
}
private AutoTableRuleSegment createCompleteAutoTableRule() {
- AutoTableRuleSegment result = new
AutoTableRuleSegment("t_order_item_input",
Collections.singletonList("logic_ds"));
+ AutoTableRuleSegment result = new
AutoTableRuleSegment("t_order_item_input", Collections.singleton("logic_ds"));
result.setKeyGenerateStrategySegment(new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties())));
result.setShardingColumn("order_id");
result.setShardingAlgorithmSegment(new
AlgorithmSegment("FOO.DISTSQL.FIXTURE", PropertiesBuilder.build(new
Property("", ""))));
@@ -249,7 +249,7 @@ class CreateShardingTableRuleStatementUpdaterTest {
private TableRuleSegment createCompleteTableRule() {
KeyGenerateStrategySegment keyGenerator = new
KeyGenerateStrategySegment("product_id", new
AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
- TableRuleSegment result = new TableRuleSegment("t_order_input",
Collections.singletonList("ds_${0..1}.t_order_${0..1}"), keyGenerator, null);
+ TableRuleSegment result = new TableRuleSegment("t_order_input",
Collections.singleton("ds_${0..1}.t_order_${0..1}"), keyGenerator, null);
result.setTableStrategySegment(new ShardingStrategySegment("standard",
"product_id", new AlgorithmSegment("CORE.STANDARD.FIXTURE", new Properties())));
AlgorithmSegment databaseAlgorithmSegment = new
AlgorithmSegment("inline", PropertiesBuilder.build(new
Property("algorithm-expression", "ds_${user_id % 2}")));
result.setDatabaseStrategySegment(new
ShardingStrategySegment("standard", "product_id", databaseAlgorithmSegment));
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
index b496be82def..d2e25849ab2 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingAuditorStatementUpdaterTest.java
@@ -64,7 +64,7 @@ class DropShardingAuditorStatementUpdaterTest {
@Test
void assertExecuteWithNotExistWithIfExists() {
- DropShardingAuditorStatement sqlStatement = new
DropShardingAuditorStatement(true,
Collections.singletonList("sharding_key_required_auditor"));
+ DropShardingAuditorStatement sqlStatement = new
DropShardingAuditorStatement(true,
Collections.singleton("sharding_key_required_auditor"));
updater.checkSQLStatement(database, sqlStatement, new
ShardingRuleConfiguration());
}
@@ -86,7 +86,7 @@ class DropShardingAuditorStatementUpdaterTest {
private ShardingAutoTableRuleConfiguration
createShardingAutoTableRuleConfiguration() {
ShardingAutoTableRuleConfiguration result = new
ShardingAutoTableRuleConfiguration("auto_table", null);
- result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singletonList("sharding_key_required_auditor"),
true));
+ result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singleton("sharding_key_required_auditor"),
true));
return result;
}
diff --git
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
index 3dc84acb802..947b6756205 100644
---
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
+++
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/update/DropShardingKeyGeneratorStatementUpdaterTest.java
@@ -46,7 +46,7 @@ class DropShardingKeyGeneratorStatementUpdaterTest {
@Test
void assertExecuteWithNotExistWithIfExists() {
- DropShardingKeyGeneratorStatement sqlStatement = new
DropShardingKeyGeneratorStatement(true,
Collections.singletonList("uuid_key_generator"));
+ DropShardingKeyGeneratorStatement sqlStatement = new
DropShardingKeyGeneratorStatement(true,
Collections.singleton("uuid_key_generator"));
new
DropShardingKeyGeneratorStatementUpdater().checkSQLStatement(mock(ShardingSphereDatabase.class),
sqlStatement, new ShardingRuleConfiguration());
}
diff --git
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
index 4434dcacd93..5a8e8716a30 100644
---
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
+++
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
@@ -125,7 +125,7 @@ class BatchPreparedStatementExecutorTest {
void assertNoPreparedStatement() throws SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.executeBatch()).thenReturn(new int[]{0, 0});
- setExecutionGroups(Collections.singletonList(preparedStatement));
+ setExecutionGroups(Collections.singleton(preparedStatement));
assertThat(executor.executeBatch(sqlStatementContext), is(new int[]{0,
0}));
}
@@ -133,7 +133,7 @@ class BatchPreparedStatementExecutorTest {
void assertExecuteBatchForSinglePreparedStatementSuccess() throws
SQLException {
PreparedStatement preparedStatement = getPreparedStatement();
when(preparedStatement.executeBatch()).thenReturn(new int[]{10, 20});
- setExecutionGroups(Collections.singletonList(preparedStatement));
+ setExecutionGroups(Collections.singleton(preparedStatement));
assertThat(executor.executeBatch(sqlStatementContext), is(new
int[]{10, 20}));
verify(preparedStatement).executeBatch();
}
@@ -155,7 +155,7 @@ class BatchPreparedStatementExecutorTest {
PreparedStatement preparedStatement = getPreparedStatement();
SQLException ex = new SQLException("");
when(preparedStatement.executeBatch()).thenThrow(ex);
- setExecutionGroups(Collections.singletonList(preparedStatement));
+ setExecutionGroups(Collections.singleton(preparedStatement));
assertThrows(SQLException.class, () ->
executor.executeBatch(sqlStatementContext));
verify(preparedStatement).executeBatch();
}
@@ -176,7 +176,7 @@ class BatchPreparedStatementExecutorTest {
return result;
}
- private void setExecutionGroups(final List<PreparedStatement>
preparedStatements) {
+ private void setExecutionGroups(final Collection<PreparedStatement>
preparedStatements) {
Collection<ExecutionGroup<JDBCExecutionUnit>> executionGroups = new
LinkedList<>();
List<JDBCExecutionUnit> executionUnits = new LinkedList<>();
executionGroups.add(new ExecutionGroup<>(executionUnits));
diff --git
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
index 8309a103d9e..037a7dfce3e 100644
---
a/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
+++
b/jdbc/core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
@@ -99,8 +99,8 @@ class ShardingSphereDatabaseMetaDataTest {
private ShardingRule mockShardingRule() {
ShardingRuleConfiguration ruleConfig = new ShardingRuleConfiguration();
ShardingTableRuleConfiguration shardingTableRuleConfig = new
ShardingTableRuleConfiguration(TABLE_NAME, DATA_SOURCE_NAME + "." + TABLE_NAME);
-
ruleConfig.setTables(Collections.singletonList(shardingTableRuleConfig));
- return new ShardingRule(ruleConfig,
Collections.singletonList(DATA_SOURCE_NAME), mock(InstanceContext.class));
+ ruleConfig.setTables(Collections.singleton(shardingTableRuleConfig));
+ return new ShardingRule(ruleConfig,
Collections.singleton(DATA_SOURCE_NAME), mock(InstanceContext.class));
}
@Test
diff --git
a/mode/type/cluster/repository/provider/nacos/src/main/java/org/apache/shardingsphere/mode/repository/cluster/nacos/NacosRepository.java
b/mode/type/cluster/repository/provider/nacos/src/main/java/org/apache/shardingsphere/mode/repository/cluster/nacos/NacosRepository.java
index 89d2ec4f0cc..0a076804be0 100644
---
a/mode/type/cluster/repository/provider/nacos/src/main/java/org/apache/shardingsphere/mode/repository/cluster/nacos/NacosRepository.java
+++
b/mode/type/cluster/repository/provider/nacos/src/main/java/org/apache/shardingsphere/mode/repository/cluster/nacos/NacosRepository.java
@@ -22,7 +22,6 @@ import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
import com.alibaba.nacos.api.naming.pojo.Instance;
-import com.alibaba.nacos.common.utils.CollectionUtils;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import lombok.SneakyThrows;
@@ -336,9 +335,9 @@ public final class NacosRepository implements
ClusterPersistRepository {
ServiceMetaData service =
serviceController.getService(entry.getKey());
Map<String, List<Instance>> instanceMap =
client.getAllInstances(service.getServiceName(),
false).stream().collect(Collectors.groupingBy(NacosMetaDataUtils::getKey));
keyValues.removeIf(keyValue -> {
- Collection<Instance> instances =
instanceMap.get(keyValue.getKey());
+ String key = keyValue.getKey();
String value = keyValue.getValue();
- return CollectionUtils.isNotEmpty(instances) ?
instances.stream().anyMatch(instance ->
Objects.equals(NacosMetaDataUtils.getValue(instance), value)) : null == value;
+ return instanceMap.containsKey(key) ?
instanceMap.get(key).stream().anyMatch(each ->
Objects.equals(NacosMetaDataUtils.getValue(each), value)) : null == value;
});
}
return keyValues.isEmpty();
diff --git
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
index 0a2cc0ff12e..586314b999e 100644
---
a/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
+++
b/mode/type/standalone/core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneModeContextManager.java
@@ -139,7 +139,7 @@ public final class StandaloneModeContextManager implements
ModeContextManager, C
private void removeSchemaMetaData(final ShardingSphereDatabase database,
final String schemaName) {
ShardingSphereSchema schema = new
ShardingSphereSchema(database.getSchema(schemaName).getTables(),
database.getSchema(schemaName).getViews());
database.removeSchema(schemaName);
-
removeDataNode(database.getRuleMetaData().findRules(MutableDataNodeRule.class),
Collections.singletonList(schemaName), schema.getAllTableNames());
+
removeDataNode(database.getRuleMetaData().findRules(MutableDataNodeRule.class),
Collections.singleton(schemaName), schema.getAllTableNames());
}
private void removeDataNode(final Collection<MutableDataNodeRule> rules,
final Collection<String> schemaNames, final Collection<String>
tobeRemovedTables) {
diff --git
a/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java
b/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java
index 4a63ec40777..ff57857de21 100644
---
a/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java
+++
b/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDDLStatementVisitor.java
@@ -428,7 +428,7 @@ public final class OpenGaussDDLStatementVisitor extends
OpenGaussStatementVisito
ColumnDefinitionContext columnDefinition = ctx.columnDefinition();
if (null != columnDefinition) {
AddColumnDefinitionSegment addColumnDefinition = new
AddColumnDefinitionSegment(
- ctx.columnDefinition().getStart().getStartIndex(),
columnDefinition.getStop().getStopIndex(),
Collections.singletonList((ColumnDefinitionSegment) visit(columnDefinition)));
+ ctx.columnDefinition().getStart().getStartIndex(),
columnDefinition.getStop().getStopIndex(),
Collections.singleton((ColumnDefinitionSegment) visit(columnDefinition)));
result.getValue().add(addColumnDefinition);
}
return result;
@@ -488,7 +488,7 @@ public final class OpenGaussDDLStatementVisitor extends
OpenGaussStatementVisito
@Override
public ASTNode visitDropColumnSpecification(final
DropColumnSpecificationContext ctx) {
- return new DropColumnDefinitionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), Collections.singletonList((ColumnSegment)
visit(ctx.columnName())));
+ return new DropColumnDefinitionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), Collections.singleton((ColumnSegment)
visit(ctx.columnName())));
}
@Override
diff --git
a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
index 81a1cf628be..f965f31cec6 100644
---
a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
+++
b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDDLStatementVisitor.java
@@ -541,7 +541,7 @@ public final class PostgreSQLDDLStatementVisitor extends
PostgreSQLStatementVisi
ColumnDefinitionContext columnDefinition = ctx.columnDefinition();
if (null != columnDefinition) {
AddColumnDefinitionSegment addColumnDefinition = new
AddColumnDefinitionSegment(
- ctx.columnDefinition().getStart().getStartIndex(),
columnDefinition.getStop().getStopIndex(),
Collections.singletonList((ColumnDefinitionSegment) visit(columnDefinition)));
+ ctx.columnDefinition().getStart().getStartIndex(),
columnDefinition.getStop().getStopIndex(),
Collections.singleton((ColumnDefinitionSegment) visit(columnDefinition)));
result.getValue().add(addColumnDefinition);
}
return result;
@@ -601,7 +601,7 @@ public final class PostgreSQLDDLStatementVisitor extends
PostgreSQLStatementVisi
@Override
public ASTNode visitDropColumnSpecification(final
DropColumnSpecificationContext ctx) {
- return new DropColumnDefinitionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), Collections.singletonList((ColumnSegment)
visit(ctx.columnName())));
+ return new DropColumnDefinitionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), Collections.singleton((ColumnSegment)
visit(ctx.columnName())));
}
@Override
diff --git
a/parser/sql/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/type/SQL92DDLStatementVisitor.java
b/parser/sql/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/type/SQL92DDLStatementVisitor.java
index 56be358b2b2..d686dc21308 100644
---
a/parser/sql/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/type/SQL92DDLStatementVisitor.java
+++
b/parser/sql/dialect/sql92/src/main/java/org/apache/shardingsphere/sql/parser/sql92/visitor/statement/type/SQL92DDLStatementVisitor.java
@@ -205,8 +205,7 @@ public final class SQL92DDLStatementVisitor extends
SQL92StatementVisitor implem
@Override
public ASTNode visitDropColumnSpecification(final
DropColumnSpecificationContext ctx) {
- return new DropColumnDefinitionSegment(
- ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(),
Collections.singletonList((ColumnSegment) visit(ctx.columnName())));
+ return new DropColumnDefinitionSegment(ctx.getStart().getStartIndex(),
ctx.getStop().getStopIndex(), Collections.singleton((ColumnSegment)
visit(ctx.columnName())));
}
@SuppressWarnings("unchecked")
diff --git
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtils.java
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtils.java
index 08a62737d1a..6d69c31ae75 100644
---
a/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtils.java
+++
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtils.java
@@ -109,14 +109,14 @@ public final class ExpressionExtractUtils {
}
// TODO support more expression type if necessary
if (each instanceof BinaryOperationExpression) {
- extractParameterMarkerExpressions(result,
Collections.singletonList(((BinaryOperationExpression) each).getLeft()));
- extractParameterMarkerExpressions(result,
Collections.singletonList(((BinaryOperationExpression) each).getRight()));
+ extractParameterMarkerExpressions(result,
Collections.singleton(((BinaryOperationExpression) each).getLeft()));
+ extractParameterMarkerExpressions(result,
Collections.singleton(((BinaryOperationExpression) each).getRight()));
}
if (each instanceof FunctionSegment) {
extractParameterMarkerExpressions(result, ((FunctionSegment)
each).getParameters());
}
if (each instanceof TypeCastExpression) {
- extractParameterMarkerExpressions(result,
Collections.singletonList(((TypeCastExpression) each).getExpression()));
+ extractParameterMarkerExpressions(result,
Collections.singleton(((TypeCastExpression) each).getExpression()));
}
if (each instanceof InExpression) {
extractParameterMarkerExpressions(result, ((InExpression)
each).getExpressionList());
diff --git
a/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorTest.java
b/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorTest.java
index 164a05ffa10..0ca35e57dfa 100644
---
a/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorTest.java
+++
b/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ColumnExtractorTest.java
@@ -51,6 +51,6 @@ class ColumnExtractorTest {
new ColumnSegment(10, 13, new IdentifierValue("name")), new
LiteralExpressionSegment(18, 22, "LiLei"), "=", "name = 'LiLei'");
BinaryOperationExpression rightExpression = new
BinaryOperationExpression(30, 44,
new ColumnSegment(30, 32, new IdentifierValue("pwd")), new
LiteralExpressionSegment(40, 45, "123456"), "=", "pwd = '123456'");
- return Collections.singletonList(new WhereSegment(0, 0, new
BinaryOperationExpression(0, 0, leftExpression, rightExpression, "AND", "name =
'LiLei' AND pwd = '123456'")));
+ return Collections.singleton(new WhereSegment(0, 0, new
BinaryOperationExpression(0, 0, leftExpression, rightExpression, "AND", "name =
'LiLei' AND pwd = '123456'")));
}
}
diff --git
a/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtilsTest.java
b/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtilsTest.java
index 3f189a1ff33..173db7f1220 100644
---
a/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtilsTest.java
+++
b/parser/sql/statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/util/ExpressionExtractUtilsTest.java
@@ -121,14 +121,14 @@ class ExpressionExtractUtilsTest {
functionSegment.getParameters().add(param1);
functionSegment.getParameters().add(param2);
functionSegment.getParameters().add(param3);
- List<ParameterMarkerExpressionSegment> result =
ExpressionExtractUtils.getParameterMarkerExpressions(Collections.singletonList(functionSegment));
+ List<ParameterMarkerExpressionSegment> result =
ExpressionExtractUtils.getParameterMarkerExpressions(Collections.singleton(functionSegment));
assertThat(result.size(), is(1));
}
@Test
void assertGetParameterMarkerExpressionsFromTypeCastExpression() {
ParameterMarkerExpressionSegment expected = new
ParameterMarkerExpressionSegment(0, 0, 1, ParameterMarkerType.DOLLAR);
- List<ExpressionSegment> input = Collections.singletonList(new
TypeCastExpression(0, 0, "$2::varchar", expected, "varchar"));
+ Collection<ExpressionSegment> input = Collections.singleton(new
TypeCastExpression(0, 0, "$2::varchar", expected, "varchar"));
List<ParameterMarkerExpressionSegment> actual =
ExpressionExtractUtils.getParameterMarkerExpressions(input);
assertThat(actual.size(), is(1));
assertThat(actual.get(0), is(expected));
@@ -139,7 +139,7 @@ class ExpressionExtractUtilsTest {
ListExpression listExpression = new ListExpression(0, 0);
listExpression.getItems().add(new ParameterMarkerExpressionSegment(0,
0, 1, ParameterMarkerType.QUESTION));
listExpression.getItems().add(new ParameterMarkerExpressionSegment(0,
0, 2, ParameterMarkerType.QUESTION));
- List<ExpressionSegment> inExpressions = Collections.singletonList(new
InExpression(0, 0, new ColumnSegment(0, 0, new IdentifierValue("order_id")),
listExpression, false));
+ Collection<ExpressionSegment> inExpressions =
Collections.singleton(new InExpression(0, 0, new ColumnSegment(0, 0, new
IdentifierValue("order_id")), listExpression, false));
List<ParameterMarkerExpressionSegment> actual =
ExpressionExtractUtils.getParameterMarkerExpressions(inExpressions);
assertThat(actual.size(), is(2));
}
diff --git
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
index 22f72c543a1..4cc07bb9794 100644
---
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
+++
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/RefreshTableMetaDataUpdater.java
@@ -65,7 +65,7 @@ public final class RefreshTableMetaDataUpdater implements
ConnectionSessionRequi
if (sqlStatement.getStorageUnitName().isPresent()) {
String storageUnitName = sqlStatement.getStorageUnitName().get();
ShardingSpherePreconditions.checkState(
- storageUnits.containsKey(storageUnitName), () -> new
MissingRequiredStorageUnitsException(databaseName,
Collections.singletonList(storageUnitName)));
+ storageUnits.containsKey(storageUnitName), () -> new
MissingRequiredStorageUnitsException(databaseName,
Collections.singleton(storageUnitName)));
}
}