You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/09/01 06:33:16 UTC
(shardingsphere) branch master updated: Enforce static import rules with Checkstyle (#39675)
This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 48730d8a405 Enforce static import rules with Checkstyle (#39675)
48730d8a405 is described below
commit 48730d8a405db5d65f570700357fadbafc5047fa
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Sep 1 14:33:08 2026 +0800
Enforce static import rules with Checkstyle (#39675)
* Remove StringUtils usages and prohibit StringUtils and CollectionUtils imports
* Remove StringUtils usages and prohibit StringUtils and CollectionUtils imports
* Enforce static import rules with Checkstyle
---
CODE_OF_CONDUCT.md | 1 -
.../data/loader/FirebirdMetaDataLoaderTest.java | 3 +-
.../FirebirdBlobBinaryProtocolValueTest.java | 9 ++--
.../FirebirdByteBinaryProtocolValueTest.java | 3 +-
.../FirebirdInt16BinaryProtocolValueTest.java | 3 +-
.../FirebirdStringBinaryProtocolValueTest.java | 3 +-
.../execute/MySQLComStmtExecutePacketTest.java | 5 +-
.../query/text/query/MySQLComQueryPacketTest.java | 5 +-
docs/community/content/involved/conduct/code.cn.md | 1 -
docs/community/content/involved/conduct/code.en.md | 1 -
.../CreateBroadcastTableRuleExecutorTest.java | 8 +--
.../encrypt/merge/dql/EncryptMergedResultTest.java | 11 +++--
.../changed/EncryptTableChangedProcessorTest.java | 4 +-
.../changed/EncryptorChangedProcessorTest.java | 4 +-
.../rule/column/item/CipherColumnItemTest.java | 11 +++--
.../update/AlterEncryptRuleExecutorTest.java | 10 ++--
.../update/CreateEncryptRuleExecutorTest.java | 4 +-
.../update/DropEncryptRuleExecutorTest.java | 8 +--
.../changed/MaskAlgorithmChangedProcessorTest.java | 4 +-
.../changed/MaskTableChangedProcessorTest.java | 4 +-
.../handler/update/CreateMaskRuleExecutorTest.java | 6 +--
.../handler/update/DropMaskRuleExecutorTest.java | 8 +--
...SplittingStaticDataSourceRuleAttributeTest.java | 8 +--
...iteSplittingDataSourceChangedProcessorTest.java | 6 +--
...eSplittingLoadBalancerChangedProcessorTest.java | 4 +-
...adwriteSplittingRuleStatementConverterTest.java | 8 +--
...teStatementDataSourceMappingsRetrieverTest.java | 4 +-
...rtStatementDataSourceMappingsRetrieverTest.java | 4 +-
...teStatementDataSourceMappingsRetrieverTest.java | 4 +-
.../ShadowAlgorithmChangedProcessorTest.java | 4 +-
.../ShadowDataSourceChangedProcessorTest.java | 4 +-
.../changed/ShadowTableChangedProcessorTest.java | 4 +-
...tabaseShardingStrategyChangedProcessorTest.java | 4 +-
...ultKeyGenerateStrategyChangedProcessorTest.java | 4 +-
...hardingAuditorStrategyChangedProcessorTest.java | 4 +-
...tTableShardingStrategyChangedProcessorTest.java | 4 +-
.../changed/KeyGeneratorChangedProcessorTest.java | 4 +-
.../ShardingAlgorithmChangedProcessorTest.java | 4 +-
.../ShardingAuditorChangedProcessorTest.java | 4 +-
.../ShardingAutoTableChangedProcessorTest.java | 4 +-
.../changed/ShardingTableChangedProcessorTest.java | 4 +-
...ShardingTableReferenceChangedProcessorTest.java | 4 +-
.../ShowShardingKeyGeneratorExecutorTest.java | 4 +-
.../processor/AlgorithmChangedProcessorTest.java | 4 +-
.../schema/model/ShardingSphereTableTest.java | 9 ++--
.../ShardingSphereStatisticsFactoryTest.java | 2 +-
.../data/swapper/YamlRowStatisticsSwapperTest.java | 6 +--
.../yaml/schema/swapper/YamlTableSwapperTest.java | 8 +--
.../yaml/schema/swapper/YamlViewSwapperTest.java | 6 +--
.../pool/creator/DataSourcePoolCreatorTest.java | 9 ++--
.../destroyer/DataSourcePoolDestroyerTest.java | 4 +-
.../kernel/thread/ExecutorServiceManagerTest.java | 4 +-
.../sql/process/lock/ProcessOperationLockTest.java | 12 ++++-
.../MySQLToBeRemovedSegmentsProviderTest.java | 5 +-
.../spi/type/ordered/OrderedSPILoaderTest.java | 22 ++++-----
.../CRC32TableInventoryCheckCalculatorTest.java | 2 +-
.../core/execute/PipelineExecuteEngineTest.java | 49 ++++++++++++-------
.../type/pk/UniqueKeyIngestPositionTest.java | 11 ++---
.../client/netty/MySQLNegotiateHandlerTest.java | 4 +-
.../data/pipeline/cdc/api/CDCJobAPITest.java | 10 ++--
.../YamlCDCJobConfigurationSwapperTest.java | 6 +--
.../collect/StatisticsCollectJobWorkerTest.java | 2 +-
...tDefaultSingleTableStorageUnitExecutorTest.java | 8 +--
.../operator/physical/EnumerableModifyTest.java | 3 +-
.../memory/MemoryTableStatisticsBuilderTest.java | 7 +--
.../natived/NativeSQLTranslatorTest.java | 4 +-
.../handler/MetadataCompletionHandlerTest.java | 2 +-
.../metadata/model/MCPMetadataSnapshotTest.java | 4 +-
...ContextManagerLifecycleListenerFactoryTest.java | 4 +-
.../factory/MetaDataContextsFactoryTest.java | 8 +--
...isterCenterMetaDataContextsInitFactoryTest.java | 6 +--
.../resource/ResourceSwitchManagerTest.java | 9 ++--
.../statistics/StatisticsPersistServiceTest.java | 4 +-
.../AlterViewFederationMetaDataRefresherTest.java | 5 +-
.../CreateViewFederationMetaDataRefresherTest.java | 3 +-
.../AlterSchemaPushDownMetaDataRefresherTest.java | 5 +-
.../CreateSchemaPushDownMetaDataRefresherTest.java | 3 +-
.../RenameTablePushDownMetaDataRefresherTest.java | 3 +-
.../YamlRuleConfigurationReflectionEngineTest.java | 9 ++--
...medRuleItemConfigurationChangedHandlerTest.java | 9 ++--
...queRuleItemConfigurationChangedHandlerTest.java | 11 +++--
...tandaloneMetaDataManagerPersistServiceTest.java | 8 +--
.../standalone/jdbc/JDBCRepositoryTest.java | 4 +-
.../ProxyDatabaseConnectionManagerTest.java | 3 +-
.../backend/connector/ProxySQLExecutorTest.java | 10 ++--
.../StandardDatabaseProxyConnectorTest.java | 6 +--
.../ProxyBackendTransactionManagerTest.java | 3 +-
.../updatable/lock/LockClusterExecutorTest.java | 6 +--
.../updatable/lock/UnlockClusterExecutorTest.java | 6 +--
.../executor/MySQLKillProcessExecutorTest.java | 2 +-
.../FirebirdAuthenticationEngineTest.java | 3 +-
.../FirebirdBatchExecuteCommandExecutorTest.java | 13 +++--
.../FirebirdBatchedStatementsExecutorTest.java | 37 +++++++-------
.../FirebirdStatementResourceCleanerTest.java | 3 +-
...irebirdExecuteStatementCommandExecutorTest.java | 3 +-
.../FirebirdConnectionResourceManagerTest.java | 5 +-
.../binary/MySQLServerPreparedStatementTest.java | 6 +--
.../execute/MySQLComStmtExecuteExecutorTest.java | 7 ++-
.../prepare/MySQLComStmtPrepareExecutorTest.java | 4 +-
.../MySQLComQueryBackendHandlerFactoryTest.java | 11 ++---
.../MySQLComQueryBinaryParameterExtractorTest.java | 23 +++++----
src/resources/checkstyle.xml | 11 +++--
.../DistSQLDatabaseRuleQueryExecutorAssert.java | 4 +-
.../DistSQLGlobalRuleQueryExecutorAssert.java | 4 +-
.../DistSQLGlobalRuleDefinitionExecutorAssert.java | 4 +-
.../type/DorisDescFunctionStatementAssert.java | 4 +-
.../type/DorisPlanReplayerPlayStatementAssert.java | 4 +-
.../DorisShowCreateRoutineLoadStatementAssert.java | 6 +--
.../type/DorisShowDatabaseStatementAssert.java | 4 +-
.../doris/type/DorisShowProcStatementAssert.java | 4 +-
.../doris/type/DorisShowTableStatementAssert.java | 4 +-
.../type/DorisUnsetVariableStatementAssert.java | 6 +--
.../doris/DorisPauseSyncJobStatementAssert.java | 4 +-
.../doris/DorisResumeSyncJobStatementAssert.java | 4 +-
.../dialect/oracle/OracleDDLStatementAssert.java | 7 ++-
.../DorisAlterRoutineLoadStatementAssert.java | 23 +++++----
.../doris/DorisBrokerLoadStatementAssert.java | 57 +++++++++++-----------
.../DorisCreateRoutineLoadStatementAssert.java | 29 ++++++-----
.../DorisPauseRoutineLoadStatementAssert.java | 6 +--
.../DorisResumeRoutineLoadStatementAssert.java | 6 +--
.../doris/DorisStopRoutineLoadStatementAssert.java | 4 +-
.../mysql/type/MySQLLoadDataStatementAssert.java | 31 ++++++------
.../test/it/yaml/YamlRuleConfigurationIT.java | 8 +--
.../test/natived/commons/TestShardingService.java | 8 ++-
124 files changed, 456 insertions(+), 441 deletions(-)
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 233f0a95597..e3c76315fe5 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -105,7 +105,6 @@ The following code of conduct is based on full compliance with the [Apache Softw
- Each test case needs precise assertions, try not to use `not`, `containsString` assertions.
- Use JUnit 5 and Mockito. Keep environment preparation, test action, and assertions distinct; reset static state between scenarios and reuse existing swappers or helpers for complex configuration.
- Default to direct Mockito mocks. Use a private helper only for repeated local setup and a standalone fixture only for a stable external or packaged test boundary. Give fixtures the narrowest practical visibility, keep them in the nearest owning test package or module, and do not create cross-module test APIs for convenience. Delete or inline thin mock wrappers.
-- Only Mockito, junit `Assertions`, hamcrest `CoreMatchers` and `MatcherAssert` related can use static import.
- Data assertion standards should follow:
- Boolean type assertions should use `assertTrue` and `assertFalse`;
- Null value assertions should use `assertNull` and `assertNotNull`;
diff --git a/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdMetaDataLoaderTest.java b/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdMetaDataLoaderTest.java
index 2170837fbc0..244802b733b 100644
--- a/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdMetaDataLoaderTest.java
+++ b/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdMetaDataLoaderTest.java
@@ -40,7 +40,6 @@ import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
@@ -73,7 +72,7 @@ class FirebirdMetaDataLoaderTest {
mockConstruction(FirebirdBlobColumnLoader.class, (mock, context) -> when(mock.load()).thenReturn(allBlobColumns))) {
tableLoaderMocked.when(() -> TableMetaDataLoader.loadNormalized(dataSource, "TEST_TABLE", databaseType)).thenReturn(Optional.of(tableMetaData));
Collection<SchemaMetaData> actual = dialectMetaDataLoader.load(material);
- assertThat(actual, hasSize(1));
+ assertThat(actual.size(), is(1));
SchemaMetaData schema = actual.iterator().next();
assertThat(schema.getName(), is("schema"));
assertThat(schema.getTables(), contains(tableMetaData));
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBlobBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBlobBinaryProtocolValueTest.java
index 233f54b9750..60d0312f38e 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBlobBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBlobBinaryProtocolValueTest.java
@@ -36,7 +36,6 @@ import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -68,7 +67,7 @@ class FirebirdBlobBinaryProtocolValueTest {
@Test
void assertContentIsScopedByConnection() {
long blobId = writeAndGetBlobId(new byte[]{1, 2});
- assertArrayEquals(new byte[]{1, 2}, FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId));
+ assertThat(FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId), is(new byte[]{1, 2}));
assertNull(FirebirdBlobBinaryProtocolValue.getBlobContent(2, blobId));
}
@@ -87,7 +86,7 @@ class FirebirdBlobBinaryProtocolValueTest {
new FirebirdBlobBinaryProtocolValue().write(payload, value);
long blobId = byteBuf.getLong(0);
assertTrue(blobId < 0);
- assertArrayEquals(expected, FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId));
+ assertThat(FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId), is(expected));
}
@Test
@@ -117,7 +116,7 @@ class FirebirdBlobBinaryProtocolValueTest {
new FirebirdBlobBinaryProtocolValue().write(payload, blob);
long blobId = byteBuf.getLong(0);
assertTrue(blobId < 0);
- assertArrayEquals(new byte[]{0, 0}, FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId));
+ assertThat(FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId), is(new byte[]{0, 0}));
}
@Test
@@ -150,7 +149,7 @@ class FirebirdBlobBinaryProtocolValueTest {
new FirebirdBlobBinaryProtocolValue().write(payload, clob);
long blobId = byteBuf.getLong(0);
assertTrue(blobId < 0);
- assertArrayEquals(new byte[]{120, 121, 122}, FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId));
+ assertThat(FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobId), is(new byte[]{120, 121, 122}));
}
@Test
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
index 312df00a5e1..648dc28beee 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdByteBinaryProtocolValueTest.java
@@ -27,7 +27,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -44,7 +43,7 @@ class FirebirdByteBinaryProtocolValueTest {
void assertRead() {
byte[] expected = {1, 2};
when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(expected));
- assertArrayEquals(expected, (byte[]) new FirebirdByteBinaryProtocolValue().read(payload));
+ assertThat((byte[]) new FirebirdByteBinaryProtocolValue().read(payload), is(expected));
}
@Test
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdInt16BinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdInt16BinaryProtocolValueTest.java
index 647a928a525..11dd2114fe3 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdInt16BinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdInt16BinaryProtocolValueTest.java
@@ -35,7 +35,6 @@ import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -65,7 +64,7 @@ class FirebirdInt16BinaryProtocolValueTest {
new FirebirdInt16BinaryProtocolValue().write(actualPayload, value);
byte[] actual = new byte[16];
actualBuffer.getBytes(0, actual);
- assertArrayEquals(expected, actual);
+ assertThat(actual, is(expected));
}
@Test
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdStringBinaryProtocolValueTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdStringBinaryProtocolValueTest.java
index 03bbbe99bd2..ec387951193 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdStringBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdStringBinaryProtocolValueTest.java
@@ -33,7 +33,6 @@ import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -59,7 +58,7 @@ class FirebirdStringBinaryProtocolValueTest {
new FirebirdStringBinaryProtocolValue().write(actualPayload, value);
byte[] actual = new byte[actualBuffer.writerIndex()];
actualBuffer.getBytes(0, actual);
- assertArrayEquals(expected, actual);
+ assertThat(actual, is(expected));
}
@Test
diff --git a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacketTest.java b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacketTest.java
index 7f4223f6df4..ca174473977 100644
--- a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacketTest.java
+++ b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/MySQLComStmtExecutePacketTest.java
@@ -39,7 +39,6 @@ import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -139,7 +138,7 @@ class MySQLComStmtExecutePacketTest {
List<MySQLPreparedStatementParameterType> parameterTypes = actual.getNewParameterTypes();
Object actualValue = actual.readParameters(parameterTypes, Collections.emptySet(), Collections.singletonList(parameterColumnType)).get(0);
assertTrue(actualValue instanceof byte[]);
- assertArrayEquals(new byte[]{(byte) 0xac, (byte) 0xed, (byte) 0xff}, (byte[]) actualValue);
+ assertThat((byte[]) actualValue, is(new byte[]{(byte) 0xac, (byte) 0xed, (byte) 0xff}));
}
private static Stream<Arguments> stringParameterTypesBoundToBlobColumnsArguments() {
@@ -173,7 +172,7 @@ class MySQLComStmtExecutePacketTest {
assertThat(actualValue, is("a"));
return;
}
- assertArrayEquals(new byte[]{0x61}, (byte[]) actualValue);
+ assertThat((byte[]) actualValue, is(new byte[]{0x61}));
}
private static Stream<Arguments> stringDecodingArguments() {
diff --git a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/text/query/MySQLComQueryPacketTest.java b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/text/query/MySQLComQueryPacketTest.java
index baa2b461b07..0340839f943 100644
--- a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/text/query/MySQLComQueryPacketTest.java
+++ b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/text/query/MySQLComQueryPacketTest.java
@@ -32,7 +32,6 @@ import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -60,7 +59,7 @@ class MySQLComQueryPacketTest {
MySQLComQueryPacket actual = new MySQLComQueryPacket(payload);
assertThat(actual.getSQL(), is(expectedSQL));
assertThat(actual.getHintValueContext().isWriteRouteOnly(), is(expectedWriteRouteOnly));
- assertArrayEquals(inputSQL.getBytes(StandardCharsets.UTF_8), actual.findOriginalSQLBytes().get());
+ assertThat(actual.findOriginalSQLBytes().get(), is(inputSQL.getBytes(StandardCharsets.UTF_8)));
}
@Test
@@ -69,7 +68,7 @@ class MySQLComQueryPacketTest {
when(payload.readStringEOFByBytes()).thenReturn(sql);
when(payload.getCharset()).thenReturn(StandardCharsets.UTF_8);
MySQLComQueryPacket actual = new MySQLComQueryPacket(payload);
- assertArrayEquals(sql, actual.findOriginalSQLBytes().get());
+ assertThat(actual.findOriginalSQLBytes().get(), is(sql));
}
@Test
diff --git a/docs/community/content/involved/conduct/code.cn.md b/docs/community/content/involved/conduct/code.cn.md
index 2ee32d2d0bb..a192ce33008 100644
--- a/docs/community/content/involved/conduct/code.cn.md
+++ b/docs/community/content/involved/conduct/code.cn.md
@@ -110,7 +110,6 @@ chapter = true
- 每个测试用例需精确断言,尽量不使用 `not`、`containsString` 断言。
- 使用 JUnit 5 和 Mockito。 明确区分环境准备、测试执行和断言;不同场景之间应重置静态状态,并复用现有的 swapper 或辅助工具处理复杂配置。
- 默认直接使用 Mockito mock。 仅对重复的局部准备使用私有辅助方法,仅对稳定的外部测试边界或打包测试边界使用独立测试夹具。 测试夹具应采用实际可行的最小可见性,并放在最近的所属测试包或模块中;不要为了方便而创建跨模块测试 API。 删除或内联内容单薄的 mock 包装器。
- - 只有 Mockito,junit `Assertions`,hamcrest `CoreMatchers` 和 `MatcherAssert` 相关可以使用 static import。
- 数据断言规范应遵循:
- 布尔类型断言应使用 `assertTrue` 和 `assertFalse`;
- 空值断言应使用 `assertNull` 和 `assertNotNull`;
diff --git a/docs/community/content/involved/conduct/code.en.md b/docs/community/content/involved/conduct/code.en.md
index 5a86c7c3a57..4aa9b99b7eb 100644
--- a/docs/community/content/involved/conduct/code.en.md
+++ b/docs/community/content/involved/conduct/code.en.md
@@ -110,7 +110,6 @@ The following code of conduct is based on full compliance with the [Apache Softw
- Each test case needs precise assertions, try not to use `not`, `containsString` assertions.
- Use JUnit 5 and Mockito. Keep environment preparation, test action, and assertions distinct; reset static state between scenarios and reuse existing swappers or helpers for complex configuration.
- Default to direct Mockito mocks. Use a private helper only for repeated local setup and a standalone fixture only for a stable external or packaged test boundary. Give fixtures the narrowest practical visibility, keep them in the nearest owning test package or module, and do not create cross-module test APIs for convenience. Delete or inline thin mock wrappers.
-- Only Mockito, junit `Assertions`, hamcrest `CoreMatchers` and `MatcherAssert` related can use static import.
- Data assertion standards should follow:
- Boolean type assertions should use `assertTrue` and `assertFalse`;
- Null value assertions should use `assertNull` and `assertNotNull`;
diff --git a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
index acf46ef3248..0664a65467d 100644
--- a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
+++ b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/update/CreateBroadcastTableRuleExecutorTest.java
@@ -29,7 +29,6 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -39,6 +38,7 @@ import java.util.HashSet;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -82,7 +82,7 @@ class CreateBroadcastTableRuleExecutorTest {
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
verify(metaDataManagerPersistService).alterRuleConfiguration(any(),
- ArgumentMatchers.<BroadcastRuleConfiguration>argThat(x -> x.getTables().equals(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl")))));
+ argThat((BroadcastRuleConfiguration x) -> x.getTables().equals(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl")))));
}
@Test
@@ -95,7 +95,7 @@ class CreateBroadcastTableRuleExecutorTest {
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
verify(metaDataManagerPersistService).alterRuleConfiguration(any(),
- ArgumentMatchers.<BroadcastRuleConfiguration>argThat(x -> x.getTables().equals(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl")))));
+ argThat((BroadcastRuleConfiguration x) -> x.getTables().equals(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl")))));
}
@Test
@@ -106,7 +106,7 @@ class CreateBroadcastTableRuleExecutorTest {
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
verify(metaDataManagerPersistService).alterRuleConfiguration(any(),
- ArgumentMatchers.<BroadcastRuleConfiguration>argThat(x -> x.getTables().equals(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl")))));
+ argThat((BroadcastRuleConfiguration x) -> x.getTables().equals(new HashSet<>(Arrays.asList("foo_tbl", "bar_tbl")))));
}
private ContextManager mockContextManager(final ShardingSphereDatabase database, final BroadcastRule rule) {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
index a4f40a8e375..9a14e06d9c8 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
@@ -34,6 +34,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.enums.TableSourceType
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.ColumnSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.bound.TableSegmentBoundInfo;
import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
@@ -51,7 +52,6 @@ import java.util.Date;
import java.util.Optional;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -114,7 +114,8 @@ class EncryptMergedResultTest {
when(selectStatementContext.findColumnBoundInfo(1)).thenReturn(Optional.of(columnSegmentBoundInfo));
when(selectStatementContext.getTablesContext().getSchemaName()).thenReturn(Optional.of("foo_schema"));
EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
- when(encryptAlgorithm.decrypt(eq("foo_value"), deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col")))).thenReturn("foo_decrypted_value");
+ when(encryptAlgorithm.decrypt(eq("foo_value"), ShardingSphereArgumentVerifyMatchers.deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col"))))
+ .thenReturn("foo_decrypted_value");
EncryptRule rule = mockRule(encryptAlgorithm);
ShardingSphereDatabase database =
new ShardingSphereDatabase("foo_db", mock(), mock(), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList(), new ConfigurationProperties(new Properties()));
@@ -131,7 +132,8 @@ class EncryptMergedResultTest {
when(selectStatementContext.findColumnBoundInfo(1)).thenReturn(Optional.of(columnSegmentBoundInfo));
when(selectStatementContext.getTablesContext().getSchemaName()).thenReturn(Optional.empty());
EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
- when(encryptAlgorithm.decrypt(eq("foo_value"), deepEq(new AlgorithmSQLContext("foo_db", "foo_default_schema", "foo_tbl", "foo_col")))).thenReturn("foo_decrypted_value");
+ when(encryptAlgorithm.decrypt(eq("foo_value"), ShardingSphereArgumentVerifyMatchers.deepEq(new AlgorithmSQLContext("foo_db", "foo_default_schema", "foo_tbl", "foo_col"))))
+ .thenReturn("foo_decrypted_value");
EncryptRule rule = mockRule(encryptAlgorithm);
ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
when(database.getName()).thenReturn("foo_db");
@@ -149,7 +151,8 @@ class EncryptMergedResultTest {
when(selectStatementContext.findColumnBoundInfo(1)).thenReturn(Optional.of(columnSegmentBoundInfo));
when(selectStatementContext.getTablesContext().getSchemaName()).thenReturn(Optional.of("foo_schema"));
EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
- when(encryptAlgorithm.decrypt(eq("foo_value"), deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col")))).thenThrow(new RuntimeException("Test failed"));
+ when(encryptAlgorithm.decrypt(eq("foo_value"), ShardingSphereArgumentVerifyMatchers.deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col"))))
+ .thenThrow(new RuntimeException("Test failed"));
EncryptRule rule = mockRule(encryptAlgorithm);
ShardingSphereDatabase database =
new ShardingSphereDatabase("foo_db", mock(), mock(), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList(), new ConfigurationProperties(new Properties()));
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessorTest.java
index 739036eedf3..ded4f8ef55b 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptTableChangedProcessorTest.java
@@ -31,13 +31,13 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -53,7 +53,7 @@ class EncryptTableChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
EncryptTableRuleConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new EncryptTableRuleConfiguration("foo_tbl",
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new EncryptTableRuleConfiguration("foo_tbl",
Collections.singletonList(new EncryptColumnRuleConfiguration("foo_col", new EncryptColumnItemRuleConfiguration("foo_col_cipher", "foo_algo"))))));
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessorTest.java
index d9af5a28820..d7362f44adc 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/changed/EncryptorChangedProcessorTest.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -32,7 +33,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class EncryptorChangedProcessorTest {
@SuppressWarnings("CollectionWithoutInitialCapacity")
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new EncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new EncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/column/item/CipherColumnItemTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/column/item/CipherColumnItemTest.java
index b7332d521cf..d58d7b8e3ee 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/column/item/CipherColumnItemTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/column/item/CipherColumnItemTest.java
@@ -19,11 +19,11 @@ package org.apache.shardingsphere.encrypt.rule.column.item;
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.infra.algorithm.core.context.AlgorithmSQLContext;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -42,7 +42,8 @@ class CipherColumnItemTest {
@Test
void assertEncryptSingleValue() {
EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
- when(encryptAlgorithm.encrypt(eq("foo_value"), deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col")))).thenReturn("encrypted_foo_value");
+ when(encryptAlgorithm.encrypt(eq("foo_value"), ShardingSphereArgumentVerifyMatchers.deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col"))))
+ .thenReturn("encrypted_foo_value");
CipherColumnItem cipherColumnItem = new CipherColumnItem("foo_col", encryptAlgorithm);
assertThat(cipherColumnItem.encrypt("foo_db", "foo_schema", "foo_tbl", "foo_col", "foo_value"), is("encrypted_foo_value"));
}
@@ -50,7 +51,8 @@ class CipherColumnItemTest {
@Test
void assertEncryptMultipleValues() {
EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
- when(encryptAlgorithm.encrypt(eq("foo_value"), deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col")))).thenReturn("encrypted_foo_value");
+ when(encryptAlgorithm.encrypt(eq("foo_value"), ShardingSphereArgumentVerifyMatchers.deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col"))))
+ .thenReturn("encrypted_foo_value");
CipherColumnItem cipherColumnItem = new CipherColumnItem("foo_col", encryptAlgorithm);
assertThat(cipherColumnItem.encrypt("foo_db", "foo_schema", "foo_tbl", "foo_col", Arrays.asList(null, "foo_value")), is(Arrays.asList(null, "encrypted_foo_value")));
}
@@ -63,7 +65,8 @@ class CipherColumnItemTest {
@Test
void assertDecrypt() {
EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class, RETURNS_DEEP_STUBS);
- when(encryptAlgorithm.decrypt(eq("encrypted_foo_value"), deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col")))).thenReturn("foo_value");
+ when(encryptAlgorithm.decrypt(eq("encrypted_foo_value"), ShardingSphereArgumentVerifyMatchers.deepEq(new AlgorithmSQLContext("foo_db", "foo_schema", "foo_tbl", "foo_col"))))
+ .thenReturn("foo_value");
CipherColumnItem cipherColumnItem = new CipherColumnItem("foo_col", encryptAlgorithm);
assertThat(cipherColumnItem.decrypt("foo_db", "foo_schema", "foo_tbl", "foo_col", "encrypted_foo_value"), is("foo_value"));
}
diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
index e649b077de2..a6ac6fb2068 100644
--- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
+++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleExecutorTest.java
@@ -36,7 +36,6 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.Collections;
@@ -49,6 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -95,8 +95,8 @@ class AlterEncryptRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
new DistSQLUpdateExecuteEngine(createSQLStatementWithAssistQueryAndLikeColumns(), "foo_db", contextManager, null).executeUpdate();
- metaDataManagerPersistService.removeRuleConfigurationItem(any(), ArgumentMatchers.argThat(this::assertToBeDroppedRuleConfiguration));
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertToBeAlteredRuleConfiguration)));
+ metaDataManagerPersistService.removeRuleConfigurationItem(any(), argThat(this::assertToBeDroppedRuleConfiguration));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertToBeAlteredRuleConfiguration)));
}
@Test
@@ -107,8 +107,8 @@ class AlterEncryptRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(createSQLStatementWithoutAssistQueryAndLikeColumns(), "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- metaDataManagerPersistService.removeRuleConfigurationItem(any(), ArgumentMatchers.argThat(this::assertToBeDroppedRuleConfiguration));
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertToBeAlteredRuleConfiguration)));
+ metaDataManagerPersistService.removeRuleConfigurationItem(any(), argThat(this::assertToBeDroppedRuleConfiguration));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertToBeAlteredRuleConfiguration)));
}
private ContextManager mockContextManager(final EncryptRule rule) {
diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
index 8c76caf971d..6c145014b00 100644
--- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
+++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleExecutorTest.java
@@ -36,7 +36,6 @@ import org.apache.shardingsphere.infra.util.props.PropertiesBuilder.Property;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.Arrays;
@@ -48,6 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
@@ -102,7 +102,7 @@ class CreateEncryptRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertIfNotExistsRuleConfiguration)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertIfNotExistsRuleConfiguration)));
}
private CreateEncryptRuleStatement createAESEncryptRuleSQLStatement() {
diff --git a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
index b33611a0962..0f8dca1b443 100644
--- a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
+++ b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/DropEncryptRuleExecutorTest.java
@@ -32,7 +32,6 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.Arrays;
@@ -49,6 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -71,7 +71,7 @@ class DropEncryptRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(createSQLStatement("T_ENCRYPT"), "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfiguration)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfiguration)));
}
@Test
@@ -101,7 +101,7 @@ class DropEncryptRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(createSQLStatement("T_ENCRYPT"), "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfigurationWithoutEncryptors)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfigurationWithoutEncryptors)));
}
private boolean assertRuleConfigurationWithoutEncryptors(final EncryptRuleConfiguration actual) {
@@ -119,7 +119,7 @@ class DropEncryptRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(statement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfigurationWithoutEncryptors)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfigurationWithoutEncryptors)));
}
private DropEncryptRuleStatement createSQLStatement(final String tableName) {
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessorTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessorTest.java
index 89367a0fe5a..eee9da4871e 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessorTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskAlgorithmChangedProcessorTest.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -32,7 +33,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class MaskAlgorithmChangedProcessorTest {
@SuppressWarnings("CollectionWithoutInitialCapacity")
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new MaskRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new MaskRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessorTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessorTest.java
index e1942a144be..c9799f90ff1 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessorTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/changed/MaskTableChangedProcessorTest.java
@@ -29,13 +29,13 @@ import org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskColumnRuleConfigu
import org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -51,7 +51,7 @@ class MaskTableChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
MaskTableRuleConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new MaskTableRuleConfiguration("foo_tbl", Collections.singletonList(new MaskColumnRuleConfiguration("foo_col", "foo_algo")))));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new MaskTableRuleConfiguration("foo_tbl", Collections.singletonList(new MaskColumnRuleConfiguration("foo_col", "foo_algo")))));
}
private String createYAMLContent() {
diff --git a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
index b070c7c605e..2b4ca444c36 100644
--- a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
+++ b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleExecutorTest.java
@@ -31,7 +31,6 @@ import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.Collection;
@@ -45,6 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -67,7 +67,7 @@ class CreateMaskRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfiguration)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfiguration)));
}
@Test
@@ -79,7 +79,7 @@ class CreateMaskRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfiguration)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfiguration)));
}
private CreateMaskRuleStatement createSQLStatement(final boolean ifNotExists, final String algorithmType) {
diff --git a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
index a6260ccaac0..6dc5352e77e 100644
--- a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
+++ b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/DropMaskRuleExecutorTest.java
@@ -30,7 +30,6 @@ import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.Collections;
@@ -43,6 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -64,7 +64,7 @@ class DropMaskRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(createSQLStatement(false, "T_MASK"), "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfigurationWithoutIfExists)));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfigurationWithoutIfExists)));
}
private boolean assertRuleConfigurationWithoutIfExists(final MaskRuleConfiguration actual) {
@@ -82,8 +82,8 @@ class DropMaskRuleExecutorTest {
ContextManager contextManager = mockContextManager(rule);
new DistSQLUpdateExecuteEngine(createSQLStatement(true, "T_USER"), "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfigurationWithoutIfExists));
- assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), ArgumentMatchers.argThat(this::assertRuleConfigurationWithIfExists)));
+ metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfigurationWithoutIfExists));
+ assertDoesNotThrow(() -> metaDataManagerPersistService.alterRuleConfiguration(any(), argThat(this::assertRuleConfigurationWithIfExists)));
}
private DropMaskRuleStatement createSQLStatement(final boolean ifExists, final String tableName) {
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/attribute/ReadwriteSplittingStaticDataSourceRuleAttributeTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/attribute/ReadwriteSplittingStaticDataSourceRuleAttributeTest.java
index f38cd8006fb..91aab774899 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/attribute/ReadwriteSplittingStaticDataSourceRuleAttributeTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/attribute/ReadwriteSplittingStaticDataSourceRuleAttributeTest.java
@@ -23,11 +23,11 @@ import org.apache.shardingsphere.infra.state.datasource.DataSourceState;
import org.apache.shardingsphere.readwritesplitting.deliver.QualifiedDataSourceDeletedEvent;
import org.apache.shardingsphere.readwritesplitting.exception.logic.ReadwriteSplittingDataSourceRuleNotFoundException;
import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingDataSourceGroupRule;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -75,7 +75,8 @@ class ReadwriteSplittingStaticDataSourceRuleAttributeTest {
ReadwriteSplittingStaticDataSourceRuleAttribute ruleAttribute = new ReadwriteSplittingStaticDataSourceRuleAttribute(
"foo_db", Collections.singletonMap("foo_group", dataSourceGroupRule), computeNodeInstanceContext);
ruleAttribute.cleanStorageNodeDataSource("foo_group");
- verify(computeNodeInstanceContext.getEventBusContext()).post(deepEq(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
+ verify(computeNodeInstanceContext.getEventBusContext())
+ .post(ShardingSphereArgumentVerifyMatchers.deepEq(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
}
@Test
@@ -87,6 +88,7 @@ class ReadwriteSplittingStaticDataSourceRuleAttributeTest {
ReadwriteSplittingStaticDataSourceRuleAttribute ruleAttribute = new ReadwriteSplittingStaticDataSourceRuleAttribute(
"foo_db", Collections.singletonMap("foo_group", dataSourceGroupRule), computeNodeInstanceContext);
ruleAttribute.cleanStorageNodeDataSources();
- verify(computeNodeInstanceContext.getEventBusContext()).post(deepEq(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
+ verify(computeNodeInstanceContext.getEventBusContext())
+ .post(ShardingSphereArgumentVerifyMatchers.deepEq(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
}
}
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessorTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessorTest.java
index b020721d979..dd682e1b3e3 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessorTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingDataSourceChangedProcessorTest.java
@@ -28,13 +28,13 @@ import org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplitti
import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy;
import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -50,13 +50,13 @@ class ReadwriteSplittingDataSourceChangedProcessorTest {
@Test
void assertSwapRuleItemConfigurationWithoutTransactionalReadQueryStrategy() {
ReadwriteSplittingDataSourceGroupRuleConfiguration actual = processor.swapRuleItemConfiguration("foo", createYAMLContent(null));
- assertThat(actual, deepEqual(new ReadwriteSplittingDataSourceGroupRuleConfiguration("foo", "write_ds", Collections.singletonList("read_ds"), "foo_balancer")));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ReadwriteSplittingDataSourceGroupRuleConfiguration("foo", "write_ds", Collections.singletonList("read_ds"), "foo_balancer")));
}
@Test
void assertSwapRuleItemConfigurationWithTransactionalReadQueryStrategy() {
ReadwriteSplittingDataSourceGroupRuleConfiguration actual = processor.swapRuleItemConfiguration("foo", createYAMLContent(TransactionalReadQueryStrategy.PRIMARY));
- assertThat(actual, deepEqual(new ReadwriteSplittingDataSourceGroupRuleConfiguration(
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ReadwriteSplittingDataSourceGroupRuleConfiguration(
"foo", "write_ds", Collections.singletonList("read_ds"), TransactionalReadQueryStrategy.PRIMARY, "foo_balancer")));
}
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessorTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessorTest.java
index fa550e775b8..6112656f3ed 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessorTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/changed/ReadwriteSplittingLoadBalancerChangedProcessorTest.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -32,7 +33,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class ReadwriteSplittingLoadBalancerChangedProcessorTest {
@SuppressWarnings("CollectionWithoutInitialCapacity")
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new ReadwriteSplittingRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new ReadwriteSplittingRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>())));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java
index ac3a8888cd4..939d4afe359 100644
--- a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java
+++ b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/converter/ReadwriteSplittingRuleStatementConverterTest.java
@@ -23,13 +23,13 @@ import org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRul
import org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.distsql.segment.ReadwriteSplittingRuleSegment;
import org.apache.shardingsphere.readwritesplitting.transaction.TransactionalReadQueryStrategy;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -42,15 +42,15 @@ class ReadwriteSplittingRuleStatementConverterTest {
ReadwriteSplittingRuleConfiguration actual = ReadwriteSplittingRuleStatementConverter.convert(Collections.singleton(ruleSegment));
ReadwriteSplittingDataSourceGroupRuleConfiguration expectedDataSourceGroupRuleConfig = new ReadwriteSplittingDataSourceGroupRuleConfiguration(
"foo_name", "write_ds", Arrays.asList("read_ds0", "read_ds1"), TransactionalReadQueryStrategy.FIXED, "foo_name_foo_algo");
- assertThat(actual.getDataSourceGroups(), deepEqual(Collections.singletonList(expectedDataSourceGroupRuleConfig)));
- assertThat(actual.getLoadBalancers(), deepEqual(Collections.singletonMap("foo_name_foo_algo", new AlgorithmConfiguration("foo_algo", new Properties()))));
+ assertThat(actual.getDataSourceGroups(), ShardingSphereAssertionMatchers.deepEqual(Collections.singletonList(expectedDataSourceGroupRuleConfig)));
+ assertThat(actual.getLoadBalancers(), ShardingSphereAssertionMatchers.deepEqual(Collections.singletonMap("foo_name_foo_algo", new AlgorithmConfiguration("foo_algo", new Properties()))));
}
@Test
void assertConvertWithoutTransactionalReadQueryStrategyAndLoadBalancer() {
ReadwriteSplittingRuleConfiguration actual = ReadwriteSplittingRuleStatementConverter.convert(
Collections.singleton(new ReadwriteSplittingRuleSegment("foo_name", "write_ds", Arrays.asList("read_ds0", "read_ds1"), null)));
- assertThat(actual.getDataSourceGroups(), deepEqual(Collections.singletonList(
+ assertThat(actual.getDataSourceGroups(), ShardingSphereAssertionMatchers.deepEqual(Collections.singletonList(
new ReadwriteSplittingDataSourceGroupRuleConfiguration("foo_name", "write_ds", Arrays.asList("read_ds0", "read_ds1"), null))));
assertTrue(actual.getLoadBalancers().isEmpty());
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowDeleteStatementDataSourceMappingsRetrieverTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowDeleteStatementDataSourceMappingsRetrieverTest.java
index b39d0cd2eff..51600bb7d3a 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowDeleteStatementDataSourceMappingsRetrieverTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowDeleteStatementDataSourceMappingsRetrieverTest.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.Expr
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
import org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -31,7 +32,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -53,6 +53,6 @@ class ShadowDeleteStatementDataSourceMappingsRetrieverTest {
ShadowDeleteStatementDataSourceMappingsRetriever retriever = new ShadowDeleteStatementDataSourceMappingsRetriever(sqlStatementContext, Collections.singletonList("foo"));
Collection<ShadowColumnCondition> actual = retriever.getShadowColumnConditions("foo_col");
Collection<ShadowColumnCondition> expected = Collections.singletonList(new ShadowColumnCondition("foo_tbl", "foo_col", Collections.singleton("foo")));
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowInsertStatementDataSourceMappingsRetrieverTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowInsertStatementDataSourceMappingsRetrieverTest.java
index 4ce15f61520..0699c05a95b 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowInsertStatementDataSourceMappingsRetrieverTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowInsertStatementDataSourceMappingsRetrieverTest.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.binder.context.segment.insert.values.Inse
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.InsertStatementContext;
import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
import org.apache.shardingsphere.shadow.exception.syntax.UnsupportedShadowInsertValueException;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
@@ -28,7 +29,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -48,7 +48,7 @@ class ShadowInsertStatementDataSourceMappingsRetrieverTest {
ShadowInsertStatementDataSourceMappingsRetriever retriever = new ShadowInsertStatementDataSourceMappingsRetriever(sqlStatementContext);
Collection<ShadowColumnCondition> actual = retriever.getShadowColumnConditions("foo_col");
Collection<ShadowColumnCondition> expected = Collections.singletonList(new ShadowColumnCondition("foo_tbl", "foo_col", Collections.singletonList("foo")));
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
@Test
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowUpdateStatementDataSourceMappingsRetrieverTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowUpdateStatementDataSourceMappingsRetrieverTest.java
index de7996e7c56..777d6aeda90 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowUpdateStatementDataSourceMappingsRetrieverTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/dml/table/column/impl/ShadowUpdateStatementDataSourceMappingsRetrieverTest.java
@@ -26,6 +26,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.Expr
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.predicate.WhereSegment;
import org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
import org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -34,7 +35,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -57,6 +57,6 @@ class ShadowUpdateStatementDataSourceMappingsRetrieverTest {
ShadowUpdateStatementDataSourceMappingsRetriever retriever = new ShadowUpdateStatementDataSourceMappingsRetriever(sqlStatementContext, Collections.singletonList("foo"));
Collection<ShadowColumnCondition> actual = retriever.getShadowColumnConditions("foo_col");
Collection<ShadowColumnCondition> expected = Collections.singletonList(new ShadowColumnCondition("foo_tbl", "foo_col", Collections.singleton("foo")));
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessorTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessorTest.java
index f2b83c2cb09..fafa14cd9db 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessorTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowAlgorithmChangedProcessorTest.java
@@ -24,12 +24,12 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -44,7 +44,7 @@ class ShadowAlgorithmChangedProcessorTest {
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new ShadowRuleConfiguration()));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new ShadowRuleConfiguration()));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessorTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessorTest.java
index c24d4ebfa54..87109285d6c 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessorTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowDataSourceChangedProcessorTest.java
@@ -27,12 +27,12 @@ import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
import org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class ShadowDataSourceChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShadowDataSourceConfiguration actual = processor.swapRuleItemConfiguration("foo_ds", createYAMLContent());
- assertThat(actual, deepEqual(new ShadowDataSourceConfiguration("foo_ds", "prod_ds", "shadow_ds")));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ShadowDataSourceConfiguration("foo_ds", "prod_ds", "shadow_ds")));
}
private String createYAMLContent() {
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessorTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessorTest.java
index 78a779e1b47..44a6448e278 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessorTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/changed/ShadowTableChangedProcessorTest.java
@@ -27,11 +27,11 @@ import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
import org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -47,7 +47,7 @@ class ShadowTableChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShadowTableConfiguration actual = processor.swapRuleItemConfiguration("foo_ds", createYAMLContent());
- assertThat(actual, deepEqual(new ShadowTableConfiguration(Collections.singletonList("foo_ds"), Collections.singletonList("foo_algo"))));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ShadowTableConfiguration(Collections.singletonList("foo_ds"), Collections.singletonList("foo_algo"))));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessorTest.java
index aa6f49a2911..06c094c9034 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultDatabaseShardingStrategyChangedProcessorTest.java
@@ -30,11 +30,11 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingS
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlNoneShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -50,7 +50,7 @@ class DefaultDatabaseShardingStrategyChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShardingStrategyConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new NoneShardingStrategyConfiguration()));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new NoneShardingStrategyConfiguration()));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessorTest.java
index 011d5e368f4..6f3ad14aa1e 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultKeyGenerateStrategyChangedProcessorTest.java
@@ -27,11 +27,11 @@ import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -47,7 +47,7 @@ class DefaultKeyGenerateStrategyChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
KeyGenerateStrategyConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new KeyGenerateStrategyConfiguration("foo_col", "foo_algo")));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new KeyGenerateStrategyConfiguration("foo_col", "foo_algo")));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessorTest.java
index eebe1b1c951..d6a050fda27 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultShardingAuditorStrategyChangedProcessorTest.java
@@ -27,11 +27,11 @@ import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -48,7 +48,7 @@ class DefaultShardingAuditorStrategyChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShardingAuditStrategyConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new ShardingAuditStrategyConfiguration(Collections.singletonList("foo_algo"), true)));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ShardingAuditStrategyConfiguration(Collections.singletonList("foo_algo"), true)));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessorTest.java
index 8a4a74233bc..3387a85a0e7 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/DefaultTableShardingStrategyChangedProcessorTest.java
@@ -30,11 +30,11 @@ import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingS
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlNoneShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -50,7 +50,7 @@ class DefaultTableShardingStrategyChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShardingStrategyConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new NoneShardingStrategyConfiguration()));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new NoneShardingStrategyConfiguration()));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessorTest.java
index 2e5cb2d0f16..1aa879c48fa 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/KeyGeneratorChangedProcessorTest.java
@@ -24,12 +24,12 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -44,7 +44,7 @@ class KeyGeneratorChangedProcessorTest {
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new ShardingRuleConfiguration()));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new ShardingRuleConfiguration()));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessorTest.java
index 408cca768a2..0e212699a84 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAlgorithmChangedProcessorTest.java
@@ -24,12 +24,12 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -44,7 +44,7 @@ class ShardingAlgorithmChangedProcessorTest {
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new ShardingRuleConfiguration()));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new ShardingRuleConfiguration()));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessorTest.java
index 61b9709d2f8..3bdabc7f802 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAuditorChangedProcessorTest.java
@@ -24,12 +24,12 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -44,7 +44,7 @@ class ShardingAuditorChangedProcessorTest {
@Test
void assertFindRuleConfigurationWhenAbsent() {
- assertThat(processor.findRuleConfiguration(mockDatabase()), deepEqual(new ShardingRuleConfiguration()));
+ assertThat(processor.findRuleConfiguration(mockDatabase()), ShardingSphereAssertionMatchers.deepEqual(new ShardingRuleConfiguration()));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessorTest.java
index e770aabee61..9ec09c3fbae 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingAutoTableChangedProcessorTest.java
@@ -27,12 +27,12 @@ import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class ShardingAutoTableChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShardingAutoTableRuleConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new ShardingAutoTableRuleConfiguration("foo_tbl", "foo_ds")));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ShardingAutoTableRuleConfiguration("foo_tbl", "foo_ds")));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessorTest.java
index ae17ca9a0f7..df93f3c5a73 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableChangedProcessorTest.java
@@ -27,12 +27,12 @@ import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class ShardingTableChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShardingTableRuleConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new ShardingTableRuleConfiguration("foo_tbl", "foo_ds.foo_tbl")));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ShardingTableRuleConfiguration("foo_tbl", "foo_ds.foo_tbl")));
}
private String createYAMLContent() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessorTest.java
index 9954a3f1f4b..368b7242c99 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/changed/ShardingTableReferenceChangedProcessorTest.java
@@ -25,12 +25,12 @@ import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProce
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -46,7 +46,7 @@ class ShardingTableReferenceChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
ShardingTableReferenceRuleConfiguration actual = processor.swapRuleItemConfiguration(null, "foo_ref:foo_tbl_0,foo_tbl_1");
- assertThat(actual, deepEqual(new ShardingTableReferenceRuleConfiguration("foo_ref", "foo_tbl_0,foo_tbl_1")));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ShardingTableReferenceRuleConfiguration("foo_ref", "foo_tbl_0,foo_tbl_1")));
}
@Test
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGeneratorExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGeneratorExecutorTest.java
index a002c7b0cad..809314e3508 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGeneratorExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingKeyGeneratorExecutorTest.java
@@ -35,7 +35,7 @@ import java.util.Collection;
import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -59,6 +59,6 @@ class ShowShardingKeyGeneratorExecutorTest {
ShowShardingKeyGeneratorExecutor executor = new ShowShardingKeyGeneratorExecutor();
executor.setRule(rule);
Collection<LocalDataQueryResultRow> actual = executor.getRows(new ShowShardingKeyGeneratorsStatement("snowflake", null), null);
- assertThat(actual, hasSize(1));
+ assertThat(actual.size(), is(1));
}
}
diff --git a/infra/algorithm/core/src/test/java/org/apache/shardingsphere/infra/algorithm/core/processor/AlgorithmChangedProcessorTest.java b/infra/algorithm/core/src/test/java/org/apache/shardingsphere/infra/algorithm/core/processor/AlgorithmChangedProcessorTest.java
index 0367ad46d95..2bf94925ee5 100644
--- a/infra/algorithm/core/src/test/java/org/apache/shardingsphere/infra/algorithm/core/processor/AlgorithmChangedProcessorTest.java
+++ b/infra/algorithm/core/src/test/java/org/apache/shardingsphere/infra/algorithm/core/processor/AlgorithmChangedProcessorTest.java
@@ -27,12 +27,12 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.spi.rule.RuleChangedItemType;
import org.apache.shardingsphere.mode.spi.rule.RuleItemConfigurationChangedProcessor;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -48,7 +48,7 @@ class AlgorithmChangedProcessorTest {
@Test
void assertSwapRuleItemConfiguration() {
AlgorithmConfiguration actual = processor.swapRuleItemConfiguration(null, createYAMLContent());
- assertThat(actual, deepEqual(new AlgorithmConfiguration("foo_algo", new Properties())));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new AlgorithmConfiguration("foo_algo", new Properties())));
}
private String createYAMLContent() {
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java
index 75b4252ddfd..04bdca2b914 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java
@@ -27,7 +27,6 @@ import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -58,7 +57,7 @@ class ShardingSphereTableTest {
ShardingSphereColumn column1 = new ShardingSphereColumn("foo_col", Types.INTEGER, true, true, false, true, false, false);
ShardingSphereColumn column2 = new ShardingSphereColumn("foo_col", Types.VARCHAR, false, true, false, true, false, false);
ShardingSphereTable table = new ShardingSphereTable("foo_tbl", Arrays.asList(column1, column2), Collections.emptyList(), Collections.emptyList());
- assertThat(table.getAllColumns(), hasSize(1));
+ assertThat(table.getAllColumns().size(), is(1));
assertThat(table.getColumn("foo_col"), is(column1));
}
@@ -68,7 +67,7 @@ class ShardingSphereTableTest {
ShardingSphereColumn column2 = new ShardingSphereColumn("foo_col_2", Types.INTEGER, false, true, false, true, false, false);
ShardingSphereTable shardingSphereTable = new ShardingSphereTable("foo_tbl", Arrays.asList(column1, column2), Collections.emptyList(), Collections.emptyList());
assertThat(shardingSphereTable.getAllColumns(), hasItems(column1, column2));
- assertThat(shardingSphereTable.getAllColumns(), hasSize(2));
+ assertThat(shardingSphereTable.getAllColumns().size(), is(2));
}
@Test
@@ -102,7 +101,7 @@ class ShardingSphereTableTest {
ShardingSphereIndex index1 = new ShardingSphereIndex("foo_idx_1", Collections.emptyList(), false);
ShardingSphereIndex index2 = new ShardingSphereIndex("foo_idx_2", Collections.emptyList(), false);
ShardingSphereTable table = new ShardingSphereTable("foo_tbl", Collections.emptyList(), Arrays.asList(index1, index2), Collections.emptyList());
- assertThat(table.getAllIndexes(), hasSize(2));
+ assertThat(table.getAllIndexes().size(), is(2));
assertThat(table.getAllIndexes(), hasItems(index1, index2));
}
@@ -126,7 +125,7 @@ class ShardingSphereTableTest {
table.removeIndex("foo_idx_1");
assertFalse(table.containsIndex("foo_idx_1"));
table.removeIndex("invalid");
- assertThat(table.getAllIndexes(), hasSize(1));
+ assertThat(table.getAllIndexes().size(), is(1));
assertTrue(table.containsIndex("foo_idx_2"));
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/statistics/builder/ShardingSphereStatisticsFactoryTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/statistics/builder/ShardingSphereStatisticsFactoryTest.java
index 670e3d50338..f616353473b 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/statistics/builder/ShardingSphereStatisticsFactoryTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/statistics/builder/ShardingSphereStatisticsFactoryTest.java
@@ -36,8 +36,8 @@ import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java
index b3b8c199023..556cb33f2cb 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java
@@ -30,9 +30,9 @@ import java.sql.Types;
import java.util.Collections;
import java.util.stream.Stream;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
class YamlRowStatisticsSwapperTest {
@@ -41,7 +41,7 @@ class YamlRowStatisticsSwapperTest {
void assertSwapToYamlConfigurationWithNullRows() {
YamlRowStatisticsSwapper swapper = new YamlRowStatisticsSwapper(Collections.emptyList());
YamlRowStatistics actual = swapper.swapToYamlConfiguration(new RowStatistics("foo_unique_key", null));
- assertThat(actual.getRows(), is(empty()));
+ assertTrue(actual.getRows().isEmpty());
assertThat(actual.getUniqueKey(), is("foo_unique_key"));
}
@@ -69,7 +69,7 @@ class YamlRowStatisticsSwapperTest {
yamlConfig.setUniqueKey("foo_unique_key");
yamlConfig.setRows(null);
RowStatistics actual = new YamlRowStatisticsSwapper(Collections.emptyList()).swapToObject(yamlConfig);
- assertThat(actual.getRows(), is(empty()));
+ assertTrue(actual.getRows().isEmpty());
assertThat(actual.getUniqueKey(), is("foo_unique_key"));
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
index 313aec8eccb..9351810a534 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
@@ -28,6 +28,7 @@ import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereColumn
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereConstraint;
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereIndex;
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereTable;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
@@ -35,7 +36,6 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.is;
@@ -54,21 +54,21 @@ class YamlTableSwapperTest {
ShardingSphereTable table = createShardingSphereTable();
YamlShardingSphereTable actual = swapper.swapToYamlConfiguration(table);
YamlShardingSphereTable expected = YamlEngine.unmarshal(SystemResourceFileUtils.readFile(YAML_FILE), YamlShardingSphereTable.class);
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
@Test
void assertSwapToObject() {
ShardingSphereTable actual = swapper.swapToObject(YamlEngine.unmarshal(SystemResourceFileUtils.readFile(YAML_FILE), YamlShardingSphereTable.class));
ShardingSphereTable expected = createShardingSphereTable();
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
@Test
void assertSwapToObjectWithEmptySchema() {
ShardingSphereTable actual = swapper.swapToObject(YamlEngine.unmarshal(SystemResourceFileUtils.readFile(EMPTY_YAML_FILE), YamlShardingSphereTable.class));
ShardingSphereTable expected = new ShardingSphereTable("", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), TableType.TABLE);
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
@Test
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlViewSwapperTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlViewSwapperTest.java
index c532d295138..09a10d72dd0 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlViewSwapperTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlViewSwapperTest.java
@@ -21,9 +21,9 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.util.file.SystemResourceFileUtils;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereView;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
class YamlViewSwapperTest {
@@ -37,14 +37,14 @@ class YamlViewSwapperTest {
ShardingSphereView view = createShardingSphereView();
YamlShardingSphereView actual = swapper.swapToYamlConfiguration(view);
YamlShardingSphereView expected = YamlEngine.unmarshal(SystemResourceFileUtils.readFile(YAML_FILE), YamlShardingSphereView.class);
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
@Test
void assertSwapToObject() {
ShardingSphereView actual = swapper.swapToObject(YamlEngine.unmarshal(SystemResourceFileUtils.readFile(YAML_FILE), YamlShardingSphereView.class));
ShardingSphereView expected = createShardingSphereView();
- assertThat(actual, deepEqual(expected));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(expected));
}
private ShardingSphereView createShardingSphereView() {
diff --git a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreatorTest.java b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreatorTest.java
index af01eac250f..bbfa75d5377 100644
--- a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreatorTest.java
+++ b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreatorTest.java
@@ -56,9 +56,12 @@ import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class DataSourcePoolCreatorTest {
@@ -176,7 +179,7 @@ class DataSourcePoolCreatorTest {
MockedDataSource actual = (MockedDataSource) DataSourcePoolCreator.create(
"foo_ds", new DataSourcePoolProperties(MockedDataSource.class.getName(), createMockedDataSourceProperties()), false, Collections.singleton(storageNode));
assertMockedDataSource(actual);
- assertThrows(WantedButNotInvoked.class, () -> org.mockito.Mockito.verify(storageNode).close());
+ assertThrows(WantedButNotInvoked.class, () -> verify(storageNode).close());
}
@Test
@@ -189,7 +192,7 @@ class DataSourcePoolCreatorTest {
assertThrows(NumberFormatException.class,
() -> DataSourcePoolCreator.create("foo_ds", new DataSourcePoolProperties(MockedDataSource.class.getName(), props), false, Collections.singleton(storageNode)));
Awaitility.await().atMost(1L, TimeUnit.SECONDS).pollInterval(10L, TimeUnit.MILLISECONDS)
- .untilAsserted(() -> org.mockito.Mockito.verify(storageNode, org.mockito.Mockito.atLeastOnce()).close());
+ .untilAsserted(() -> verify(storageNode, atLeastOnce()).close());
}
@Disabled
@@ -200,7 +203,7 @@ class DataSourcePoolCreatorTest {
props.put("connectionTimeout", "invalid");
assertThrows(NumberFormatException.class,
() -> DataSourcePoolCreator.create("foo_ds", new DataSourcePoolProperties(MockedDataSource.class.getName(), props), true, Collections.singleton(storageNode)));
- Awaitility.await().during(200L, TimeUnit.MILLISECONDS).atMost(500L, TimeUnit.MILLISECONDS).untilAsserted(() -> org.mockito.Mockito.verify(storageNode, org.mockito.Mockito.never()).close());
+ Awaitility.await().during(200L, TimeUnit.MILLISECONDS).atMost(500L, TimeUnit.MILLISECONDS).untilAsserted(() -> verify(storageNode, never()).close());
}
private Map<String, Object> createMockedDataSourceProperties() {
diff --git a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/DataSourcePoolDestroyerTest.java b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/DataSourcePoolDestroyerTest.java
index 5335783b630..a0d5b85a450 100644
--- a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/DataSourcePoolDestroyerTest.java
+++ b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/DataSourcePoolDestroyerTest.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.infra.datasource.pool.destroyer;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@@ -31,6 +30,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Stream;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.mockito.ArgumentMatchers.any;
@@ -96,7 +96,7 @@ class DataSourcePoolDestroyerTest {
verify(executor).shutdown();
verify(activeDetector, times(expectedContainsActiveConnectionCount)).containsActiveConnection(dataSource);
verify(closeable).close();
- MatcherAssert.assertThat(Thread.currentThread().isInterrupted(), is(interruptedBeforeDestroy));
+ assertThat(Thread.currentThread().isInterrupted(), is(interruptedBeforeDestroy));
} finally {
Thread.interrupted();
}
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/thread/ExecutorServiceManagerTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/thread/ExecutorServiceManagerTest.java
index f1c431e1c5a..ba90b16354f 100644
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/thread/ExecutorServiceManagerTest.java
+++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/kernel/thread/ExecutorServiceManagerTest.java
@@ -47,11 +47,11 @@ class ExecutorServiceManagerTest {
assertValueChangedInConcurrencyThread();
finished.set(true);
});
- assertTimeout(Duration.ofSeconds(1L), () -> assertFinished(finished));
+ assertTimeout(Duration.ofSeconds(2L), () -> assertFinished(finished));
}
private void assertFinished(final AtomicBoolean finished) {
- Awaitility.await().atMost(1L, TimeUnit.MINUTES).pollInterval(100L, TimeUnit.MILLISECONDS).until(finished::get);
+ Awaitility.await().atMost(1L, TimeUnit.SECONDS).pollInterval(100L, TimeUnit.MILLISECONDS).until(finished::get);
}
private void assertValueChangedInConcurrencyThread() {
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java
index aacb37e9f0b..1e5d6886fb0 100644
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java
+++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java
@@ -22,7 +22,8 @@ import org.junit.jupiter.api.Test;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTimeout;
import static org.junit.jupiter.api.Assertions.assertTrue;
class ProcessOperationLockTest {
@@ -39,7 +40,14 @@ class ProcessOperationLockTest {
Thread awaitingThread = new Thread(() -> result.set(lock.awaitDefaultTime(() -> false)));
awaitingThread.start();
lock.doNotify();
- assertTimeoutPreemptively(Duration.ofSeconds(1), () -> awaitingThread.join());
+ try {
+ assertTimeout(Duration.ofSeconds(2L), () -> {
+ awaitingThread.join(1000L);
+ assertFalse(awaitingThread.isAlive());
+ });
+ } finally {
+ awaitingThread.interrupt();
+ }
assertTrue(result.get());
}
}
diff --git a/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java b/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java
index ea8429d892e..55af5ed2359 100644
--- a/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java
+++ b/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java
@@ -32,10 +32,9 @@ import org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.table.MySQL
import org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.table.MySQLShowTablesStatement;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.mock;
class MySQLToBeRemovedSegmentsProviderTest {
@@ -54,7 +53,7 @@ class MySQLToBeRemovedSegmentsProviderTest {
@Test
void assertGetToBeRemovedSQLSegmentsWhenShowColumnsWithoutFromDatabase() {
MySQLShowColumnsStatement statement = new MySQLShowColumnsStatement(mock(DatabaseType.class), createSimpleTableSegment(), null, null);
- assertThat(provider.getToBeRemovedSQLSegments(statement), is(empty()));
+ assertTrue(provider.getToBeRemovedSQLSegments(statement).isEmpty());
}
@Test
diff --git a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoaderTest.java b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoaderTest.java
index 89480eae018..5abe625e0d5 100644
--- a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoaderTest.java
+++ b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoaderTest.java
@@ -35,9 +35,9 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
import static org.hamcrest.Matchers.not;
@@ -65,18 +65,18 @@ class OrderedSPILoaderTest {
@Test
void assertGetServicesByClassWithMultiClass() {
Map<Class<?>, OrderedSPIFixture> actual = OrderedSPILoader.getServicesByClass(OrderedSPIFixture.class,
- Arrays.<Class<?>>asList(OrderedInterfaceFixtureImpl.class, ParentOrderedInterfaceFixtureImpl.class));
+ Arrays.asList(OrderedInterfaceFixtureImpl.class, ParentOrderedInterfaceFixtureImpl.class));
assertThat(actual.keySet(), contains(ParentOrderedInterfaceFixtureImpl.class, OrderedInterfaceFixtureImpl.class));
}
@Test
void assertGetServicesByClassWithEmptyClass() {
- assertThat(OrderedSPILoader.getServicesByClass(OrderedSPIFixture.class, Collections.<Class<?>>emptyList()).entrySet(), empty());
+ assertTrue(OrderedSPILoader.getServicesByClass(OrderedSPIFixture.class, Collections.emptyList()).isEmpty());
}
@Test
void assertGetServicesByClassWithNoMatchClass() {
- assertThat(OrderedSPILoader.getServicesByClass(OrderedSPIFixture.class, Collections.<Class<?>>singleton(ChildOrderedInterfaceFixtureImpl.class)).entrySet(), empty());
+ assertTrue(OrderedSPILoader.getServicesByClass(OrderedSPIFixture.class, Collections.singleton(ChildOrderedInterfaceFixtureImpl.class)).isEmpty());
}
@Test
@@ -91,27 +91,27 @@ class OrderedSPILoaderTest {
void assertGetServicesWithMultiObject() {
OrderedInterfaceFixtureImpl orderedKey = new OrderedInterfaceFixtureImpl();
ParentOrderedInterfaceFixtureImpl parentKey = new ParentOrderedInterfaceFixtureImpl();
- Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Arrays.<OrderedInterfaceFixture>asList(orderedKey, parentKey));
+ Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Arrays.asList(orderedKey, parentKey));
assertThat(actual.keySet(), contains(parentKey, orderedKey));
}
@Test
void assertGetServicesWithEmptyObject() {
- assertThat(OrderedSPILoader.getServices(OrderedSPIFixture.class, Collections.<OrderedInterfaceFixture>emptyList()).entrySet(), empty());
+ assertTrue(OrderedSPILoader.getServices(OrderedSPIFixture.class, Collections.<OrderedInterfaceFixture>emptyList()).isEmpty());
}
@Test
void assertGetServicesWithExactRuntimeClass() {
Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class,
- Collections.<OrderedInterfaceFixture>singleton(new ChildOrderedInterfaceFixtureImpl()));
- assertThat(actual.entrySet(), empty());
+ Collections.singleton(new ChildOrderedInterfaceFixtureImpl()));
+ assertTrue(actual.isEmpty());
}
@Test
void assertGetServicesWithSameClassObjects() {
ComparableOrderedInterfaceFixtureImpl firstKey = new ComparableOrderedInterfaceFixtureImpl("foo_same_1");
ComparableOrderedInterfaceFixtureImpl secondKey = new ComparableOrderedInterfaceFixtureImpl("foo_same_2");
- Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Arrays.<OrderedInterfaceFixture>asList(firstKey, secondKey));
+ Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Arrays.asList(firstKey, secondKey));
assertThat(actual.keySet(), contains(firstKey, secondKey));
}
@@ -121,7 +121,7 @@ class OrderedSPILoaderTest {
new ComparableOrderedInterfaceFixtureImpl("foo_equal_2")));
ComparableOrderedInterfaceFixtureImpl firstKey = new ComparableOrderedInterfaceFixtureImpl("foo_equal_1");
ComparableOrderedInterfaceFixtureImpl secondKey = new ComparableOrderedInterfaceFixtureImpl("foo_equal_2");
- Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Arrays.<OrderedInterfaceFixture>asList(firstKey, secondKey));
+ Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Arrays.asList(firstKey, secondKey));
assertThat(actual.keySet(), contains(sameInstance(firstKey), sameInstance(secondKey)));
}
@@ -131,7 +131,7 @@ class OrderedSPILoaderTest {
ParentOrderedInterfaceFixtureImpl parentKey = new ParentOrderedInterfaceFixtureImpl();
ComparableOrderedInterfaceFixtureImpl comparableKey = new ComparableOrderedInterfaceFixtureImpl("foo_comparator");
Map<OrderedInterfaceFixture, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class,
- Arrays.<OrderedInterfaceFixture>asList(parentKey, orderedKey, comparableKey), Collections.<Integer>reverseOrder());
+ Arrays.asList(parentKey, orderedKey, comparableKey), Collections.reverseOrder());
assertThat(actual.keySet(), contains(comparableKey, orderedKey, parentKey));
}
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32TableInventoryCheckCalculatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32TableInventoryCheckCalculatorTest.java
index 2b80f13afff..0dc4230f694 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32TableInventoryCheckCalculatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/calculator/CRC32TableInventoryCheckCalculatorTest.java
@@ -47,8 +47,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/PipelineExecuteEngineTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/PipelineExecuteEngineTest.java
index bc9f02b06e1..b459b839e23 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/PipelineExecuteEngineTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/execute/PipelineExecuteEngineTest.java
@@ -26,6 +26,8 @@ import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -38,14 +40,21 @@ import static org.mockito.Mockito.verify;
class PipelineExecuteEngineTest {
+ private static final long FUTURE_TIMEOUT_SECONDS = 30L;
+
+ private static final Duration ASSERTION_TIMEOUT = Duration.ofSeconds(FUTURE_TIMEOUT_SECONDS + 1L);
+
@Test
void assertSubmitWithoutExecuteCallback() {
PipelineLifecycleRunnable pipelineLifecycleRunnable = mock(PipelineLifecycleRunnable.class);
PipelineExecuteEngine executeEngine = PipelineExecuteEngine.newFixedThreadInstance(1, PipelineExecuteEngineTest.class.getSimpleName());
- Future<?> future = executeEngine.submit(pipelineLifecycleRunnable);
- assertTimeout(Duration.ofSeconds(30L), () -> future.get());
- verify(pipelineLifecycleRunnable).run();
- executeEngine.shutdown();
+ try {
+ Future<?> future = executeEngine.submit(pipelineLifecycleRunnable);
+ assertTimeout(ASSERTION_TIMEOUT, () -> future.get(FUTURE_TIMEOUT_SECONDS, TimeUnit.SECONDS));
+ verify(pipelineLifecycleRunnable).run();
+ } finally {
+ executeEngine.shutdown();
+ }
}
@Test
@@ -53,11 +62,14 @@ class PipelineExecuteEngineTest {
PipelineLifecycleRunnable pipelineLifecycleRunnable = mock(PipelineLifecycleRunnable.class);
ExecuteCallback callback = mock(ExecuteCallback.class);
PipelineExecuteEngine executeEngine = PipelineExecuteEngine.newCachedThreadInstance(PipelineExecuteEngineTest.class.getSimpleName());
- Future<?> future = executeEngine.submit(pipelineLifecycleRunnable, callback);
- assertTimeout(Duration.ofSeconds(30L), () -> future.get());
- verify(pipelineLifecycleRunnable).run();
- verify(callback).onSuccess();
- executeEngine.shutdown();
+ try {
+ Future<?> future = executeEngine.submit(pipelineLifecycleRunnable, callback);
+ assertTimeout(ASSERTION_TIMEOUT, () -> future.get(FUTURE_TIMEOUT_SECONDS, TimeUnit.SECONDS));
+ verify(pipelineLifecycleRunnable).run();
+ verify(callback).onSuccess();
+ } finally {
+ executeEngine.shutdown();
+ }
}
@Test
@@ -67,17 +79,20 @@ class PipelineExecuteEngineTest {
doThrow(expectedException).when(pipelineLifecycleRunnable).run();
ExecuteCallback callback = mock(ExecuteCallback.class);
PipelineExecuteEngine executeEngine = PipelineExecuteEngine.newCachedThreadInstance(PipelineExecuteEngineTest.class.getSimpleName());
- Future<?> future = executeEngine.submit(pipelineLifecycleRunnable, callback);
- Optional<Throwable> actualCause = assertTimeout(Duration.ofSeconds(30L), () -> execute(future));
- assertTrue(actualCause.isPresent());
- assertThat(actualCause.get(), is(expectedException));
- verify(callback).onFailure(expectedException);
- executeEngine.shutdown();
+ try {
+ Future<?> future = executeEngine.submit(pipelineLifecycleRunnable, callback);
+ Optional<Throwable> actualCause = assertTimeout(ASSERTION_TIMEOUT, () -> execute(future));
+ assertTrue(actualCause.isPresent());
+ assertThat(actualCause.get(), is(expectedException));
+ verify(callback).onFailure(expectedException);
+ } finally {
+ executeEngine.shutdown();
+ }
}
- private Optional<Throwable> execute(final Future<?> future) throws InterruptedException {
+ private Optional<Throwable> execute(final Future<?> future) throws InterruptedException, TimeoutException {
try {
- future.get();
+ future.get(FUTURE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
return Optional.empty();
} catch (final ExecutionException ex) {
return Optional.of(ex.getCause());
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/UniqueKeyIngestPositionTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/UniqueKeyIngestPositionTest.java
index b721f53c57b..0fa236dd45c 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/UniqueKeyIngestPositionTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/type/pk/UniqueKeyIngestPositionTest.java
@@ -25,7 +25,6 @@ import java.math.BigInteger;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -180,8 +179,8 @@ class UniqueKeyIngestPositionTest {
UniqueKeyIngestPosition<?> actual = UniqueKeyIngestPosition.decode("b,AQID,BAUG");
assertThat(actual, isA(UniqueKeyIngestPosition.class));
assertThat(actual.getType(), is('b'));
- assertArrayEquals(new byte[]{0x01, 0x02, 0x03}, (byte[]) actual.getLowerBound());
- assertArrayEquals(new byte[]{0x04, 0x05, 0x06}, (byte[]) actual.getUpperBound());
+ assertThat((byte[]) actual.getLowerBound(), is(new byte[]{0x01, 0x02, 0x03}));
+ assertThat((byte[]) actual.getUpperBound(), is(new byte[]{0x04, 0x05, 0x06}));
}
@Test
@@ -198,8 +197,8 @@ class UniqueKeyIngestPositionTest {
byte[] upperBound = new byte[]{0x03, 0x04};
UniqueKeyIngestPosition<?> actual = UniqueKeyIngestPosition.newInstance(Range.closed(lowerBound, upperBound));
assertThat(actual.getType(), is('b'));
- assertArrayEquals(lowerBound, (byte[]) actual.getLowerBound());
- assertArrayEquals(upperBound, (byte[]) actual.getUpperBound());
+ assertThat((byte[]) actual.getLowerBound(), is(lowerBound));
+ assertThat((byte[]) actual.getUpperBound(), is(upperBound));
}
@Test
@@ -207,7 +206,7 @@ class UniqueKeyIngestPositionTest {
byte[] lowerBound = new byte[]{0x01, 0x02};
UniqueKeyIngestPosition<?> actual = UniqueKeyIngestPosition.newInstance(Range.closed(lowerBound, null));
assertThat(actual.getType(), is('b'));
- assertArrayEquals(lowerBound, (byte[]) actual.getLowerBound());
+ assertThat((byte[]) actual.getLowerBound(), is(lowerBound));
assertNull(actual.getUpperBound());
}
}
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiateHandlerTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiateHandlerTest.java
index 30ad89f36da..a85e375b31e 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiateHandlerTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiateHandlerTest.java
@@ -44,7 +44,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.ArgumentCaptor;
-import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.internal.configuration.plugins.Plugins;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -59,6 +58,7 @@ import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -149,7 +149,7 @@ class MySQLNegotiateHandlerTest {
@Test
void assertHandleCachingSha2SkipPublicKeyRequest() throws ReflectiveOperationException {
mysqlNegotiateHandler.channelRead(channelHandlerContext, new MySQLAuthMoreDataPacket(new byte[]{1}));
- verify(channel, never()).writeAndFlush(ArgumentMatchers.any());
+ verify(channel, never()).writeAndFlush(any());
assertFalse((Boolean) Plugins.getMemberAccessor().get(MySQLNegotiateHandler.class.getDeclaredField("publicKeyRequested"), mysqlNegotiateHandler));
}
diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPITest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPITest.java
index 6a09541a41d..9151fb38557 100644
--- a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPITest.java
+++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/api/CDCJobAPITest.java
@@ -100,8 +100,6 @@ import java.util.stream.IntStream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.emptyString;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -110,10 +108,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
@@ -396,9 +394,9 @@ class CDCJobAPITest {
when(DatabaseTypedSPILoader.getService(DialectPipelineSQLBuilder.class, storageUnitWithoutSQL.getStorageType())).thenReturn(builderWithoutSQL);
when(DatabaseTypedSPILoader.getService(DialectPipelineSQLBuilder.class, storageUnitWithSQL.getStorageType())).thenReturn(builderWithSQL);
List<CDCJobItemInfo> actual = new ArrayList<>(jobAPI.getJobItemInfos("foo_job"));
- assertThat(actual, hasSize(3));
- assertThat(actual.get(0).getConfirmedPosition(), emptyString());
- assertThat(actual.get(1).getConfirmedPosition(), emptyString());
+ assertThat(actual.size(), is(3));
+ assertTrue(actual.get(0).getConfirmedPosition().isEmpty());
+ assertTrue(actual.get(1).getConfirmedPosition().isEmpty());
assertThat(actual.get(2).getConfirmedPosition(), is("binlog_001"));
assertThat(actual.get(2).getCurrentPosition(), is("bar_position"));
}
diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
index 992de7f3b32..18d2708d98f 100644
--- a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
+++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
@@ -44,8 +44,6 @@ import java.util.Map;
import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -67,7 +65,7 @@ class YamlCDCJobConfigurationSwapperTest {
assertThat(actual.getSchemaTableNames(), is(Arrays.asList("test.t_order", "t_order_item")));
assertTrue(actual.isFull());
assertThat(actual.getTablesFirstDataNodes().marshal(), is("foo_tbl:foo_ds.foo_tbl"));
- assertThat(actual.getJobShardingDataNodes(), hasSize(1));
+ assertThat(actual.getJobShardingDataNodes().size(), is(1));
assertThat(actual.getJobShardingDataNodes().get(0).marshal(), is("bar_tbl:bar_ds.bar_tbl"));
assertThat(actual.getSinkConfig().getSinkType(), is(CDCSinkType.SOCKET));
assertThat(actual.getSinkConfig().getProps().getProperty("foo_key"), is("foo_value"));
@@ -163,7 +161,7 @@ class YamlCDCJobConfigurationSwapperTest {
String jobParam = YamlEngine.marshal(yamlConfig);
CDCJobConfiguration actual = swapper.swapToObject(jobParam);
assertThat(actual.getJobId(), is("j0302p00007a8bf46da145dc155ba25c710b550220"));
- assertThat(actual.getJobShardingDataNodes(), empty());
+ assertTrue(actual.getJobShardingDataNodes().isEmpty());
assertNull(actual.getTablesFirstDataNodes());
assertThat(actual.getDataSourceConfig(), isA(ShardingSpherePipelineDataSourceConfiguration.class));
assertThat(actual.getSinkConfig().getProps().getProperty("foo_key"), is("foo_value"));
diff --git a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
index 5080bff55b3..b489fcf5f03 100644
--- a/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
+++ b/kernel/schedule/core/src/test/java/org/apache/shardingsphere/schedule/core/job/statistics/collect/StatisticsCollectJobWorkerTest.java
@@ -51,7 +51,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
diff --git a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
index 5bf8bf51d1b..1ced077fcd4 100644
--- a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
+++ b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/update/SetDefaultSingleTableStorageUnitExecutorTest.java
@@ -28,7 +28,6 @@ import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.distsql.statement.rdl.SetDefaultSingleTableStorageUnitStatement;
import org.apache.shardingsphere.single.rule.SingleRule;
import org.junit.jupiter.api.Test;
-import org.mockito.ArgumentMatchers;
import java.sql.SQLException;
import java.util.Arrays;
@@ -38,6 +37,7 @@ import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -66,8 +66,8 @@ class SetDefaultSingleTableStorageUnitExecutorTest {
SetDefaultSingleTableStorageUnitStatement sqlStatement = new SetDefaultSingleTableStorageUnitStatement(null);
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- verify(metaDataManagerPersistService).removeRuleConfigurationItem(any(), ArgumentMatchers.<SingleRuleConfiguration>argThat(x -> x.getDefaultDataSource().equals(Optional.of("foo_ds"))));
- verify(metaDataManagerPersistService).alterRuleConfiguration(any(), ArgumentMatchers.<SingleRuleConfiguration>argThat(x -> !x.getDefaultDataSource().isPresent()));
+ verify(metaDataManagerPersistService).removeRuleConfigurationItem(any(), argThat((SingleRuleConfiguration x) -> x.getDefaultDataSource().equals(Optional.of("foo_ds"))));
+ verify(metaDataManagerPersistService).alterRuleConfiguration(any(), argThat((SingleRuleConfiguration x) -> !x.getDefaultDataSource().isPresent()));
}
@Test
@@ -83,7 +83,7 @@ class SetDefaultSingleTableStorageUnitExecutorTest {
SetDefaultSingleTableStorageUnitStatement sqlStatement = new SetDefaultSingleTableStorageUnitStatement("bar_ds");
new DistSQLUpdateExecuteEngine(sqlStatement, "foo_db", contextManager, null).executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- verify(metaDataManagerPersistService).alterRuleConfiguration(any(), ArgumentMatchers.<SingleRuleConfiguration>argThat(x -> x.getDefaultDataSource().equals(Optional.of("bar_ds"))));
+ verify(metaDataManagerPersistService).alterRuleConfiguration(any(), argThat((SingleRuleConfiguration x) -> x.getDefaultDataSource().equals(Optional.of("bar_ds"))));
}
private ContextManager mockContextManager(final ShardingSphereDatabase database, final SingleRule rule, final String defaultDataSource) {
diff --git a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/rel/operator/physical/EnumerableModifyTest.java b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/rel/operator/physical/EnumerableModifyTest.java
index 30b85d0ddfd..7873f3002e8 100644
--- a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/rel/operator/physical/EnumerableModifyTest.java
+++ b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/rel/operator/physical/EnumerableModifyTest.java
@@ -47,6 +47,7 @@ import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -70,7 +71,7 @@ class EnumerableModifyTest {
RelDataType rowType = typeFactory.builder().add("col", SqlTypeName.INTEGER).build();
SQLFederationTable federationTable = mock(SQLFederationTable.class);
when(federationTable.getRowType(typeFactory)).thenReturn(rowType);
- when(federationTable.toRel(org.mockito.ArgumentMatchers.any(RelOptTable.ToRelContext.class), org.mockito.ArgumentMatchers.any(RelOptTable.class))).thenAnswer(
+ when(federationTable.toRel(any(RelOptTable.ToRelContext.class), any(RelOptTable.class))).thenAnswer(
invocation -> LogicalTableScan.create(invocation.getArgument(0, RelOptTable.ToRelContext.class).getCluster(), invocation.getArgument(1, RelOptTable.class), Collections.emptyList()));
when(federationTable.getStatistic()).thenReturn(Statistics.of(1D, ImmutableList.of()));
when(federationTable.getJdbcTableType()).thenReturn(Schema.TableType.TABLE);
diff --git a/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/enumerator/memory/MemoryTableStatisticsBuilderTest.java b/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/enumerator/memory/MemoryTableStatisticsBuilderTest.java
index 3b983790275..4d2ac49a91c 100644
--- a/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/enumerator/memory/MemoryTableStatisticsBuilderTest.java
+++ b/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/enumerator/memory/MemoryTableStatisticsBuilderTest.java
@@ -39,10 +39,11 @@ import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -84,7 +85,7 @@ class MemoryTableStatisticsBuilderTest {
void assertBuildRoleData() {
DialectDriverQuerySystemCatalogOption option = mock(DialectDriverQuerySystemCatalogOption.class);
when(option.isRoleDataTable("pg_roles")).thenReturn(true);
- AuthorityRule authorityRule = mock(AuthorityRule.class, org.mockito.Mockito.RETURNS_DEEP_STUBS);
+ AuthorityRule authorityRule = mock(AuthorityRule.class, RETURNS_DEEP_STUBS);
when(authorityRule.getGrantees()).thenReturn(new LinkedHashSet<>(Arrays.asList(new Grantee("alice", ""), new Grantee("bob", ""))));
ShardingSphereMetaData metaData = createMetaData(Collections.emptyList(), new RuleMetaData(Collections.singleton(authorityRule)));
TableStatistics actual = MemoryTableStatisticsBuilder.buildTableStatistics(mockTable("pg_roles"), metaData, option);
@@ -98,7 +99,7 @@ class MemoryTableStatisticsBuilderTest {
void assertBuildDefaultWhenNoMatch() {
DialectDriverQuerySystemCatalogOption option = mock(DialectDriverQuerySystemCatalogOption.class);
TableStatistics actual = MemoryTableStatisticsBuilder.buildTableStatistics(mockTable("other"), createMetaData(Collections.emptyList(), new RuleMetaData(Collections.emptyList())), option);
- assertThat(actual.getRows(), empty());
+ assertTrue(actual.getRows().isEmpty());
assertThat(actual.getName(), is("other"));
}
diff --git a/kernel/sql-translator/provider/native/src/test/java/org/apache/shardingsphere/sqltranslator/natived/NativeSQLTranslatorTest.java b/kernel/sql-translator/provider/native/src/test/java/org/apache/shardingsphere/sqltranslator/natived/NativeSQLTranslatorTest.java
index 1bd6f6a9137..80796fc4f46 100644
--- a/kernel/sql-translator/provider/native/src/test/java/org/apache/shardingsphere/sqltranslator/natived/NativeSQLTranslatorTest.java
+++ b/kernel/sql-translator/provider/native/src/test/java/org/apache/shardingsphere/sqltranslator/natived/NativeSQLTranslatorTest.java
@@ -24,11 +24,11 @@ import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sqltranslator.context.SQLTranslatorContext;
import org.apache.shardingsphere.sqltranslator.spi.SQLTranslator;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.mock;
@@ -38,6 +38,6 @@ class NativeSQLTranslatorTest {
void assertTranslateByType() {
SQLTranslator sqlTranslator = TypedSPILoader.getService(SQLTranslator.class, "NATIVE");
assertThat(sqlTranslator.translate("SELECT 1", Collections.emptyList(), mock(QueryContext.class), mock(DatabaseType.class), mock(ShardingSphereDatabase.class), mock(RuleMetaData.class)),
- deepEqual(new SQLTranslatorContext("SELECT 1", Collections.emptyList())));
+ ShardingSphereAssertionMatchers.deepEqual(new SQLTranslatorContext("SELECT 1", Collections.emptyList())));
}
}
diff --git a/mcp/core/src/test/java/org/apache/shardingsphere/mcp/core/completion/handler/MetadataCompletionHandlerTest.java b/mcp/core/src/test/java/org/apache/shardingsphere/mcp/core/completion/handler/MetadataCompletionHandlerTest.java
index 923e2baba14..962f1d61848 100644
--- a/mcp/core/src/test/java/org/apache/shardingsphere/mcp/core/completion/handler/MetadataCompletionHandlerTest.java
+++ b/mcp/core/src/test/java/org/apache/shardingsphere/mcp/core/completion/handler/MetadataCompletionHandlerTest.java
@@ -47,7 +47,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.anyString;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
diff --git a/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/database/metadata/model/MCPMetadataSnapshotTest.java b/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/database/metadata/model/MCPMetadataSnapshotTest.java
index 2a3afa426cb..e0b17d2057b 100644
--- a/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/database/metadata/model/MCPMetadataSnapshotTest.java
+++ b/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/database/metadata/model/MCPMetadataSnapshotTest.java
@@ -23,8 +23,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
class MCPMetadataSnapshotTest {
@@ -39,6 +39,6 @@ class MCPMetadataSnapshotTest {
@Test
void assertGetSequencesWithoutSchema() {
MCPMetadataSnapshot snapshot = new MCPMetadataSnapshot(Collections.emptyList(), Collections.emptyMap());
- assertThat(snapshot.getSequences("public"), is(empty()));
+ assertTrue(snapshot.getSequences("public").isEmpty());
}
}
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/listener/ContextManagerLifecycleListenerFactoryTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/listener/ContextManagerLifecycleListenerFactoryTest.java
index e2d77525d2e..fbcbcc3e763 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/listener/ContextManagerLifecycleListenerFactoryTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/manager/listener/ContextManagerLifecycleListenerFactoryTest.java
@@ -29,7 +29,7 @@ import java.util.Arrays;
import java.util.Collection;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -50,7 +50,7 @@ class ContextManagerLifecycleListenerFactoryTest {
Collection<ContextManagerLifecycleListener> listeners = Arrays.asList(noAnnotationListener, matchedModeListener, mismatchedModeListener);
when(ShardingSphereServiceLoader.getServiceInstances(ContextManagerLifecycleListener.class)).thenReturn(listeners);
Collection<ContextManagerLifecycleListener> actual = ContextManagerLifecycleListenerFactory.getListeners(contextManager);
- assertThat(actual, hasSize(2));
+ assertThat(actual.size(), is(2));
assertTrue(actual.contains(noAnnotationListener));
assertTrue(actual.contains(matchedModeListener));
assertFalse(actual.contains(mismatchedModeListener));
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java
index af410c059e9..e5b62be411a 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/MetaDataContextsFactoryTest.java
@@ -74,12 +74,12 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
-import static org.mockito.Mockito.anyMap;
-import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/init/type/RegisterCenterMetaDataContextsInitFactoryTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/init/type/RegisterCenterMetaDataContextsInitFactoryTest.java
index a9e156e74fe..ff43a3a5213 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/init/type/RegisterCenterMetaDataContextsInitFactoryTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/factory/init/type/RegisterCenterMetaDataContextsInitFactoryTest.java
@@ -59,7 +59,7 @@ import java.util.Map;
import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyMap;
@@ -102,8 +102,8 @@ class RegisterCenterMetaDataContextsInitFactoryTest {
});
MockedConstruction<DataSourcePoolDestroyer> destroyerMocked = mockConstruction(DataSourcePoolDestroyer.class)) {
MetaDataContexts actual = new RegisterCenterMetaDataContextsInitFactory(repository, instanceContext).create(createContextManagerBuilderParameter(databaseConfigs));
- assertThat(actual.getMetaData().getAllDatabases(), hasSize(2));
- assertThat(destroyerMocked.constructed(), hasSize(1));
+ assertThat(actual.getMetaData().getAllDatabases().size(), is(2));
+ assertThat(destroyerMocked.constructed().size(), is(1));
verify(destroyerMocked.constructed().get(0)).asyncDestroy();
}
}
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/resource/ResourceSwitchManagerTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/resource/ResourceSwitchManagerTest.java
index da01b6799d0..97b8882ad9d 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/resource/ResourceSwitchManagerTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/resource/ResourceSwitchManagerTest.java
@@ -40,7 +40,6 @@ import java.util.Map;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.aMapWithSize;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasKey;
@@ -181,8 +180,8 @@ class ResourceSwitchManagerTest {
ResourceMetaData resourceMetaData = createResourceMetaDataWithSingleUnit("ds_existing");
Map<String, DataSourcePoolProperties> toBeRegistered = Collections.emptyMap();
SwitchingResource actual = resourceSwitchManager.switchByRegisterStorageUnit(resourceMetaData, toBeRegistered, false);
- assertThat(actual.getNewDataSources(), aMapWithSize(0));
- assertThat(actual.getStaleDataSources(), aMapWithSize(0));
+ assertTrue(actual.getNewDataSources().isEmpty());
+ assertTrue(actual.getStaleDataSources().isEmpty());
assertTrue(actual.getStaleStorageUnitNames().isEmpty());
assertThat(actual.getMergedDataSourcePoolPropertiesMap(), hasKey("ds_existing"));
}
@@ -206,7 +205,7 @@ class ResourceSwitchManagerTest {
void assertSwitchByUnregisterStorageUnitWithEmptyInput() {
ResourceMetaData resourceMetaData = createResourceMetaDataWithSingleUnit("ds_existing");
SwitchingResource actual = resourceSwitchManager.switchByUnregisterStorageUnit(resourceMetaData, Collections.emptySet());
- assertThat(actual.getStaleDataSources(), aMapWithSize(0));
+ assertTrue(actual.getStaleDataSources().isEmpty());
assertTrue(actual.getStaleStorageUnitNames().isEmpty());
assertThat(actual.getMergedDataSourcePoolPropertiesMap(), hasKey("ds_existing"));
}
@@ -215,7 +214,7 @@ class ResourceSwitchManagerTest {
void assertCreateByUnregisterStorageUnitWithEmptyInput() {
ResourceMetaData resourceMetaData = createResourceMetaDataWithSingleUnit("ds_existing");
SwitchingResource actual = resourceSwitchManager.createByUnregisterStorageUnit(resourceMetaData, Collections.emptySet());
- assertThat(actual.getStaleDataSources(), aMapWithSize(0));
+ assertTrue(actual.getStaleDataSources().isEmpty());
assertTrue(actual.getStaleStorageUnitNames().isEmpty());
assertThat(actual.getMergedDataSourcePoolPropertiesMap(), hasKey("ds_existing"));
}
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistServiceTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistServiceTest.java
index 097dc00f92d..9a26be25264 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistServiceTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/statistics/StatisticsPersistServiceTest.java
@@ -43,9 +43,9 @@ import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.argThat;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/AlterViewFederationMetaDataRefresherTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/AlterViewFederationMetaDataRefresherTest.java
index 7f1f280e50e..6bd4c689930 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/AlterViewFederationMetaDataRefresherTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/AlterViewFederationMetaDataRefresherTest.java
@@ -45,7 +45,6 @@ import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
@@ -82,7 +81,7 @@ class AlterViewFederationMetaDataRefresherTest {
verify(metaDataManagerPersistService).alterViews(eq(database), eq(schemaName), alteredViewsCaptor.capture());
verify(metaDataManagerPersistService).dropViews(eq(database), eq(schemaName), droppedViewsCaptor.capture());
Collection<ShardingSphereView> alteredViews = alteredViewsCaptor.getValue();
- assertThat(alteredViews, hasSize(1));
+ assertThat(alteredViews.size(), is(1));
ShardingSphereView actualView = alteredViews.iterator().next();
assertThat(actualView.getName(), is("bar_view"));
assertThat(actualView.getViewDefinition(), is("SELECT * FROM foo_tbl"));
@@ -102,7 +101,7 @@ class AlterViewFederationMetaDataRefresherTest {
verify(metaDataManagerPersistService).alterViews(eq(database), eq(schemaName), alteredViewsCaptor.capture());
verify(metaDataManagerPersistService).dropViews(eq(database), eq(schemaName), droppedViewsCaptor.capture());
Collection<ShardingSphereView> alteredViews = alteredViewsCaptor.getValue();
- assertThat(alteredViews, hasSize(1));
+ assertThat(alteredViews.size(), is(1));
ShardingSphereView actualView = alteredViews.iterator().next();
assertThat(actualView.getName(), is("foo_view"));
assertThat(actualView.getViewDefinition(), is(expectedViewDefinition));
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/CreateViewFederationMetaDataRefresherTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/CreateViewFederationMetaDataRefresherTest.java
index 0031f044091..4b1194627cb 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/CreateViewFederationMetaDataRefresherTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/federation/type/CreateViewFederationMetaDataRefresherTest.java
@@ -43,7 +43,6 @@ import java.util.Collections;
import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyString;
@@ -81,7 +80,7 @@ class CreateViewFederationMetaDataRefresherTest {
verify(metaDataManagerPersistService).alterViews(eq(database), eq(schemaName), alteredViewsCaptor.capture());
verify(metaDataManagerPersistService, never()).dropViews(eq(database), anyString(), anyCollection());
Collection<ShardingSphereView> alteredViews = alteredViewsCaptor.getValue();
- assertThat(alteredViews, hasSize(1));
+ assertThat(alteredViews.size(), is(1));
ShardingSphereView actualView = alteredViews.iterator().next();
assertThat(actualView.getName(), is("foo_view"));
assertThat(actualView.getViewDefinition(), is(expectedViewDefinition));
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/AlterSchemaPushDownMetaDataRefresherTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/AlterSchemaPushDownMetaDataRefresherTest.java
index cee6b604458..e81d3e16fd9 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/AlterSchemaPushDownMetaDataRefresherTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/AlterSchemaPushDownMetaDataRefresherTest.java
@@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -58,8 +59,8 @@ class AlterSchemaPushDownMetaDataRefresherTest {
AlterSchemaStatement sqlStatement = new AlterSchemaStatement(databaseType);
sqlStatement.setSchemaName(new IdentifierValue("FOO_SCHEMA"));
refresher.refresh(persistService, createDatabase(), "logic_ds", "foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new Properties()));
- assertThat(persistService.getSourceSchemaName(), org.hamcrest.Matchers.nullValue());
- assertThat(persistService.getRenamedSchemaName(), org.hamcrest.Matchers.nullValue());
+ assertNull(persistService.getSourceSchemaName());
+ assertNull(persistService.getRenamedSchemaName());
}
private ShardingSphereDatabase createDatabase() {
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/CreateSchemaPushDownMetaDataRefresherTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/CreateSchemaPushDownMetaDataRefresherTest.java
index 6714b4653c3..8178fe2aee2 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/CreateSchemaPushDownMetaDataRefresherTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/schema/CreateSchemaPushDownMetaDataRefresherTest.java
@@ -31,6 +31,7 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -53,7 +54,7 @@ class CreateSchemaPushDownMetaDataRefresherTest {
void assertRefreshNoSchemaOrUserDoesNothing() {
SchemaMetaDataManagerPersistServiceFixture persistService = new SchemaMetaDataManagerPersistServiceFixture();
refresher.refresh(persistService, createDatabase(), "logic_ds", "foo_schema", databaseType, new CreateSchemaStatement(databaseType), new ConfigurationProperties(new Properties()));
- assertThat(persistService.getCreatedSchemaName(), org.hamcrest.Matchers.nullValue());
+ assertNull(persistService.getCreatedSchemaName());
}
private ShardingSphereDatabase createDatabase() {
diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/table/RenameTablePushDownMetaDataRefresherTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/table/RenameTablePushDownMetaDataRefresherTest.java
index a58a34e0eef..b145a412286 100644
--- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/table/RenameTablePushDownMetaDataRefresherTest.java
+++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/table/RenameTablePushDownMetaDataRefresherTest.java
@@ -38,7 +38,6 @@ import java.util.Collections;
import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
class RenameTablePushDownMetaDataRefresherTest {
@@ -54,7 +53,7 @@ class RenameTablePushDownMetaDataRefresherTest {
new IdentifierValue("foo_tbl"), new IdentifierValue("bar_tbl"))));
refresher.refresh(persistService, createDatabase(), "logic_ds", "foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new Properties()));
assertThat(persistService.getAlteredTableSchemaName(), is("Foo_Schema"));
- assertThat(persistService.getAlteredTables(), hasSize(1));
+ assertThat(persistService.getAlteredTables().size(), is(1));
assertThat(persistService.getAlteredTables().iterator().next().getName(), is("bar_tbl"));
assertThat(persistService.getDroppedTableSchemaName(), is("Foo_Schema"));
assertThat(persistService.getDroppedTableNames().iterator().next(), is("Foo_Tbl"));
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleConfigurationReflectionEngineTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleConfigurationReflectionEngineTest.java
index b9dcdc1fb93..32ce04ce92d 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleConfigurationReflectionEngineTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleConfigurationReflectionEngineTest.java
@@ -35,9 +35,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mockStatic;
@@ -72,7 +71,7 @@ class YamlRuleConfigurationReflectionEngineTest {
@Test
void assertGetFieldsOrderedByType() {
Collection<Field> actual = YamlRuleConfigurationReflectionEngine.getFields(FixtureYamlRuleConfiguration.class);
- assertThat(actual, hasSize(2));
+ assertThat(actual.size(), is(2));
Iterator<Field> iterator = actual.iterator();
assertThat(iterator.next().getName(), is("algorithmName"));
assertThat(iterator.next().getName(), is("strategyName"));
@@ -117,13 +116,13 @@ class YamlRuleConfigurationReflectionEngineTest {
@Test
void assertGetFieldsWithNoAnnotatedFields() {
Collection<Field> actual = YamlRuleConfigurationReflectionEngine.getFields(EmptyYamlRuleConfiguration.class);
- assertThat(actual, empty());
+ assertTrue(actual.isEmpty());
}
@Test
void assertGetFieldsWithAllTypeValues() {
Collection<Field> actual = YamlRuleConfigurationReflectionEngine.getFields(CompleteYamlRuleConfiguration.class);
- assertThat(actual, hasSize(7));
+ assertThat(actual.size(), is(7));
Iterator<Field> iterator = actual.iterator();
assertThat(iterator.next().getName(), is("algorithm"));
assertThat(iterator.next().getName(), is("defaultAlgorithm"));
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/NamedRuleItemConfigurationChangedHandlerTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/NamedRuleItemConfigurationChangedHandlerTest.java
index 65cd93684c7..8ad6ef63ba4 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/NamedRuleItemConfigurationChangedHandlerTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/NamedRuleItemConfigurationChangedHandlerTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.node.path.type.database.metadata.rule.DatabaseRuleItem;
import org.apache.shardingsphere.mode.node.path.type.database.metadata.rule.DatabaseRuleNodePath;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,7 +30,6 @@ import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -65,19 +65,20 @@ class NamedRuleItemConfigurationChangedHandlerTest {
void assertHandleWithAddItem() {
handler.handle("foo_db", new DataChangedEvent("/metadata/foo_db/rules/fixture/named/foo_rule_item/active_version", "0", Type.ADDED));
verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager())
- .alter(deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("named", "foo_rule_item"))));
+ .alter(ShardingSphereArgumentVerifyMatchers.deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("named", "foo_rule_item"))));
}
@Test
void assertHandleWithAlterItem() {
handler.handle("foo_db", new DataChangedEvent("/metadata/foo_db/rules/fixture/named/foo_rule_item/active_version", "0", Type.UPDATED));
verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager())
- .alter(deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("named", "foo_rule_item"))));
+ .alter(ShardingSphereArgumentVerifyMatchers.deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("named", "foo_rule_item"))));
}
@Test
void assertHandleDropItem() {
handler.handle("foo_db", new DataChangedEvent("/metadata/foo_db/rules/fixture/named/foo_rule_item", "0", Type.DELETED));
- verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager()).drop(deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("named", "foo_rule_item"))));
+ verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager())
+ .drop(ShardingSphereArgumentVerifyMatchers.deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("named", "foo_rule_item"))));
}
}
diff --git a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/UniqueRuleItemConfigurationChangedHandlerTest.java b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/UniqueRuleItemConfigurationChangedHandlerTest.java
index 8660efc4497..4f39482cf63 100644
--- a/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/UniqueRuleItemConfigurationChangedHandlerTest.java
+++ b/mode/type/cluster/core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/dispatch/handler/database/rule/type/UniqueRuleItemConfigurationChangedHandlerTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.mode.event.DataChangedEvent.Type;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.node.path.type.database.metadata.rule.DatabaseRuleItem;
import org.apache.shardingsphere.mode.node.path.type.database.metadata.rule.DatabaseRuleNodePath;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,7 +30,6 @@ import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -64,18 +64,21 @@ class UniqueRuleItemConfigurationChangedHandlerTest {
@Test
void assertHandleWithAddItem() {
handler.handle("foo_db", new DataChangedEvent("/metadata/foo_db/rules/fixture/unique/active_version", "0", Type.ADDED));
- verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager()).alter(deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("unique"))));
+ verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager())
+ .alter(ShardingSphereArgumentVerifyMatchers.deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("unique"))));
}
@Test
void assertHandleWithAlterItem() {
handler.handle("foo_db", new DataChangedEvent("/metadata/foo_db/rules/fixture/unique/active_version", "0", Type.UPDATED));
- verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager()).alter(deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("unique"))));
+ verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager())
+ .alter(ShardingSphereArgumentVerifyMatchers.deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("unique"))));
}
@Test
void assertHandleWitDropItem() {
handler.handle("foo_db", new DataChangedEvent("/metadata/foo_db/rules/fixture/unique", "0", Type.DELETED));
- verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager()).drop(deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("unique"))));
+ verify(contextManager.getMetaDataContextManager().getDatabaseRuleItemManager())
+ .drop(ShardingSphereArgumentVerifyMatchers.deepEq(new DatabaseRuleNodePath("foo_db", "fixture", new DatabaseRuleItem("unique"))));
}
}
diff --git a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java
index 049b50e26fb..c100bfbf0dd 100644
--- a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java
+++ b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/service/StandaloneMetaDataManagerPersistServiceTest.java
@@ -38,6 +38,7 @@ import org.apache.shardingsphere.mode.node.path.type.database.metadata.rule.Data
import org.apache.shardingsphere.mode.node.path.version.MetaDataVersion;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.rule.SingleRule;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -51,7 +52,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Properties;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
@@ -176,7 +176,7 @@ class StandaloneMetaDataManagerPersistServiceTest {
when(metaDataPersistFacade.getDatabaseRuleService().persist("foo_db", Collections.singleton(ruleConfig))).thenReturn(Collections.singleton(new MetaDataVersion(databaseRuleNodePath)));
when(metaDataPersistFacade.getRepository().query("/metadata/foo_db/rules/fixture/unique/active_version")).thenReturn("0");
metaDataManagerPersistService.alterRuleConfiguration(database, ruleConfig);
- verify(metaDataContextManager.getDatabaseRuleItemManager()).alter(deepEq(databaseRuleNodePath));
+ verify(metaDataContextManager.getDatabaseRuleItemManager()).alter(ShardingSphereArgumentVerifyMatchers.deepEq(databaseRuleNodePath));
}
@Test
@@ -221,8 +221,8 @@ class StandaloneMetaDataManagerPersistServiceTest {
when(metaDataPersistFacade.getDatabaseRuleService().delete("foo_db", Collections.singleton(ruleConfig))).thenReturn(Arrays.asList(
new MetaDataVersion(uniqueDatabaseRuleNodePath), new MetaDataVersion(namedDatabaseRuleNodePath)));
metaDataManagerPersistService.removeRuleConfigurationItem(database, ruleConfig);
- verify(metaDataContextManager.getDatabaseRuleItemManager()).drop(deepEq(uniqueDatabaseRuleNodePath));
- verify(metaDataContextManager.getDatabaseRuleItemManager()).drop(deepEq(namedDatabaseRuleNodePath));
+ verify(metaDataContextManager.getDatabaseRuleItemManager()).drop(ShardingSphereArgumentVerifyMatchers.deepEq(uniqueDatabaseRuleNodePath));
+ verify(metaDataContextManager.getDatabaseRuleItemManager()).drop(ShardingSphereArgumentVerifyMatchers.deepEq(namedDatabaseRuleNodePath));
}
@Test
diff --git a/mode/type/standalone/repository/provider/jdbc/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryTest.java b/mode/type/standalone/repository/provider/jdbc/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryTest.java
index 594e012e33e..c65634bc5cf 100644
--- a/mode/type/standalone/repository/provider/jdbc/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryTest.java
+++ b/mode/type/standalone/repository/provider/jdbc/src/test/java/org/apache/shardingsphere/mode/repository/standalone/jdbc/JDBCRepositoryTest.java
@@ -42,8 +42,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.eq;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
index 74ff6c1ed92..a3821d4a254 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
@@ -88,7 +88,6 @@ import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -484,7 +483,7 @@ class ProxyDatabaseConnectionManagerTest {
Multimap<String, Connection> cachedConnections = (Multimap<String, Connection>) Plugins.getMemberAccessor()
.get(ProxyDatabaseConnectionManager.class.getDeclaredField("cachedConnections"), databaseConnectionManager);
assertTrue(cachedConnections.containsKey(dataSourceName));
- assertArrayEquals(cachedConnections.get(dataSourceName).toArray(), connections.toArray());
+ assertThat(connections.toArray(), is(cachedConnections.get(dataSourceName).toArray()));
}
@Test
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
index 403ee5adff4..c674fe924e4 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutorTest.java
@@ -117,14 +117,14 @@ import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
-import static org.mockito.Mockito.anyCollection;
-import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
index 388e669cc83..a44d45d0f2d 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/StandardDatabaseProxyConnectorTest.java
@@ -128,11 +128,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
index c5b71cc504b..330934aa537 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
@@ -49,7 +49,6 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Answers;
-import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.internal.configuration.plugins.Plugins;
import org.mockito.junit.jupiter.MockitoSettings;
@@ -382,7 +381,7 @@ class ProxyBackendTransactionManagerTest {
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(transactionRule)));
when(contextManager.getExclusiveOperatorEngine()).thenReturn(exclusiveOperatorEngine);
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- when(OrderedSPILoader.getServices(eq(TransactionHook.class), ArgumentMatchers.<Collection<ShardingSphereRule>>any())).thenReturn(transactionHooks);
+ when(OrderedSPILoader.<ShardingSphereRule, TransactionHook>getServices(eq(TransactionHook.class), anyCollection())).thenReturn(transactionHooks);
}
@SneakyThrows(ReflectiveOperationException.class)
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java
index ae47500eef3..67421c13552 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/LockClusterExecutorTest.java
@@ -43,11 +43,11 @@ import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java
index 62edcfb6ded..9944caf6d29 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/lock/UnlockClusterExecutorTest.java
@@ -34,11 +34,11 @@ import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyLong;
import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
diff --git a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLKillProcessExecutorTest.java b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLKillProcessExecutorTest.java
index 7abf8e09f49..d1022326bbc 100644
--- a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLKillProcessExecutorTest.java
+++ b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLKillProcessExecutorTest.java
@@ -35,8 +35,8 @@ import org.mockito.Mock;
import java.sql.SQLException;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/authentication/FirebirdAuthenticationEngineTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/authentication/FirebirdAuthenticationEngineTest.java
index bd319dbc928..9be70a287c5 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/authentication/FirebirdAuthenticationEngineTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/authentication/FirebirdAuthenticationEngineTest.java
@@ -79,8 +79,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.isA;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
@@ -246,7 +246,6 @@ class FirebirdAuthenticationEngineTest {
}
}
- @SuppressWarnings("rawtypes")
@SneakyThrows(ReflectiveOperationException.class)
@Test
void assertAuthenticateAttachWithUnknownCharset() {
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchExecuteCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchExecuteCommandExecutorTest.java
index 4606db22ccf..878142d7566 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchExecuteCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchExecuteCommandExecutorTest.java
@@ -52,7 +52,6 @@ import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.clearInvocations;
@@ -119,7 +118,7 @@ class FirebirdBatchExecuteCommandExecutorTest {
FirebirdBatchCompletionStateResponse actualResponse = (FirebirdBatchCompletionStateResponse) actual.iterator().next();
assertThat(actualResponse, isA(FirebirdBatchCompletionStateResponse.class));
assertThat(getRecordsCount(actualResponse), is(2L));
- assertArrayEquals(new int[0], getUpdateCounts(actualResponse));
+ assertThat(getUpdateCounts(actualResponse), is(new int[0]));
verify(batchRegistry).getBatchStatement(CONNECTION_ID, STATEMENT_ID);
verify(connectionSession.getServerPreparedStatementRegistry()).getPreparedStatement(STATEMENT_ID);
verify(batchStatement).reset();
@@ -143,7 +142,7 @@ class FirebirdBatchExecuteCommandExecutorTest {
mockedRegistry.when(FirebirdBatchRegistry::getInstance).thenReturn(batchRegistry);
FirebirdBatchCompletionStateResponse actual = (FirebirdBatchCompletionStateResponse) new FirebirdBatchExecuteCommandExecutor(packet, connectionSession).execute().iterator().next();
assertThat(getRecordsCount(actual), is(2L));
- assertArrayEquals(new int[]{5, 5}, getUpdateCounts(actual));
+ assertThat(getUpdateCounts(actual), is(new int[]{5, 5}));
verify(batchStatement).reset();
}
}
@@ -164,7 +163,7 @@ class FirebirdBatchExecuteCommandExecutorTest {
clearInvocations(connectionSession.getServerPreparedStatementRegistry());
FirebirdBatchCompletionStateResponse actual = (FirebirdBatchCompletionStateResponse) new FirebirdBatchExecuteCommandExecutor(packet, connectionSession).execute().iterator().next();
assertThat(getRecordsCount(actual), is(0L));
- assertArrayEquals(new int[0], getUpdateCounts(actual));
+ assertThat(getUpdateCounts(actual), is(new int[0]));
verify(connectionSession.getServerPreparedStatementRegistry(), never()).getPreparedStatement(anyInt());
} finally {
FirebirdBatchRegistry.getInstance().unregisterConnection(CONNECTION_ID);
@@ -191,7 +190,7 @@ class FirebirdBatchExecuteCommandExecutorTest {
mockedRegistry.when(FirebirdBatchRegistry::getInstance).thenReturn(batchRegistry);
FirebirdBatchCompletionStateResponse actual = (FirebirdBatchCompletionStateResponse) new FirebirdBatchExecuteCommandExecutor(packet, connectionSession).execute().iterator().next();
assertThat(getRecordsCount(actual), is(2L));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}, getUpdateCounts(actual));
+ assertThat(getUpdateCounts(actual), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}));
List<DetailedError> detailedErrors = getDetailedErrors(actual);
assertThat(detailedErrors.size(), is(1));
assertThat(detailedErrors.get(0).getElement(), is(1));
@@ -218,7 +217,7 @@ class FirebirdBatchExecuteCommandExecutorTest {
mockedRegistry.when(FirebirdBatchRegistry::getInstance).thenReturn(batchRegistry);
FirebirdBatchCompletionStateResponse actual = (FirebirdBatchCompletionStateResponse) new FirebirdBatchExecuteCommandExecutor(packet, connectionSession).execute().iterator().next();
assertThat(getRecordsCount(actual), is(1L));
- assertArrayEquals(new int[0], getUpdateCounts(actual));
+ assertThat(getUpdateCounts(actual), is(new int[0]));
List<DetailedError> detailedErrors = getDetailedErrors(actual);
assertThat(detailedErrors.size(), is(1));
assertThat(detailedErrors.get(0).getElement(), is(0));
@@ -248,7 +247,7 @@ class FirebirdBatchExecuteCommandExecutorTest {
}
@Test
- void assertExecuteWithNoBatchStatement() throws SQLException {
+ void assertExecuteWithNoBatchStatement() {
when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
when(packet.getStatementHandle()).thenReturn(STATEMENT_ID);
when(batchRegistry.getBatchStatement(CONNECTION_ID, STATEMENT_ID)).thenReturn(null);
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchedStatementsExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchedStatementsExecutorTest.java
index f5c1b25cc26..6456a868e13 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchedStatementsExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchedStatementsExecutorTest.java
@@ -77,7 +77,6 @@ import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -122,7 +121,7 @@ class FirebirdBatchedStatementsExecutorTest {
List<List<Object>> parameterSets = Arrays.asList(Arrays.asList(1, "foo_1"), Arrays.asList(2, "foo_2"));
FirebirdBatchCompletion actual = new FirebirdBatchedStatementsExecutor(mockConnectionSession(), firebirdPreparedStatement, parameterSets, false).executeBatch();
assertThat(actual.getRecordsCount(), is(2));
- assertArrayEquals(new int[]{1, 2}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, 2}));
assertTrue(actual.getFailures().isEmpty());
InOrder inOrder = inOrder(preparedStatement);
for (List<Object> each : parameterSets) {
@@ -160,7 +159,7 @@ class FirebirdBatchedStatementsExecutorTest {
.thenReturn(new ExecutionContext(null, Arrays.asList(firstExecutionUnit, secondExecutionUnit), mock(RouteContext.class))))) {
FirebirdBatchCompletion actual = new FirebirdBatchedStatementsExecutor(mockConnectionSession(), firebirdPreparedStatement, Collections.singletonList(params), false).executeBatch();
assertThat(actual.getRecordsCount(), is(1));
- assertArrayEquals(new int[]{2}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{2}));
assertTrue(actual.getFailures().isEmpty());
}
}
@@ -195,7 +194,7 @@ class FirebirdBatchedStatementsExecutorTest {
FirebirdBatchCompletion actual = new FirebirdBatchedStatementsExecutor(mockConnectionSession(), firebirdPreparedStatement,
Arrays.asList(firstParams, secondParams), false).executeBatch();
assertThat(actual.getRecordsCount(), is(2));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(1));
@@ -235,7 +234,7 @@ class FirebirdBatchedStatementsExecutorTest {
verify(secondPreparedStatement, never()).executeBatch();
verify(secondPreparedStatement).close();
assertThat(actual.getRecordsCount(), is(1));
- assertArrayEquals(new int[]{FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(0));
@@ -273,7 +272,7 @@ class FirebirdBatchedStatementsExecutorTest {
FirebirdBatchCompletion actual = new FirebirdBatchedStatementsExecutor(mockConnectionSession(), firebirdPreparedStatement,
Arrays.asList(firstParams, secondParams), true).executeBatch();
assertThat(actual.getRecordsCount(), is(2));
- assertArrayEquals(new int[]{FirebirdBatchCompletion.EXECUTE_FAILED, 1}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{FirebirdBatchCompletion.EXECUTE_FAILED, 1}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(0));
@@ -285,10 +284,10 @@ class FirebirdBatchedStatementsExecutorTest {
void assertExecuteBatchWithoutMultiErrorStopsSameRouteAtFailedMessage() throws SQLException {
PreparedStatement preparedStatement = mockSameRoutePreparedStatement();
when(preparedStatement.executeBatch()).thenReturn(new int[]{1}).thenThrow(createFailure(new int[0]));
- FirebirdBatchCompletion actual = executeSameRouteBatch(preparedStatement, false);
+ FirebirdBatchCompletion actual = executeSameRouteBatch(false);
verify(preparedStatement, times(2)).executeBatch();
assertThat(actual.getRecordsCount(), is(2));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
assertThat(actual.getFailures().iterator().next().getMessageIndex(), is(1));
}
@@ -298,10 +297,10 @@ class FirebirdBatchedStatementsExecutorTest {
PreparedStatement preparedStatement = mockSameRoutePreparedStatement();
BatchUpdateException failure = createFailure(new int[0]);
when(preparedStatement.executeBatch()).thenReturn(new int[]{1}).thenThrow(failure);
- FirebirdBatchCompletion actual = executeSameRouteBatch(preparedStatement, false);
+ FirebirdBatchCompletion actual = executeSameRouteBatch(false);
assertThat(actual.getRecordsCount(), is(2));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(1));
@@ -316,9 +315,9 @@ class FirebirdBatchedStatementsExecutorTest {
void assertExecuteBatchWithMultiErrorContinuesSameRouteAfterFailedMessage() throws SQLException {
PreparedStatement preparedStatement = mockSameRoutePreparedStatement();
when(preparedStatement.executeBatch()).thenThrow(createFailure(new int[]{1})).thenReturn(new int[]{1});
- FirebirdBatchCompletion actual = executeSameRouteBatch(preparedStatement, true);
+ FirebirdBatchCompletion actual = executeSameRouteBatch(true);
assertThat(actual.getRecordsCount(), is(3));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED, 1}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED, 1}));
assertThat(actual.getFailures().size(), is(1));
assertThat(actual.getFailures().iterator().next().getMessageIndex(), is(1));
verify(preparedStatement, times(2)).executeBatch();
@@ -332,9 +331,9 @@ class FirebirdBatchedStatementsExecutorTest {
PreparedStatement preparedStatement = mockSameRoutePreparedStatement();
SQLException failure = new SQLException("connection lost", "08006", 335544721);
when(preparedStatement.executeBatch()).thenThrow(failure);
- FirebirdBatchCompletion actual = executeSameRouteBatch(preparedStatement, false);
+ FirebirdBatchCompletion actual = executeSameRouteBatch(false);
assertThat(actual.getRecordsCount(), is(1));
- assertArrayEquals(new int[]{FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(0));
@@ -351,9 +350,9 @@ class FirebirdBatchedStatementsExecutorTest {
SQLException secondCause = new SQLException("second violation", "23000", 335544349);
secondFailure.setNextException(secondCause);
when(preparedStatement.executeBatch()).thenThrow(firstFailure).thenThrow(secondFailure);
- FirebirdBatchCompletion actual = executeSameRouteBatch(preparedStatement, true);
+ FirebirdBatchCompletion actual = executeSameRouteBatch(true);
assertThat(actual.getRecordsCount(), is(3));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED, FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED, FirebirdBatchCompletion.EXECUTE_FAILED}));
Iterator<FirebirdBatchCompletion.Failure> actualFailures = actual.getFailures().iterator();
FirebirdBatchCompletion.Failure actualFirstFailure = actualFailures.next();
assertThat(actualFirstFailure.getMessageIndex(), is(1));
@@ -372,7 +371,7 @@ class FirebirdBatchedStatementsExecutorTest {
when(secondPreparedStatement.executeBatch()).thenThrow(failure);
FirebirdBatchCompletion actual = executeInterleavedRoutesBatch(firstPreparedStatement, secondPreparedStatement);
assertThat(actual.getRecordsCount(), is(2));
- assertArrayEquals(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(1));
@@ -400,7 +399,7 @@ class FirebirdBatchedStatementsExecutorTest {
when(secondPreparedStatement.executeBatch()).thenReturn(new int[]{1});
FirebirdBatchCompletion actual = executeInterleavedRoutesBatch(firstPreparedStatement, secondPreparedStatement);
assertThat(actual.getRecordsCount(), is(3));
- assertArrayEquals(new int[]{1, 1, FirebirdBatchCompletion.EXECUTE_FAILED}, actual.getUpdateCounts());
+ assertThat(actual.getUpdateCounts(), is(new int[]{1, 1, FirebirdBatchCompletion.EXECUTE_FAILED}));
assertThat(actual.getFailures().size(), is(1));
FirebirdBatchCompletion.Failure actualFailure = actual.getFailures().iterator().next();
assertThat(actualFailure.getMessageIndex(), is(2));
@@ -463,7 +462,7 @@ class FirebirdBatchedStatementsExecutorTest {
return result;
}
- private FirebirdBatchCompletion executeSameRouteBatch(final PreparedStatement preparedStatement, final boolean multiError) throws SQLException {
+ private FirebirdBatchCompletion executeSameRouteBatch(final boolean multiError) throws SQLException {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
FirebirdServerPreparedStatement firebirdPreparedStatement = new FirebirdServerPreparedStatement("INSERT INTO t (id, col) VALUES (?, ?)",
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementResourceCleanerTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementResourceCleanerTest.java
index a13c91125d8..4074582b6aa 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementResourceCleanerTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementResourceCleanerTest.java
@@ -43,6 +43,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -142,7 +143,7 @@ class FirebirdStatementResourceCleanerTest {
actualConnectionManager.add(actualProxyBackendHandler);
actualConnectionManager.markResourceInUse(actualProxyBackendHandler);
AtomicBoolean closed = new AtomicBoolean(false);
- org.mockito.Mockito.doAnswer(invocation -> {
+ doAnswer(invocation -> {
if (closed.getAndSet(true)) {
throw new SQLException("close twice");
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
index fcf327cd9c5..dc006f0ccbf 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/execute/FirebirdExecuteStatementCommandExecutorTest.java
@@ -83,7 +83,6 @@ import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -309,7 +308,7 @@ class FirebirdExecuteStatementCommandExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(new UpdateResponseHeader(UpdateStatement.builder().databaseType(DATABASE_TYPE).build()));
when(ProxyBackendHandlerFactory.newInstance(eq(DATABASE_TYPE), queryContextCaptor.capture(), eq(connectionSession), eq(true))).thenReturn(proxyBackendHandler);
executor.execute();
- assertArrayEquals(new byte[]{5, 6}, (byte[]) queryContextCaptor.getValue().getParameters().get(0));
+ assertThat((byte[]) queryContextCaptor.getValue().getParameters().get(0), is(new byte[]{5, 6}));
}
@Test
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/resource/FirebirdConnectionResourceManagerTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/resource/FirebirdConnectionResourceManagerTest.java
index 07f75e9422d..b8785dbcab1 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/resource/FirebirdConnectionResourceManagerTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/resource/FirebirdConnectionResourceManagerTest.java
@@ -37,7 +37,8 @@ import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;
import org.mockito.Mock;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
@@ -117,7 +118,7 @@ class FirebirdConnectionResourceManagerTest {
new FirebirdBlobBinaryProtocolValue().write(payload, expectedBlobContent);
ArgumentCaptor<Long> blobIdCaptor = ArgumentCaptor.forClass(Long.class);
verify(payload).writeInt8(blobIdCaptor.capture());
- assertArrayEquals(expectedBlobContent, FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobIdCaptor.getValue()));
+ assertThat(FirebirdBlobBinaryProtocolValue.getBlobContent(CONNECTION_ID, blobIdCaptor.getValue()), is(expectedBlobContent));
FirebirdConnectionResourceManager.getInstance().unregisterConnection(CONNECTION_ID);
InOrder inOrder = inOrder(statementIdGenerator, transactionIdGenerator, blobIdGenerator, blobHandleGenerator, blobWriteCache, blobReadCache,
connectionProtocolVersion, fetchStatementCache, batchStatementManager);
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLServerPreparedStatementTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLServerPreparedStatementTest.java
index 8537a256ea1..3419a2651b6 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLServerPreparedStatementTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/MySQLServerPreparedStatementTest.java
@@ -36,10 +36,10 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
@@ -51,7 +51,7 @@ class MySQLServerPreparedStatementTest {
@Test
void assertGetLongDataIndexesWhenEmpty() throws SQLException {
- assertThat(createPreparedStatement(Collections.emptyList()).getLongDataIndexes(), is(empty()));
+ assertTrue(createPreparedStatement(Collections.emptyList()).getLongDataIndexes().isEmpty());
}
@Test
@@ -126,7 +126,7 @@ class MySQLServerPreparedStatementTest {
assertThat(actual.getMessage(), is("Parameter of prepared statement which is set through mysql_send_long_data() is longer than 'max_allowed_packet' bytes"));
assertThrows(SQLException.class, preparedStatement::getLongDataIndexes);
preparedStatement.clearLongData();
- assertThat(preparedStatement.getLongDataIndexes(), is(empty()));
+ assertTrue(preparedStatement.getLongDataIndexes().isEmpty());
}
private void appendRepeatedLongData(final MySQLServerPreparedStatement preparedStatement, final int count) {
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
index decc5a5d060..d7b5285ecab 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutorTest.java
@@ -94,7 +94,6 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -396,7 +395,7 @@ class MySQLComStmtExecuteExecutorTest {
});
new MySQLComStmtExecuteExecutor(packet, connectionSession).execute();
assertThat(actualQueryContext.get().getParameters(), contains("中"));
- assertThat(preparedStatement.getLongDataIndexes(), is(empty()));
+ assertTrue(preparedStatement.getLongDataIndexes().isEmpty());
}
@Test
@@ -409,7 +408,7 @@ class MySQLComStmtExecuteExecutorTest {
when(packet.readParameters(anyList(), any(), anyList())).thenThrow(expected);
SQLException actual = assertThrows(SQLException.class, () -> new MySQLComStmtExecuteExecutor(packet, connectionSession).execute());
assertThat(actual, is(expected));
- assertThat(preparedStatement.getLongDataIndexes(), is(empty()));
+ assertTrue(preparedStatement.getLongDataIndexes().isEmpty());
}
@Test
@@ -427,7 +426,7 @@ class MySQLComStmtExecuteExecutorTest {
when(ProxyBackendHandlerFactory.newInstance(eq(databaseType), any(QueryContext.class), eq(connectionSession), anyBoolean())).thenReturn(proxyBackendHandler);
SQLException actual = assertThrows(SQLException.class, () -> new MySQLComStmtExecuteExecutor(packet, connectionSession).execute());
assertThat(actual, is(expected));
- assertThat(preparedStatement.getLongDataIndexes(), is(empty()));
+ assertTrue(preparedStatement.getLongDataIndexes().isEmpty());
}
@Test
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
index fd16ad05b4f..8f68c58e81d 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
@@ -87,9 +87,9 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.when;
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBackendHandlerFactoryTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBackendHandlerFactoryTest.java
index b0136977a3d..58dae033e93 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBackendHandlerFactoryTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBackendHandlerFactoryTest.java
@@ -69,13 +69,12 @@ import java.util.Properties;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isA;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -164,7 +163,7 @@ class MySQLComQueryBackendHandlerFactoryTest {
assertThat(actual.getParameters().size(), is(1));
assertTrue(actual.isUseCache());
Blob blob = (Blob) actual.getParameters().get(0);
- assertArrayEquals(new byte[]{(byte) 0xFF}, blob.getBytes(1, (int) blob.length()));
+ assertThat(blob.getBytes(1, (int) blob.length()), is(new byte[]{(byte) 0xFF}));
}
@Test
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBinaryParameterExtractorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBinaryParameterExtractorTest.java
index ef5563d2c52..3d573f829b8 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBinaryParameterExtractorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryBinaryParameterExtractorTest.java
@@ -25,10 +25,9 @@ import java.nio.charset.StandardCharsets;
import java.sql.Blob;
import java.sql.SQLException;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
class MySQLComQueryBinaryParameterExtractorTest {
@@ -38,7 +37,7 @@ class MySQLComQueryBinaryParameterExtractorTest {
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(
sql("INSERT INTO t VALUES (_binary'", content, "')"), StandardCharsets.UTF_8);
assertThat(actual.getSql(), is("INSERT INTO t VALUES (?)"));
- assertArrayEquals(new byte[]{0, '\'', '\\', (byte) 0xFF}, getBlobBytes(actual.getBinaryLiteralValues().get(0)));
+ assertThat(getBlobBytes(actual.getBinaryLiteralValues().get(0)), is(new byte[]{0, '\'', '\\', (byte) 0xFF}));
}
@Test
@@ -47,7 +46,7 @@ class MySQLComQueryBinaryParameterExtractorTest {
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(
sql("INSERT INTO t VALUES ('", content, "')"), StandardCharsets.UTF_8);
assertThat(actual.getSql(), is("INSERT INTO t VALUES (?)"));
- assertArrayEquals(new byte[]{'\b', '\n', '\r', '\t', 0x1A, 'q', '\\', '%', '\\', '_', (byte) 0xFF}, getBlobBytes(actual.getBinaryLiteralValues().get(0)));
+ assertThat(getBlobBytes(actual.getBinaryLiteralValues().get(0)), is(new byte[]{'\b', '\n', '\r', '\t', 0x1A, 'q', '\\', '%', '\\', '_', (byte) 0xFF}));
}
@Test
@@ -56,7 +55,7 @@ class MySQLComQueryBinaryParameterExtractorTest {
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(
sql("INSERT INTO t VALUES ('", content, "')"), StandardCharsets.UTF_8);
assertThat(actual.getSql(), is("INSERT INTO t VALUES (?)"));
- assertArrayEquals(new byte[]{'f', 'o', '\'', (byte) 0xFF}, getBlobBytes(actual.getBinaryLiteralValues().get(0)));
+ assertThat(getBlobBytes(actual.getBinaryLiteralValues().get(0)), is(new byte[]{'f', 'o', '\'', (byte) 0xFF}));
}
@Test
@@ -65,21 +64,21 @@ class MySQLComQueryBinaryParameterExtractorTest {
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(sql, StandardCharsets.UTF_8);
assertThat(actual.getSql(), is("SELECT _BiNaRy 'fo''o', ?"));
assertThat(actual.getBinaryLiteralValues().size(), is(1));
- assertArrayEquals(new byte[]{(byte) 0xFF}, getBlobBytes(actual.getBinaryLiteralValues().get(0)));
+ assertThat(getBlobBytes(actual.getBinaryLiteralValues().get(0)), is(new byte[]{(byte) 0xFF}));
}
@Test
void assertSkipValidLiteral() throws SQLException {
String sql = "SELECT '😀', _binary'foo'";
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(sql.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
- assertThat(actual.getBinaryLiteralValues(), empty());
+ assertTrue(actual.getBinaryLiteralValues().isEmpty());
}
@Test
void assertIgnoreNonLiteralBinaryTokens() throws SQLException {
String sql = "SELECT '_binary', `_binary'ignored`, \"_binary'ignored'\", 1 /* _binary'x' */ -- _binary'y'\n";
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(sql.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
- assertThat(actual.getBinaryLiteralValues(), empty());
+ assertTrue(actual.getBinaryLiteralValues().isEmpty());
}
@Test
@@ -87,28 +86,28 @@ class MySQLComQueryBinaryParameterExtractorTest {
Charset charset = Charset.forName("Shift_JIS");
byte[] content = {(byte) 0x83, '\\', (byte) 0xFF};
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(sql("SELECT _binary'", content, "'"), charset);
- assertArrayEquals(content, getBlobBytes(actual.getBinaryLiteralValues().get(0)));
+ assertThat(getBlobBytes(actual.getBinaryLiteralValues().get(0)), is(content));
}
@Test
void assertKeepMalformedSQLForParser() throws SQLException {
byte[] sql = "SELECT _binary'foo".getBytes(StandardCharsets.UTF_8);
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(sql, StandardCharsets.UTF_8);
- assertThat(actual.getBinaryLiteralValues(), empty());
+ assertTrue(actual.getBinaryLiteralValues().isEmpty());
}
@Test
void assertSkipDoubleQuotedLiteral() throws SQLException {
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(
sql("SELECT _binary\"", new byte[]{(byte) 0xFF}, "\""), StandardCharsets.UTF_8);
- assertThat(actual.getBinaryLiteralValues(), empty());
+ assertTrue(actual.getBinaryLiteralValues().isEmpty());
}
@Test
void assertSkipAdjacentLiteral() throws SQLException {
MySQLComQueryBinaryParameterExtractor.ExtractionResult actual = MySQLComQueryBinaryParameterExtractor.extract(
sql("SELECT _binary'", new byte[]{(byte) 0xFF}, "' 'foo'"), StandardCharsets.UTF_8);
- assertThat(actual.getBinaryLiteralValues(), empty());
+ assertTrue(actual.getBinaryLiteralValues().isEmpty());
}
private static byte[] sql(final String prefix, final byte[] content, final String suffix) {
diff --git a/src/resources/checkstyle.xml b/src/resources/checkstyle.xml
index 27cbac36d38..ca7a12f727a 100644
--- a/src/resources/checkstyle.xml
+++ b/src/resources/checkstyle.xml
@@ -168,12 +168,17 @@
<!-- Imports -->
<module name="AvoidStarImport" />
<module name="AvoidStaticImport">
- <property name="excludes" value="org.junit.jupiter.api.Assertions.assertTrue,org.junit.jupiter.api.Assertions.assertFalse,org.junit.jupiter.api.Assertions.assertNull,org.junit.jupiter.api.Assertions.assertNotNull,org.junit.jupiter.api.Assertions.assertArrayEquals,org.junit.jupiter.api.Assertions.assertThrows,org.junit.jupiter.api.Assertions.assertDoesNotThrow,org.junit.jupiter.api.Assertions.assertTimeout,org.junit.jupiter.api.Assertions.assertTimeoutPreemptively,org.junit.ju [...]
+ <property name="excludes" value="org.junit.jupiter.api.Assertions.assertTrue,org.junit.jupiter.api.Assertions.assertFalse,org.junit.jupiter.api.Assertions.assertNull,org.junit.jupiter.api.Assertions.assertNotNull,org.junit.jupiter.api.Assertions.assertThrows,org.junit.jupiter.api.Assertions.assertDoesNotThrow,org.junit.jupiter.api.Assertions.assertTimeout,org.junit.jupiter.api.Assertions.assertTimeoutPreemptively,org.junit.jupiter.api.Assertions.fail,org.hamcrest.Matchers.arr [...]
</module>
<module name="RegexpSinglelineJava">
- <property name="format" value="^\s*import\s+org\.(hamcrest\.Matchers|junit\.jupiter\.api\.Assertions)\s*;" />
+ <property name="format" value="^\s*import\s+(org\.hamcrest\.(CoreMatchers|MatcherAssert|Matchers)|org\.junit\.jupiter\.api\.Assertions|org\.mockito\.(ArgumentMatchers|Mockito))\s*;" />
<property name="ignoreComments" value="true" />
- <property name="message" value="Use static import for org.hamcrest.Matchers and org.junit.jupiter.api.Assertions." />
+ <property name="message" value="Use static import for Mockito, JUnit assertions, Hamcrest matchers and MatcherAssert." />
+ </module>
+ <module name="RegexpSinglelineJava">
+ <property name="format" value="^(?!\s*import\s+static\s+).*\b(Mockito|ArgumentMatchers|Assertions|CoreMatchers|Matchers|MatcherAssert)\s*(\.|::)" />
+ <property name="ignoreComments" value="true" />
+ <property name="message" value="Use an allowed static import instead of a qualified static member call." />
</module>
<module name="IllegalImport">
<property name="regexp" value="true" />
diff --git a/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLDatabaseRuleQueryExecutorAssert.java b/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLDatabaseRuleQueryExecutorAssert.java
index dc74b5a0eb1..cd8b65037ab 100644
--- a/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLDatabaseRuleQueryExecutorAssert.java
+++ b/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLDatabaseRuleQueryExecutorAssert.java
@@ -29,13 +29,13 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.rule.scope.DatabaseRule;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -61,7 +61,7 @@ public final class DistSQLDatabaseRuleQueryExecutorAssert {
DistSQLQueryExecuteEngine engine = new DistSQLQueryExecuteEngine(sqlStatement, "foo_db", mockContextManager(ruleConfig), mock(DistSQLConnectionContext.class));
engine.executeQuery();
Collection<LocalDataQueryResultRow> actual = new ArrayList<>(engine.getRows());
- assertThat(actual, deepEqual(new ArrayList<>(expected)));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ArrayList<>(expected)));
}
private ContextManager mockContextManager(final DatabaseRuleConfiguration ruleConfig) {
diff --git a/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLGlobalRuleQueryExecutorAssert.java b/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLGlobalRuleQueryExecutorAssert.java
index 92b31932e45..35e3355b08d 100644
--- a/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLGlobalRuleQueryExecutorAssert.java
+++ b/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/query/DistSQLGlobalRuleQueryExecutorAssert.java
@@ -26,13 +26,13 @@ import org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryRes
import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -59,7 +59,7 @@ public final class DistSQLGlobalRuleQueryExecutorAssert {
DistSQLQueryExecuteEngine engine = new DistSQLQueryExecuteEngine(sqlStatement, null, mockContextManager(currentRuleConfig), mock(DistSQLConnectionContext.class));
engine.executeQuery();
Collection<LocalDataQueryResultRow> actual = new ArrayList<>(engine.getRows());
- assertThat(actual, deepEqual(new ArrayList<>(expected)));
+ assertThat(actual, ShardingSphereAssertionMatchers.deepEqual(new ArrayList<>(expected)));
}
private ContextManager mockContextManager(final GlobalRuleConfiguration ruleConfig) {
diff --git a/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/update/DistSQLGlobalRuleDefinitionExecutorAssert.java b/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/update/DistSQLGlobalRuleDefinitionExecutorAssert.java
index 64b6d6b0a52..d277c5014cb 100644
--- a/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/update/DistSQLGlobalRuleDefinitionExecutorAssert.java
+++ b/test/it/distsql/src/main/java/org/apache/shardingsphere/test/it/distsql/handler/engine/update/DistSQLGlobalRuleDefinitionExecutorAssert.java
@@ -27,11 +27,11 @@ import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers;
import java.sql.SQLException;
import java.util.Collections;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereArgumentVerifyMatchers.deepEq;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -65,7 +65,7 @@ public final class DistSQLGlobalRuleDefinitionExecutorAssert {
}
engine.executeUpdate();
MetaDataManagerPersistService metaDataManagerPersistService = contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService();
- verify(metaDataManagerPersistService).alterGlobalRuleConfiguration(deepEq(matchedRuleConfig));
+ verify(metaDataManagerPersistService).alterGlobalRuleConfiguration(ShardingSphereArgumentVerifyMatchers.deepEq(matchedRuleConfig));
}
private ContextManager mockContextManager(final GlobalRuleConfiguration ruleConfig) {
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisDescFunctionStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisDescFunctionStatementAssert.java
index 76df53a0af3..b7519c6c5cf 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisDescFunctionStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisDescFunctionStatementAssert.java
@@ -24,8 +24,8 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAsse
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQLSegmentAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisDescFunctionStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -50,7 +50,7 @@ public final class DorisDescFunctionStatementAssert {
private static void assertFunctionName(final SQLCaseAssertContext assertContext, final DorisDescFunctionStatement actual, final DorisDescFunctionStatementTestCase expected) {
if (null != expected.getFunctionName()) {
assertTrue(actual.getFunctionName().isPresent(), assertContext.getText("Function name should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Function name assertion error: "), actual.getFunctionName().get().getIdentifier().getValue(),
+ assertThat(assertContext.getText("Function name assertion error: "), actual.getFunctionName().get().getIdentifier().getValue(),
is(expected.getFunctionName().getFunctionName()));
SQLSegmentAssert.assertIs(assertContext, actual.getFunctionName().get(), expected.getFunctionName());
if (null == expected.getFunctionName().getOwner()) {
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisPlanReplayerPlayStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisPlanReplayerPlayStatementAssert.java
index 4397227b365..67e4e2dc854 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisPlanReplayerPlayStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisPlanReplayerPlayStatementAssert.java
@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisPlanReplayerPlayStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisPlanReplayerPlayStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -40,6 +40,6 @@ public final class DorisPlanReplayerPlayStatementAssert {
* @param expected expected plan replayer play statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisPlanReplayerPlayStatement actual, final DorisPlanReplayerPlayStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("Assertion error: dump file path does not match."), actual.getDumpFilePath(), is(expected.getDumpFilePath()));
+ assertThat(assertContext.getText("Assertion error: dump file path does not match."), actual.getDumpFilePath(), is(expected.getDumpFilePath()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowCreateRoutineLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowCreateRoutineLoadStatementAssert.java
index 8741fe47562..af72244b309 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowCreateRoutineLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowCreateRoutineLoadStatementAssert.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisShowCreateR
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.database.DatabaseAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisShowCreateRoutineLoadStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -41,9 +41,9 @@ public final class DorisShowCreateRoutineLoadStatementAssert {
* @param expected expected show create routine load statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisShowCreateRoutineLoadStatement actual, final DorisShowCreateRoutineLoadStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("All flag does not match: "), actual.isAll(), is(expected.isAll()));
+ assertThat(assertContext.getText("All flag does not match: "), actual.isAll(), is(expected.isAll()));
if (actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getDatabase()) {
DatabaseAssert.assertIs(assertContext, actual.getJobName().get().getDatabase().orElse(null), expected.getDatabase());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowDatabaseStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowDatabaseStatementAssert.java
index 38981956715..902772ecadc 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowDatabaseStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowDatabaseStatementAssert.java
@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisShowDatabaseStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisShowDatabaseStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -40,6 +40,6 @@ public final class DorisShowDatabaseStatementAssert {
* @param expected expected show database statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisShowDatabaseStatement actual, final DorisShowDatabaseStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("Assertion error: database id does not match."), actual.getDatabaseId(), is(expected.getDatabaseId()));
+ assertThat(assertContext.getText("Assertion error: database id does not match."), actual.getDatabaseId(), is(expected.getDatabaseId()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowProcStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowProcStatementAssert.java
index b52a41d7fa7..04ed7e59627 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowProcStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowProcStatementAssert.java
@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisShowProcStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisShowProcStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -40,6 +40,6 @@ public final class DorisShowProcStatementAssert {
* @param expected expected show proc statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisShowProcStatement actual, final DorisShowProcStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("Assertion error: proc path does not match."), actual.getProcPath(), is(expected.getProcPath()));
+ assertThat(assertContext.getText("Assertion error: proc path does not match."), actual.getProcPath(), is(expected.getProcPath()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowTableStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowTableStatementAssert.java
index 95a77049f69..6ee8db975f4 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowTableStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisShowTableStatementAssert.java
@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.doris.dal.DorisShowTableStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisShowTableStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -40,6 +40,6 @@ public final class DorisShowTableStatementAssert {
* @param expected expected show table statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisShowTableStatement actual, final DorisShowTableStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("Assertion error: table id does not match."), actual.getTableId(), is(expected.getTableId()));
+ assertThat(assertContext.getText("Assertion error: table id does not match."), actual.getTableId(), is(expected.getTableId()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisUnsetVariableStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisUnsetVariableStatementAssert.java
index 5d266562ddb..a1ba89d1ca6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisUnsetVariableStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/dialect/doris/type/DorisUnsetVariableStatementAssert.java
@@ -22,8 +22,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dal.UnsetVariableStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.DorisUnsetVariableStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -40,7 +40,7 @@ public final class DorisUnsetVariableStatementAssert {
* @param expected expected unset variable statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final UnsetVariableStatement actual, final DorisUnsetVariableStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("Unset variable scope assertion error: "), actual.getScope(), is(expected.getScope()));
- MatcherAssert.assertThat(assertContext.getText("Unset variable name assertion error: "), actual.getVariableName(), is(expected.getVariableName()));
+ assertThat(assertContext.getText("Unset variable scope assertion error: "), actual.getScope(), is(expected.getScope()));
+ assertThat(assertContext.getText("Unset variable name assertion error: "), actual.getVariableName(), is(expected.getVariableName()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisPauseSyncJobStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisPauseSyncJobStatementAssert.java
index dab8b676a28..afe3eb26f67 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisPauseSyncJobStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisPauseSyncJobStatementAssert.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisPauseSyncJo
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisPauseSyncJobStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -42,7 +42,7 @@ public final class DorisPauseSyncJobStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisPauseSyncJobStatement actual, final DorisPauseSyncJobStatementTestCase expected) {
if (actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisResumeSyncJobStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisResumeSyncJobStatementAssert.java
index ef6db9f8bf6..9ab883798f5 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisResumeSyncJobStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/doris/DorisResumeSyncJobStatementAssert.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisResumeSyncJ
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisResumeSyncJobStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -42,7 +42,7 @@ public final class DorisResumeSyncJobStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisResumeSyncJobStatement actual, final DorisResumeSyncJobStatementTestCase expected) {
if (actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/oracle/OracleDDLStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/oracle/OracleDDLStatementAssert.java
index abf53f79e25..0f19491699d 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/oracle/OracleDDLStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ddl/dialect/oracle/OracleDDLStatementAssert.java
@@ -58,6 +58,9 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.oracle.statistics.OracleAssociateStatisticsStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.oracle.statistics.OracleDisassociateStatisticsStatementTestCase;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
+
/**
* DDL statement assert for Oracle.
*/
@@ -95,8 +98,8 @@ public final class OracleDDLStatementAssert {
} else if (actual instanceof OraclePurgeStatement) {
OraclePurgeStatementAssert.assertIs(assertContext, (OraclePurgeStatement) actual, (OraclePurgeStatementTestCase) expected);
} else if (expected instanceof OracleCreateIndexTypeStatementTestCase) {
- org.hamcrest.MatcherAssert.assertThat(assertContext.getText("Actual statement should be OracleCreateIndexTypeStatement."),
- actual, org.hamcrest.CoreMatchers.instanceOf(OracleCreateIndexTypeStatement.class));
+ assertThat(assertContext.getText("Actual statement should be OracleCreateIndexTypeStatement."),
+ actual, isA(OracleCreateIndexTypeStatement.class));
}
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisAlterRoutineLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisAlterRoutineLoadStatementAssert.java
index 86a1de6e518..f9da18b9c99 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisAlterRoutineLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisAlterRoutineLoadStatementAssert.java
@@ -26,9 +26,8 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.SQL
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.PropertyTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.DorisAlterRoutineLoadStatementTestCase;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -54,7 +53,7 @@ public final class DorisAlterRoutineLoadStatementAssert {
private static void assertJobName(final SQLCaseAssertContext assertContext, final DorisAlterRoutineLoadStatement actual, final DorisAlterRoutineLoadStatementTestCase expected) {
if (actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
@@ -62,10 +61,10 @@ public final class DorisAlterRoutineLoadStatementAssert {
}
private static void assertJobProperties(final SQLCaseAssertContext assertContext, final DorisAlterRoutineLoadStatement actual, final DorisAlterRoutineLoadStatementTestCase expected) {
- if (actual.getJobProperties().isPresent() && null != expected.getJobProperties() && !expected.getJobProperties().isEmpty()) {
+ if (actual.getJobProperties().isPresent() && !expected.getJobProperties().isEmpty()) {
assertNotNull(actual.getJobProperties().get(), assertContext.getText("Job properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Job properties size does not match: "), actual.getJobProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getJobProperties().size()));
+ assertThat(assertContext.getText("Job properties size does not match: "), actual.getJobProperties().get().getProperties().size(),
+ is(expected.getJobProperties().size()));
for (int i = 0; i < expected.getJobProperties().size(); i++) {
assertProperty(assertContext, actual.getJobProperties().get().getProperties().get(i), expected.getJobProperties().get(i));
}
@@ -74,15 +73,15 @@ public final class DorisAlterRoutineLoadStatementAssert {
private static void assertDataSource(final SQLCaseAssertContext assertContext, final DorisAlterRoutineLoadStatement actual, final DorisAlterRoutineLoadStatementTestCase expected) {
if (null != expected.getDataSource()) {
- MatcherAssert.assertThat(assertContext.getText("Data source does not match: "), actual.getDataSource().orElse(null), is(expected.getDataSource()));
+ assertThat(assertContext.getText("Data source does not match: "), actual.getDataSource().orElse(null), is(expected.getDataSource()));
}
}
private static void assertDataSourceProperties(final SQLCaseAssertContext assertContext, final DorisAlterRoutineLoadStatement actual, final DorisAlterRoutineLoadStatementTestCase expected) {
- if (actual.getDataSourceProperties().isPresent() && null != expected.getDataSourceProperties() && !expected.getDataSourceProperties().isEmpty()) {
+ if (actual.getDataSourceProperties().isPresent() && !expected.getDataSourceProperties().isEmpty()) {
assertNotNull(actual.getDataSourceProperties().get(), assertContext.getText("Data source properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Data source properties size does not match: "), actual.getDataSourceProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getDataSourceProperties().size()));
+ assertThat(assertContext.getText("Data source properties size does not match: "), actual.getDataSourceProperties().get().getProperties().size(),
+ is(expected.getDataSourceProperties().size()));
for (int i = 0; i < expected.getDataSourceProperties().size(); i++) {
assertProperty(assertContext, actual.getDataSourceProperties().get().getProperties().get(i), expected.getDataSourceProperties().get(i));
}
@@ -90,8 +89,8 @@ public final class DorisAlterRoutineLoadStatementAssert {
}
private static void assertProperty(final SQLCaseAssertContext assertContext, final PropertySegment actual, final PropertyTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
- MatcherAssert.assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
+ assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
+ assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
SQLSegmentAssert.assertIs(assertContext, actual, expected);
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisBrokerLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisBrokerLoadStatementAssert.java
index f42b1921cf6..e6f40c5c863 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisBrokerLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisBrokerLoadStatementAssert.java
@@ -36,13 +36,12 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.tab
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.PropertyTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.BrokerLoadDataDescTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.DorisBrokerLoadStatementTestCase;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -72,7 +71,7 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertLoadLabel(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (null != expected.getLoadLabel()) {
- MatcherAssert.assertThat(assertContext.getText("Load label does not match: "), actual.getLoadLabel(), is(expected.getLoadLabel()));
+ assertThat(assertContext.getText("Load label does not match: "), actual.getLoadLabel(), is(expected.getLoadLabel()));
}
}
@@ -80,7 +79,7 @@ public final class DorisBrokerLoadStatementAssert {
if (null != expected.getOwner()) {
DatabaseSegment database = actual.getDatabase().orElse(null);
assertNotNull(database, assertContext.getText("Database should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Database name does not match: "), database.getIdentifier().getValue(), is(expected.getOwner().getName()));
+ assertThat(assertContext.getText("Database name does not match: "), database.getIdentifier().getValue(), is(expected.getOwner().getName()));
SQLSegmentAssert.assertIs(assertContext, database, expected.getOwner());
}
}
@@ -88,7 +87,7 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertDataDescs(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (!expected.getDataDescs().isEmpty()) {
List<BrokerLoadDataDescSegment> actualDescs = new ArrayList<>(actual.getDataDescs());
- MatcherAssert.assertThat(assertContext.getText("Data descs size does not match: "), actualDescs.size(), is(expected.getDataDescs().size()));
+ assertThat(assertContext.getText("Data descs size does not match: "), actualDescs.size(), is(expected.getDataDescs().size()));
for (int i = 0; i < expected.getDataDescs().size(); i++) {
assertDataDesc(assertContext, actualDescs.get(i), expected.getDataDescs().get(i));
}
@@ -118,24 +117,24 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertMergeType(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getMergeType()) {
- MatcherAssert.assertThat(assertContext.getText("Merge type does not match: "), actual.getMergeType().orElse(null), is(expected.getMergeType()));
+ assertThat(assertContext.getText("Merge type does not match: "), actual.getMergeType().orElse(null), is(expected.getMergeType()));
}
}
private static void assertFilePaths(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getFilePaths()) {
List<String> expectedPaths = Arrays.asList(expected.getFilePaths().split(","));
- MatcherAssert.assertThat(assertContext.getText("File paths size does not match: "), actual.getFilePaths().size(), is(expectedPaths.size()));
+ assertThat(assertContext.getText("File paths size does not match: "), actual.getFilePaths().size(), is(expectedPaths.size()));
List<String> actualPaths = new ArrayList<>(actual.getFilePaths());
for (int i = 0; i < expectedPaths.size(); i++) {
- MatcherAssert.assertThat(assertContext.getText("File path does not match: "), actualPaths.get(i), is(expectedPaths.get(i).trim()));
+ assertThat(assertContext.getText("File path does not match: "), actualPaths.get(i), is(expectedPaths.get(i).trim()));
}
}
}
private static void assertNegative(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getNegative()) {
- MatcherAssert.assertThat(assertContext.getText("Negative does not match: "), actual.isNegative(), is(expected.getNegative()));
+ assertThat(assertContext.getText("Negative does not match: "), actual.isNegative(), is(expected.getNegative()));
}
}
@@ -147,7 +146,7 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertPartitions(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (!expected.getPartitions().isEmpty()) {
- MatcherAssert.assertThat(assertContext.getText("Partitions size does not match: "), actual.getPartitions().size(), is(expected.getPartitions().size()));
+ assertThat(assertContext.getText("Partitions size does not match: "), actual.getPartitions().size(), is(expected.getPartitions().size()));
int count = 0;
for (PartitionSegment each : actual.getPartitions()) {
PartitionAssert.assertIs(assertContext, each, expected.getPartitions().get(count));
@@ -158,32 +157,32 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertColumnSeparator(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getColumnSeparator()) {
- MatcherAssert.assertThat(assertContext.getText("Column separator does not match: "), actual.getColumnSeparator().orElse(null), is(expected.getColumnSeparator()));
+ assertThat(assertContext.getText("Column separator does not match: "), actual.getColumnSeparator().orElse(null), is(expected.getColumnSeparator()));
}
}
private static void assertLineDelimiter(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getLineDelimiter()) {
- MatcherAssert.assertThat(assertContext.getText("Line delimiter does not match: "), actual.getLineDelimiter().orElse(null), is(expected.getLineDelimiter()));
+ assertThat(assertContext.getText("Line delimiter does not match: "), actual.getLineDelimiter().orElse(null), is(expected.getLineDelimiter()));
}
}
private static void assertFormatType(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getFormatType()) {
- MatcherAssert.assertThat(assertContext.getText("Format type does not match: "), actual.getFormatType().orElse(null), is(expected.getFormatType()));
+ assertThat(assertContext.getText("Format type does not match: "), actual.getFormatType().orElse(null), is(expected.getFormatType()));
}
}
private static void assertCompressType(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getCompressType()) {
- MatcherAssert.assertThat(assertContext.getText("Compress type does not match: "), actual.getCompressType().orElse(null), is(expected.getCompressType()));
+ assertThat(assertContext.getText("Compress type does not match: "), actual.getCompressType().orElse(null), is(expected.getCompressType()));
}
}
private static void assertColumnList(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (!expected.getColumnList().isEmpty()) {
List<ColumnSegment> actualCols = new ArrayList<>(actual.getColumnList());
- MatcherAssert.assertThat(assertContext.getText("Column list size does not match: "), actualCols.size(), is(expected.getColumnList().size()));
+ assertThat(assertContext.getText("Column list size does not match: "), actualCols.size(), is(expected.getColumnList().size()));
for (int i = 0; i < expected.getColumnList().size(); i++) {
ColumnAssert.assertIs(assertContext, actualCols.get(i), expected.getColumnList().get(i));
}
@@ -193,7 +192,7 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertColumnsFromPath(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (!expected.getColumnsFromPath().isEmpty()) {
List<ColumnSegment> actualCols = new ArrayList<>(actual.getColumnsFromPath());
- MatcherAssert.assertThat(assertContext.getText("Columns from path size does not match: "), actualCols.size(), is(expected.getColumnsFromPath().size()));
+ assertThat(assertContext.getText("Columns from path size does not match: "), actualCols.size(), is(expected.getColumnsFromPath().size()));
for (int i = 0; i < expected.getColumnsFromPath().size(); i++) {
ColumnAssert.assertIs(assertContext, actualCols.get(i), expected.getColumnsFromPath().get(i));
}
@@ -203,7 +202,7 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertSetAssignments(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (!expected.getSetAssignments().isEmpty()) {
List<ColumnAssignmentSegment> actualAssignments = new ArrayList<>(actual.getSetAssignments());
- MatcherAssert.assertThat(assertContext.getText("Set assignments size does not match: "), actualAssignments.size(), is(expected.getSetAssignments().size()));
+ assertThat(assertContext.getText("Set assignments size does not match: "), actualAssignments.size(), is(expected.getSetAssignments().size()));
for (int i = 0; i < expected.getSetAssignments().size(); i++) {
AssignmentAssert.assertIs(assertContext, actualAssignments.get(i), expected.getSetAssignments().get(i));
}
@@ -230,15 +229,15 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertOrderByColumn(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (null != expected.getOrderByColumn()) {
- MatcherAssert.assertThat(assertContext.getText("Order by column does not match: "), actual.getOrderByColumn().orElse(null), is(expected.getOrderByColumn()));
+ assertThat(assertContext.getText("Order by column does not match: "), actual.getOrderByColumn().orElse(null), is(expected.getOrderByColumn()));
}
}
private static void assertDataProperties(final SQLCaseAssertContext assertContext, final BrokerLoadDataDescSegment actual, final BrokerLoadDataDescTestCase expected) {
if (!expected.getDataProperties().isEmpty()) {
assertNotNull(actual.getDataProperties().orElse(null), assertContext.getText("Data properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Data properties size does not match: "), actual.getDataProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getDataProperties().size()));
+ assertThat(assertContext.getText("Data properties size does not match: "), actual.getDataProperties().get().getProperties().size(),
+ is(expected.getDataProperties().size()));
for (int i = 0; i < expected.getDataProperties().size(); i++) {
assertProperty(assertContext, actual.getDataProperties().get().getProperties().get(i), expected.getDataProperties().get(i));
}
@@ -247,21 +246,21 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertBrokerType(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (null != expected.getBrokerType()) {
- MatcherAssert.assertThat(assertContext.getText("Broker type does not match: "), actual.getBrokerType(), is(expected.getBrokerType()));
+ assertThat(assertContext.getText("Broker type does not match: "), actual.getBrokerType(), is(expected.getBrokerType()));
}
}
private static void assertBrokerName(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (null != expected.getBrokerName()) {
- MatcherAssert.assertThat(assertContext.getText("Broker name does not match: "), actual.getBrokerName().orElse(null), is(expected.getBrokerName()));
+ assertThat(assertContext.getText("Broker name does not match: "), actual.getBrokerName().orElse(null), is(expected.getBrokerName()));
}
}
private static void assertBrokerProperties(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (actual.getBrokerProperties().isPresent() && !expected.getBrokerProperties().isEmpty()) {
assertNotNull(actual.getBrokerProperties().get(), assertContext.getText("Broker properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Broker properties size does not match: "), actual.getBrokerProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getBrokerProperties().size()));
+ assertThat(assertContext.getText("Broker properties size does not match: "), actual.getBrokerProperties().get().getProperties().size(),
+ is(expected.getBrokerProperties().size()));
for (int i = 0; i < expected.getBrokerProperties().size(); i++) {
assertProperty(assertContext, actual.getBrokerProperties().get().getProperties().get(i), expected.getBrokerProperties().get(i));
}
@@ -271,8 +270,8 @@ public final class DorisBrokerLoadStatementAssert {
private static void assertLoadProperties(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (actual.getLoadProperties().isPresent() && !expected.getLoadProperties().isEmpty()) {
assertNotNull(actual.getLoadProperties().get(), assertContext.getText("Load properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Load properties size does not match: "), actual.getLoadProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getLoadProperties().size()));
+ assertThat(assertContext.getText("Load properties size does not match: "), actual.getLoadProperties().get().getProperties().size(),
+ is(expected.getLoadProperties().size()));
for (int i = 0; i < expected.getLoadProperties().size(); i++) {
assertProperty(assertContext, actual.getLoadProperties().get().getProperties().get(i), expected.getLoadProperties().get(i));
}
@@ -280,14 +279,14 @@ public final class DorisBrokerLoadStatementAssert {
}
private static void assertProperty(final SQLCaseAssertContext assertContext, final PropertySegment actual, final PropertyTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
- MatcherAssert.assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
+ assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
+ assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
SQLSegmentAssert.assertIs(assertContext, actual, expected);
}
private static void assertComment(final SQLCaseAssertContext assertContext, final DorisBrokerLoadStatement actual, final DorisBrokerLoadStatementTestCase expected) {
if (null != expected.getComment()) {
- MatcherAssert.assertThat(assertContext.getText("Comment does not match: "), actual.getComment().orElse(null), is(expected.getComment()));
+ assertThat(assertContext.getText("Comment does not match: "), actual.getComment().orElse(null), is(expected.getComment()));
}
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisCreateRoutineLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisCreateRoutineLoadStatementAssert.java
index b789b645206..c1154d7140c 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisCreateRoutineLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisCreateRoutineLoadStatementAssert.java
@@ -35,9 +35,8 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.whe
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.column.ExpectedColumnMapping;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.PropertyTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.DorisCreateRoutineLoadStatementTestCase;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -73,7 +72,7 @@ public final class DorisCreateRoutineLoadStatementAssert {
private static void assertJobName(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
@@ -88,19 +87,19 @@ public final class DorisCreateRoutineLoadStatementAssert {
private static void assertMergeType(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (null != expected.getMergeType()) {
- MatcherAssert.assertThat(assertContext.getText("Merge type does not match: "), actual.getMergeType().orElse(null), is(expected.getMergeType()));
+ assertThat(assertContext.getText("Merge type does not match: "), actual.getMergeType().orElse(null), is(expected.getMergeType()));
}
}
private static void assertColumnSeparator(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (null != expected.getColumnSeparator()) {
- MatcherAssert.assertThat(assertContext.getText("Column separator does not match: "), actual.getColumnSeparator().orElse(null), is(expected.getColumnSeparator()));
+ assertThat(assertContext.getText("Column separator does not match: "), actual.getColumnSeparator().orElse(null), is(expected.getColumnSeparator()));
}
}
private static void assertColumnMappings(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (!expected.getColumnMappings().isEmpty()) {
- MatcherAssert.assertThat(assertContext.getText("Column mappings size does not match: "), actual.getColumnMappings().size(), is(expected.getColumnMappings().size()));
+ assertThat(assertContext.getText("Column mappings size does not match: "), actual.getColumnMappings().size(), is(expected.getColumnMappings().size()));
int count = 0;
for (ColumnMappingSegment each : actual.getColumnMappings()) {
assertColumnMapping(assertContext, each, expected.getColumnMappings().get(count));
@@ -119,7 +118,7 @@ public final class DorisCreateRoutineLoadStatementAssert {
private static void assertPartitions(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (!expected.getPartitions().isEmpty()) {
- MatcherAssert.assertThat(assertContext.getText("Partitions size does not match: "), actual.getPartitions().size(), is(expected.getPartitions().size()));
+ assertThat(assertContext.getText("Partitions size does not match: "), actual.getPartitions().size(), is(expected.getPartitions().size()));
int count = 0;
for (PartitionSegment each : actual.getPartitions()) {
PartitionAssert.assertIs(assertContext, each, expected.getPartitions().get(count));
@@ -155,8 +154,8 @@ public final class DorisCreateRoutineLoadStatementAssert {
private static void assertJobProperties(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (actual.getJobProperties().isPresent() && null != expected.getJobProperties() && !expected.getJobProperties().isEmpty()) {
assertNotNull(actual.getJobProperties().get(), assertContext.getText("Job properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Job properties size does not match: "), actual.getJobProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getJobProperties().size()));
+ assertThat(assertContext.getText("Job properties size does not match: "), actual.getJobProperties().get().getProperties().size(),
+ is(expected.getJobProperties().size()));
for (int i = 0; i < expected.getJobProperties().size(); i++) {
assertProperty(assertContext, actual.getJobProperties().get().getProperties().get(i), expected.getJobProperties().get(i));
}
@@ -165,15 +164,15 @@ public final class DorisCreateRoutineLoadStatementAssert {
private static void assertDataSource(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (null != expected.getDataSource()) {
- MatcherAssert.assertThat(assertContext.getText("Data source does not match: "), actual.getDataSource().orElse(null), is(expected.getDataSource()));
+ assertThat(assertContext.getText("Data source does not match: "), actual.getDataSource().orElse(null), is(expected.getDataSource()));
}
}
private static void assertDataSourceProperties(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (actual.getDataSourceProperties().isPresent() && null != expected.getDataSourceProperties() && !expected.getDataSourceProperties().isEmpty()) {
assertNotNull(actual.getDataSourceProperties().get(), assertContext.getText("Data source properties should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Data source properties size does not match: "), actual.getDataSourceProperties().get().getProperties().size(),
- CoreMatchers.is(expected.getDataSourceProperties().size()));
+ assertThat(assertContext.getText("Data source properties size does not match: "), actual.getDataSourceProperties().get().getProperties().size(),
+ is(expected.getDataSourceProperties().size()));
for (int i = 0; i < expected.getDataSourceProperties().size(); i++) {
assertProperty(assertContext, actual.getDataSourceProperties().get().getProperties().get(i), expected.getDataSourceProperties().get(i));
}
@@ -181,14 +180,14 @@ public final class DorisCreateRoutineLoadStatementAssert {
}
private static void assertProperty(final SQLCaseAssertContext assertContext, final PropertySegment actual, final PropertyTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
- MatcherAssert.assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
+ assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
+ assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
SQLSegmentAssert.assertIs(assertContext, actual, expected);
}
private static void assertComment(final SQLCaseAssertContext assertContext, final DorisCreateRoutineLoadStatement actual, final DorisCreateRoutineLoadStatementTestCase expected) {
if (null != expected.getComment()) {
- MatcherAssert.assertThat(assertContext.getText("Comment does not match: "), actual.getComment().orElse(null), is(expected.getComment()));
+ assertThat(assertContext.getText("Comment does not match: "), actual.getComment().orElse(null), is(expected.getComment()));
}
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisPauseRoutineLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisPauseRoutineLoadStatementAssert.java
index 4eecade52c4..9c96ea89f5b 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisPauseRoutineLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisPauseRoutineLoadStatementAssert.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.sql.parser.statement.doris.dml.DorisPauseRoutin
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.DorisPauseRoutineLoadStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -41,9 +41,9 @@ public final class DorisPauseRoutineLoadStatementAssert {
* @param expected expected pause routine load statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisPauseRoutineLoadStatement actual, final DorisPauseRoutineLoadStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("All flag does not match: "), actual.isAll(), is(expected.isAll()));
+ assertThat(assertContext.getText("All flag does not match: "), actual.isAll(), is(expected.isAll()));
if (!expected.isAll() && actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisResumeRoutineLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisResumeRoutineLoadStatementAssert.java
index a4065ad2cda..960383b8528 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisResumeRoutineLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisResumeRoutineLoadStatementAssert.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.sql.parser.statement.doris.dml.DorisResumeRouti
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.DorisResumeRoutineLoadStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -41,9 +41,9 @@ public final class DorisResumeRoutineLoadStatementAssert {
* @param expected expected resume routine load statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisResumeRoutineLoadStatement actual, final DorisResumeRoutineLoadStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("All flag does not match: "), actual.isAll(), is(expected.isAll()));
+ assertThat(assertContext.getText("All flag does not match: "), actual.isAll(), is(expected.isAll()));
if (!expected.isAll() && actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisStopRoutineLoadStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisStopRoutineLoadStatementAssert.java
index 32c66f3ea6e..65a5eb540a6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisStopRoutineLoadStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/doris/DorisStopRoutineLoadStatementAssert.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.sql.parser.statement.doris.dml.DorisStopRoutine
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.owner.OwnerAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.doris.DorisStopRoutineLoadStatementTestCase;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
/**
@@ -42,7 +42,7 @@ public final class DorisStopRoutineLoadStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisStopRoutineLoadStatement actual, final DorisStopRoutineLoadStatementTestCase expected) {
if (actual.getJobName().isPresent()) {
- MatcherAssert.assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
+ assertThat(assertContext.getText("Job name does not match: "), actual.getJobName().get().getIdentifier().getValue(), is(expected.getJobName()));
if (null != expected.getOwner()) {
OwnerAssert.assertIs(assertContext, actual.getJobName().get().getOwner().orElse(null), expected.getOwner());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/mysql/type/MySQLLoadDataStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/mysql/type/MySQLLoadDataStatementAssert.java
index b73c1da3c69..b76a501db44 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/mysql/type/MySQLLoadDataStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dml/dialect/mysql/type/MySQLLoadDataStatementAssert.java
@@ -31,9 +31,8 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.tab
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.index.ExpectedPartition;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.dialect.doris.PropertyTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dml.dialect.mysql.MySQLLoadDataStatementTestCase;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.MatcherAssert;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -66,13 +65,13 @@ public final class MySQLLoadDataStatementAssert {
}
private static void assertLocal(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText("LOCAL flag does not match: "), actual.isLocal(), is(null != expected.getLocal() && expected.getLocal()));
+ assertThat(assertContext.getText("LOCAL flag does not match: "), actual.isLocal(), is(null != expected.getLocal() && expected.getLocal()));
}
private static void assertFileName(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (null != expected.getFileName()) {
assertNotNull(actual.getFileName(), assertContext.getText("File name segment should not be null"));
- MatcherAssert.assertThat(assertContext.getText("File name value does not match: "), actual.getFileName().getValue(), is(expected.getFileName().getValue()));
+ assertThat(assertContext.getText("File name value does not match: "), actual.getFileName().getValue(), is(expected.getFileName().getValue()));
SQLSegmentAssert.assertIs(assertContext, actual.getFileName(), expected.getFileName());
}
}
@@ -87,7 +86,7 @@ public final class MySQLLoadDataStatementAssert {
private static void assertPartitions(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (!expected.getPartitions().isEmpty()) {
- MatcherAssert.assertThat(assertContext.getText("Partitions size does not match: "), actual.getPartitions().size(), is(expected.getPartitions().size()));
+ assertThat(assertContext.getText("Partitions size does not match: "), actual.getPartitions().size(), is(expected.getPartitions().size()));
int count = 0;
for (PartitionSegment each : actual.getPartitions()) {
PartitionAssert.assertIs(assertContext, each, expected.getPartitions().get(count));
@@ -99,8 +98,8 @@ public final class MySQLLoadDataStatementAssert {
private static void assertColumnSeparator(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (null != expected.getColumnSeparator()) {
assertNotNull(actual.getColumnSeparator().orElse(null), assertContext.getText("Column separator should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Column separator value does not match: "), actual.getColumnSeparator().get().getValue(),
- CoreMatchers.is(expected.getColumnSeparator().getValue()));
+ assertThat(assertContext.getText("Column separator value does not match: "), actual.getColumnSeparator().get().getValue(),
+ is(expected.getColumnSeparator().getValue()));
SQLSegmentAssert.assertIs(assertContext, actual.getColumnSeparator().get(), expected.getColumnSeparator());
}
}
@@ -108,8 +107,8 @@ public final class MySQLLoadDataStatementAssert {
private static void assertLineDelimiter(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (null != expected.getLineDelimiter()) {
assertNotNull(actual.getLineDelimiter().orElse(null), assertContext.getText("Line delimiter should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Line delimiter value does not match: "), actual.getLineDelimiter().get().getValue(),
- CoreMatchers.is(expected.getLineDelimiter().getValue()));
+ assertThat(assertContext.getText("Line delimiter value does not match: "), actual.getLineDelimiter().get().getValue(),
+ is(expected.getLineDelimiter().getValue()));
SQLSegmentAssert.assertIs(assertContext, actual.getLineDelimiter().get(), expected.getLineDelimiter());
}
}
@@ -117,19 +116,19 @@ public final class MySQLLoadDataStatementAssert {
private static void assertIgnoreLines(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (null != expected.getIgnoreLines()) {
assertNotNull(actual.getIgnoreLines().orElse(null), assertContext.getText("Ignore lines segment should not be null"));
- MatcherAssert.assertThat(assertContext.getText("Ignore lines number does not match: "), actual.getIgnoreLines().get().getNumber(), is(expected.getIgnoreLines().getNumber()));
- MatcherAssert.assertThat(assertContext.getText("Ignore lines unit does not match: "), actual.getIgnoreLines().get().getUnit(), is(expected.getIgnoreLines().getUnit()));
+ assertThat(assertContext.getText("Ignore lines number does not match: "), actual.getIgnoreLines().get().getNumber(), is(expected.getIgnoreLines().getNumber()));
+ assertThat(assertContext.getText("Ignore lines unit does not match: "), actual.getIgnoreLines().get().getUnit(), is(expected.getIgnoreLines().getUnit()));
SQLSegmentAssert.assertIs(assertContext, actual.getIgnoreLines().get(), expected.getIgnoreLines());
}
}
private static void assertColumnList(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (!expected.getColumns().isEmpty()) {
- MatcherAssert.assertThat(assertContext.getText("Column list size does not match: "), actual.getColumnList().size(), is(expected.getColumns().size()));
+ assertThat(assertContext.getText("Column list size does not match: "), actual.getColumnList().size(), is(expected.getColumns().size()));
int count = 0;
for (ColNameOrUserVarSegment each : actual.getColumnList()) {
ExpectedPartition exp = expected.getColumns().get(count);
- MatcherAssert.assertThat(assertContext.getText("Column name does not match: "), each.getIdentifier().getValue(), is(exp.getName()));
+ assertThat(assertContext.getText("Column name does not match: "), each.getIdentifier().getValue(), is(exp.getName()));
SQLSegmentAssert.assertIs(assertContext, each, exp);
count++;
}
@@ -146,7 +145,7 @@ public final class MySQLLoadDataStatementAssert {
private static void assertProperties(final SQLCaseAssertContext assertContext, final MySQLLoadDataStatement actual, final MySQLLoadDataStatementTestCase expected) {
if (!expected.getProperties().isEmpty()) {
assertNotNull(actual.getProperties().orElse(null), assertContext.getText("Actual properties should exist."));
- MatcherAssert.assertThat(assertContext.getText("Properties size does not match: "), actual.getProperties().get().getProperties().size(), is(expected.getProperties().size()));
+ assertThat(assertContext.getText("Properties size does not match: "), actual.getProperties().get().getProperties().size(), is(expected.getProperties().size()));
for (int i = 0; i < expected.getProperties().size(); i++) {
assertProperty(assertContext, actual.getProperties().get().getProperties().get(i), expected.getProperties().get(i));
}
@@ -156,8 +155,8 @@ public final class MySQLLoadDataStatementAssert {
}
private static void assertProperty(final SQLCaseAssertContext assertContext, final PropertySegment actual, final PropertyTestCase expected) {
- MatcherAssert.assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
- MatcherAssert.assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
+ assertThat(assertContext.getText(String.format("Property key '%s' assertion error: ", expected.getKey())), actual.getKey(), is(expected.getKey()));
+ assertThat(assertContext.getText(String.format("Property value for key '%s' assertion error: ", expected.getKey())), actual.getValue(), is(expected.getValue()));
SQLSegmentAssert.assertIs(assertContext, actual, expected);
}
}
diff --git a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationIT.java b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationIT.java
index 0a4c9db451a..f09f80c0141 100644
--- a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationIT.java
+++ b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationIT.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers;
import org.junit.jupiter.api.Test;
import java.io.File;
@@ -34,7 +35,6 @@ import java.nio.file.Paths;
import java.util.Collections;
import java.util.stream.Collectors;
-import static org.apache.shardingsphere.test.infra.framework.matcher.ShardingSphereAssertionMatchers.deepEqual;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -61,7 +61,7 @@ public abstract class YamlRuleConfigurationIT {
YamlRootConfiguration yamlRootConfigFromFile = YamlEngine.unmarshal(new File(url.getFile()), YamlRootConfiguration.class);
YamlRootConfiguration yamlRootConfigFromBytes = YamlEngine.unmarshal(
Files.readAllLines(Paths.get(url.toURI())).stream().collect(Collectors.joining(System.lineSeparator())).getBytes(), YamlRootConfiguration.class);
- assertThat(yamlRootConfigFromFile, deepEqual(yamlRootConfigFromBytes));
+ assertThat(yamlRootConfigFromFile, ShardingSphereAssertionMatchers.deepEqual(yamlRootConfigFromBytes));
}
@SuppressWarnings("unchecked")
@@ -74,7 +74,7 @@ public abstract class YamlRuleConfigurationIT {
YamlRuleConfiguration actualYAMLRuleConfig = actual.getRules().iterator().next();
YamlRuleConfiguration expectedYAMLRuleConfig = (YamlRuleConfiguration) swapper.swapToYamlConfiguration(expectedRuleConfig);
if (!assertYamlConfiguration(actualYAMLRuleConfig)) {
- assertThat(actualYAMLRuleConfig, deepEqual(expectedYAMLRuleConfig));
+ assertThat(actualYAMLRuleConfig, ShardingSphereAssertionMatchers.deepEqual(expectedYAMLRuleConfig));
}
}
@@ -85,7 +85,7 @@ public abstract class YamlRuleConfigurationIT {
assertNotNull(url);
YamlRootConfiguration actual = YamlEngine.unmarshal(new File(url.getFile()), YamlRootConfiguration.class);
RuleConfiguration actualRuleConfig = (RuleConfiguration) swapper.swapToObject(actual.getRules().iterator().next());
- assertThat(actualRuleConfig, deepEqual(expectedRuleConfig));
+ assertThat(actualRuleConfig, ShardingSphereAssertionMatchers.deepEqual(expectedRuleConfig));
}
// TODO should remove the method when yaml rule swapper fixed by map's key
diff --git a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/TestShardingService.java b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/TestShardingService.java
index e45d9032551..4f60baaf0c2 100644
--- a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/TestShardingService.java
+++ b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/TestShardingService.java
@@ -35,11 +35,10 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Getter
@@ -135,7 +134,7 @@ public final class TestShardingService {
private void assertQueryInTOrder() throws SQLException {
List<Order> orders = orderRepository.selectAll();
- assertThat(orders.stream().map(Order::getOrderId).collect(Collectors.toList()), not(empty()));
+ assertFalse(orders.isEmpty());
assertThat(orders.stream().map(Order::getOrderType).collect(Collectors.toList()),
containsInAnyOrder(0, 1, 0, 1, 0, 1, 0, 1, 0, 1));
assertThat(orders.stream().map(Order::getUserId).collect(Collectors.toList()),
@@ -147,8 +146,7 @@ public final class TestShardingService {
}
private void assertQueryInTOrderItem(final List<OrderItem> orderItems) {
- assertThat(orderItems.stream().map(OrderItem::getOrderItemId).collect(Collectors.toList()), not(empty()));
- assertThat(orderItems.stream().map(OrderItem::getOrderId).collect(Collectors.toList()), not(empty()));
+ assertFalse(orderItems.isEmpty());
assertThat(orderItems.stream().map(OrderItem::getUserId).collect(Collectors.toList()),
containsInAnyOrder(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
assertThat(orderItems.stream().map(OrderItem::getPhone).collect(Collectors.toList()),