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 2025/08/24 17:07:37 UTC
(shardingsphere) branch master updated: Use isA to instead of instanceOf for test cases (#36410)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ae802ac2f42 Use isA to instead of instanceOf for test cases (#36410)
ae802ac2f42 is described below
commit ae802ac2f422dba233665f58371203cd4daab5de
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Aug 25 01:07:31 2025 +0800
Use isA to instead of instanceOf for test cases (#36410)
* Use isA to instead of instanceOf for test cases
* Use isA to instead of instanceOf for test cases
---
.../agent/core/spi/AgentServiceLoaderTest.java | 4 +-
.../PrometheusMetricsCollectorFactoryTest.java | 12 ++--
...theusMetricsGaugeMetricFamilyCollectorTest.java | 4 +-
.../command/FirebirdCommandPacketFactoryTest.java | 42 ++++++--------
.../FirebirdBinaryProtocolValueFactoryTest.java | 30 +++++-----
.../value/MySQLBinlogProtocolValueFactoryTest.java | 4 +-
.../string/MySQLStringBinlogProtocolValueTest.java | 6 +-
.../MySQLVarcharBinlogProtocolValueTest.java | 6 +-
.../MySQLBinaryProtocolValueFactoryTest.java | 52 ++++++++---------
.../command/OpenGaussCommandPacketFactoryTest.java | 6 +-
.../command/OpenGaussCommandPacketTypeTest.java | 4 +-
.../PostgreSQLCommandPacketFactoryTest.java | 20 +++----
.../PostgreSQLBinaryProtocolValueFactoryTest.java | 24 ++++----
...stgreSQLUnspecifiedBinaryProtocolValueTest.java | 4 +-
.../engine/BroadcastRouteEngineFactoryTest.java | 16 +++---
.../rule/builder/BroadcastRuleBuilderTest.java | 4 +-
.../EncryptSupportedSQLCheckersBuilderTest.java | 14 ++---
.../merge/EncryptResultDecoratorEngineTest.java | 6 +-
.../merge/dal/EncryptDALResultDecoratorTest.java | 8 +--
.../EncryptParameterRewritersRegistryTest.java | 12 ++--
.../token/EncryptTokenGenerateBuilderTest.java | 10 ++--
.../ddl/EncryptAlterTableTokenGeneratorTest.java | 4 +-
.../ddl/EncryptCreateTableTokenGeneratorTest.java | 4 +-
.../rule/builder/EncryptRuleBuilderTest.java | 6 +-
.../mask/merge/MaskResultDecoratorEngineTest.java | 4 +-
.../mask/rule/builder/MaskRuleBuilderTest.java | 4 +-
.../builder/ReadwriteSplittingRuleBuilderTest.java | 4 +-
...adowDataSourceMappingsRetrieverFactoryTest.java | 10 ++--
.../shadow/rule/builder/ShadowRuleBuilderTest.java | 4 +-
.../ClassBasedShardingAlgorithmFactoryTest.java | 4 +-
.../temporal/TemporalHandlerFactoryTest.java | 14 ++---
.../merge/ShardingResultMergerEngineTest.java | 10 ++--
.../merge/dal/ShardingDALResultMergerTest.java | 6 +-
.../merge/ddl/ShardingDDLResultMergerTest.java | 8 +--
.../merge/dql/ShardingDQLResultMergerTest.java | 65 +++++++++++----------
.../aggregation/AggregationUnitFactoryTest.java | 28 ++++-----
.../ShardingParameterRewritersRegistryTest.java | 6 +-
.../token/ShardingTokenGenerateBuilderTest.java | 10 ++--
.../impl/ShardingCursorTokenGeneratorTest.java | 4 +-
.../impl/ShardingRemoveTokenGeneratorTest.java | 4 +-
.../impl/ShardingTableTokenGeneratorTest.java | 4 +-
.../WhereClauseShardingConditionEngineTest.java | 6 +-
...ConditionValueBetweenOperatorGeneratorTest.java | 4 +-
...ConditionValueCompareOperatorGeneratorTest.java | 4 +-
.../ConditionValueInOperatorGeneratorTest.java | 6 +-
.../type/ShardingRouteEngineFactoryTest.java | 28 ++++-----
.../strategy/ShardingStrategyFactoryTest.java | 10 ++--
.../sharding/rule/ShardingRuleTest.java | 12 ++--
.../rule/builder/ShardingRuleBuilderTest.java | 6 +-
.../mysql/MySQLShardingDALResultMergerTest.java | 12 ++--
.../update/AlterShardingTableRuleExecutorTest.java | 14 ++---
.../CreateShardingTableRuleExecutorTest.java | 10 ++--
.../engine/PaginationContextEngineTest.java | 14 ++---
.../RowNumberPaginationContextEngineTest.java | 6 +-
.../engine/TopPaginationContextEngineTest.java | 6 +-
.../projection/engine/ProjectionEngineTest.java | 18 +++---
.../statement/SQLStatementContextFactoryTest.java | 16 +++---
.../expression/type/SubquerySegmentBinderTest.java | 8 +--
.../dml/from/type/JoinTableSegmentBinderTest.java | 32 +++++------
.../from/type/SubqueryTableSegmentBinderTest.java | 10 ++--
.../statement/dml/DeleteStatementBinderTest.java | 10 ++--
.../statement/dml/InsertStatementBinderTest.java | 8 +--
.../statement/dml/SelectStatementBinderTest.java | 18 +++---
.../statement/dml/UpdateStatementBinderTest.java | 10 ++--
...taSourceGeneratedDatabaseConfigurationTest.java | 6 +-
.../metadata/database/rule/RuleMetaDataTest.java | 4 +-
.../builder/database/DatabaseRulesBuilderTest.java | 4 +-
.../builder/global/GlobalRulesBuilderTest.java | 4 +-
.../props/domain/DataSourcePoolPropertiesTest.java | 4 +-
.../driver/jdbc/type/util/ResultSetUtilsTest.java | 6 +-
.../rewrite/context/SQLRewriteContextTest.java | 10 ++--
.../builder/DefaultTokenGeneratorBuilderTest.java | 6 +-
.../GeneratedKeyAssignmentTokenGeneratorTest.java | 6 +-
...GeneratedKeyInsertValuesTokenGeneratorTest.java | 8 +--
.../tableless/TablelessRouteEngineFactoryTest.java | 22 ++++----
.../infra/spi/ShardingSphereServiceLoaderTest.java | 6 +-
.../spi/type/ordered/OrderedSPILoaderTest.java | 7 ++-
.../infra/spi/type/typed/TypedSPILoaderTest.java | 4 +-
.../driver/ShardingSphereDriverTest.java | 8 +--
.../adapter/AbstractDataSourceAdapterTest.java | 4 +-
.../ShardingSphereDatabaseMetaDataTest.java | 54 +++++++++---------
.../resultset/ShardingSphereResultSetTest.java | 14 ++---
.../driver/state/DriverStateContextTest.java | 6 +-
.../state/circuit/CircuitBreakDriverStateTest.java | 4 +-
.../connection/CircuitBreakerConnectionTest.java | 24 ++++----
.../datasource/CircuitBreakerDataSourceTest.java | 6 +-
.../driver/state/ok/OKDriverStateTest.java | 4 +-
.../simple/AllPermittedPrivilegeProviderTest.java | 4 +-
...gSpherePipelineDataSourceConfigurationTest.java | 4 +-
.../channel/IncrementalChannelCreatorTest.java | 4 +-
.../core/channel/InventoryChannelCreatorTest.java | 4 +-
.../memory/MemoryPipelineChannelCreatorTest.java | 6 +-
.../TableDataConsistencyCheckerFactoryTest.java | 8 +--
...PipelineDataSourceConfigurationFactoryTest.java | 6 +-
...lderInventoryDataRecordPositionCreatorTest.java | 4 +-
...eKeyInventoryDataRecordPositionCreatorTest.java | 4 +-
.../progress/TransmissionJobItemProgressTest.java | 20 +++----
.../InventoryPositionCalculatorTest.java | 10 ++--
.../MySQLJdbcQueryPropertiesExtensionTest.java | 4 +-
.../netty/MySQLBinlogEventPacketDecoderTest.java | 14 ++---
.../netty/MySQLCommandPacketDecoderTest.java | 4 +-
.../netty/MySQLNegotiatePackageDecoderTest.java | 6 +-
.../dumper/MySQLIncrementalDumperCreatorTest.java | 4 +-
.../dumper/MySQLIncrementalDumperTest.java | 10 ++--
.../OpenGaussJdbcQueryPropertiesExtensionTest.java | 4 +-
.../OpenGaussIncrementalDumperCreatorTest.java | 4 +-
.../wal/decode/MppdbDecodingPluginTest.java | 18 +++---
...PostgreSQLJdbcQueryPropertiesExtensionTest.java | 4 +-
.../PostgreSQLIncrementalDumperCreatorTest.java | 4 +-
.../incremental/wal/WALEventConverterTest.java | 16 +++---
.../wal/decode/TestDecodingPluginTest.java | 8 +--
.../data/pipeline/cdc/CDCJobIdTest.java | 4 +-
.../core/job/id/PipelineJobIdUtilsTest.java | 4 +-
.../rule/builder/GlobalClockRuleBuilderTest.java | 4 +-
.../tso/provider/local/LocalTSOProviderTest.java | 4 +-
.../DefaultSingleRuleConfigurationBuilderTest.java | 4 +-
.../single/rule/builder/SingleRuleBuilderTest.java | 6 +-
.../compiler/context/CompilerContextTest.java | 8 +--
.../resultset/SQLFederationResultSetTest.java | 6 +-
.../executor/EnumerableScanImplementorTest.java | 6 +-
...ShardingSphereTransactionManagerEngineTest.java | 4 +-
.../transaction/core/ResourceDataSourceTest.java | 4 +-
.../transaction/rule/TransactionRuleTest.java | 8 +--
...eataATShardingSphereTransactionManagerTest.java | 16 +++---
.../xa/XAShardingSphereTransactionManagerTest.java | 8 +--
.../dialect/FirebirdXAConnectionWrapperTest.java | 6 +-
.../dialect/H2XAConnectionWrapperTest.java | 4 +-
.../dialect/MariaDBXAConnectionWrapperTest.java | 4 +-
.../dialect/OpenGaussXAConnectionWrapperTest.java | 6 +-
.../dialect/OracleXAConnectionWrapperTest.java | 4 +-
.../dialect/PostgreSQLXAConnectionWrapperTest.java | 4 +-
.../datasource/swapper/DataSourceSwapperTest.java | 4 +-
.../factory/MetaDataContextsFactoryTest.java | 6 +-
.../cluster/etcd/EtcdRepositoryTest.java | 10 ++--
.../sql/parser/core/SQLParserFactoryTest.java | 4 +-
.../connector/DatabaseConnectorFactoryTest.java | 6 +-
.../jdbc/datasource/JDBCBackendDataSourceTest.java | 4 +-
.../handler/ProxyBackendHandlerFactoryTest.java | 30 +++++-----
.../data/DatabaseBackendHandlerFactoryTest.java | 8 +--
.../impl/UnicastDatabaseBackendHandlerTest.java | 4 +-
.../database/CreateDatabaseBackendHandlerTest.java | 6 +-
.../DatabaseOperateBackendHandlerFactoryTest.java | 10 ++--
.../database/DropDatabaseBackendHandlerTest.java | 8 +--
.../distsql/DistSQLBackendHandlerFactoryTest.java | 30 +++++-----
.../distsql/DistSQLUpdateBackendHandlerTest.java | 4 +-
.../export/ExportMetaDataExecutorTest.java | 4 +-
.../handler/skip/SkipBackendHandlerTest.java | 4 +-
.../handler/tcl/TCLBackendHandlerFactoryTest.java | 8 +--
.../backend/handler/tcl/TCLBackendHandlerTest.java | 4 +-
.../admin/FirebirdAdminExecutorCreatorTest.java | 6 +-
.../MySQLDialectSaneQueryResultEngineTest.java | 8 +--
.../admin/MySQLAdminExecutorCreatorTest.java | 38 ++++++-------
.../admin/OpenGaussAdminExecutorCreatorTest.java | 8 +--
...aussSystemFunctionQueryExecutorCreatorTest.java | 8 +--
...enGaussSystemTableQueryExecutorCreatorTest.java | 6 +-
.../admin/PostgreSQLAdminExecutorCreatorTest.java | 8 +--
.../FirebirdCommandExecutorFactoryTest.java | 26 ++++-----
.../FirebirdUnsupportedCommandExecutorTest.java | 4 +-
.../info/FirebirdDatabaseInfoExecutorTest.java | 6 +-
.../query/info/FirebirdSQLInfoExecutorTest.java | 6 +-
...rebirdAllocateStatementCommandExecutorTest.java | 4 +-
.../FirebirdFetchStatementCommandExecutorTest.java | 4 +-
.../FirebirdFreeStatementCommandExecutorTest.java | 6 +-
...irebirdExecuteStatementCommandExecutorTest.java | 10 ++--
...irebirdPrepareStatementCommandExecutorTest.java | 4 +-
...rebirdCommitTransactionCommandExecutorTest.java | 4 +-
...birdRollbackTransactionCommandExecutorTest.java | 4 +-
...irebirdStartTransactionCommandExecutorTest.java | 4 +-
.../command/MySQLCommandExecutorFactoryTest.java | 30 +++++-----
.../command/MySQLCommandPacketFactoryTest.java | 66 +++++++++++-----------
.../admin/MySQLComResetConnectionExecutorTest.java | 4 +-
.../admin/MySQLComSetOptionExecutorTest.java | 4 +-
.../execute/MySQLComStmtExecuteExecutorTest.java | 14 ++---
.../prepare/MySQLComStmtPrepareExecutorTest.java | 46 +++++++--------
.../reset/MySQLComStmtResetExecutorTest.java | 4 +-
.../query/builder/ResponsePacketBuilderTest.java | 6 +-
.../query/MySQLComQueryPacketExecutorTest.java | 10 ++--
.../query/MySQLMultiStatementsHandlerTest.java | 8 +--
.../opengauss/OpenGaussFrontendEngineTest.java | 8 +--
.../OpenGaussCommandExecutorFactoryTest.java | 32 +++++------
.../bind/OpenGaussComBatchBindExecutorTest.java | 4 +-
.../simple/OpenGaussComQueryExecutorTest.java | 10 ++--
.../PostgreSQLCommandExecutorFactoryTest.java | 30 +++++-----
.../PostgreSQLUnsupportedCommandExecutorTest.java | 4 +-
.../command/query/extended/PortalTest.java | 26 ++++-----
...egatedBatchedStatementsCommandExecutorTest.java | 4 +-
.../PostgreSQLAggregatedCommandExecutorTest.java | 4 +-
.../close/PostgreSQLComCloseExecutorTest.java | 6 +-
.../PostgreSQLComDescribeExecutorTest.java | 6 +-
.../parse/PostgreSQLComParseExecutorTest.java | 14 ++---
.../sync/PostgreSQLComSyncExecutorTest.java | 4 +-
.../simple/PostgreSQLComQueryExecutorTest.java | 10 ++--
.../segment/projection/ProjectionAssert.java | 16 +++---
.../asserts/statement/comment/CommentAssert.java | 4 +-
.../rql/type/ShowRulesStatementAssert.java | 4 +-
.../rql/type/ShowStorageUnitsStatementAssert.java | 4 +-
.../rql/type/ShowTablesStatementAssert.java | 4 +-
.../datasource/PipelineDataSourceManagerTest.java | 4 +-
.../pipeline/core/task/IncrementalTaskTest.java | 4 +-
.../data/pipeline/core/task/InventoryTaskTest.java | 4 +-
200 files changed, 985 insertions(+), 999 deletions(-)
diff --git a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/spi/AgentServiceLoaderTest.java b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/spi/AgentServiceLoaderTest.java
index 3d25685aef3..9312fcbf8ac 100644
--- a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/spi/AgentServiceLoaderTest.java
+++ b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/spi/AgentServiceLoaderTest.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.fixture.agent.AgentServiceSPIFixture;
import org.apache.shardingsphere.fixture.agent.impl.AgentServiceSPIFixtureImpl;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -50,7 +50,7 @@ class AgentServiceLoaderTest {
AgentServiceLoader<AgentServiceSPIFixture> actual = AgentServiceLoader.getServiceLoader(AgentServiceSPIFixture.class);
assertThat(actual.getServices().size(), is(1));
AgentServiceSPIFixture actualInstance = actual.getServices().iterator().next();
- assertThat(actualInstance, instanceOf(AgentServiceSPIFixtureImpl.class));
+ assertThat(actualInstance, isA(AgentServiceSPIFixtureImpl.class));
assertThat(actualInstance, is(AgentServiceLoader.getServiceLoader(AgentServiceSPIFixture.class).getServices().iterator().next()));
}
}
diff --git a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/PrometheusMetricsCollectorFactoryTest.java b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/PrometheusMetricsCollectorFactoryTest.java
index ee3462ffe0a..48c895f893f 100644
--- a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/PrometheusMetricsCollectorFactoryTest.java
+++ b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/PrometheusMetricsCollectorFactoryTest.java
@@ -28,38 +28,38 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class PrometheusMetricsCollectorFactoryTest {
@Test
void assertCreateCounterCollector() {
MetricConfiguration config = new MetricConfiguration("test_counter", MetricCollectorType.COUNTER, null, Collections.emptyList(), Collections.emptyMap());
- assertThat(new PrometheusMetricsCollectorFactory().create(config), instanceOf(PrometheusMetricsCounterCollector.class));
+ assertThat(new PrometheusMetricsCollectorFactory().create(config), isA(PrometheusMetricsCounterCollector.class));
}
@Test
void assertCreateGaugeCollector() {
MetricConfiguration config = new MetricConfiguration("test_gauge", MetricCollectorType.GAUGE, null, Collections.emptyList(), Collections.emptyMap());
- assertThat(new PrometheusMetricsCollectorFactory().create(config), instanceOf(PrometheusMetricsGaugeCollector.class));
+ assertThat(new PrometheusMetricsCollectorFactory().create(config), isA(PrometheusMetricsGaugeCollector.class));
}
@Test
void assertCreateHistogramCollector() {
MetricConfiguration config = new MetricConfiguration("test_histogram", MetricCollectorType.HISTOGRAM, null, Collections.emptyList(), Collections.emptyMap());
- assertThat(new PrometheusMetricsCollectorFactory().create(config), instanceOf(PrometheusMetricsHistogramCollector.class));
+ assertThat(new PrometheusMetricsCollectorFactory().create(config), isA(PrometheusMetricsHistogramCollector.class));
}
@Test
void assertCreateSummaryCollector() {
MetricConfiguration config = new MetricConfiguration("test_summary", MetricCollectorType.SUMMARY, null, Collections.emptyList(), Collections.emptyMap());
- assertThat(new PrometheusMetricsCollectorFactory().create(config), instanceOf(PrometheusMetricsSummaryCollector.class));
+ assertThat(new PrometheusMetricsCollectorFactory().create(config), isA(PrometheusMetricsSummaryCollector.class));
}
@Test
void assertCreateGaugeMetricFamilyCollector() {
MetricConfiguration config = new MetricConfiguration("test_summary", MetricCollectorType.GAUGE_METRIC_FAMILY, null, Collections.emptyList(), Collections.emptyMap());
- assertThat(new PrometheusMetricsCollectorFactory().create(config), instanceOf(PrometheusMetricsGaugeMetricFamilyCollector.class));
+ assertThat(new PrometheusMetricsCollectorFactory().create(config), isA(PrometheusMetricsGaugeMetricFamilyCollector.class));
}
}
diff --git a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/type/PrometheusMetricsGaugeMetricFamilyCollectorTest.java b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/type/PrometheusMetricsGaugeMetricFamilyCollectorTest.java
index 4c1619cf36e..3eb9e8be36b 100644
--- a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/type/PrometheusMetricsGaugeMetricFamilyCollectorTest.java
+++ b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/collector/type/PrometheusMetricsGaugeMetricFamilyCollectorTest.java
@@ -25,8 +25,8 @@ import org.mockito.internal.configuration.plugins.Plugins;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class PrometheusMetricsGaugeMetricFamilyCollectorTest {
@@ -35,6 +35,6 @@ class PrometheusMetricsGaugeMetricFamilyCollectorTest {
PrometheusMetricsGaugeMetricFamilyCollector collector = new PrometheusMetricsGaugeMetricFamilyCollector(new MetricConfiguration("foo_gauge_metric_family",
MetricCollectorType.GAUGE_METRIC_FAMILY, "foo_help", Collections.emptyList(), Collections.emptyMap()));
collector.addMetric(Collections.emptyList(), 1D);
- assertThat(Plugins.getMemberAccessor().get(PrometheusMetricsGaugeMetricFamilyCollector.class.getDeclaredField("gaugeMetricFamily"), collector), instanceOf(GaugeMetricFamily.class));
+ assertThat(Plugins.getMemberAccessor().get(PrometheusMetricsGaugeMetricFamilyCollector.class.getDeclaredField("gaugeMetricFamily"), collector), isA(GaugeMetricFamily.class));
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java
index cbcd5ee179a..01eb1e91db5 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/FirebirdCommandPacketFactoryTest.java
@@ -29,15 +29,16 @@ import org.apache.shardingsphere.database.protocol.firebird.packet.command.query
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.transaction.FirebirdRollbackTransactionPacket;
import org.apache.shardingsphere.database.protocol.firebird.packet.command.query.transaction.FirebirdStartTransactionPacket;
import org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
-import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -48,20 +49,18 @@ class FirebirdCommandPacketFactoryTest {
@Test
void assertNewInstanceWithInfoDatabase() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.INFO_DATABASE, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdInfoPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.INFO_DATABASE, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdInfoPacket.class));
}
@Test
void assertNewInstanceWithTransaction() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.TRANSACTION, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdStartTransactionPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.TRANSACTION, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdStartTransactionPacket.class));
}
@Test
void assertNewInstanceWithAllocateStatement() {
assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdAllocateStatementPacket.class));
+ isA(FirebirdAllocateStatementPacket.class));
}
@Test
@@ -70,56 +69,47 @@ class FirebirdCommandPacketFactoryTest {
when(payload.readString()).thenReturn("");
when(payload.readBuffer()).thenReturn(org.mockito.Mockito.mock(io.netty.buffer.ByteBuf.class));
assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.PREPARE_STATEMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdPrepareStatementPacket.class));
+ isA(FirebirdPrepareStatementPacket.class));
}
@Test
void assertNewInstanceWithExecuteStatement() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.EXECUTE, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdExecuteStatementPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.EXECUTE, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdExecuteStatementPacket.class));
}
@Test
void assertNewInstanceWithFetch() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.FETCH, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdFetchStatementPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.FETCH, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdFetchStatementPacket.class));
}
@Test
void assertNewInstanceWithInfoSQL() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.INFO_SQL, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdInfoPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.INFO_SQL, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdInfoPacket.class));
}
@Test
void assertNewInstanceWithCommit() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.COMMIT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdCommitTransactionPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.COMMIT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdCommitTransactionPacket.class));
}
@Test
void assertNewInstanceWithRollback() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.ROLLBACK, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdRollbackTransactionPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.ROLLBACK, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdRollbackTransactionPacket.class));
}
@Test
void assertNewInstanceWithFreeStatement() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.FREE_STATEMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdFreeStatementPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.FREE_STATEMENT, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdFreeStatementPacket.class));
}
@Test
void assertNewInstanceWithUnsupportedCommand() {
- assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.VOID, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13),
- instanceOf(FirebirdUnsupportedCommandPacket.class));
+ assertThat(FirebirdCommandPacketFactory.newInstance(FirebirdCommandPacketType.VOID, payload, FirebirdProtocolVersion.PROTOCOL_VERSION13), isA(FirebirdUnsupportedCommandPacket.class));
}
@Test
void assertIsValidLength() {
- assertThat(FirebirdCommandPacketFactory.isValidLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload,
- 8, FirebirdProtocolVersion.PROTOCOL_VERSION13), CoreMatchers.is(true));
- assertThat(FirebirdCommandPacketFactory.isValidLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload,
- 7, FirebirdProtocolVersion.PROTOCOL_VERSION13), CoreMatchers.is(false));
+ assertTrue(FirebirdCommandPacketFactory.isValidLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, 8, FirebirdProtocolVersion.PROTOCOL_VERSION13));
+ assertFalse(FirebirdCommandPacketFactory.isValidLength(FirebirdCommandPacketType.ALLOCATE_STATEMENT, payload, 7, FirebirdProtocolVersion.PROTOCOL_VERSION13));
}
}
diff --git a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java
index 5a36201f4ec..98bce03f474 100644
--- a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java
+++ b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/statement/execute/protocol/FirebirdBinaryProtocolValueFactoryTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.database.protocol.firebird.packet.command.query
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class FirebirdBinaryProtocolValueFactoryTest {
@@ -29,85 +29,85 @@ class FirebirdBinaryProtocolValueFactoryTest {
@Test
void assertGetStringBinaryProtocolValueByVarying() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.VARYING);
- assertThat(actual, instanceOf(FirebirdStringBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdStringBinaryProtocolValue.class));
}
@Test
void assertGetByteBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.BLOB);
- assertThat(actual, instanceOf(FirebirdByteBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdByteBinaryProtocolValue.class));
}
@Test
void assertGetInt16BinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.INT128);
- assertThat(actual, instanceOf(FirebirdInt16BinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdInt16BinaryProtocolValue.class));
}
@Test
void assertGetInt8BinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.INT64);
- assertThat(actual, instanceOf(FirebirdInt8BinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdInt8BinaryProtocolValue.class));
}
@Test
void assertGetInt4BinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.LONG);
- assertThat(actual, instanceOf(FirebirdInt4BinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdInt4BinaryProtocolValue.class));
}
@Test
void assertGetInt2BinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.SHORT);
- assertThat(actual, instanceOf(FirebirdInt2BinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdInt2BinaryProtocolValue.class));
}
@Test
void assertGetInt1BinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.BOOLEAN);
- assertThat(actual, instanceOf(FirebirdInt1BinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdInt1BinaryProtocolValue.class));
}
@Test
void assertGetDoubleBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.DOUBLE);
- assertThat(actual, instanceOf(FirebirdDoubleBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdDoubleBinaryProtocolValue.class));
}
@Test
void assertGetFloatBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.FLOAT);
- assertThat(actual, instanceOf(FirebirdFloatBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdFloatBinaryProtocolValue.class));
}
@Test
void assertGetDateBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.DATE);
- assertThat(actual, instanceOf(FirebirdDateBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdDateBinaryProtocolValue.class));
}
@Test
void assertGetTimeBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.TIME);
- assertThat(actual, instanceOf(FirebirdTimeBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdTimeBinaryProtocolValue.class));
}
@Test
void assertGetTimestampBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.TIMESTAMP);
- assertThat(actual, instanceOf(FirebirdTimestampBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdTimestampBinaryProtocolValue.class));
}
@Test
void assertGetTimestampTZBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.TIMESTAMP_TZ);
- assertThat(actual, instanceOf(FirebirdTimestampTZBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdTimestampTZBinaryProtocolValue.class));
}
@Test
void assertGetNullBinaryProtocolValue() {
FirebirdBinaryProtocolValue actual = FirebirdBinaryProtocolValueFactory.getBinaryProtocolValue(FirebirdBinaryColumnType.NULL);
- assertThat(actual, instanceOf(FirebirdNullBinaryProtocolValue.class));
+ assertThat(actual, isA(FirebirdNullBinaryProtocolValue.class));
}
@Test
diff --git a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
index 63a6d7b6fa6..3b22a772b1a 100644
--- a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
+++ b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/MySQLBinlogProtocolValueFactoryTest.java
@@ -21,15 +21,15 @@ import org.apache.shardingsphere.database.protocol.mysql.constant.MySQLBinaryCol
import org.apache.shardingsphere.database.protocol.mysql.packet.binlog.row.column.value.integer.MySQLTinyBinlogProtocolValue;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class MySQLBinlogProtocolValueFactoryTest {
@Test
void assertGetBinlogProtocolValue() {
- assertThat(MySQLBinlogProtocolValueFactory.getBinlogProtocolValue(MySQLBinaryColumnType.TINY), instanceOf(MySQLTinyBinlogProtocolValue.class));
+ assertThat(MySQLBinlogProtocolValueFactory.getBinlogProtocolValue(MySQLBinaryColumnType.TINY), isA(MySQLTinyBinlogProtocolValue.class));
}
@Test
diff --git a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
index 15387fa3156..0e9b6326f79 100644
--- a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
+++ b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLStringBinlogProtocolValueTest.java
@@ -30,9 +30,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.io.Serializable;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
@@ -88,7 +88,7 @@ class MySQLStringBinlogProtocolValueTest {
when(byteBuf.readUnsignedByte()).thenReturn((short) expected.length());
when(payload.readStringFixByBytes(expected.length())).thenReturn(expected.getBytes());
Serializable actual = new MySQLStringBinlogProtocolValue().read(columnDef, payload);
- assertThat(actual, instanceOf(MySQLBinaryString.class));
+ assertThat(actual, isA(MySQLBinaryString.class));
assertThat(((MySQLBinaryString) actual).getBytes(), is(expected.getBytes()));
}
@@ -100,7 +100,7 @@ class MySQLStringBinlogProtocolValueTest {
when(byteBuf.readUnsignedShortLE()).thenReturn(expected.length());
when(payload.readStringFixByBytes(expected.length())).thenReturn(expected.getBytes());
Serializable actual = new MySQLStringBinlogProtocolValue().read(columnDef, payload);
- assertThat(actual, instanceOf(MySQLBinaryString.class));
+ assertThat(actual, isA(MySQLBinaryString.class));
assertThat(((MySQLBinaryString) actual).getBytes(), is(expected.getBytes()));
}
diff --git a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
index 5e385396d6d..5a4b842c49b 100644
--- a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
+++ b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/string/MySQLVarcharBinlogProtocolValueTest.java
@@ -29,9 +29,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.io.Serializable;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -62,7 +62,7 @@ class MySQLVarcharBinlogProtocolValueTest {
when(byteBuf.readUnsignedByte()).thenReturn((short) expected.length);
when(payload.readStringFixByBytes(expected.length)).thenReturn(expected);
Serializable actual = new MySQLVarcharBinlogProtocolValue().read(columnDef, payload);
- assertThat(actual, instanceOf(MySQLBinaryString.class));
+ assertThat(actual, isA(MySQLBinaryString.class));
assertThat(((MySQLBinaryString) actual).getBytes(), is(expected));
}
@@ -78,7 +78,7 @@ class MySQLVarcharBinlogProtocolValueTest {
when(byteBuf.readUnsignedShortLE()).thenReturn(expected.length);
when(payload.readStringFixByBytes(expected.length)).thenReturn(expected);
Serializable actual = new MySQLVarcharBinlogProtocolValue().read(columnDef, payload);
- assertThat(actual, instanceOf(MySQLBinaryString.class));
+ assertThat(actual, isA(MySQLBinaryString.class));
assertThat(((MySQLBinaryString) actual).getBytes(), is(expected));
}
}
diff --git a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactoryTest.java b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactoryTest.java
index e08aece95d2..4137eef9918 100644
--- a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactoryTest.java
+++ b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/command/query/binary/execute/protocol/MySQLBinaryProtocolValueFactoryTest.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.database.protocol.mysql.packet.command.query.b
import org.apache.shardingsphere.database.protocol.mysql.constant.MySQLBinaryColumnType;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -29,127 +29,127 @@ class MySQLBinaryProtocolValueFactoryTest {
@Test
void assertGetBinaryProtocolValueWithMySQLTypeString() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.STRING), instanceOf(MySQLByteLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.STRING), isA(MySQLByteLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeVarchar() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.VARCHAR), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.VARCHAR), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeVarString() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.VAR_STRING), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.VAR_STRING), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeEnum() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.ENUM), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.ENUM), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeSet() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.SET), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.SET), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeLongBlob() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.LONG_BLOB), instanceOf(MySQLByteLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.LONG_BLOB), isA(MySQLByteLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeMediumBlob() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MEDIUM_BLOB), instanceOf(MySQLByteLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.MEDIUM_BLOB), isA(MySQLByteLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeBlob() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.BLOB), instanceOf(MySQLByteLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.BLOB), isA(MySQLByteLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeTinyBlob() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TINY_BLOB), instanceOf(MySQLByteLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TINY_BLOB), isA(MySQLByteLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeGeometry() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.GEOMETRY), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.GEOMETRY), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeBit() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.BIT), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.BIT), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeDecimal() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DECIMAL), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DECIMAL), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeNewDecimal() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.NEWDECIMAL), instanceOf(MySQLStringLenencBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.NEWDECIMAL), isA(MySQLStringLenencBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeLongLong() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.LONGLONG), instanceOf(MySQLInt8BinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.LONGLONG), isA(MySQLInt8BinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeLong() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.LONG), instanceOf(MySQLInt4BinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.LONG), isA(MySQLInt4BinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeInt24() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.INT24), instanceOf(MySQLInt4BinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.INT24), isA(MySQLInt4BinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeShort() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.SHORT), instanceOf(MySQLInt2BinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.SHORT), isA(MySQLInt2BinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeYear() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.YEAR), instanceOf(MySQLInt2BinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.YEAR), isA(MySQLInt2BinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeTiny() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TINY), instanceOf(MySQLInt1BinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TINY), isA(MySQLInt1BinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeDouble() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DOUBLE), instanceOf(MySQLDoubleBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DOUBLE), isA(MySQLDoubleBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeFloat() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.FLOAT), instanceOf(MySQLFloatBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.FLOAT), isA(MySQLFloatBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeDate() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DATE), instanceOf(MySQLDateBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DATE), isA(MySQLDateBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeDatetime() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DATETIME), instanceOf(MySQLDateBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.DATETIME), isA(MySQLDateBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeTimestamp() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TIMESTAMP), instanceOf(MySQLDateBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TIMESTAMP), isA(MySQLDateBinaryProtocolValue.class));
}
@Test
void assertGetBinaryProtocolValueWithMySQLTypeTime() {
- assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TIME), instanceOf(MySQLTimeBinaryProtocolValue.class));
+ assertThat(MySQLBinaryProtocolValueFactory.getBinaryProtocolValue(MySQLBinaryColumnType.TIME), isA(MySQLTimeBinaryProtocolValue.class));
}
@Test
diff --git a/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketFactoryTest.java b/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketFactoryTest.java
index 6578ef4713e..11af95cc3d0 100644
--- a/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketFactoryTest.java
+++ b/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketFactoryTest.java
@@ -30,8 +30,8 @@ import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -44,11 +44,11 @@ class OpenGaussCommandPacketFactoryTest {
@Test
void assertNewOpenGaussComBatchBindPacket() {
when(payload.getByteBuf()).thenReturn(mock(ByteBuf.class));
- assertThat(OpenGaussCommandPacketFactory.newInstance(OpenGaussCommandPacketType.BATCH_BIND_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(OpenGaussCommandPacketFactory.newInstance(OpenGaussCommandPacketType.BATCH_BIND_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewPostgreSQLPacket() {
- assertThat(OpenGaussCommandPacketFactory.newInstance(mock(PostgreSQLCommandPacketType.class), payload), instanceOf(PostgreSQLCommandPacket.class));
+ assertThat(OpenGaussCommandPacketFactory.newInstance(mock(PostgreSQLCommandPacketType.class), payload), isA(PostgreSQLCommandPacket.class));
}
}
diff --git a/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketTypeTest.java b/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketTypeTest.java
index 9a1f8f69785..3dbb08639e9 100644
--- a/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketTypeTest.java
+++ b/database/protocol/dialect/opengauss/src/test/java/org/apache/shardingsphere/database/protocol/opengauss/packet/command/packet/command/OpenGaussCommandPacketTypeTest.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.database.protocol.packet.command.CommandPacketT
import org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class OpenGaussCommandPacketTypeTest {
@@ -37,6 +37,6 @@ class OpenGaussCommandPacketTypeTest {
@Test
void assertValueOfPostgreSQLCommand() {
CommandPacketType actual = OpenGaussCommandPacketType.valueOf('Q');
- assertThat(actual, instanceOf(PostgreSQLCommandPacketType.class));
+ assertThat(actual, isA(PostgreSQLCommandPacketType.class));
}
}
diff --git a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
index 67fa6428589..281e9e1c2ec 100644
--- a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
+++ b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/PostgreSQLCommandPacketFactoryTest.java
@@ -27,8 +27,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -42,47 +42,47 @@ class PostgreSQLCommandPacketFactoryTest {
void assertNewInstanceWithQueryComPacket() {
when(payload.getByteBuf()).thenReturn(mock(ByteBuf.class));
when(payload.readStringNul()).thenReturn("");
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SIMPLE_QUERY, payload), instanceOf(PostgreSQLComQueryPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SIMPLE_QUERY, payload), isA(PostgreSQLComQueryPacket.class));
}
@Test
void assertNewInstanceWithParseComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.PARSE_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.PARSE_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithBindComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.BIND_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.BIND_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithDescribeComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.DESCRIBE_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.DESCRIBE_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithExecuteComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.EXECUTE_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.EXECUTE_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithSyncComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SYNC_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.SYNC_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithCloseComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.CLOSE_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.CLOSE_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithFlushComPacket() {
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.FLUSH_COMMAND, payload), instanceOf(PostgreSQLAggregatedCommandPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.FLUSH_COMMAND, payload), isA(PostgreSQLAggregatedCommandPacket.class));
}
@Test
void assertNewInstanceWithTerminationComPacket() {
when(payload.getByteBuf()).thenReturn(mock(ByteBuf.class));
- assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.TERMINATE, payload), instanceOf(PostgreSQLComTerminationPacket.class));
+ assertThat(PostgreSQLCommandPacketFactory.newInstance(PostgreSQLCommandPacketType.TERMINATE, payload), isA(PostgreSQLComTerminationPacket.class));
}
}
diff --git a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
index 820ff6ae4ff..bb18b78fce9 100644
--- a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
+++ b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLBinaryProtocolValueFactoryTest.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.database.protocol.postgresql.packet.command.qu
import org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class PostgreSQLBinaryProtocolValueFactoryTest {
@@ -29,67 +29,67 @@ class PostgreSQLBinaryProtocolValueFactoryTest {
@Test
void assertGetStringBinaryProtocolValueByVarchar() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.VARCHAR);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLStringBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLStringBinaryProtocolValue.class));
}
@Test
void assertGetStringBinaryProtocolValueByChar() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.CHAR);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLStringBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLStringBinaryProtocolValue.class));
}
@Test
void assertGetInt8BinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.INT8);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLInt8BinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLInt8BinaryProtocolValue.class));
}
@Test
void assertGetInt4BinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.INT4);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLInt4BinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLInt4BinaryProtocolValue.class));
}
@Test
void assertGetInt2BinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.INT2);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLInt2BinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLInt2BinaryProtocolValue.class));
}
@Test
void assertGetDoubleBinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.FLOAT8);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLDoubleBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLDoubleBinaryProtocolValue.class));
}
@Test
void assertGetFloatBinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.FLOAT4);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLFloatBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLFloatBinaryProtocolValue.class));
}
@Test
void assertGetNumericBinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.NUMERIC);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLNumericBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLNumericBinaryProtocolValue.class));
}
@Test
void assertGetDateBinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.DATE);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLDateBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLDateBinaryProtocolValue.class));
}
@Test
void assertGetTimeBinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.TIMESTAMP);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLTimeBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLTimeBinaryProtocolValue.class));
}
@Test
void assertGetBoolBinaryProtocolValue() {
PostgreSQLBinaryProtocolValue binaryProtocolValue = PostgreSQLBinaryProtocolValueFactory.getBinaryProtocolValue(PostgreSQLColumnType.BOOL);
- assertThat(binaryProtocolValue, instanceOf(PostgreSQLBoolBinaryProtocolValue.class));
+ assertThat(binaryProtocolValue, isA(PostgreSQLBoolBinaryProtocolValue.class));
}
@Test
diff --git a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
index 29c0010051d..dea95ab078b 100644
--- a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
+++ b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLUnspecifiedBinaryProtocolValueTest.java
@@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
@@ -49,7 +49,7 @@ class PostgreSQLUnspecifiedBinaryProtocolValueTest {
byteBuf.readInt();
PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(byteBuf, StandardCharsets.UTF_8);
Object actual = new PostgreSQLUnspecifiedBinaryProtocolValue().read(payload, timestampStr.length());
- assertThat(actual, instanceOf(PostgreSQLTypeUnspecifiedSQLParameter.class));
+ assertThat(actual, isA(PostgreSQLTypeUnspecifiedSQLParameter.class));
assertThat(actual.toString(), is(timestampStr));
assertThat(byteBuf.readerIndex(), is(expectedLength));
}
diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
index 5d51adc5a15..472de8b4e27 100644
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
+++ b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/route/engine/BroadcastRouteEngineFactoryTest.java
@@ -51,8 +51,8 @@ import org.mockito.quality.Strictness;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -81,7 +81,7 @@ class BroadcastRouteEngineFactoryTest {
@Test
void assertNewInstanceWithTCLStatement() {
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(TCLStatement.class));
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastDatabaseBroadcastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastDatabaseBroadcastRouteEngine.class));
}
@Test
@@ -90,7 +90,7 @@ class BroadcastRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(new CloseStatement(databaseType, mock(), false));
when(sqlStatementContext.getTablesContext()).thenReturn(createTablesContext());
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastUnicastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastUnicastRouteEngine.class));
}
@Test
@@ -99,7 +99,7 @@ class BroadcastRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DDLStatement.class, RETURNS_DEEP_STUBS));
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
when(SQLStatementContextExtractor.getTableNames(database, sqlStatementContext)).thenReturn(Collections.singleton("foo_tbl"));
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastTableBroadcastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastTableBroadcastRouteEngine.class));
}
@Test
@@ -108,7 +108,7 @@ class BroadcastRouteEngineFactoryTest {
when(sqlStatementContext.getTablesContext()).thenReturn(createTablesContext());
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DALStatement.class));
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastTableBroadcastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastTableBroadcastRouteEngine.class));
}
@Test
@@ -117,7 +117,7 @@ class BroadcastRouteEngineFactoryTest {
when(sqlStatementContext.getTablesContext()).thenReturn(createTablesContext());
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DCLStatement.class));
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastTableBroadcastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastTableBroadcastRouteEngine.class));
}
@Test
@@ -126,7 +126,7 @@ class BroadcastRouteEngineFactoryTest {
when(sqlStatementContext.getTablesContext()).thenReturn(createTablesContext());
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(SelectStatement.class));
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastUnicastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastUnicastRouteEngine.class));
}
@Test
@@ -135,7 +135,7 @@ class BroadcastRouteEngineFactoryTest {
when(sqlStatementContext.getTablesContext()).thenReturn(createTablesContext());
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(UpdateStatement.class));
when(queryContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
- assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), instanceOf(BroadcastDatabaseBroadcastRouteEngine.class));
+ assertThat(BroadcastRouteEngineFactory.newInstance(queryContext, Collections.emptyList()), isA(BroadcastDatabaseBroadcastRouteEngine.class));
}
private TablesContext createTablesContext() {
diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/rule/builder/BroadcastRuleBuilderTest.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/rule/builder/BroadcastRuleBuilderTest.java
index 2315b849297..693329a7be6 100644
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/rule/builder/BroadcastRuleBuilderTest.java
+++ b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/rule/builder/BroadcastRuleBuilderTest.java
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class BroadcastRuleBuilderTest {
@@ -42,6 +42,6 @@ class BroadcastRuleBuilderTest {
void assertBuild() {
BroadcastRuleConfiguration ruleConfig = mock(BroadcastRuleConfiguration.class);
DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class, Collections.singleton(ruleConfig)).get(ruleConfig);
- assertThat(builder.build(ruleConfig, "", databaseType, mock(ResourceMetaData.class), Collections.emptyList(), mock(ComputeNodeInstanceContext.class)), instanceOf(BroadcastRule.class));
+ assertThat(builder.build(ruleConfig, "", databaseType, mock(ResourceMetaData.class), Collections.emptyList(), mock(ComputeNodeInstanceContext.class)), isA(BroadcastRule.class));
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/EncryptSupportedSQLCheckersBuilderTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/EncryptSupportedSQLCheckersBuilderTest.java
index c0db41f81ce..172d16eb912 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/EncryptSupportedSQLCheckersBuilderTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/EncryptSupportedSQLCheckersBuilderTest.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.encrypt.checker.sql;
-import org.apache.shardingsphere.encrypt.checker.sql.projection.EncryptInsertSelectProjectionSupportedChecker;
-import org.apache.shardingsphere.encrypt.checker.sql.projection.EncryptSelectProjectionSupportedChecker;
import org.apache.shardingsphere.encrypt.checker.sql.orderby.EncryptOrderByItemSupportedChecker;
import org.apache.shardingsphere.encrypt.checker.sql.predicate.EncryptPredicateColumnSupportedChecker;
+import org.apache.shardingsphere.encrypt.checker.sql.projection.EncryptInsertSelectProjectionSupportedChecker;
+import org.apache.shardingsphere.encrypt.checker.sql.projection.EncryptSelectProjectionSupportedChecker;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
import org.apache.shardingsphere.infra.checker.SupportedSQLCheckersBuilder;
@@ -32,8 +32,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class EncryptSupportedSQLCheckersBuilderTest {
@@ -49,9 +49,9 @@ class EncryptSupportedSQLCheckersBuilderTest {
@Test
void assertGetSupportedSQLCheckers() {
List<SupportedSQLChecker<?, EncryptRule>> actual = new ArrayList<SupportedSQLChecker<?, EncryptRule>>(builder.getSupportedSQLCheckers());
- assertThat(actual.get(0), instanceOf(EncryptSelectProjectionSupportedChecker.class));
- assertThat(actual.get(1), instanceOf(EncryptInsertSelectProjectionSupportedChecker.class));
- assertThat(actual.get(2), instanceOf(EncryptPredicateColumnSupportedChecker.class));
- assertThat(actual.get(3), instanceOf(EncryptOrderByItemSupportedChecker.class));
+ assertThat(actual.get(0), isA(EncryptSelectProjectionSupportedChecker.class));
+ assertThat(actual.get(1), isA(EncryptInsertSelectProjectionSupportedChecker.class));
+ assertThat(actual.get(2), isA(EncryptPredicateColumnSupportedChecker.class));
+ assertThat(actual.get(3), isA(EncryptOrderByItemSupportedChecker.class));
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/EncryptResultDecoratorEngineTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/EncryptResultDecoratorEngineTest.java
index 71782da8779..85603feff8c 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/EncryptResultDecoratorEngineTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/EncryptResultDecoratorEngineTest.java
@@ -39,8 +39,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -62,7 +62,7 @@ class EncryptResultDecoratorEngineTest {
Optional<ResultDecorator<EncryptRule>> actual =
engine.newInstance(mock(ShardingSphereMetaData.class), database, mock(ConfigurationProperties.class), mock(SelectStatementContext.class, RETURNS_DEEP_STUBS));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(EncryptDQLResultDecorator.class));
+ assertThat(actual.get(), isA(EncryptDQLResultDecorator.class));
}
@Test
@@ -72,7 +72,7 @@ class EncryptResultDecoratorEngineTest {
EncryptResultDecoratorEngine engine = (EncryptResultDecoratorEngine) OrderedSPILoader.getServices(ResultProcessEngine.class, Collections.singleton(rule)).get(rule);
Optional<ResultDecorator<EncryptRule>> actual = engine.newInstance(mock(ShardingSphereMetaData.class), database, mock(ConfigurationProperties.class), sqlStatementContext);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(EncryptDALResultDecorator.class));
+ assertThat(actual.get(), isA(EncryptDALResultDecorator.class));
}
@Test
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java
index d7ea0189d24..bddbed1055d 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/EncryptDALResultDecoratorTest.java
@@ -40,8 +40,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -61,7 +61,7 @@ class EncryptDALResultDecoratorTest {
void assertMergedResultWithShowColumnsStatement() {
sqlStatementContext = mockColumnInResultSetSQLStatementAttributeContext();
EncryptDALResultDecorator decorator = new EncryptDALResultDecorator(mock(RuleMetaData.class));
- assertThat(decorator.decorate(mock(MergedResult.class), sqlStatementContext, rule), instanceOf(EncryptShowColumnsMergedResult.class));
+ assertThat(decorator.decorate(mock(MergedResult.class), sqlStatementContext, rule), isA(EncryptShowColumnsMergedResult.class));
}
@Test
@@ -70,14 +70,14 @@ class EncryptDALResultDecoratorTest {
RuleMetaData ruleMetaData = mock(RuleMetaData.class);
when(ruleMetaData.getSingleRule(SQLParserRule.class)).thenReturn(mock(SQLParserRule.class));
EncryptDALResultDecorator decorator = new EncryptDALResultDecorator(ruleMetaData);
- assertThat(decorator.decorate(mock(MergedResult.class), sqlStatementContext, rule), instanceOf(EncryptShowCreateTableMergedResult.class));
+ assertThat(decorator.decorate(mock(MergedResult.class), sqlStatementContext, rule), isA(EncryptShowCreateTableMergedResult.class));
}
@Test
void assertMergedResultWithOtherStatement() {
sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
EncryptDALResultDecorator decorator = new EncryptDALResultDecorator(mock(RuleMetaData.class));
- assertThat(decorator.decorate(mock(MergedResult.class), sqlStatementContext, rule), instanceOf(MergedResult.class));
+ assertThat(decorator.decorate(mock(MergedResult.class), sqlStatementContext, rule), isA(MergedResult.class));
}
private SQLStatementContext mockColumnInResultSetSQLStatementAttributeContext() {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewritersRegistryTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewritersRegistryTest.java
index eba80e98dba..f7b01e6e678 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewritersRegistryTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewritersRegistryTest.java
@@ -31,9 +31,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -46,10 +46,10 @@ class EncryptParameterRewritersRegistryTest {
when(sqlRewriteContext.getDatabase().getName()).thenReturn("foo_db");
List<ParameterRewriter> actual = new ArrayList<>(new EncryptParameterRewritersRegistry(mock(EncryptRule.class), sqlRewriteContext, Collections.emptyList()).getParameterRewriters());
assertThat(actual.size(), is(5));
- assertThat(actual.get(0), instanceOf(EncryptAssignmentParameterRewriter.class));
- assertThat(actual.get(1), instanceOf(EncryptPredicateParameterRewriter.class));
- assertThat(actual.get(2), instanceOf(EncryptInsertPredicateParameterRewriter.class));
- assertThat(actual.get(3), instanceOf(EncryptInsertValueParameterRewriter.class));
- assertThat(actual.get(4), instanceOf(EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.class));
+ assertThat(actual.get(0), isA(EncryptAssignmentParameterRewriter.class));
+ assertThat(actual.get(1), isA(EncryptPredicateParameterRewriter.class));
+ assertThat(actual.get(2), isA(EncryptInsertPredicateParameterRewriter.class));
+ assertThat(actual.get(3), isA(EncryptInsertValueParameterRewriter.class));
+ assertThat(actual.get(4), isA(EncryptInsertOnDuplicateKeyUpdateValueParameterRewriter.class));
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
index 91ed0d56023..6f5ea0038a7 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptTokenGenerateBuilderTest.java
@@ -17,13 +17,13 @@
package org.apache.shardingsphere.encrypt.rewrite.token;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.predicate.EncryptPredicateColumnTokenGenerator;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.predicate.EncryptPredicateValueTokenGenerator;
import org.apache.shardingsphere.encrypt.rewrite.token.generator.projection.EncryptSelectProjectionTokenGenerator;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.binder.context.segment.select.orderby.OrderByItem;
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.SQLTokenGenerator;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
@@ -38,9 +38,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -68,10 +68,10 @@ class EncryptTokenGenerateBuilderTest {
assertThat(sqlTokenGenerators.size(), is(3));
Iterator<SQLTokenGenerator> iterator = sqlTokenGenerators.iterator();
SQLTokenGenerator item1 = iterator.next();
- assertThat(item1, instanceOf(EncryptSelectProjectionTokenGenerator.class));
+ assertThat(item1, isA(EncryptSelectProjectionTokenGenerator.class));
SQLTokenGenerator item2 = iterator.next();
- assertThat(item2, instanceOf(EncryptPredicateColumnTokenGenerator.class));
+ assertThat(item2, isA(EncryptPredicateColumnTokenGenerator.class));
SQLTokenGenerator item3 = iterator.next();
- assertThat(item3, instanceOf(EncryptPredicateValueTokenGenerator.class));
+ assertThat(item3, isA(EncryptPredicateValueTokenGenerator.class));
}
}
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
index 701e6473e9e..0ccdb662a03 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptAlterTableTokenGeneratorTest.java
@@ -48,9 +48,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -103,7 +103,7 @@ class EncryptAlterTableTokenGeneratorTest {
Collection<SQLToken> actual = generator.generateSQLTokens(new CommonSQLStatementContext(createAddColumnStatement()));
assertThat(actual.size(), is(4));
Iterator<SQLToken> actualIterator = actual.iterator();
- assertThat(actualIterator.next(), instanceOf(RemoveToken.class));
+ assertThat(actualIterator.next(), isA(RemoveToken.class));
EncryptColumnToken cipherToken = (EncryptColumnToken) actualIterator.next();
assertThat(cipherToken.toString(), is("cipher_certificate_number VARCHAR(4000)"));
assertThat(cipherToken.getStartIndex(), is(68));
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java
index fd572567bec..f7e9dc443a7 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/ddl/EncryptCreateTableTokenGeneratorTest.java
@@ -43,9 +43,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -89,7 +89,7 @@ class EncryptCreateTableTokenGeneratorTest {
Collection<SQLToken> actual = generator.generateSQLTokens(new CommonSQLStatementContext(createCreateTableStatement()));
assertThat(actual.size(), is(1));
SQLToken token = actual.iterator().next();
- assertThat(token, instanceOf(SubstituteColumnDefinitionToken.class));
+ assertThat(token, isA(SubstituteColumnDefinitionToken.class));
Collection<SQLToken> columnTokens = ((SubstituteColumnDefinitionToken) token).getColumnDefinitionTokens();
Iterator<SQLToken> actualIterator = columnTokens.iterator();
ColumnDefinitionToken cipherToken = (ColumnDefinitionToken) actualIterator.next();
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
index 262fef0f670..49e484ce25a 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.encrypt.rule.builder;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRuleBuilder;
import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
@@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class EncryptRuleBuilderTest {
@@ -40,6 +40,6 @@ class EncryptRuleBuilderTest {
void assertBuild() {
EncryptRuleConfiguration ruleConfig = mock(EncryptRuleConfiguration.class);
DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class, Collections.singleton(ruleConfig)).get(ruleConfig);
- assertThat(builder.build(ruleConfig, "", databaseType, mock(), Collections.emptyList(), mock()), instanceOf(EncryptRule.class));
+ assertThat(builder.build(ruleConfig, "", databaseType, mock(), Collections.emptyList(), mock()), isA(EncryptRule.class));
}
}
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/MaskResultDecoratorEngineTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/MaskResultDecoratorEngineTest.java
index 4dc56ba35a2..9526156b250 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/MaskResultDecoratorEngineTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/merge/MaskResultDecoratorEngineTest.java
@@ -35,8 +35,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -57,7 +57,7 @@ class MaskResultDecoratorEngineTest {
Optional<ResultDecorator<MaskRule>> actual =
engine.newInstance(mock(ShardingSphereMetaData.class), database, mock(ConfigurationProperties.class), mock(SelectStatementContext.class, RETURNS_DEEP_STUBS));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MaskDQLResultDecorator.class));
+ assertThat(actual.get(), isA(MaskDQLResultDecorator.class));
}
@Test
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/builder/MaskRuleBuilderTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/builder/MaskRuleBuilderTest.java
index b438d188f27..08f41de7f9a 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/builder/MaskRuleBuilderTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/rule/builder/MaskRuleBuilderTest.java
@@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class MaskRuleBuilderTest {
@@ -37,6 +37,6 @@ class MaskRuleBuilderTest {
void assertBuild() {
MaskRuleConfiguration ruleConfig = mock(MaskRuleConfiguration.class);
DatabaseRuleBuilder<MaskRuleConfiguration> builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class, Collections.singleton(ruleConfig)).get(ruleConfig);
- assertThat(builder.build(ruleConfig, "", mock(), mock(), Collections.emptyList(), mock(ComputeNodeInstanceContext.class)), instanceOf(MaskRule.class));
+ assertThat(builder.build(ruleConfig, "", mock(), mock(), Collections.emptyList(), mock(ComputeNodeInstanceContext.class)), isA(MaskRule.class));
}
}
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
index 36ceff08924..96b0b065749 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/rule/builder/ReadwriteSplittingRuleBuilderTest.java
@@ -28,8 +28,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class ReadwriteSplittingRuleBuilderTest {
@@ -42,6 +42,6 @@ class ReadwriteSplittingRuleBuilderTest {
ReadwriteSplittingRuleConfiguration ruleConfig = new ReadwriteSplittingRuleConfiguration(Collections.singleton(
new ReadwriteSplittingDataSourceGroupRuleConfiguration("name", "writeDataSourceName", Collections.singletonList("readDataSourceName"), "loadBalancerName")), Collections.emptyMap());
DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class, Collections.singleton(ruleConfig)).get(ruleConfig);
- assertThat(builder.build(ruleConfig, "", databaseType, mock(), Collections.emptyList(), mock()), instanceOf(ReadwriteSplittingRule.class));
+ assertThat(builder.build(ruleConfig, "", databaseType, mock(), Collections.emptyList(), mock()), isA(ReadwriteSplittingRule.class));
}
}
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java
index 83c8e240e8e..0bc4f2927c3 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/retriever/ShadowDataSourceMappingsRetrieverFactoryTest.java
@@ -36,8 +36,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -48,16 +48,16 @@ class ShadowDataSourceMappingsRetrieverFactoryTest {
void assertNewInstance() {
ShadowDataSourceMappingsRetriever retriever = ShadowDataSourceMappingsRetrieverFactory.newInstance(
new QueryContext(createInsertSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class)));
- assertThat(retriever, instanceOf(ShadowDMLStatementDataSourceMappingsRetriever.class));
+ assertThat(retriever, isA(ShadowDMLStatementDataSourceMappingsRetriever.class));
ShadowDataSourceMappingsRetriever shadowUpdateRouteEngine = ShadowDataSourceMappingsRetrieverFactory.newInstance(
new QueryContext(createUpdateSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class)));
- assertThat(shadowUpdateRouteEngine, instanceOf(ShadowDMLStatementDataSourceMappingsRetriever.class));
+ assertThat(shadowUpdateRouteEngine, isA(ShadowDMLStatementDataSourceMappingsRetriever.class));
ShadowDataSourceMappingsRetriever shadowDeleteRouteEngine = ShadowDataSourceMappingsRetrieverFactory.newInstance(
new QueryContext(createDeleteSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class)));
- assertThat(shadowDeleteRouteEngine, instanceOf(ShadowDMLStatementDataSourceMappingsRetriever.class));
+ assertThat(shadowDeleteRouteEngine, isA(ShadowDMLStatementDataSourceMappingsRetriever.class));
ShadowDataSourceMappingsRetriever shadowSelectRouteEngine = ShadowDataSourceMappingsRetrieverFactory.newInstance(
new QueryContext(createSelectSqlStatementContext(), "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class)));
- assertThat(shadowSelectRouteEngine, instanceOf(ShadowDMLStatementDataSourceMappingsRetriever.class));
+ assertThat(shadowSelectRouteEngine, isA(ShadowDMLStatementDataSourceMappingsRetriever.class));
}
private ConnectionContext mockConnectionContext() {
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
index d8621ab6357..2d22459d67c 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class ShadowRuleBuilderTest {
@@ -36,6 +36,6 @@ class ShadowRuleBuilderTest {
void assertBuild() {
ShadowRuleConfiguration ruleConfig = new ShadowRuleConfiguration();
DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class, Collections.singleton(ruleConfig)).get(ruleConfig);
- assertThat(builder.build(ruleConfig, "", mock(), mock(), Collections.emptyList(), mock()), instanceOf(ShadowRule.class));
+ assertThat(builder.build(ruleConfig, "", mock(), mock(), Collections.emptyList(), mock()), isA(ShadowRule.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
index 48f0c215092..156635d38ca 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/classbased/ClassBasedShardingAlgorithmFactoryTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class ClassBasedShardingAlgorithmFactoryTest {
@@ -40,6 +40,6 @@ class ClassBasedShardingAlgorithmFactoryTest {
@Test
void assertNewInstance() {
assertThat(ClassBasedShardingAlgorithmFactory.newInstance(ClassBasedStandardShardingAlgorithmFixture.class.getName(), StandardShardingAlgorithm.class, new Properties()),
- instanceOf(ClassBasedStandardShardingAlgorithmFixture.class));
+ isA(ClassBasedStandardShardingAlgorithmFixture.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/temporal/TemporalHandlerFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/temporal/TemporalHandlerFactoryTest.java
index ec98ce58c01..5e63851bca7 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/temporal/TemporalHandlerFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/datetime/temporal/TemporalHandlerFactoryTest.java
@@ -32,38 +32,38 @@ import java.time.Month;
import java.time.Year;
import java.time.YearMonth;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class TemporalHandlerFactoryTest {
@Test
void assertNewInstanceWithLocalDate() {
- assertThat(TemporalHandlerFactory.newInstance(LocalDate.now()), instanceOf(LocalDateTemporalHandler.class));
+ assertThat(TemporalHandlerFactory.newInstance(LocalDate.now()), isA(LocalDateTemporalHandler.class));
}
@Test
void assertNewInstanceWithLocalTime() {
- assertThat(TemporalHandlerFactory.newInstance(LocalTime.now()), instanceOf(LocalTimeTemporalHandler.class));
+ assertThat(TemporalHandlerFactory.newInstance(LocalTime.now()), isA(LocalTimeTemporalHandler.class));
}
@Test
void assertNewInstanceWithLocalDateTime() {
- assertThat(TemporalHandlerFactory.newInstance(LocalDateTime.now()), instanceOf(LocalDateTimeTemporalHandler.class));
+ assertThat(TemporalHandlerFactory.newInstance(LocalDateTime.now()), isA(LocalDateTimeTemporalHandler.class));
}
@Test
void assertNewInstanceWithYearMonth() {
- assertThat(TemporalHandlerFactory.newInstance(YearMonth.now()), instanceOf(YearMonthTemporalHandler.class));
+ assertThat(TemporalHandlerFactory.newInstance(YearMonth.now()), isA(YearMonthTemporalHandler.class));
}
@Test
void assertNewInstanceWithYear() {
- assertThat(TemporalHandlerFactory.newInstance(Year.now()), instanceOf(YearTemporalHandler.class));
+ assertThat(TemporalHandlerFactory.newInstance(Year.now()), isA(YearTemporalHandler.class));
}
@Test
void assertNewInstanceWithMonth() {
- assertThat(TemporalHandlerFactory.newInstance(Month.JANUARY), instanceOf(MonthTemporalHandler.class));
+ assertThat(TemporalHandlerFactory.newInstance(Month.JANUARY), isA(MonthTemporalHandler.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
index ba1729879ea..4c6841c83bd 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ShardingResultMergerEngineTest.java
@@ -47,8 +47,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -66,7 +66,7 @@ class ShardingResultMergerEngineTest {
SelectStatementContext sqlStatementContext = new SelectStatementContext(
selectStatement, new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), mock()), "foo_db", Collections.emptyList());
assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, new ConfigurationProperties(new Properties()), sqlStatementContext),
- instanceOf(ShardingDQLResultMerger.class));
+ isA(ShardingDQLResultMerger.class));
}
@Test
@@ -75,7 +75,7 @@ class ShardingResultMergerEngineTest {
SQLStatement sqlStatement = mock(ShowStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
- assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), instanceOf(ShardingDALResultMerger.class));
+ assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), isA(ShardingDALResultMerger.class));
}
@Test
@@ -86,7 +86,7 @@ class ShardingResultMergerEngineTest {
insertStatement.setInsertColumns(insertColumnsSegment);
InsertStatementContext sqlStatementContext = createInsertStatementContext(insertStatement);
ConfigurationProperties props = new ConfigurationProperties(new Properties());
- assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), instanceOf(TransparentResultMerger.class));
+ assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), isA(TransparentResultMerger.class));
}
private InsertStatementContext createInsertStatementContext(final InsertStatement insertStatement) {
@@ -99,6 +99,6 @@ class ShardingResultMergerEngineTest {
void assertNewInstanceWithDDLStatement() {
ConfigurationProperties props = new ConfigurationProperties(new Properties());
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new FetchStatement(databaseType, null, null));
- assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), instanceOf(ShardingDDLResultMerger.class));
+ assertThat(new ShardingResultMergerEngine().newInstance("foo_db", databaseType, null, props, sqlStatementContext), isA(ShardingDDLResultMerger.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dal/ShardingDALResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dal/ShardingDALResultMergerTest.java
index 4d02a28c5c2..a8796fe8e0f 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dal/ShardingDALResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dal/ShardingDALResultMergerTest.java
@@ -33,8 +33,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -51,7 +51,7 @@ class ShardingDALResultMergerTest {
@Test
void assertMergeForExplainStatement() throws SQLException {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(mock(ExplainStatement.class));
- assertThat(resultMerger.merge(queryResults, sqlStatementContext, mock(), mock()), instanceOf(TransparentMergedResult.class));
+ assertThat(resultMerger.merge(queryResults, sqlStatementContext, mock(), mock()), isA(TransparentMergedResult.class));
}
@Test
@@ -59,7 +59,7 @@ class ShardingDALResultMergerTest {
SQLStatementContext sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
when(sqlStatementContext.getSqlStatement().getDatabaseType()).thenReturn(databaseType);
- assertThat(resultMerger.merge(queryResults, sqlStatementContext, mock(), mock()), instanceOf(TransparentMergedResult.class));
+ assertThat(resultMerger.merge(queryResults, sqlStatementContext, mock(), mock()), isA(TransparentMergedResult.class));
}
private SQLStatementContext mockSQLStatementContext(final DALStatement dalStatement) {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
index 37b2b6df89f..10b8acd2942 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/ddl/ShardingDDLResultMergerTest.java
@@ -45,8 +45,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -61,12 +61,12 @@ class ShardingDDLResultMergerTest {
void assertMergeWithIteratorStreamMergedResult() throws SQLException {
CursorHeldSQLStatementContext sqlStatement = mock(CursorHeldSQLStatementContext.class);
when(sqlStatement.getSqlStatement()).thenReturn(mock(FetchStatement.class));
- assertThat(merger.merge(Collections.singletonList(createQueryResult()), sqlStatement, mock(), mock()), instanceOf(IteratorStreamMergedResult.class));
+ assertThat(merger.merge(Collections.singletonList(createQueryResult()), sqlStatement, mock(), mock()), isA(IteratorStreamMergedResult.class));
}
@Test
void assertMergeWithTransparentMergedResult() throws SQLException {
- assertThat(merger.merge(createQueryResults(), mock(SelectStatementContext.class), mock(), mock()), instanceOf(TransparentMergedResult.class));
+ assertThat(merger.merge(createQueryResults(), mock(SelectStatementContext.class), mock(), mock()), isA(TransparentMergedResult.class));
}
@Test
@@ -75,7 +75,7 @@ class ShardingDDLResultMergerTest {
when(database.getName()).thenReturn("foo_db");
ConnectionContext connectionContext = mock(ConnectionContext.class);
when(connectionContext.getCursorContext()).thenReturn(new CursorConnectionContext());
- assertThat(merger.merge(createQueryResults(), createCursorHeldSQLStatementContext(database), mock(), connectionContext), instanceOf(FetchStreamMergedResult.class));
+ assertThat(merger.merge(createQueryResults(), createCursorHeldSQLStatementContext(database), mock(), connectionContext), isA(FetchStreamMergedResult.class));
}
private CursorHeldSQLStatementContext createCursorHeldSQLStatementContext(final ShardingSphereDatabase database) {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
index d195ff985b6..3d440745d0b 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
@@ -65,8 +65,8 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -87,7 +87,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
- assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(IteratorStreamMergedResult.class));
+ assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), isA(IteratorStreamMergedResult.class));
}
@Test
@@ -99,8 +99,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setLimit(new LimitSegment(0, 0, new NumberLiteralLimitValueSegment(0, 0, 1L), null));
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
- assertThat(resultMerger.merge(Collections.singletonList(createQueryResult()), selectStatementContext, createDatabase(), mock(ConnectionContext.class)),
- instanceOf(IteratorStreamMergedResult.class));
+ assertThat(resultMerger.merge(Collections.singletonList(createQueryResult()), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), isA(IteratorStreamMergedResult.class));
}
@Test
@@ -113,8 +112,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
- assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(IteratorStreamMergedResult.class));
+ assertThat(actual, isA(LimitDecoratorMergedResult.class));
+ assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), isA(IteratorStreamMergedResult.class));
}
@Test
@@ -142,7 +141,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setWhere(whereSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(IteratorStreamMergedResult.class));
+ assertThat(actual, isA(IteratorStreamMergedResult.class));
}
@Test
@@ -155,8 +154,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
- assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(IteratorStreamMergedResult.class));
+ assertThat(actual, isA(TopAndRowNumberDecoratorMergedResult.class));
+ assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), isA(IteratorStreamMergedResult.class));
}
@Test
@@ -168,7 +167,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
- assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(OrderByStreamMergedResult.class));
+ assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), isA(OrderByStreamMergedResult.class));
}
@Test
@@ -182,8 +181,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
- assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
+ assertThat(actual, isA(LimitDecoratorMergedResult.class));
+ assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), isA(OrderByStreamMergedResult.class));
}
@Test
@@ -212,7 +211,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setWhere(whereSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(OrderByStreamMergedResult.class));
+ assertThat(actual, isA(OrderByStreamMergedResult.class));
}
@Test
@@ -226,8 +225,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
- assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
+ assertThat(actual, isA(TopAndRowNumberDecoratorMergedResult.class));
+ assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), isA(OrderByStreamMergedResult.class));
}
@Test
@@ -240,7 +239,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
- assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(GroupByStreamMergedResult.class));
+ assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), isA(GroupByStreamMergedResult.class));
}
@Test
@@ -255,8 +254,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
- assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByStreamMergedResult.class));
+ assertThat(actual, isA(LimitDecoratorMergedResult.class));
+ assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), isA(GroupByStreamMergedResult.class));
}
@Test
@@ -286,7 +285,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setWhere(whereSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(GroupByStreamMergedResult.class));
+ assertThat(actual, isA(GroupByStreamMergedResult.class));
}
@Test
@@ -301,8 +300,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
- assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByStreamMergedResult.class));
+ assertThat(actual, isA(TopAndRowNumberDecoratorMergedResult.class));
+ assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), isA(GroupByStreamMergedResult.class));
}
@Test
@@ -314,7 +313,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
- assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(GroupByStreamMergedResult.class));
+ assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), isA(GroupByStreamMergedResult.class));
}
@Test
@@ -328,8 +327,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
- assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByStreamMergedResult.class));
+ assertThat(actual, isA(LimitDecoratorMergedResult.class));
+ assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), isA(GroupByStreamMergedResult.class));
}
@Test
@@ -359,7 +358,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setWhere(whereSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(GroupByStreamMergedResult.class));
+ assertThat(actual, isA(GroupByStreamMergedResult.class));
}
@Test
@@ -375,8 +374,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
- assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
+ assertThat(actual, isA(TopAndRowNumberDecoratorMergedResult.class));
+ assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), isA(GroupByMemoryMergedResult.class));
}
@Test
@@ -389,7 +388,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setProjections(projectionsSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
- assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), instanceOf(GroupByMemoryMergedResult.class));
+ assertThat(resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class)), isA(GroupByMemoryMergedResult.class));
}
@Test
@@ -403,8 +402,8 @@ class ShardingDQLResultMergerTest {
selectStatement, createShardingSphereMetaData(mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS)), "foo_db", Collections.emptyList());
ShardingDQLResultMerger resultMerger = new ShardingDQLResultMerger(mysqlDatabaseType);
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
- assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
+ assertThat(actual, isA(LimitDecoratorMergedResult.class));
+ assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), isA(GroupByMemoryMergedResult.class));
}
@Test
@@ -433,7 +432,7 @@ class ShardingDQLResultMergerTest {
selectStatement.setWhere(whereSegment);
SelectStatementContext selectStatementContext = new SelectStatementContext(selectStatement, createShardingSphereMetaData(database), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(GroupByMemoryMergedResult.class));
+ assertThat(actual, isA(GroupByMemoryMergedResult.class));
}
@Test
@@ -447,8 +446,8 @@ class ShardingDQLResultMergerTest {
SelectStatementContext selectStatementContext = new SelectStatementContext(
selectStatement, createShardingSphereMetaData(mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS)), "foo_db", Collections.emptyList());
MergedResult actual = resultMerger.merge(createQueryResults(), selectStatementContext, createSQLServerDatabase(), mock(ConnectionContext.class));
- assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
- assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
+ assertThat(actual, isA(TopAndRowNumberDecoratorMergedResult.class));
+ assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), isA(GroupByMemoryMergedResult.class));
}
private ShardingSphereMetaData createShardingSphereMetaData(final ShardingSphereDatabase database) {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactoryTest.java
index 92bc71a5fa3..ab72304e90e 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/aggregation/AggregationUnitFactoryTest.java
@@ -20,57 +20,57 @@ package org.apache.shardingsphere.sharding.merge.dql.groupby.aggregation;
import org.apache.shardingsphere.sql.parser.statement.core.enums.AggregationType;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class AggregationUnitFactoryTest {
@Test
void assertCreateComparableAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.MIN, false, null), instanceOf(ComparableAggregationUnit.class));
- assertThat(AggregationUnitFactory.create(AggregationType.MAX, false, null), instanceOf(ComparableAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.MIN, false, null), isA(ComparableAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.MAX, false, null), isA(ComparableAggregationUnit.class));
}
@Test
void assertCreateAccumulationAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.SUM, false, null), instanceOf(AccumulationAggregationUnit.class));
- assertThat(AggregationUnitFactory.create(AggregationType.COUNT, false, null), instanceOf(AccumulationAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.SUM, false, null), isA(AccumulationAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.COUNT, false, null), isA(AccumulationAggregationUnit.class));
}
@Test
void assertCreateAverageAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.AVG, false, null), instanceOf(AverageAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.AVG, false, null), isA(AverageAggregationUnit.class));
}
@Test
void assertCreateDistinctSumAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.SUM, true, null), instanceOf(DistinctSumAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.SUM, true, null), isA(DistinctSumAggregationUnit.class));
}
@Test
void assertCreateDistinctCountAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.COUNT, true, null), instanceOf(DistinctCountAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.COUNT, true, null), isA(DistinctCountAggregationUnit.class));
}
@Test
void assertCreateDistinctAverageAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.AVG, true, null), instanceOf(DistinctAverageAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.AVG, true, null), isA(DistinctAverageAggregationUnit.class));
}
@Test
void assertCreateBitXorAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.BIT_XOR, false, null), instanceOf(BitXorAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.BIT_XOR, false, null), isA(BitXorAggregationUnit.class));
}
@Test
void assertGroupConcatAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, false, null), instanceOf(GroupConcatAggregationUnit.class));
- assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, false, " "), instanceOf(GroupConcatAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, false, null), isA(GroupConcatAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, false, " "), isA(GroupConcatAggregationUnit.class));
}
@Test
void assertDistinctGroupConcatAggregationUnit() {
- assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, true, null), instanceOf(DistinctGroupConcatAggregationUnit.class));
- assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, true, " "), instanceOf(DistinctGroupConcatAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, true, null), isA(DistinctGroupConcatAggregationUnit.class));
+ assertThat(AggregationUnitFactory.create(AggregationType.GROUP_CONCAT, true, " "), isA(DistinctGroupConcatAggregationUnit.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameter/ShardingParameterRewritersRegistryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameter/ShardingParameterRewritersRegistryTest.java
index 210fb968c1e..964dabcd92c 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameter/ShardingParameterRewritersRegistryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameter/ShardingParameterRewritersRegistryTest.java
@@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class ShardingParameterRewritersRegistryTest {
@@ -37,7 +37,7 @@ class ShardingParameterRewritersRegistryTest {
void assertGetParameterRewriters() {
List<ParameterRewriter> actual = new ArrayList<>(new ShardingParameterRewritersRegistry(mock(RouteContext.class)).getParameterRewriters());
assertThat(actual.size(), is(2));
- assertThat(actual.get(0), instanceOf(GeneratedKeyInsertValueParameterRewriter.class));
- assertThat(actual.get(1), instanceOf(ShardingPaginationParameterRewriter.class));
+ assertThat(actual.get(0), isA(GeneratedKeyInsertValueParameterRewriter.class));
+ assertThat(actual.get(1), isA(ShardingPaginationParameterRewriter.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingTokenGenerateBuilderTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingTokenGenerateBuilderTest.java
index f6f25c453c0..90ee744dcdb 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingTokenGenerateBuilderTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingTokenGenerateBuilderTest.java
@@ -34,9 +34,9 @@ import org.mockito.internal.configuration.plugins.Plugins;
import java.util.Collection;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -64,16 +64,16 @@ class ShardingTokenGenerateBuilderTest {
assertThat(sqlTokenGenerators.size(), is(4));
Iterator<SQLTokenGenerator> iterator = sqlTokenGenerators.iterator();
SQLTokenGenerator tableTokenGenerator = iterator.next();
- assertThat(tableTokenGenerator, instanceOf(ShardingTableTokenGenerator.class));
+ assertThat(tableTokenGenerator, isA(ShardingTableTokenGenerator.class));
assertSqlTokenGenerator(tableTokenGenerator);
SQLTokenGenerator distinctProjectionPrefixTokenGenerator = iterator.next();
- assertThat(distinctProjectionPrefixTokenGenerator, instanceOf(ShardingDistinctProjectionPrefixTokenGenerator.class));
+ assertThat(distinctProjectionPrefixTokenGenerator, isA(ShardingDistinctProjectionPrefixTokenGenerator.class));
assertSqlTokenGenerator(distinctProjectionPrefixTokenGenerator);
SQLTokenGenerator aggregationDistinctTokenGenerator = iterator.next();
- assertThat(aggregationDistinctTokenGenerator, instanceOf(ShardingAggregationDistinctTokenGenerator.class));
+ assertThat(aggregationDistinctTokenGenerator, isA(ShardingAggregationDistinctTokenGenerator.class));
assertSqlTokenGenerator(aggregationDistinctTokenGenerator);
SQLTokenGenerator shardingRemoveTokenGenerator = iterator.next();
- assertThat(shardingRemoveTokenGenerator, instanceOf(ShardingRemoveTokenGenerator.class));
+ assertThat(shardingRemoveTokenGenerator, isA(ShardingRemoveTokenGenerator.class));
assertSqlTokenGenerator(shardingRemoveTokenGenerator);
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingCursorTokenGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingCursorTokenGeneratorTest.java
index 3b51e72255f..a8dece78f07 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingCursorTokenGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingCursorTokenGeneratorTest.java
@@ -30,8 +30,8 @@ import org.junit.jupiter.api.Test;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -76,6 +76,6 @@ class ShardingCursorTokenGeneratorTest {
SQLStatementContext sqlStatementContext = mock(SQLStatementContext.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
SQLToken actual = generator.generateSQLToken(sqlStatementContext);
- assertThat(actual, instanceOf(CursorToken.class));
+ assertThat(actual, isA(CursorToken.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java
index 30a54cf347b..f8399bcd719 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingRemoveTokenGeneratorTest.java
@@ -41,9 +41,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -77,7 +77,7 @@ class ShardingRemoveTokenGeneratorTest {
void assertGenerateSQLTokens() {
Collection<? extends SQLToken> actual = generator.generateSQLTokens(createSelectStatementContext());
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(RemoveToken.class));
+ assertThat(actual.iterator().next(), isA(RemoveToken.class));
}
private SelectStatementContext createSelectStatementContext() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
index 1d55a666008..c46131666a6 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ShardingTableTokenGeneratorTest.java
@@ -38,9 +38,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -109,6 +109,6 @@ class ShardingTableTokenGeneratorTest {
new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("bar_tbl")))));
Collection<SQLToken> actual = generator.generateSQLTokens(sqlStatementContext);
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(ShardingTableToken.class));
+ assertThat(actual.iterator().next(), isA(ShardingTableToken.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
index bd4170c23d9..9adf16f95cf 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
@@ -41,9 +41,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -80,7 +80,7 @@ class WhereClauseShardingConditionEngineTest {
when(rule.findShardingColumn(any(), any())).thenReturn(Optional.of("foo_sharding_col"));
List<ShardingCondition> actual = shardingConditionEngine.createShardingConditions(sqlStatementContext, Collections.emptyList());
assertThat(actual.get(0).getStartIndex(), is(0));
- assertThat(actual.get(0).getValues().get(0), instanceOf(RangeShardingConditionValue.class));
+ assertThat(actual.get(0).getValues().get(0), isA(RangeShardingConditionValue.class));
}
@Test
@@ -94,6 +94,6 @@ class WhereClauseShardingConditionEngineTest {
when(rule.findShardingColumn(any(), any())).thenReturn(Optional.of("foo_sharding_col"));
List<ShardingCondition> actual = shardingConditionEngine.createShardingConditions(sqlStatementContext, Collections.emptyList());
assertThat(actual.get(0).getStartIndex(), is(0));
- assertThat(actual.get(0).getValues().get(0), instanceOf(ListShardingConditionValue.class));
+ assertThat(actual.get(0).getValues().get(0), isA(ListShardingConditionValue.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
index 4ed2910612f..0308b785035 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
@@ -44,9 +44,9 @@ import java.util.LinkedList;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.junit.jupiter.api.Assertions.assertTrue;
@@ -148,7 +148,7 @@ class ConditionValueBetweenOperatorGeneratorTest {
BetweenExpression predicate = new BetweenExpression(0, 0, left, between, and, false);
Optional<ShardingConditionValue> actual = generator.generate(predicate, column, Arrays.asList(1, 2), timestampServiceRule);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(RangeShardingConditionValue.class));
+ assertThat(actual.get(), isA(RangeShardingConditionValue.class));
RangeShardingConditionValue<Integer> conditionValue = (RangeShardingConditionValue<Integer>) actual.get();
assertThat(conditionValue.getTableName(), is("tbl"));
assertThat(conditionValue.getColumnName(), is("id"));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
index 859bec2312e..b34c2fe1e3d 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGeneratorTest.java
@@ -35,9 +35,9 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.mock;
@@ -146,7 +146,7 @@ class ConditionValueCompareOperatorGeneratorTest {
BinaryOperationExpression predicate = new BinaryOperationExpression(0, 0, left, right, "=", "id = ?");
Optional<ShardingConditionValue> actual = generator.generate(predicate, column, Collections.singletonList(1), mock(TimestampServiceRule.class));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ListShardingConditionValue.class));
+ assertThat(actual.get(), isA(ListShardingConditionValue.class));
ListShardingConditionValue<Integer> conditionValue = (ListShardingConditionValue<Integer>) actual.get();
assertThat(conditionValue.getTableName(), is("tbl"));
assertThat(conditionValue.getColumnName(), is("id"));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
index 0d8cd6605e7..2f274de71c6 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGeneratorTest.java
@@ -38,9 +38,9 @@ import java.util.LinkedList;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -59,7 +59,7 @@ class ConditionValueInOperatorGeneratorTest {
InExpression inExpression = new InExpression(0, 0, null, listExpression, false);
Optional<ShardingConditionValue> shardingConditionValue = generator.generate(inExpression, column, new LinkedList<>(), timestampServiceRule);
assertTrue(shardingConditionValue.isPresent());
- assertThat(((ListShardingConditionValue<?>) shardingConditionValue.get()).getValues().iterator().next(), instanceOf(Date.class));
+ assertThat(((ListShardingConditionValue<?>) shardingConditionValue.get()).getValues().iterator().next(), isA(Date.class));
assertTrue(shardingConditionValue.get().getParameterMarkerIndexes().isEmpty());
}
@@ -100,7 +100,7 @@ class ConditionValueInOperatorGeneratorTest {
InExpression predicate = new InExpression(0, 0, left, right, false);
Optional<ShardingConditionValue> actual = generator.generate(predicate, column, Collections.singletonList(1), timestampServiceRule);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ListShardingConditionValue.class));
+ assertThat(actual.get(), isA(ListShardingConditionValue.class));
ListShardingConditionValue<Integer> conditionValue = (ListShardingConditionValue<Integer>) actual.get();
assertThat(conditionValue.getTableName(), is("tbl"));
assertThat(conditionValue.getColumnName(), is("id"));
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
index 9737b98389d..ff62dbb4d54 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactoryTest.java
@@ -66,8 +66,8 @@ import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -114,7 +114,7 @@ class ShardingRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DDLStatement.class, RETURNS_DEEP_STUBS));
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.emptyList(), props);
- assertThat(actual, instanceOf(ShardingTableBroadcastRouteEngine.class));
+ assertThat(actual, isA(ShardingTableBroadcastRouteEngine.class));
}
@Test
@@ -127,7 +127,7 @@ class ShardingRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, tableNames, props);
- assertThat(actual, instanceOf(ShardingUnicastRouteEngine.class));
+ assertThat(actual, isA(ShardingUnicastRouteEngine.class));
}
@Test
@@ -137,7 +137,7 @@ class ShardingRouteEngineFactoryTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.singletonList("tbl"), props);
- assertThat(actual, instanceOf(ShardingTableBroadcastRouteEngine.class));
+ assertThat(actual, isA(ShardingTableBroadcastRouteEngine.class));
}
@Test
@@ -145,7 +145,7 @@ class ShardingRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DCLStatement.class));
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.emptyList(), props);
- assertThat(actual, instanceOf(ShardingInstanceBroadcastRouteEngine.class));
+ assertThat(actual, isA(ShardingInstanceBroadcastRouteEngine.class));
}
@Test
@@ -154,7 +154,7 @@ class ShardingRouteEngineFactoryTest {
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual =
ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.emptyList(), props);
- assertThat(actual, instanceOf(ShardingUnicastRouteEngine.class));
+ assertThat(actual, isA(ShardingUnicastRouteEngine.class));
}
@Test
@@ -162,7 +162,7 @@ class ShardingRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(SelectStatement.class));
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.emptyList(), props);
- assertThat(actual, instanceOf(ShardingUnicastRouteEngine.class));
+ assertThat(actual, isA(ShardingUnicastRouteEngine.class));
}
@Test
@@ -170,7 +170,7 @@ class ShardingRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(SQLStatement.class));
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.emptyList(), props);
- assertThat(actual, instanceOf(ShardingUnicastRouteEngine.class));
+ assertThat(actual, isA(ShardingUnicastRouteEngine.class));
}
@Test
@@ -181,7 +181,7 @@ class ShardingRouteEngineFactoryTest {
when(shardingRule.isAllShardingTables(tableNames)).thenReturn(true);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, tableNames, props);
- assertThat(actual, instanceOf(ShardingStandardRouteEngine.class));
+ assertThat(actual, isA(ShardingStandardRouteEngine.class));
}
@Test
@@ -192,7 +192,7 @@ class ShardingRouteEngineFactoryTest {
when(shardingRule.getShardingLogicTableNames(tableNames)).thenReturn(tableNames);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, tableNames, props);
- assertThat(actual, instanceOf(ShardingComplexRouteEngine.class));
+ assertThat(actual, isA(ShardingComplexRouteEngine.class));
}
@Test
@@ -204,7 +204,7 @@ class ShardingRouteEngineFactoryTest {
when(shardingRule.getShardingLogicTableNames(tableNames)).thenReturn(tableNames);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, tableNames, props);
- assertThat(actual, instanceOf(ShardingUnicastRouteEngine.class));
+ assertThat(actual, isA(ShardingUnicastRouteEngine.class));
}
@Test
@@ -219,7 +219,7 @@ class ShardingRouteEngineFactoryTest {
when(shardingRule.isAllShardingTables(Collections.singletonList("t_order"))).thenReturn(true);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, tableNames, mock(ConfigurationProperties.class));
- assertThat(actual, instanceOf(ShardingStandardRouteEngine.class));
+ assertThat(actual, isA(ShardingStandardRouteEngine.class));
}
@Test
@@ -235,7 +235,7 @@ class ShardingRouteEngineFactoryTest {
when(shardingRule.getShardingLogicTableNames(tableNames)).thenReturn(tableNames);
QueryContext queryContext = new QueryContext(cursorStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, tableNames, props);
- assertThat(actual, instanceOf(ShardingStandardRouteEngine.class));
+ assertThat(actual, isA(ShardingStandardRouteEngine.class));
}
@Test
@@ -247,7 +247,7 @@ class ShardingRouteEngineFactoryTest {
when(cursorStatementContext.getTablesContext().getDatabaseName()).thenReturn(Optional.empty());
QueryContext queryContext = new QueryContext(cursorStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
ShardingRouteEngine actual = ShardingRouteEngineFactory.newInstance(shardingRule, database, queryContext, shardingConditions, Collections.emptyList(), props);
- assertThat(actual, instanceOf(ShardingIgnoreRouteEngine.class));
+ assertThat(actual, isA(ShardingIgnoreRouteEngine.class));
}
private Collection<SimpleTableSegment> createSimpleTableSegments() {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java
index fbc7b7df0c4..ccebddf6ee4 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/strategy/ShardingStrategyFactoryTest.java
@@ -29,8 +29,8 @@ import org.apache.shardingsphere.sharding.route.strategy.type.none.NoneShardingS
import org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,7 +41,7 @@ class ShardingStrategyFactoryTest {
void assertNewInstanceForStandardShardingStrategy() {
StandardShardingStrategyConfiguration standardShardingStrategyConfig = mock(StandardShardingStrategyConfiguration.class);
when(standardShardingStrategyConfig.getShardingColumn()).thenReturn("standard_sharding_column");
- assertThat(ShardingStrategyFactory.newInstance(standardShardingStrategyConfig, mock(CoreStandardShardingAlgorithmFixture.class), null), instanceOf(StandardShardingStrategy.class));
+ assertThat(ShardingStrategyFactory.newInstance(standardShardingStrategyConfig, mock(CoreStandardShardingAlgorithmFixture.class), null), isA(StandardShardingStrategy.class));
}
@Test
@@ -54,16 +54,16 @@ class ShardingStrategyFactoryTest {
void assertNewInstanceForComplexShardingStrategy() {
ComplexShardingStrategyConfiguration complexShardingStrategyConfig = mock(ComplexShardingStrategyConfiguration.class);
when(complexShardingStrategyConfig.getShardingColumns()).thenReturn("complex_sharding_column");
- assertThat(ShardingStrategyFactory.newInstance(complexShardingStrategyConfig, mock(CoreComplexKeysShardingAlgorithmFixture.class), null), instanceOf(ComplexShardingStrategy.class));
+ assertThat(ShardingStrategyFactory.newInstance(complexShardingStrategyConfig, mock(CoreComplexKeysShardingAlgorithmFixture.class), null), isA(ComplexShardingStrategy.class));
}
@Test
void assertNewInstanceForHintShardingStrategy() {
- assertThat(ShardingStrategyFactory.newInstance(mock(HintShardingStrategyConfiguration.class), mock(CoreHintShardingAlgorithmFixture.class), null), instanceOf(HintShardingStrategy.class));
+ assertThat(ShardingStrategyFactory.newInstance(mock(HintShardingStrategyConfiguration.class), mock(CoreHintShardingAlgorithmFixture.class), null), isA(HintShardingStrategy.class));
}
@Test
void assertNewInstanceForNoneShardingStrategy() {
- assertThat(ShardingStrategyFactory.newInstance(null, null, null), instanceOf(NoneShardingStrategy.class));
+ assertThat(ShardingStrategyFactory.newInstance(null, null, null), isA(NoneShardingStrategy.class));
}
}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
index faf4950eca4..016195b5ae5 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingRuleTest.java
@@ -76,9 +76,9 @@ import java.util.Map;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -104,8 +104,8 @@ class ShardingRuleTest {
assertTrue(actual.getBindingTableRules().containsKey("logic_table"));
assertTrue(actual.getBindingTableRules().containsKey("sub_logic_table"));
assertThat(actual.getBindingTableRules().values().iterator().next().getShardingTables().size(), is(2));
- assertThat(actual.getDefaultKeyGenerateAlgorithm(), instanceOf(UUIDKeyGenerateAlgorithm.class));
- assertThat(actual.getAuditors().get("audit_algorithm"), instanceOf(DMLShardingConditionsShardingAuditAlgorithm.class));
+ assertThat(actual.getDefaultKeyGenerateAlgorithm(), isA(UUIDKeyGenerateAlgorithm.class));
+ assertThat(actual.getAuditors().get("audit_algorithm"), isA(DMLShardingConditionsShardingAuditAlgorithm.class));
assertThat(actual.getDefaultShardingColumn(), is("table_id"));
}
@@ -114,7 +114,7 @@ class ShardingRuleTest {
ShardingRule actual = createMinimumShardingRule();
assertThat(actual.getShardingTables().size(), is(1));
assertTrue(actual.getBindingTableRules().isEmpty());
- assertThat(actual.getDefaultKeyGenerateAlgorithm(), instanceOf(SnowflakeKeyGenerateAlgorithm.class));
+ assertThat(actual.getDefaultKeyGenerateAlgorithm(), isA(SnowflakeKeyGenerateAlgorithm.class));
assertNull(actual.getDefaultShardingColumn());
}
@@ -463,7 +463,7 @@ class ShardingRuleTest {
when(generateContext.getTableName()).thenReturn("logic_table");
Collection<? extends Comparable<?>> actual = createMinimumShardingRule().generateKeys(generateContext, 1);
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(Long.class));
+ assertThat(actual.iterator().next(), isA(Long.class));
}
@Test
@@ -472,7 +472,7 @@ class ShardingRuleTest {
when(generateContext.getTableName()).thenReturn("logic_table");
Collection<? extends Comparable<?>> actual = createMaximumShardingRule().generateKeys(generateContext, 1);
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(String.class));
+ assertThat(actual.iterator().next(), isA(String.class));
}
@Test
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
index 60c4a48c384..8248831e5a7 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -51,8 +51,8 @@ class ShardingRuleBuilderTest {
@SuppressWarnings("unchecked")
@Test
void assertBuild() {
- assertThat(builder.build(ruleConfig, "sharding_db", mock(),
- mock(ResourceMetaData.class, RETURNS_DEEP_STUBS), Collections.emptyList(), mock(ComputeNodeInstanceContext.class)), instanceOf(ShardingRule.class));
+ assertThat(builder.build(ruleConfig, "sharding_db", mock(), mock(ResourceMetaData.class, RETURNS_DEEP_STUBS), Collections.emptyList(), mock(ComputeNodeInstanceContext.class)),
+ isA(ShardingRule.class));
}
@SuppressWarnings("unchecked")
diff --git a/features/sharding/dialect/mysql/src/test/java/org/apache/shardingsphere/sharding/merge/mysql/MySQLShardingDALResultMergerTest.java b/features/sharding/dialect/mysql/src/test/java/org/apache/shardingsphere/sharding/merge/mysql/MySQLShardingDALResultMergerTest.java
index c6b02b932db..1221297cb83 100644
--- a/features/sharding/dialect/mysql/src/test/java/org/apache/shardingsphere/sharding/merge/mysql/MySQLShardingDALResultMergerTest.java
+++ b/features/sharding/dialect/mysql/src/test/java/org/apache/shardingsphere/sharding/merge/mysql/MySQLShardingDALResultMergerTest.java
@@ -42,8 +42,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -62,7 +62,7 @@ class MySQLShardingDALResultMergerTest {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(mock(MySQLShowDatabasesStatement.class));
Optional<MergedResult> actual = resultMerger.merge("foo_db", mock(), sqlStatementContext, mock(), queryResults);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(LocalDataMergedResult.class));
+ assertThat(actual.get(), isA(LocalDataMergedResult.class));
}
@Test
@@ -70,7 +70,7 @@ class MySQLShardingDALResultMergerTest {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(new MySQLShowTablesStatement(databaseType, null, null, false));
Optional<MergedResult> actual = resultMerger.merge("foo_db", mock(), sqlStatementContext, mock(), queryResults);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLShardingLogicTablesMergedResult.class));
+ assertThat(actual.get(), isA(MySQLShardingLogicTablesMergedResult.class));
}
@Test
@@ -78,7 +78,7 @@ class MySQLShardingDALResultMergerTest {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(new MySQLShowTableStatusStatement(databaseType, null, null));
Optional<MergedResult> actual = resultMerger.merge("foo_db", mock(), sqlStatementContext, mock(), queryResults);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLShardingShowTableStatusMergedResult.class));
+ assertThat(actual.get(), isA(MySQLShardingShowTableStatusMergedResult.class));
}
@Test
@@ -86,7 +86,7 @@ class MySQLShardingDALResultMergerTest {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(new MySQLShowIndexStatement(databaseType, null, null));
Optional<MergedResult> actual = resultMerger.merge("foo_db", mock(), sqlStatementContext, mock(), queryResults);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLShardingShowIndexMergedResult.class));
+ assertThat(actual.get(), isA(MySQLShardingShowIndexMergedResult.class));
}
@Test
@@ -94,7 +94,7 @@ class MySQLShardingDALResultMergerTest {
SQLStatementContext sqlStatementContext = mockSQLStatementContext(new MySQLShowCreateTableStatement(databaseType, null));
Optional<MergedResult> actual = resultMerger.merge("foo_db", mock(), sqlStatementContext, mock(), queryResults);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLShardingShowCreateTableMergedResult.class));
+ assertThat(actual.get(), isA(MySQLShardingShowCreateTableMergedResult.class));
}
private SQLStatementContext mockSQLStatementContext(final DALStatement sqlStatement) {
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutorTest.java
index e06ffc3c4cd..774364a89a8 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/AlterShardingTableRuleExecutorTest.java
@@ -54,9 +54,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -106,10 +106,10 @@ class AlterShardingTableRuleExecutorTest {
ShardingTableRuleConfiguration tableRule = toBeAlteredRuleConfig.getTables().iterator().next();
assertThat(tableRule.getLogicTable(), is("t_order"));
assertThat(tableRule.getActualDataNodes(), is("ds_${0..1}.t_order${0..1}"));
- assertThat(tableRule.getTableShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getTableShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(((StandardShardingStrategyConfiguration) tableRule.getTableShardingStrategy()).getShardingColumn(), is("product_id"));
assertThat(tableRule.getTableShardingStrategy().getShardingAlgorithmName(), is("t_order_table_core.standard.fixture"));
- assertThat(tableRule.getDatabaseShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getDatabaseShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("t_order_database_inline"));
assertThat(toBeAlteredRuleConfig.getTables().size(), is(1));
ShardingAutoTableRuleConfiguration autoTableRule = toBeAlteredRuleConfig.getAutoTables().iterator().next();
@@ -130,10 +130,10 @@ class AlterShardingTableRuleExecutorTest {
ShardingTableRuleConfiguration tableRule = toBeAlteredRuleConfig.getTables().iterator().next();
assertThat(tableRule.getLogicTable(), is("T_ORDER"));
assertThat(tableRule.getActualDataNodes(), is("ds_${0..1}.t_order${0..1}"));
- assertThat(tableRule.getTableShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getTableShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(((StandardShardingStrategyConfiguration) tableRule.getTableShardingStrategy()).getShardingColumn(), is("product_id"));
assertThat(tableRule.getTableShardingStrategy().getShardingAlgorithmName(), is("t_order_table_core.standard.fixture"));
- assertThat(tableRule.getDatabaseShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getDatabaseShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("t_order_database_inline"));
assertThat(toBeAlteredRuleConfig.getTables().size(), is(1));
ShardingAutoTableRuleConfiguration autoTableRule = toBeAlteredRuleConfig.getAutoTables().iterator().next();
@@ -154,10 +154,10 @@ class AlterShardingTableRuleExecutorTest {
ShardingTableRuleConfiguration tableRule = toBeAlteredRuleConfig.getTables().iterator().next();
assertThat(tableRule.getLogicTable(), is("t_order_item"));
assertThat(tableRule.getActualDataNodes(), is("ds_${0..1}.t_order${0..1}"));
- assertThat(tableRule.getTableShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getTableShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(((StandardShardingStrategyConfiguration) tableRule.getTableShardingStrategy()).getShardingColumn(), is("product_id"));
assertThat(tableRule.getTableShardingStrategy().getShardingAlgorithmName(), is("t_order_item_table_core.standard.fixture"));
- assertThat(tableRule.getDatabaseShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getDatabaseShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("t_order_item_database_inline"));
assertThat(toBeAlteredRuleConfig.getTables().size(), is(1));
ShardingAutoTableRuleConfiguration autoTableRule = toBeAlteredRuleConfig.getAutoTables().iterator().next();
diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutorTest.java
index 8aae0b98f7b..9f2abda72d2 100644
--- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutorTest.java
+++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/handler/update/CreateShardingTableRuleExecutorTest.java
@@ -63,9 +63,9 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -104,12 +104,12 @@ class CreateShardingTableRuleExecutorTest {
assertThat(actual.getTables().size(), is(1));
Iterator<ShardingTableRuleConfiguration> tableRuleIterator = actual.getTables().iterator();
ShardingTableRuleConfiguration tableRule = tableRuleIterator.next();
- assertThat(tableRule.getTableShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getTableShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getLogicTable(), is("t_order_input"));
assertThat(tableRule.getActualDataNodes(), is("ds_${0..1}.t_order_${0..1}"));
assertThat(((StandardShardingStrategyConfiguration) tableRule.getTableShardingStrategy()).getShardingColumn(), is("product_id"));
assertThat(tableRule.getTableShardingStrategy().getShardingAlgorithmName(), is("t_order_input_table_core.standard.fixture"));
- assertThat(tableRule.getDatabaseShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getDatabaseShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("t_order_input_database_inline"));
assertThat(actual.getTables().size(), is(1));
Iterator<ShardingAutoTableRuleConfiguration> autoTableIterator = actual.getAutoTables().iterator();
@@ -239,12 +239,12 @@ class CreateShardingTableRuleExecutorTest {
assertThat(actual.getTables().size(), is(1));
Iterator<ShardingTableRuleConfiguration> tableRuleIterator = actual.getTables().iterator();
ShardingTableRuleConfiguration tableRule = tableRuleIterator.next();
- assertThat(tableRule.getTableShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getTableShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getLogicTable(), is("t_order_input"));
assertThat(tableRule.getActualDataNodes(), is("ds_${0..1}.t_order_${0..1}"));
assertThat(((StandardShardingStrategyConfiguration) tableRule.getTableShardingStrategy()).getShardingColumn(), is("product_id"));
assertThat(tableRule.getTableShardingStrategy().getShardingAlgorithmName(), is("t_order_input_table_core.standard.fixture"));
- assertThat(tableRule.getDatabaseShardingStrategy(), instanceOf(StandardShardingStrategyConfiguration.class));
+ assertThat(tableRule.getDatabaseShardingStrategy(), isA(StandardShardingStrategyConfiguration.class));
assertThat(tableRule.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("t_order_input_database_inline"));
assertThat(actual.getTables().size(), is(1));
Iterator<ShardingAutoTableRuleConfiguration> autoTableIterator = actual.getAutoTables().iterator();
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/PaginationContextEngineTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/PaginationContextEngineTest.java
index 9d9bbb28b56..e48bb2b30c9 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/PaginationContextEngineTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/PaginationContextEngineTest.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.infra.binder.context.segment.select.pagination.engine;
-import org.apache.shardingsphere.infra.binder.context.segment.select.pagination.PaginationContext;
-import org.apache.shardingsphere.infra.binder.context.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.database.connector.core.metadata.database.metadata.option.pagination.DialectPaginationOption;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.binder.context.segment.select.pagination.PaginationContext;
+import org.apache.shardingsphere.infra.binder.context.segment.select.projection.ProjectionsContext;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.column.ColumnSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.expr.BinaryOperationExpression;
@@ -41,8 +41,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.mock;
@@ -59,9 +59,9 @@ class PaginationContextEngineTest {
PaginationContext paginationContext = new PaginationContextEngine(
new DialectPaginationOption(false, "", false)).createPaginationContext(selectStatement, mock(ProjectionsContext.class), Collections.emptyList(), Collections.emptyList());
assertTrue(paginationContext.getOffsetSegment().isPresent());
- assertThat(paginationContext.getOffsetSegment().get(), instanceOf(LimitValueSegment.class));
+ assertThat(paginationContext.getOffsetSegment().get(), isA(LimitValueSegment.class));
assertTrue(paginationContext.getRowCountSegment().isPresent());
- assertThat(paginationContext.getRowCountSegment().get(), instanceOf(LimitValueSegment.class));
+ assertThat(paginationContext.getRowCountSegment().get(), isA(LimitValueSegment.class));
}
@Test
@@ -77,7 +77,7 @@ class PaginationContextEngineTest {
new DialectPaginationOption(false, "", true)).createPaginationContext(selectStatement, mock(ProjectionsContext.class), Collections.emptyList(), Collections.emptyList());
assertFalse(paginationContext.getOffsetSegment().isPresent());
assertTrue(paginationContext.getRowCountSegment().isPresent());
- assertThat(paginationContext.getRowCountSegment().get(), instanceOf(NumberLiteralRowNumberValueSegment.class));
+ assertThat(paginationContext.getRowCountSegment().get(), isA(NumberLiteralRowNumberValueSegment.class));
}
@Test
@@ -103,7 +103,7 @@ class PaginationContextEngineTest {
new DialectPaginationOption(true, "ROW_NUMBER", false)).createPaginationContext(selectStatement, projectionsContext, Collections.emptyList(), Collections.singletonList(where));
assertFalse(paginationContext.getOffsetSegment().isPresent());
assertTrue(paginationContext.getRowCountSegment().isPresent());
- assertThat(paginationContext.getRowCountSegment().get(), instanceOf(NumberLiteralRowNumberValueSegment.class));
+ assertThat(paginationContext.getRowCountSegment().get(), isA(NumberLiteralRowNumberValueSegment.class));
}
@Test
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
index b64b6618987..3dd3a5ebc3d 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/RowNumberPaginationContextEngineTest.java
@@ -37,9 +37,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.mock;
@@ -112,7 +112,7 @@ class RowNumberPaginationContextEngineTest {
PaginationContext paginationContext = paginationContextEngine.createPaginationContext(Collections.singletonList(expression), projectionsContext, Collections.singletonList(1));
Optional<PaginationValueSegment> offSetSegmentPaginationValue = paginationContext.getOffsetSegment();
assertTrue(offSetSegmentPaginationValue.isPresent());
- assertThat(offSetSegmentPaginationValue.get(), instanceOf(ParameterMarkerRowNumberValueSegment.class));
+ assertThat(offSetSegmentPaginationValue.get(), isA(ParameterMarkerRowNumberValueSegment.class));
assertFalse(paginationContext.getRowCountSegment().isPresent());
}
@@ -142,7 +142,7 @@ class RowNumberPaginationContextEngineTest {
Optional<PaginationValueSegment> paginationValueSegment = rowNumberPaginationContextEngine.getOffsetSegment();
assertTrue(paginationValueSegment.isPresent());
PaginationValueSegment actualPaginationValueSegment = paginationValueSegment.get();
- assertThat(actualPaginationValueSegment, instanceOf(NumberLiteralRowNumberValueSegment.class));
+ assertThat(actualPaginationValueSegment, isA(NumberLiteralRowNumberValueSegment.class));
assertThat(actualPaginationValueSegment.getStartIndex(), is(0));
assertThat(actualPaginationValueSegment.getStopIndex(), is(10));
assertThat(((NumberLiteralRowNumberValueSegment) actualPaginationValueSegment).getValue(), is(100L));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/TopPaginationContextEngineTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/TopPaginationContextEngineTest.java
index f9611b095ce..14c895fa688 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/TopPaginationContextEngineTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/pagination/engine/TopPaginationContextEngineTest.java
@@ -33,9 +33,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -82,7 +82,7 @@ class TopPaginationContextEngineTest {
new TopProjectionSegment(0, 10, null, name), Collections.singletonList(expression), Collections.singletonList(1));
assertTrue(paginationContext.getOffsetSegment().isPresent());
PaginationValueSegment paginationValueSegment = paginationContext.getOffsetSegment().get();
- assertThat(paginationValueSegment, instanceOf(ParameterMarkerRowNumberValueSegment.class));
+ assertThat(paginationValueSegment, isA(ParameterMarkerRowNumberValueSegment.class));
ParameterMarkerRowNumberValueSegment parameterMarkerRowNumberValueSegment = (ParameterMarkerRowNumberValueSegment) paginationValueSegment;
assertThat(parameterMarkerRowNumberValueSegment.getStartIndex(), is(0));
assertThat(parameterMarkerRowNumberValueSegment.getStopIndex(), is(10));
@@ -99,7 +99,7 @@ class TopPaginationContextEngineTest {
new TopProjectionSegment(0, 10, null, name), Collections.singletonList(expression), Collections.emptyList());
assertTrue(paginationContext.getOffsetSegment().isPresent());
PaginationValueSegment paginationValueSegment = paginationContext.getOffsetSegment().get();
- assertThat(paginationValueSegment, instanceOf(NumberLiteralRowNumberValueSegment.class));
+ assertThat(paginationValueSegment, isA(NumberLiteralRowNumberValueSegment.class));
NumberLiteralRowNumberValueSegment numberLiteralRowNumberValueSegment = (NumberLiteralRowNumberValueSegment) paginationValueSegment;
assertThat(numberLiteralRowNumberValueSegment.getStartIndex(), is(0));
assertThat(numberLiteralRowNumberValueSegment.getStopIndex(), is(10));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionEngineTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionEngineTest.java
index f30daf4a4be..749683ad201 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionEngineTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/engine/ProjectionEngineTest.java
@@ -43,9 +43,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -65,7 +65,7 @@ class ProjectionEngineTest {
shorthandProjectionSegment.setOwner(new OwnerSegment(0, 0, new IdentifierValue("tbl")));
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(shorthandProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShorthandProjection.class));
+ assertThat(actual.get(), isA(ShorthandProjection.class));
}
@Test
@@ -74,7 +74,7 @@ class ProjectionEngineTest {
columnProjectionSegment.setAlias(new AliasSegment(0, 0, new IdentifierValue("alias")));
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(columnProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ColumnProjection.class));
+ assertThat(actual.get(), isA(ColumnProjection.class));
}
@Test
@@ -82,7 +82,7 @@ class ProjectionEngineTest {
ExpressionProjectionSegment expressionProjectionSegment = new ExpressionProjectionSegment(0, 10, "text");
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(expressionProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ExpressionProjection.class));
+ assertThat(actual.get(), isA(ExpressionProjection.class));
}
@Test
@@ -90,7 +90,7 @@ class ProjectionEngineTest {
AggregationDistinctProjectionSegment aggregationDistinctProjectionSegment = new AggregationDistinctProjectionSegment(0, 10, AggregationType.COUNT, "(1)", "distinctExpression");
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(aggregationDistinctProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(AggregationDistinctProjection.class));
+ assertThat(actual.get(), isA(AggregationDistinctProjection.class));
}
@Test
@@ -98,7 +98,7 @@ class ProjectionEngineTest {
AggregationProjectionSegment aggregationProjectionSegment = new AggregationProjectionSegment(0, 10, AggregationType.COUNT, "COUNT(1)");
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(aggregationProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(AggregationProjection.class));
+ assertThat(actual.get(), isA(AggregationProjection.class));
}
@Test
@@ -106,7 +106,7 @@ class ProjectionEngineTest {
AggregationDistinctProjectionSegment aggregationDistinctProjectionSegment = new AggregationDistinctProjectionSegment(0, 10, AggregationType.AVG, "(1)", "distinctExpression");
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(aggregationDistinctProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(AggregationDistinctProjection.class));
+ assertThat(actual.get(), isA(AggregationDistinctProjection.class));
}
@Test
@@ -114,7 +114,7 @@ class ProjectionEngineTest {
AggregationProjectionSegment aggregationProjectionSegment = new AggregationProjectionSegment(0, 10, AggregationType.AVG, "AVG(1)");
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(aggregationProjectionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(AggregationProjection.class));
+ assertThat(actual.get(), isA(AggregationProjection.class));
}
@Test
@@ -123,7 +123,7 @@ class ProjectionEngineTest {
parameterMarkerExpressionSegment.setAlias(new AliasSegment(0, 0, new IdentifierValue("alias")));
Optional<Projection> actual = new ProjectionEngine(databaseType).createProjection(parameterMarkerExpressionSegment);
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ParameterMarkerProjection.class));
+ assertThat(actual.get(), isA(ParameterMarkerProjection.class));
assertThat(actual.get().getAlias().map(IdentifierValue::getValue).orElse(null), is("alias"));
}
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactoryTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactoryTest.java
index b9820bf6394..2e178253ecc 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactoryTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactoryTest.java
@@ -47,8 +47,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
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 SQLStatementContextFactoryTest {
selectStatement.setLimit(new LimitSegment(0, 10, null, null));
selectStatement.setProjections(projectionsSegment);
SQLStatementContext sqlStatementContext = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(selectStatement);
- assertThat(sqlStatementContext, instanceOf(SelectStatementContext.class));
+ assertThat(sqlStatementContext, isA(SelectStatementContext.class));
}
@Test
@@ -72,14 +72,14 @@ class SQLStatementContextFactoryTest {
InsertStatement insertStatement = new InsertStatement(databaseType);
insertStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("tbl"))));
SQLStatementContext sqlStatementContext = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(insertStatement);
- assertThat(sqlStatementContext, instanceOf(InsertStatementContext.class));
+ assertThat(sqlStatementContext, isA(InsertStatementContext.class));
}
@Test
void assertSQLStatementContextCreatedWhenSQLStatementNotInstanceOfSelectStatementAndInsertStatement() {
AlterDatabaseStatement alterDatabaseStatement = new AlterDatabaseStatement(databaseType);
SQLStatementContext sqlStatementContext = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(alterDatabaseStatement);
- assertThat(sqlStatementContext, instanceOf(CommonSQLStatementContext.class));
+ assertThat(sqlStatementContext, isA(CommonSQLStatementContext.class));
}
@Test
@@ -88,25 +88,25 @@ class SQLStatementContextFactoryTest {
selectStatement.setProjections(new ProjectionsSegment(0, 0));
CursorStatement cursorStatement = new CursorStatement(databaseType, null, selectStatement);
SQLStatementContext actual = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(cursorStatement);
- assertThat(actual, instanceOf(CursorStatementContext.class));
+ assertThat(actual, isA(CursorStatementContext.class));
}
@Test
void assertNewInstanceForCloseStatement() {
SQLStatementContext actual = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(new CloseStatement(databaseType, null, false));
- assertThat(actual, instanceOf(CursorHeldSQLStatementContext.class));
+ assertThat(actual, isA(CursorHeldSQLStatementContext.class));
}
@Test
void assertNewInstanceForMoveStatement() {
SQLStatementContext actual = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(new MoveStatement(databaseType, null, null));
- assertThat(actual, instanceOf(CursorHeldSQLStatementContext.class));
+ assertThat(actual, isA(CursorHeldSQLStatementContext.class));
}
@Test
void assertNewInstanceForFetchStatement() {
SQLStatementContext actual = new SQLBindEngine(mockMetaData(), "foo_db", new HintValueContext()).bind(new FetchStatement(databaseType, null, null));
- assertThat(actual, instanceOf(CursorHeldSQLStatementContext.class));
+ assertThat(actual, isA(CursorHeldSQLStatementContext.class));
}
private ShardingSphereMetaData mockMetaData() {
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/expression/type/SubquerySegmentBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/expression/type/SubquerySegmentBinderTest.java
index 56791f15557..ae9002bcad5 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/expression/type/SubquerySegmentBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/expression/type/SubquerySegmentBinderTest.java
@@ -49,9 +49,9 @@ import java.sql.Types;
import java.util.Arrays;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -83,10 +83,10 @@ class SubquerySegmentBinderTest {
SubquerySegment actual = SubquerySegmentBinder.bind(subquerySegment, sqlStatementBinderContext, outerTableBinderContexts);
assertNotNull(actual.getSelect());
assertTrue(actual.getSelect().getFrom().isPresent());
- assertThat(actual.getSelect().getFrom().get(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getSelect().getFrom().get(), isA(SimpleTableSegment.class));
assertThat(((SimpleTableSegment) actual.getSelect().getFrom().get()).getTableName().getIdentifier().getValue(), is("t_order"));
assertTrue(actual.getSelect().getWhere().isPresent());
- assertThat(actual.getSelect().getWhere().get().getExpr(), instanceOf(ColumnSegment.class));
+ assertThat(actual.getSelect().getWhere().get().getExpr(), isA(ColumnSegment.class));
assertThat(((ColumnSegment) actual.getSelect().getWhere().get().getExpr()).getIdentifier().getValue(), is("status"));
assertNotNull(((ColumnSegment) actual.getSelect().getWhere().get().getExpr()).getColumnBoundInfo());
assertThat(((ColumnSegment) actual.getSelect().getWhere().get().getExpr()).getColumnBoundInfo().getOriginalColumn().getValue(), is("status"));
@@ -96,7 +96,7 @@ class SubquerySegmentBinderTest {
assertNotNull(actual.getSelect().getProjections());
assertThat(actual.getSelect().getProjections().getProjections().size(), is(1));
ProjectionSegment column = actual.getSelect().getProjections().getProjections().iterator().next();
- assertThat(column, instanceOf(ColumnProjectionSegment.class));
+ assertThat(column, isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) column).getColumn().getIdentifier().getValue(), is("order_id"));
assertNotNull(((ColumnProjectionSegment) column).getColumn().getColumnBoundInfo());
assertThat(((ColumnProjectionSegment) column).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("order_id"));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/JoinTableSegmentBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/JoinTableSegmentBinderTest.java
index 4d5cb837a1a..1e8678f5096 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/JoinTableSegmentBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/JoinTableSegmentBinderTest.java
@@ -46,9 +46,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -71,8 +71,8 @@ class JoinTableSegmentBinderTest {
Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts = LinkedHashMultimap.create();
JoinTableSegment actual = JoinTableSegmentBinder.bind(joinTableSegment,
new SQLStatementBinderContext(metaData, "foo_db", new HintValueContext(), new SelectStatement(databaseType)), tableBinderContexts, LinkedHashMultimap.create());
- assertThat(actual.getLeft(), instanceOf(SimpleTableSegment.class));
- assertThat(actual.getRight(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getLeft(), isA(SimpleTableSegment.class));
+ assertThat(actual.getRight(), isA(SimpleTableSegment.class));
assertJoinTableProjectionSegments(actual.getDerivedJoinTableProjectionSegments());
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("o")));
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("i")));
@@ -81,7 +81,7 @@ class JoinTableSegmentBinderTest {
private void assertJoinTableProjectionSegments(final Collection<ProjectionSegment> joinTableProjectionSegments) {
List<ProjectionSegment> actual = new ArrayList<>(joinTableProjectionSegments);
assertThat(actual.size(), is(7));
- assertThat(actual.get(0), instanceOf(ColumnProjectionSegment.class));
+ assertThat(actual.get(0), isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) actual.get(0)).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("order_id"));
assertThat(((ColumnProjectionSegment) actual.get(0)).getColumn().getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
assertThat(((ColumnProjectionSegment) actual.get(1)).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("user_id"));
@@ -109,8 +109,8 @@ class JoinTableSegmentBinderTest {
Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts = LinkedHashMultimap.create();
JoinTableSegment actual = JoinTableSegmentBinder.bind(joinTableSegment,
new SQLStatementBinderContext(metaData, "foo_db", new HintValueContext(), new SelectStatement(databaseType)), tableBinderContexts, LinkedHashMultimap.create());
- assertThat(actual.getLeft(), instanceOf(SimpleTableSegment.class));
- assertThat(actual.getRight(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getLeft(), isA(SimpleTableSegment.class));
+ assertThat(actual.getRight(), isA(SimpleTableSegment.class));
assertJoinTableProjectionSegments(actual.getDerivedJoinTableProjectionSegments());
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("t_order")));
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("t_order_item")));
@@ -131,8 +131,8 @@ class JoinTableSegmentBinderTest {
Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts = LinkedHashMultimap.create();
JoinTableSegment actual = JoinTableSegmentBinder.bind(joinTableSegment,
new SQLStatementBinderContext(metaData, "foo_db", new HintValueContext(), new SelectStatement(databaseType)), tableBinderContexts, LinkedHashMultimap.create());
- assertThat(actual.getLeft(), instanceOf(SimpleTableSegment.class));
- assertThat(actual.getRight(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getLeft(), isA(SimpleTableSegment.class));
+ assertThat(actual.getRight(), isA(SimpleTableSegment.class));
assertJoinTableProjectionSegmentsWithNaturalJoin(actual.getDerivedJoinTableProjectionSegments());
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("o")));
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("i")));
@@ -141,7 +141,7 @@ class JoinTableSegmentBinderTest {
private void assertJoinTableProjectionSegmentsWithNaturalJoin(final Collection<ProjectionSegment> joinTableProjectionSegments) {
List<ProjectionSegment> actual = new ArrayList<>(joinTableProjectionSegments);
assertThat(actual.size(), is(4));
- assertThat(actual.get(0), instanceOf(ColumnProjectionSegment.class));
+ assertThat(actual.get(0), isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) actual.get(0)).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("order_id"));
assertThat(((ColumnProjectionSegment) actual.get(0)).getColumn().getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
assertThat(((ColumnProjectionSegment) actual.get(1)).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("user_id"));
@@ -167,8 +167,8 @@ class JoinTableSegmentBinderTest {
Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts = LinkedHashMultimap.create();
JoinTableSegment actual = JoinTableSegmentBinder.bind(joinTableSegment,
new SQLStatementBinderContext(metaData, "foo_db", new HintValueContext(), new SelectStatement(databaseType)), tableBinderContexts, LinkedHashMultimap.create());
- assertThat(actual.getLeft(), instanceOf(SimpleTableSegment.class));
- assertThat(actual.getRight(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getLeft(), isA(SimpleTableSegment.class));
+ assertThat(actual.getRight(), isA(SimpleTableSegment.class));
assertJoinTableProjectionSegmentsWithUsing(actual.getDerivedJoinTableProjectionSegments());
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("o")));
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("i")));
@@ -177,7 +177,7 @@ class JoinTableSegmentBinderTest {
private void assertJoinTableProjectionSegmentsWithUsing(final Collection<ProjectionSegment> joinTableProjectionSegments) {
List<ProjectionSegment> actual = new ArrayList<>(joinTableProjectionSegments);
assertThat(actual.size(), is(5));
- assertThat(actual.get(0), instanceOf(ColumnProjectionSegment.class));
+ assertThat(actual.get(0), isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) actual.get(0)).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("status"));
assertThat(((ColumnProjectionSegment) actual.get(0)).getColumn().getColumnBoundInfo().getOriginalTable().getValue(), is("t_order_item"));
assertThat(((ColumnProjectionSegment) actual.get(1)).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("order_id"));
@@ -202,10 +202,10 @@ class JoinTableSegmentBinderTest {
Multimap<CaseInsensitiveString, TableSegmentBinderContext> tableBinderContexts = LinkedHashMultimap.create();
JoinTableSegment actual = JoinTableSegmentBinder.bind(joinTableSegment,
new SQLStatementBinderContext(metaData, "foo_db", new HintValueContext(), new SelectStatement(databaseType)), tableBinderContexts, LinkedHashMultimap.create());
- assertThat(actual.getLeft(), instanceOf(JoinTableSegment.class));
- assertThat(((JoinTableSegment) actual.getLeft()).getLeft(), instanceOf(SimpleTableSegment.class));
- assertThat(((JoinTableSegment) actual.getLeft()).getRight(), instanceOf(SimpleTableSegment.class));
- assertThat(actual.getRight(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getLeft(), isA(JoinTableSegment.class));
+ assertThat(((JoinTableSegment) actual.getLeft()).getLeft(), isA(SimpleTableSegment.class));
+ assertThat(((JoinTableSegment) actual.getLeft()).getRight(), isA(SimpleTableSegment.class));
+ assertThat(actual.getRight(), isA(SimpleTableSegment.class));
assertThat(actual.getDerivedJoinTableProjectionSegments().size(), is(10));
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("o")));
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("o2")));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SubqueryTableSegmentBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SubqueryTableSegmentBinderTest.java
index 2547b7baba5..3d55704a383 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SubqueryTableSegmentBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/dml/from/type/SubqueryTableSegmentBinderTest.java
@@ -48,9 +48,9 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -79,15 +79,15 @@ class SubqueryTableSegmentBinderTest {
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("temp")));
List<ProjectionSegment> projectionSegments = new ArrayList<>(tableBinderContexts.get(new CaseInsensitiveString("temp")).iterator().next().getProjectionSegments());
assertThat(projectionSegments.size(), is(3));
- assertThat(projectionSegments.get(0), instanceOf(ColumnProjectionSegment.class));
+ assertThat(projectionSegments.get(0), isA(ColumnProjectionSegment.class));
assertTrue(((ColumnProjectionSegment) projectionSegments.get(0)).getColumn().getOwner().isPresent());
assertThat(((ColumnProjectionSegment) projectionSegments.get(0)).getColumn().getOwner().get().getIdentifier().getValue(), is("temp"));
assertThat(((ColumnProjectionSegment) projectionSegments.get(0)).getColumn().getIdentifier().getValue(), is("order_id"));
- assertThat(projectionSegments.get(1), instanceOf(ColumnProjectionSegment.class));
+ assertThat(projectionSegments.get(1), isA(ColumnProjectionSegment.class));
assertTrue(((ColumnProjectionSegment) projectionSegments.get(1)).getColumn().getOwner().isPresent());
assertThat(((ColumnProjectionSegment) projectionSegments.get(1)).getColumn().getOwner().get().getIdentifier().getValue(), is("temp"));
assertThat(((ColumnProjectionSegment) projectionSegments.get(1)).getColumn().getIdentifier().getValue(), is("user_id"));
- assertThat(projectionSegments.get(2), instanceOf(ColumnProjectionSegment.class));
+ assertThat(projectionSegments.get(2), isA(ColumnProjectionSegment.class));
assertTrue(((ColumnProjectionSegment) projectionSegments.get(2)).getColumn().getOwner().isPresent());
assertThat(((ColumnProjectionSegment) projectionSegments.get(2)).getColumn().getOwner().get().getIdentifier().getValue(), is("temp"));
assertThat(((ColumnProjectionSegment) projectionSegments.get(2)).getColumn().getIdentifier().getValue(), is("status"));
@@ -113,7 +113,7 @@ class SubqueryTableSegmentBinderTest {
assertTrue(tableBinderContexts.containsKey(new CaseInsensitiveString("temp")));
List<ProjectionSegment> projectionSegments = new ArrayList<>(tableBinderContexts.get(new CaseInsensitiveString("temp")).iterator().next().getProjectionSegments());
assertThat(projectionSegments.size(), is(1));
- assertThat(projectionSegments.get(0), instanceOf(ColumnProjectionSegment.class));
+ assertThat(projectionSegments.get(0), isA(ColumnProjectionSegment.class));
assertTrue(((ColumnProjectionSegment) projectionSegments.get(0)).getColumn().getOwner().isPresent());
assertThat(((ColumnProjectionSegment) projectionSegments.get(0)).getColumn().getOwner().get().getIdentifier().getValue(), is("temp"));
assertThat(((ColumnProjectionSegment) projectionSegments.get(0)).getColumn().getIdentifier().getValue(), is("order_id_alias"));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java
index 4c34c49c637..e5e4ff4deb1 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java
@@ -37,10 +37,10 @@ import org.junit.jupiter.api.Test;
import java.sql.Types;
import java.util.Arrays;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -60,14 +60,14 @@ class DeleteStatementBinderTest {
DeleteStatement actual = new DeleteStatementBinder().bind(deleteStatement, new SQLStatementBinderContext(createMetaData(), "foo_db", new HintValueContext(), deleteStatement));
assertThat(actual, not(deleteStatement));
assertThat(actual.getTable(), not(deleteStatement.getTable()));
- assertThat(actual.getTable(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getTable(), isA(SimpleTableSegment.class));
assertTrue(actual.getWhere().isPresent());
assertThat(actual.getWhere().get(), not(deleteStatement.getWhere()));
- assertThat(actual.getWhere().get(), instanceOf(WhereSegment.class));
+ assertThat(actual.getWhere().get(), isA(WhereSegment.class));
assertTrue(deleteStatement.getWhere().isPresent());
assertThat(actual.getWhere().get().getExpr(), not(deleteStatement.getWhere().get().getExpr()));
- assertThat(actual.getWhere().get().getExpr(), instanceOf(BinaryOperationExpression.class));
- assertThat(((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft(), instanceOf(ColumnSegment.class));
+ assertThat(actual.getWhere().get().getExpr(), isA(BinaryOperationExpression.class));
+ assertThat(((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft(), isA(ColumnSegment.class));
assertThat(((ColumnSegment) ((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft()).getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java
index 0790d1584bf..cb851b0315c 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java
@@ -44,10 +44,10 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -149,19 +149,19 @@ class InsertStatementBinderTest {
assertThat(actualProjections.size(), is(3));
Iterator<ProjectionSegment> projectionIterator = actualProjections.iterator();
ProjectionSegment orderIdProjectionSegment = projectionIterator.next();
- assertThat(orderIdProjectionSegment, instanceOf(ColumnProjectionSegment.class));
+ assertThat(orderIdProjectionSegment, isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) orderIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalDatabase().getValue(), is("foo_db"));
assertThat(((ColumnProjectionSegment) orderIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalSchema().getValue(), is("foo_db"));
assertThat(((ColumnProjectionSegment) orderIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
assertThat(((ColumnProjectionSegment) orderIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("order_id"));
ProjectionSegment userIdProjectionSegment = projectionIterator.next();
- assertThat(userIdProjectionSegment, instanceOf(ColumnProjectionSegment.class));
+ assertThat(userIdProjectionSegment, isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) userIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalDatabase().getValue(), is("foo_db"));
assertThat(((ColumnProjectionSegment) userIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalSchema().getValue(), is("foo_db"));
assertThat(((ColumnProjectionSegment) userIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
assertThat(((ColumnProjectionSegment) userIdProjectionSegment).getColumn().getColumnBoundInfo().getOriginalColumn().getValue(), is("user_id"));
ProjectionSegment statusProjectionSegment = projectionIterator.next();
- assertThat(statusProjectionSegment, instanceOf(ColumnProjectionSegment.class));
+ assertThat(statusProjectionSegment, isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) statusProjectionSegment).getColumn().getColumnBoundInfo().getOriginalDatabase().getValue(), is("foo_db"));
assertThat(((ColumnProjectionSegment) statusProjectionSegment).getColumn().getColumnBoundInfo().getOriginalSchema().getValue(), is("foo_db"));
assertThat(((ColumnProjectionSegment) statusProjectionSegment).getColumn().getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java
index e9b6f8b5218..d68b77a7ea9 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java
@@ -43,10 +43,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -74,28 +74,28 @@ class SelectStatementBinderTest {
assertThat(actual, not(selectStatement));
assertTrue(actual.getFrom().isPresent());
assertThat(actual.getFrom().get(), not(simpleTableSegment));
- assertThat(actual.getFrom().get(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getFrom().get(), isA(SimpleTableSegment.class));
assertThat(((SimpleTableSegment) actual.getFrom().get()).getTableName(), not(simpleTableSegment.getTableName()));
assertThat(actual.getProjections(), not(selectStatement.getProjections()));
List<ProjectionSegment> actualProjections = new ArrayList<>(actual.getProjections().getProjections());
assertThat(actualProjections, not(selectStatement.getProjections()));
assertThat(actualProjections.get(0), not(orderIdProjection));
- assertThat(actualProjections.get(0), instanceOf(ColumnProjectionSegment.class));
+ assertThat(actualProjections.get(0), isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) actualProjections.get(0)).getColumn(), not(orderIdProjection.getColumn()));
assertThat(actualProjections.get(1), not(userIdProjection));
- assertThat(actualProjections.get(1), instanceOf(ColumnProjectionSegment.class));
+ assertThat(actualProjections.get(1), isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) actualProjections.get(1)).getColumn(), not(userIdProjection.getColumn()));
assertThat(actualProjections.get(2), not(statusProjection));
- assertThat(actualProjections.get(2), instanceOf(ColumnProjectionSegment.class));
+ assertThat(actualProjections.get(2), isA(ColumnProjectionSegment.class));
assertThat(((ColumnProjectionSegment) actualProjections.get(2)).getColumn(), not(statusProjection.getColumn()));
assertTrue(actual.getWhere().isPresent());
assertThat(actual.getWhere().get(), not(selectStatement.getWhere()));
- assertThat(actual.getWhere().get(), instanceOf(WhereSegment.class));
+ assertThat(actual.getWhere().get(), isA(WhereSegment.class));
assertTrue(selectStatement.getWhere().isPresent());
assertThat(actual.getWhere().get().getExpr(), not(selectStatement.getWhere().get().getExpr()));
- assertThat(actual.getWhere().get().getExpr(), instanceOf(BinaryOperationExpression.class));
- assertThat(((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft(), instanceOf(FunctionSegment.class));
- assertThat(((FunctionSegment) ((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft()).getParameters().iterator().next(), instanceOf(ColumnSegment.class));
+ assertThat(actual.getWhere().get().getExpr(), isA(BinaryOperationExpression.class));
+ assertThat(((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft(), isA(FunctionSegment.class));
+ assertThat(((FunctionSegment) ((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft()).getParameters().iterator().next(), isA(ColumnSegment.class));
assertThat(((ColumnSegment) ((FunctionSegment) ((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft()).getParameters().iterator().next())
.getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
}
diff --git a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java
index b7c068349a0..c4940c8d3fe 100644
--- a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java
+++ b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java
@@ -37,10 +37,10 @@ import org.junit.jupiter.api.Test;
import java.sql.Types;
import java.util.Arrays;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -60,14 +60,14 @@ class UpdateStatementBinderTest {
UpdateStatement actual = new UpdateStatementBinder().bind(updateStatement, new SQLStatementBinderContext(createMetaData(), "foo_db", new HintValueContext(), updateStatement));
assertThat(actual, not(updateStatement));
assertThat(actual.getTable(), not(updateStatement.getTable()));
- assertThat(actual.getTable(), instanceOf(SimpleTableSegment.class));
+ assertThat(actual.getTable(), isA(SimpleTableSegment.class));
assertTrue(actual.getWhere().isPresent());
assertThat(actual.getWhere().get(), not(updateStatement.getWhere()));
- assertThat(actual.getWhere().get(), instanceOf(WhereSegment.class));
+ assertThat(actual.getWhere().get(), isA(WhereSegment.class));
assertTrue(updateStatement.getWhere().isPresent());
assertThat(actual.getWhere().get().getExpr(), not(updateStatement.getWhere().get().getExpr()));
- assertThat(actual.getWhere().get().getExpr(), instanceOf(BinaryOperationExpression.class));
- assertThat(((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft(), instanceOf(ColumnSegment.class));
+ assertThat(actual.getWhere().get().getExpr(), isA(BinaryOperationExpression.class));
+ assertThat(((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft(), isA(ColumnSegment.class));
assertThat(((ColumnSegment) ((BinaryOperationExpression) actual.getWhere().get().getExpr()).getLeft()).getColumnBoundInfo().getOriginalTable().getValue(), is("t_order"));
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfigurationTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfigurationTest.java
index a6980b8ce48..bc01121791c 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfigurationTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfigurationTest.java
@@ -31,9 +31,9 @@ import java.util.Collections;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
class DataSourceGeneratedDatabaseConfigurationTest {
@@ -42,7 +42,7 @@ class DataSourceGeneratedDatabaseConfigurationTest {
void assertGetDataSources() {
DataSourceGeneratedDatabaseConfiguration databaseConfig = createDataSourceGeneratedDatabaseConfiguration();
DataSource dataSource = databaseConfig.getStorageUnits().get("foo_db").getDataSource();
- assertThat(dataSource, instanceOf(MockedDataSource.class));
+ assertThat(dataSource, isA(MockedDataSource.class));
}
@Test
@@ -58,7 +58,7 @@ class DataSourceGeneratedDatabaseConfigurationTest {
void assertGetStorageUnits() {
DataSourceGeneratedDatabaseConfiguration databaseConfig = createDataSourceGeneratedDatabaseConfiguration();
DataSource dataSource = databaseConfig.getStorageUnits().get("foo_db").getDataSource();
- assertThat(dataSource, instanceOf(MockedDataSource.class));
+ assertThat(dataSource, isA(MockedDataSource.class));
}
@Test
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java
index b59c26552a8..b3fd2941ba9 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java
@@ -32,9 +32,9 @@ import java.util.Collections;
import java.util.Map;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.junit.jupiter.api.Assertions.assertTrue;
@@ -89,7 +89,7 @@ class RuleMetaDataTest {
@Test
void assertGetSingleRule() {
- assertThat(ruleMetaData.getSingleRule(RuleMetaDataShardingSphereRuleFixture.class), instanceOf(RuleMetaDataShardingSphereRuleFixture.class));
+ assertThat(ruleMetaData.getSingleRule(RuleMetaDataShardingSphereRuleFixture.class), isA(RuleMetaDataShardingSphereRuleFixture.class));
}
@Test
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java
index a4fc265d45f..6f312db97f6 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java
@@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
@@ -37,7 +37,7 @@ class DatabaseRulesBuilderTest {
void assertBuild() {
Iterator<ShardingSphereRule> actual = DatabaseRulesBuilder.build("foo_db", mock(),
new DataSourceProvidedDatabaseConfiguration(Collections.emptyMap(), Collections.singleton(new FixtureRuleConfiguration())), mock(), mock()).iterator();
- assertThat(actual.next(), instanceOf(FixtureRule.class));
+ assertThat(actual.next(), isA(FixtureRule.class));
assertFalse(actual.hasNext());
}
}
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java
index def5d09b21e..8af5ac0cf4b 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/global/GlobalRulesBuilderTest.java
@@ -33,7 +33,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class GlobalRulesBuilderTest {
@@ -42,7 +42,7 @@ class GlobalRulesBuilderTest {
void assertBuildRules() {
Collection<ShardingSphereRule> rules = GlobalRulesBuilder.buildRules(Collections.singletonList(new FixtureGlobalRuleConfiguration()), Collections.singleton(buildDatabase()), mock());
assertThat(rules.size(), is(1));
- assertThat(rules.iterator().next(), instanceOf(FixtureGlobalRule.class));
+ assertThat(rules.iterator().next(), isA(FixtureGlobalRule.class));
}
@Test
diff --git a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/domain/DataSourcePoolPropertiesTest.java b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/domain/DataSourcePoolPropertiesTest.java
index 946c6ed9bd4..120057b6713 100644
--- a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/domain/DataSourcePoolPropertiesTest.java
+++ b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/domain/DataSourcePoolPropertiesTest.java
@@ -29,11 +29,11 @@ import java.util.List;
import java.util.Map;
import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -55,7 +55,7 @@ class DataSourcePoolPropertiesTest {
assertThat(actual.getAllLocalProperties().get("username").toString(), is("root"));
assertThat(actual.getAllLocalProperties().get("password").toString(), is("root"));
assertNull(actual.getAllLocalProperties().get("loginTimeout"));
- assertThat(actual.getAllLocalProperties().get("connectionInitSqls"), instanceOf(List.class));
+ assertThat(actual.getAllLocalProperties().get("connectionInitSqls"), isA(List.class));
List<String> actualConnectionInitSql = (List<String>) actual.getAllLocalProperties().get("connectionInitSqls");
assertThat(actualConnectionInitSql, hasItem("set names utf8mb4;"));
assertThat(actualConnectionInitSql, hasItem("set names utf8;"));
diff --git a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/util/ResultSetUtilsTest.java b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/util/ResultSetUtilsTest.java
index 440c3e16d95..f329d8760f1 100644
--- a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/util/ResultSetUtilsTest.java
+++ b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/type/util/ResultSetUtilsTest.java
@@ -37,9 +37,9 @@ import java.time.Month;
import java.time.OffsetDateTime;
import java.util.Date;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -88,8 +88,8 @@ class ResultSetUtilsTest {
assertThat(ResultSetUtils.convertValue(timestamp, LocalDateTime.class), is(localDateTime));
assertThat(ResultSetUtils.convertValue(timestamp, LocalDate.class), is(LocalDate.of(2021, Month.DECEMBER, 23)));
assertThat(ResultSetUtils.convertValue(timestamp, LocalTime.class), is(LocalTime.of(19, 30)));
- assertThat(ResultSetUtils.convertValue(timestamp, OffsetDateTime.class), instanceOf(OffsetDateTime.class));
- assertThat(ResultSetUtils.convertValue(timestamp, String.class), instanceOf(String.class));
+ assertThat(ResultSetUtils.convertValue(timestamp, OffsetDateTime.class), isA(OffsetDateTime.class));
+ assertThat(ResultSetUtils.convertValue(timestamp, String.class), isA(String.class));
assertThat(ResultSetUtils.convertValue(timestamp, Object.class), is(timestamp));
}
diff --git a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextTest.java b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextTest.java
index d94d5cfdb85..64090f506e1 100644
--- a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextTest.java
+++ b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextTest.java
@@ -44,8 +44,8 @@ import org.mockito.quality.Strictness;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -104,7 +104,7 @@ class SQLRewriteContextTest {
when(queryContext.getParameters()).thenReturn(Collections.singletonList(1));
when(queryContext.getHintValueContext()).thenReturn(hintValueContext);
SQLRewriteContext sqlRewriteContext = new SQLRewriteContext(database, queryContext);
- assertThat(sqlRewriteContext.getParameterBuilder(), instanceOf(GroupedParameterBuilder.class));
+ assertThat(sqlRewriteContext.getParameterBuilder(), isA(GroupedParameterBuilder.class));
}
@Test
@@ -117,7 +117,7 @@ class SQLRewriteContextTest {
when(queryContext.getParameters()).thenReturn(Collections.singletonList(1));
when(queryContext.getHintValueContext()).thenReturn(hintValueContext);
SQLRewriteContext sqlRewriteContext = new SQLRewriteContext(database, queryContext);
- assertThat(sqlRewriteContext.getParameterBuilder(), instanceOf(StandardParameterBuilder.class));
+ assertThat(sqlRewriteContext.getParameterBuilder(), isA(StandardParameterBuilder.class));
}
@Test
@@ -131,7 +131,7 @@ class SQLRewriteContextTest {
sqlRewriteContext.addSQLTokenGenerators(Collections.singleton(optionalSQLTokenGenerator));
sqlRewriteContext.generateSQLTokens();
assertFalse(sqlRewriteContext.getSqlTokens().isEmpty());
- assertThat(sqlRewriteContext.getSqlTokens().get(0), instanceOf(SQLToken.class));
+ assertThat(sqlRewriteContext.getSqlTokens().get(0), isA(SQLToken.class));
}
@Test
@@ -145,6 +145,6 @@ class SQLRewriteContextTest {
sqlRewriteContext.addSQLTokenGenerators(Collections.singleton(collectionSQLTokenGenerator));
sqlRewriteContext.generateSQLTokens();
assertFalse(sqlRewriteContext.getSqlTokens().isEmpty());
- assertThat(sqlRewriteContext.getSqlTokens().get(0), instanceOf(SQLToken.class));
+ assertThat(sqlRewriteContext.getSqlTokens().get(0), isA(SQLToken.class));
}
}
diff --git a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java
index 7a536e2b893..241fb106d1e 100644
--- a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java
+++ b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/generator/builder/DefaultTokenGeneratorBuilderTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.builder;
-import org.apache.shardingsphere.infra.binder.context.statement.type.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
+import org.apache.shardingsphere.infra.binder.context.statement.type.CommonSQLStatementContext;
import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.SQLTokenGenerator;
import org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.RemoveTokenGenerator;
@@ -27,9 +27,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -61,6 +61,6 @@ class DefaultTokenGeneratorBuilderTest {
assertThat(sqlTokenGenerators.size(), is(1));
Iterator<SQLTokenGenerator> iterator = sqlTokenGenerators.iterator();
SQLTokenGenerator removeTokenGenerator = iterator.next();
- assertThat(removeTokenGenerator, instanceOf(RemoveTokenGenerator.class));
+ assertThat(removeTokenGenerator, isA(RemoveTokenGenerator.class));
}
}
diff --git a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyAssignmentTokenGeneratorTest.java b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyAssignmentTokenGeneratorTest.java
index 5e72ec30685..9438fc032c8 100644
--- a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyAssignmentTokenGeneratorTest.java
+++ b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyAssignmentTokenGeneratorTest.java
@@ -28,8 +28,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -49,7 +49,7 @@ class GeneratedKeyAssignmentTokenGeneratorTest {
InsertStatementContext insertStatementContext = mockInsertStatementContext();
GeneratedKeyAssignmentTokenGenerator generator = new GeneratedKeyAssignmentTokenGenerator();
generator.setParameters(Collections.emptyList());
- assertThat(generator.generateSQLToken(insertStatementContext), instanceOf(LiteralGeneratedKeyAssignmentToken.class));
+ assertThat(generator.generateSQLToken(insertStatementContext), isA(LiteralGeneratedKeyAssignmentToken.class));
}
@Test
@@ -57,7 +57,7 @@ class GeneratedKeyAssignmentTokenGeneratorTest {
InsertStatementContext insertStatementContext = mockInsertStatementContext();
GeneratedKeyAssignmentTokenGenerator generator = new GeneratedKeyAssignmentTokenGenerator();
generator.setParameters(Collections.singletonList("testObject"));
- assertThat(generator.generateSQLToken(insertStatementContext), instanceOf(ParameterMarkerGeneratedKeyAssignmentToken.class));
+ assertThat(generator.generateSQLToken(insertStatementContext), isA(ParameterMarkerGeneratedKeyAssignmentToken.class));
}
private InsertStatementContext mockInsertStatementContext() {
diff --git a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyInsertValuesTokenGeneratorTest.java b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyInsertValuesTokenGeneratorTest.java
index ace1beaaf76..308d7b277c4 100644
--- a/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyInsertValuesTokenGeneratorTest.java
+++ b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/keygen/generator/GeneratedKeyInsertValuesTokenGeneratorTest.java
@@ -34,8 +34,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.junit.jupiter.api.Assertions.assertTrue;
@@ -96,12 +96,12 @@ class GeneratedKeyInsertValuesTokenGeneratorTest {
GeneratedKeyInsertValuesTokenGenerator generator = new GeneratedKeyInsertValuesTokenGenerator();
generator.setPreviousSQLTokens(getPreviousSQLTokens());
SQLToken sqlToken = generator.generateSQLToken(sqlStatementContext);
- assertThat(sqlToken, instanceOf(InsertValuesToken.class));
- assertThat(((InsertValuesToken) sqlToken).getInsertValues().get(0).getValues().get(0), instanceOf(DerivedParameterMarkerExpressionSegment.class));
+ assertThat(sqlToken, isA(InsertValuesToken.class));
+ assertThat(((InsertValuesToken) sqlToken).getInsertValues().get(0).getValues().get(0), isA(DerivedParameterMarkerExpressionSegment.class));
parameterGroups.get(0).clear();
((InsertValuesToken) sqlToken).getInsertValues().get(0).getValues().clear();
sqlToken = generator.generateSQLToken(sqlStatementContext);
- assertThat(((InsertValuesToken) sqlToken).getInsertValues().get(0).getValues().get(0), instanceOf(DerivedLiteralExpressionSegment.class));
+ assertThat(((InsertValuesToken) sqlToken).getInsertValues().get(0).getValues().get(0), isA(DerivedLiteralExpressionSegment.class));
}
private GeneratedKeyContext createGeneratedKeyContext() {
diff --git a/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java b/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
index cb9ef8e8c02..ee44d7be47d 100644
--- a/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
+++ b/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
@@ -56,8 +56,8 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -97,7 +97,7 @@ class TablelessRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(setStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -107,7 +107,7 @@ class TablelessRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(dalStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -116,7 +116,7 @@ class TablelessRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(tclStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -130,7 +130,7 @@ class TablelessRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -144,7 +144,7 @@ class TablelessRouteEngineFactoryTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessInstanceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessInstanceBroadcastRouteEngine.class));
}
@Test
@@ -154,7 +154,7 @@ class TablelessRouteEngineFactoryTest {
when(closeStatementContext.getSqlStatement()).thenReturn(new CloseStatement(databaseType, null, true));
QueryContext queryContext = new QueryContext(closeStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -162,7 +162,7 @@ class TablelessRouteEngineFactoryTest {
QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(CreateSchemaStatement.class, RETURNS_DEEP_STUBS));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -170,7 +170,7 @@ class TablelessRouteEngineFactoryTest {
QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(AlterSchemaStatement.class, RETURNS_DEEP_STUBS));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -178,7 +178,7 @@ class TablelessRouteEngineFactoryTest {
QueryContext queryContext = mock(QueryContext.class, RETURNS_DEEP_STUBS);
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(DropSchemaStatement.class, RETURNS_DEEP_STUBS));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceBroadcastRouteEngine.class));
}
@Test
@@ -187,6 +187,6 @@ class TablelessRouteEngineFactoryTest {
when(queryContext.getSqlStatementContext()).thenReturn(mock(SelectStatementContext.class));
when(queryContext.getSqlStatementContext().getSqlStatement()).thenReturn(mock(SelectStatement.class));
TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
- assertThat(actual, instanceOf(TablelessDataSourceUnicastRouteEngine.class));
+ assertThat(actual, isA(TablelessDataSourceUnicastRouteEngine.class));
}
}
diff --git a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoaderTest.java b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoaderTest.java
index a1aad5e06d8..369cdcebf3b 100644
--- a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoaderTest.java
+++ b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoaderTest.java
@@ -26,10 +26,10 @@ import org.junit.jupiter.api.Test;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -50,7 +50,7 @@ class ShardingSphereServiceLoaderTest {
Collection<SingletonSPIFixture> actual = ShardingSphereServiceLoader.getServiceInstances(SingletonSPIFixture.class);
assertThat(actual.size(), is(1));
SingletonSPIFixture actualInstance = actual.iterator().next();
- assertThat(actualInstance, instanceOf(SingletonSPIFixtureImpl.class));
+ assertThat(actualInstance, isA(SingletonSPIFixtureImpl.class));
assertThat(actualInstance, is(ShardingSphereServiceLoader.getServiceInstances(SingletonSPIFixture.class).iterator().next()));
}
@@ -59,7 +59,7 @@ class ShardingSphereServiceLoaderTest {
Collection<MultitonSPIFixture> actual = ShardingSphereServiceLoader.getServiceInstances(MultitonSPIFixture.class);
assertThat(actual.size(), is(1));
MultitonSPIFixture actualInstance = actual.iterator().next();
- assertThat(actualInstance, instanceOf(MultitonSPIFixtureImpl.class));
+ assertThat(actualInstance, isA(MultitonSPIFixtureImpl.class));
assertThat(actualInstance, not(ShardingSphereServiceLoader.getServiceInstances(MultitonSPIFixture.class).iterator().next()));
}
}
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 a2d0907c4ae..d6a45753d84 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
@@ -31,12 +31,13 @@ import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class OrderedSPILoaderTest {
+ @SuppressWarnings("CollectionWithoutInitialCapacity")
@AfterEach
void cleanCache() throws ReflectiveOperationException {
Plugins.getMemberAccessor().set(OrderedServicesCache.class.getDeclaredField("cache"), OrderedServicesCache.class, new SoftReference<>(new ConcurrentHashMap<>()));
@@ -47,7 +48,7 @@ class OrderedSPILoaderTest {
void assertGetServicesByClass() {
Map<Class<?>, OrderedSPIFixture> actual = OrderedSPILoader.getServicesByClass(OrderedSPIFixture.class, Collections.singleton(OrderedInterfaceFixtureImpl.class));
assertThat(actual.size(), is(1));
- assertThat(actual.get(OrderedInterfaceFixtureImpl.class), instanceOf(OrderedSPIFixtureImpl.class));
+ assertThat(actual.get(OrderedInterfaceFixtureImpl.class), isA(OrderedSPIFixtureImpl.class));
}
@SuppressWarnings("rawtypes")
@@ -56,7 +57,7 @@ class OrderedSPILoaderTest {
OrderedInterfaceFixtureImpl key = new OrderedInterfaceFixtureImpl();
Map<OrderedInterfaceFixtureImpl, OrderedSPIFixture> actual = OrderedSPILoader.getServices(OrderedSPIFixture.class, Collections.singleton(key));
assertThat(actual.size(), is(1));
- assertThat(actual.get(key), instanceOf(OrderedSPIFixtureImpl.class));
+ assertThat(actual.get(key), isA(OrderedSPIFixtureImpl.class));
}
@Test
diff --git a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
index 235de23ceef..141d8353b4e 100644
--- a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
+++ b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
@@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -45,7 +45,7 @@ class TypedSPILoaderTest {
@Test
void assertGetServiceWithoutProperties() {
- assertThat(TypedSPILoader.getService(TypedSPIFixture.class, "TYPED.FIXTURE"), instanceOf(TypedSPIFixtureImpl.class));
+ assertThat(TypedSPILoader.getService(TypedSPIFixture.class, "TYPED.FIXTURE"), isA(TypedSPIFixtureImpl.class));
}
@Test
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDriverTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDriverTest.java
index 199553d049e..985f7588f9b 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDriverTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDriverTest.java
@@ -30,9 +30,9 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ServiceLoader;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -62,7 +62,7 @@ class ShardingSphereDriverTest {
try (
Connection connection = DriverManager.getConnection("jdbc:shardingsphere:classpath:config/driver/foo-driver-fixture.yaml");
Statement statement = connection.createStatement()) {
- assertThat(connection, instanceOf(ShardingSphereConnection.class));
+ assertThat(connection, isA(ShardingSphereConnection.class));
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id INT)");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 101), (2, 102)");
@@ -78,7 +78,7 @@ class ShardingSphereDriverTest {
try (
Connection connection = DriverManager.getConnection("jdbc:shardingsphere:classpath:config/driver/foo-driver-fixture.yaml");
Statement statement = connection.createStatement()) {
- assertThat(connection, instanceOf(ShardingSphereConnection.class));
+ assertThat(connection, isA(ShardingSphereConnection.class));
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id VARBINARY(64) PRIMARY KEY, user_id INT)");
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t_order (order_id, user_id) VALUES (?, ?)");
@@ -98,7 +98,7 @@ class ShardingSphereDriverTest {
try (
Connection connection = DriverManager.getConnection("jdbc:shardingsphere:classpath:config/driver/foo-driver-fixture.yaml");
Statement statement = connection.createStatement()) {
- assertThat(connection, instanceOf(ShardingSphereConnection.class));
+ assertThat(connection, isA(ShardingSphereConnection.class));
statement.execute("DROP TABLE IF EXISTS t_order");
statement.execute("CREATE TABLE t_order (order_id INT PRIMARY KEY, user_id INT)");
statement.execute("INSERT INTO t_order (order_id, user_id) VALUES (1, 101), (2, 102)");
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractDataSourceAdapterTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractDataSourceAdapterTest.java
index 22a0039481b..6782201a768 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractDataSourceAdapterTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/AbstractDataSourceAdapterTest.java
@@ -32,9 +32,9 @@ import java.util.Collections;
import java.util.Properties;
import java.util.logging.Logger;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
class AbstractDataSourceAdapterTest {
@@ -55,7 +55,7 @@ class AbstractDataSourceAdapterTest {
@Test
void assertSetLogWriter() {
- assertThat(shardingSphereDataSource.getLogWriter(), instanceOf(PrintWriter.class));
+ assertThat(shardingSphereDataSource.getLogWriter(), isA(PrintWriter.class));
shardingSphereDataSource.setLogWriter(null);
assertNull(shardingSphereDataSource.getLogWriter());
}
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
index fe5f530e743..99363cdce20 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
@@ -46,9 +46,9 @@ import java.sql.SQLException;
import java.sql.Types;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -849,156 +849,156 @@ class ShardingSphereDatabaseMetaDataTest {
@Test
void assertGetSuperTypes() throws SQLException {
when(databaseMetaData.getSuperTypes("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getSuperTypes("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getSuperTypes("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetSuperTables() throws SQLException {
when(databaseMetaData.getSuperTables("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getSuperTables("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getSuperTables("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetAttributes() throws SQLException {
when(databaseMetaData.getAttributes("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getAttributes("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getAttributes("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetProcedures() throws SQLException {
when(databaseMetaData.getProcedures("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getProcedures("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getProcedures("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetProcedureColumns() throws SQLException {
when(databaseMetaData.getProcedureColumns("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getProcedureColumns("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getProcedureColumns("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetTables() throws SQLException {
when(databaseMetaData.getTables("test", null, "%" + TABLE_NAME + "%", null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getTables("test", null, TABLE_NAME, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getTables("test", null, TABLE_NAME, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetSchemas() throws SQLException {
when(databaseMetaData.getSchemas()).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getSchemas(), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getSchemas(), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetSchemasForCatalogAndSchemaPattern() throws SQLException {
when(databaseMetaData.getSchemas("test", null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getSchemas("test", null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getSchemas("test", null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetCatalogs() throws SQLException {
when(databaseMetaData.getCatalogs()).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getCatalogs(), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getCatalogs(), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetTableTypes() throws SQLException {
when(databaseMetaData.getTableTypes()).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getTableTypes(), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getTableTypes(), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetColumns() throws SQLException {
when(databaseMetaData.getColumns("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getColumns("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getColumns("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetColumnPrivileges() throws SQLException {
when(databaseMetaData.getColumnPrivileges("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getColumnPrivileges("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getColumnPrivileges("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetTablePrivileges() throws SQLException {
when(databaseMetaData.getTablePrivileges("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getTablePrivileges("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getTablePrivileges("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetBestRowIdentifier() throws SQLException {
when(databaseMetaData.getBestRowIdentifier("test", null, null, 1, true)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getBestRowIdentifier("test", null, null, 1, true), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getBestRowIdentifier("test", null, null, 1, true), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetVersionColumns() throws SQLException {
when(databaseMetaData.getVersionColumns("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getVersionColumns("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getVersionColumns("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetPrimaryKeys() throws SQLException {
when(databaseMetaData.getPrimaryKeys("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getPrimaryKeys("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getPrimaryKeys("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetImportedKeys() throws SQLException {
when(databaseMetaData.getImportedKeys("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getImportedKeys("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getImportedKeys("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetExportedKeys() throws SQLException {
when(databaseMetaData.getExportedKeys("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getExportedKeys("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getExportedKeys("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetCrossReference() throws SQLException {
when(databaseMetaData.getCrossReference("test", null, null, null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getCrossReference("test", null, null, null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getCrossReference("test", null, null, null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetTypeInfo() throws SQLException {
when(databaseMetaData.getTypeInfo()).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getTypeInfo(), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getTypeInfo(), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetIndexInfo() throws SQLException {
when(databaseMetaData.getIndexInfo("test", null, TABLE_NAME, true, true)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getIndexInfo("test", null, TABLE_NAME, true, true), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getIndexInfo("test", null, TABLE_NAME, true, true), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetUDTs() throws SQLException {
when(databaseMetaData.getUDTs("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getUDTs("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getUDTs("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetClientInfoProperties() throws SQLException {
when(databaseMetaData.getClientInfoProperties()).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getClientInfoProperties(), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getClientInfoProperties(), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetFunctions() throws SQLException {
when(databaseMetaData.getFunctions("test", null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getFunctions("test", null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getFunctions("test", null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetFunctionColumns() throws SQLException {
when(databaseMetaData.getFunctionColumns("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getFunctionColumns("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getFunctionColumns("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
@Test
void assertGetPseudoColumns() throws SQLException {
when(databaseMetaData.getPseudoColumns("test", null, null, null)).thenReturn(resultSet);
- assertThat(shardingSphereDatabaseMetaData.getPseudoColumns("test", null, null, null), instanceOf(DatabaseMetaDataResultSet.class));
+ assertThat(shardingSphereDatabaseMetaData.getPseudoColumns("test", null, null, null), isA(DatabaseMetaDataResultSet.class));
}
}
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetTest.java
index 6abdf9f3e72..4ec2dcbbed8 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ShardingSphereResultSetTest.java
@@ -51,9 +51,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -347,42 +347,42 @@ class ShardingSphereResultSetTest {
void assertGetAsciiStreamWithColumnIndex() throws SQLException {
InputStream inputStream = mock(InputStream.class);
when(mergeResultSet.getInputStream(1, "Ascii")).thenReturn(inputStream);
- assertThat(shardingSphereResultSet.getAsciiStream(1), instanceOf(InputStream.class));
+ assertThat(shardingSphereResultSet.getAsciiStream(1), isA(InputStream.class));
}
@Test
void assertGetAsciiStreamWithColumnLabel() throws SQLException {
InputStream inputStream = mock(InputStream.class);
when(mergeResultSet.getInputStream(1, "Ascii")).thenReturn(inputStream);
- assertThat(shardingSphereResultSet.getAsciiStream("label"), instanceOf(InputStream.class));
+ assertThat(shardingSphereResultSet.getAsciiStream("label"), isA(InputStream.class));
}
@Test
void assertGetUnicodeStreamWithColumnIndex() throws SQLException {
InputStream inputStream = mock(InputStream.class);
when(mergeResultSet.getInputStream(1, "Unicode")).thenReturn(inputStream);
- assertThat(shardingSphereResultSet.getUnicodeStream(1), instanceOf(InputStream.class));
+ assertThat(shardingSphereResultSet.getUnicodeStream(1), isA(InputStream.class));
}
@Test
void assertGetUnicodeStreamWithColumnLabel() throws SQLException {
InputStream inputStream = mock(InputStream.class);
when(mergeResultSet.getInputStream(1, "Unicode")).thenReturn(inputStream);
- assertThat(shardingSphereResultSet.getUnicodeStream("label"), instanceOf(InputStream.class));
+ assertThat(shardingSphereResultSet.getUnicodeStream("label"), isA(InputStream.class));
}
@Test
void assertGetBinaryStreamWithColumnIndex() throws SQLException {
InputStream inputStream = mock(InputStream.class);
when(mergeResultSet.getInputStream(1, "Binary")).thenReturn(inputStream);
- assertThat(shardingSphereResultSet.getBinaryStream(1), instanceOf(InputStream.class));
+ assertThat(shardingSphereResultSet.getBinaryStream(1), isA(InputStream.class));
}
@Test
void assertGetBinaryStreamWithColumnLabel() throws SQLException {
InputStream inputStream = mock(InputStream.class);
when(mergeResultSet.getInputStream(1, "Binary")).thenReturn(inputStream);
- assertThat(shardingSphereResultSet.getBinaryStream("label"), instanceOf(InputStream.class));
+ assertThat(shardingSphereResultSet.getBinaryStream("label"), isA(InputStream.class));
}
@Test
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
index 097f170de53..78cf15f123d 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
@@ -24,8 +24,8 @@ import org.apache.shardingsphere.infra.state.instance.InstanceStateContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,13 +35,13 @@ class DriverStateContextTest {
@Test
void assertGetConnectionWithOkState() {
ContextManager contextManager = mockContextManager(InstanceState.OK);
- assertThat(DriverStateContext.getConnection("foo_db", contextManager), instanceOf(ShardingSphereConnection.class));
+ assertThat(DriverStateContext.getConnection("foo_db", contextManager), isA(ShardingSphereConnection.class));
}
@Test
void assertGetConnectionWithCircuitBreakState() {
ContextManager contextManager = mockContextManager(InstanceState.CIRCUIT_BREAK);
- assertThat(DriverStateContext.getConnection("foo_db", contextManager), instanceOf(CircuitBreakerConnection.class));
+ assertThat(DriverStateContext.getConnection("foo_db", contextManager), isA(CircuitBreakerConnection.class));
}
private ContextManager mockContextManager(final InstanceState instanceState) {
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/CircuitBreakDriverStateTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/CircuitBreakDriverStateTest.java
index 9e634d32c1c..8e0cc42e07e 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/CircuitBreakDriverStateTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/CircuitBreakDriverStateTest.java
@@ -23,8 +23,8 @@ import org.junit.jupiter.api.Test;
import java.sql.Connection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -33,6 +33,6 @@ class CircuitBreakDriverStateTest {
@Test
void assertGetConnection() {
Connection actual = new CircuitBreakDriverState().getConnection("foo_db", mock(ContextManager.class, RETURNS_DEEP_STUBS));
- assertThat(actual, instanceOf(CircuitBreakerConnection.class));
+ assertThat(actual, isA(CircuitBreakerConnection.class));
}
}
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnectionTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnectionTest.java
index 387244d28cb..430c4493083 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnectionTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/connection/CircuitBreakerConnectionTest.java
@@ -26,12 +26,12 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.hamcrest.MatcherAssert.assertThat;
class CircuitBreakerConnectionTest {
@@ -39,7 +39,7 @@ class CircuitBreakerConnectionTest {
@Test
void assertGetMetaData() {
- assertThat(connection.getMetaData(), instanceOf(CircuitBreakerDatabaseMetaData.class));
+ assertThat(connection.getMetaData(), isA(CircuitBreakerDatabaseMetaData.class));
}
@Test
@@ -109,19 +109,19 @@ class CircuitBreakerConnectionTest {
@Test
void assertPrepareStatement() {
String sql = "SELECT 1";
- assertThat(connection.prepareStatement(sql), instanceOf(CircuitBreakerPreparedStatement.class));
- assertThat(connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY), instanceOf(CircuitBreakerPreparedStatement.class));
- assertThat(connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT), instanceOf(CircuitBreakerPreparedStatement.class));
- assertThat(connection.prepareStatement(sql, Statement.NO_GENERATED_KEYS), instanceOf(CircuitBreakerPreparedStatement.class));
- assertThat(connection.prepareStatement(sql, new int[]{0}), instanceOf(CircuitBreakerPreparedStatement.class));
- assertThat(connection.prepareStatement(sql, new String[]{""}), instanceOf(CircuitBreakerPreparedStatement.class));
+ assertThat(connection.prepareStatement(sql), isA(CircuitBreakerPreparedStatement.class));
+ assertThat(connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY), isA(CircuitBreakerPreparedStatement.class));
+ assertThat(connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT), isA(CircuitBreakerPreparedStatement.class));
+ assertThat(connection.prepareStatement(sql, Statement.NO_GENERATED_KEYS), isA(CircuitBreakerPreparedStatement.class));
+ assertThat(connection.prepareStatement(sql, new int[]{0}), isA(CircuitBreakerPreparedStatement.class));
+ assertThat(connection.prepareStatement(sql, new String[]{""}), isA(CircuitBreakerPreparedStatement.class));
}
@Test
void assertCreateStatement() {
- assertThat(connection.createStatement(), instanceOf(CircuitBreakerStatement.class));
- assertThat(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY), instanceOf(CircuitBreakerStatement.class));
- assertThat(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT), instanceOf(CircuitBreakerStatement.class));
+ assertThat(connection.createStatement(), isA(CircuitBreakerStatement.class));
+ assertThat(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY), isA(CircuitBreakerStatement.class));
+ assertThat(connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT), isA(CircuitBreakerStatement.class));
}
@Test
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/datasource/CircuitBreakerDataSourceTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/datasource/CircuitBreakerDataSourceTest.java
index 59989f21a0d..45b6bcfda68 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/datasource/CircuitBreakerDataSourceTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/circuit/datasource/CircuitBreakerDataSourceTest.java
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.driver.state.circuit.datasource;
import org.apache.shardingsphere.driver.state.circuit.connection.CircuitBreakerConnection;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class CircuitBreakerDataSourceTest {
@@ -30,8 +30,8 @@ class CircuitBreakerDataSourceTest {
@Test
void assertGetConnection() {
- assertThat(dataSource.getConnection(), instanceOf(CircuitBreakerConnection.class));
- assertThat(dataSource.getConnection("", ""), instanceOf(CircuitBreakerConnection.class));
+ assertThat(dataSource.getConnection(), isA(CircuitBreakerConnection.class));
+ assertThat(dataSource.getConnection("", ""), isA(CircuitBreakerConnection.class));
}
@Test
diff --git a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
index 597178e7c2c..16807d84409 100644
--- a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
+++ b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
@@ -26,8 +26,8 @@ import org.junit.jupiter.api.Test;
import java.sql.Connection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -39,6 +39,6 @@ class OKDriverStateTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new RuleMetaData(Collections.singleton(mock(TransactionRule.class, RETURNS_DEEP_STUBS))));
Connection actual = new OKDriverState().getConnection("foo_db", contextManager);
- assertThat(actual, instanceOf(ShardingSphereConnection.class));
+ assertThat(actual, isA(ShardingSphereConnection.class));
}
}
diff --git a/kernel/authority/provider/simple/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegeProviderTest.java b/kernel/authority/provider/simple/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegeProviderTest.java
index a17422545e9..d4ccd4c6ad0 100644
--- a/kernel/authority/provider/simple/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegeProviderTest.java
+++ b/kernel/authority/provider/simple/src/test/java/org/apache/shardingsphere/authority/provider/simple/AllPermittedPrivilegeProviderTest.java
@@ -34,8 +34,8 @@ import org.junit.jupiter.params.support.ParameterDeclarations;
import java.util.Collections;
import java.util.stream.Stream;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class AllPermittedPrivilegeProviderTest {
@@ -46,7 +46,7 @@ class AllPermittedPrivilegeProviderTest {
AuthorityRuleConfiguration ruleConfig = new AuthorityRuleConfiguration(
Collections.singleton(new UserConfiguration("root", "", "%", null, false)), mock(AlgorithmConfiguration.class), Collections.emptyMap(), null);
ShardingSpherePrivileges actual = provider.build(ruleConfig, new Grantee("root@%"));
- assertThat(actual, instanceOf(AllPermittedPrivileges.class));
+ assertThat(actual, isA(AllPermittedPrivileges.class));
}
private static final class TestCaseArgumentsProvider implements ArgumentsProvider {
diff --git a/kernel/data-pipeline/api/src/test/java/org/apache/shardingsphere/data/pipeline/api/type/ShardingSpherePipelineDataSourceConfigurationTest.java b/kernel/data-pipeline/api/src/test/java/org/apache/shardingsphere/data/pipeline/api/type/ShardingSpherePipelineDataSourceConfigurationTest.java
index 84b63c9cbdc..70b764d7159 100644
--- a/kernel/data-pipeline/api/src/test/java/org/apache/shardingsphere/data/pipeline/api/type/ShardingSpherePipelineDataSourceConfigurationTest.java
+++ b/kernel/data-pipeline/api/src/test/java/org/apache/shardingsphere/data/pipeline/api/type/ShardingSpherePipelineDataSourceConfigurationTest.java
@@ -35,9 +35,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
@@ -74,7 +74,7 @@ class ShardingSpherePipelineDataSourceConfigurationTest {
private void assertPipelineDataSourceConfiguration(final ShardingSpherePipelineDataSourceConfiguration actual) {
assertThat(actual.getDatabaseType().getType(), is("FIXTURE"));
assertThat(actual.getType(), is(ShardingSpherePipelineDataSourceConfiguration.TYPE));
- assertThat(actual.getDataSourceConfiguration(), instanceOf(YamlRootConfiguration.class));
+ assertThat(actual.getDataSourceConfiguration(), isA(YamlRootConfiguration.class));
Map<String, Map<String, Object>> dataSources = actual.getRootConfig().getDataSources();
assertThat(dataSources.size(), is(2));
assertTrue(dataSources.containsKey("ds_0"));
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/IncrementalChannelCreatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/IncrementalChannelCreatorTest.java
index 67418aee57d..f427ee86c85 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/IncrementalChannelCreatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/IncrementalChannelCreatorTest.java
@@ -24,14 +24,14 @@ import org.junit.jupiter.api.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class IncrementalChannelCreatorTest {
@Test
void assertCreate() {
- assertThat(IncrementalChannelCreator.create(new AlgorithmConfiguration("MEMORY", new Properties()), mock(IncrementalTaskProgress.class)), instanceOf(MemoryPipelineChannel.class));
+ assertThat(IncrementalChannelCreator.create(new AlgorithmConfiguration("MEMORY", new Properties()), mock(IncrementalTaskProgress.class)), isA(MemoryPipelineChannel.class));
}
}
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/InventoryChannelCreatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/InventoryChannelCreatorTest.java
index 89eabe3604c..56a11c85fc7 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/InventoryChannelCreatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/InventoryChannelCreatorTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class InventoryChannelCreatorTest {
@@ -34,6 +34,6 @@ class InventoryChannelCreatorTest {
@Test
void assertCreate() {
assertThat(InventoryChannelCreator.create(new AlgorithmConfiguration("MEMORY", new Properties()), 1, new AtomicReference<>(mock(IngestPosition.class))),
- instanceOf(MemoryPipelineChannel.class));
+ isA(MemoryPipelineChannel.class));
}
}
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannelCreatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannelCreatorTest.java
index bd0110475dd..a66e4b70f05 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannelCreatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/channel/memory/MemoryPipelineChannelCreatorTest.java
@@ -30,9 +30,9 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.atomic.AtomicReference;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class MemoryPipelineChannelCreatorTest {
@@ -41,7 +41,7 @@ class MemoryPipelineChannelCreatorTest {
PipelineChannelCreator creator = TypedSPILoader.getService(PipelineChannelCreator.class, "MEMORY", PropertiesBuilder.build(new Property("block-queue-size", "2000")));
assertThat(Plugins.getMemberAccessor().get(MemoryPipelineChannelCreator.class.getDeclaredField("queueSize"), creator), is(2000));
PipelineChannel channel = creator.newInstance(1000, new InventoryTaskAckCallback(new AtomicReference<>()));
- assertThat(Plugins.getMemberAccessor().get(MemoryPipelineChannel.class.getDeclaredField("queue"), channel), instanceOf(ArrayBlockingQueue.class));
+ assertThat(Plugins.getMemberAccessor().get(MemoryPipelineChannel.class.getDeclaredField("queue"), channel), isA(ArrayBlockingQueue.class));
}
@Test
@@ -49,7 +49,7 @@ class MemoryPipelineChannelCreatorTest {
PipelineChannelCreator creator = TypedSPILoader.getService(PipelineChannelCreator.class, "MEMORY", PropertiesBuilder.build(new Property("block-queue-size", "0")));
assertThat(Plugins.getMemberAccessor().get(MemoryPipelineChannelCreator.class.getDeclaredField("queueSize"), creator), is(0));
PipelineChannel channel = creator.newInstance(1000, new InventoryTaskAckCallback(new AtomicReference<>()));
- assertThat(Plugins.getMemberAccessor().get(MemoryPipelineChannel.class.getDeclaredField("queue"), channel), instanceOf(SynchronousQueue.class));
+ assertThat(Plugins.getMemberAccessor().get(MemoryPipelineChannel.class.getDeclaredField("queue"), channel), isA(SynchronousQueue.class));
}
@Test
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/TableDataConsistencyCheckerFactoryTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/TableDataConsistencyCheckerFactoryTest.java
index dc261ac84a0..fc130ab23bb 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/TableDataConsistencyCheckerFactoryTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/TableDataConsistencyCheckerFactoryTest.java
@@ -21,17 +21,17 @@ import org.junit.jupiter.api.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class TableDataConsistencyCheckerFactoryTest {
@Test
void assertNewInstanceTypeMatched() {
- assertThat(TableDataConsistencyCheckerFactory.newInstance(null, new Properties()), instanceOf(DataMatchTableDataConsistencyChecker.class));
- assertThat(TableDataConsistencyCheckerFactory.newInstance("DATA_MATCH", new Properties()), instanceOf(DataMatchTableDataConsistencyChecker.class));
- assertThat(TableDataConsistencyCheckerFactory.newInstance("CRC32_MATCH", new Properties()), instanceOf(CRC32MatchTableDataConsistencyChecker.class));
+ assertThat(TableDataConsistencyCheckerFactory.newInstance(null, new Properties()), isA(DataMatchTableDataConsistencyChecker.class));
+ assertThat(TableDataConsistencyCheckerFactory.newInstance("DATA_MATCH", new Properties()), isA(DataMatchTableDataConsistencyChecker.class));
+ assertThat(TableDataConsistencyCheckerFactory.newInstance("CRC32_MATCH", new Properties()), isA(CRC32MatchTableDataConsistencyChecker.class));
}
@Test
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/config/PipelineDataSourceConfigurationFactoryTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/config/PipelineDataSourceConfigurationFactoryTest.java
index e385ae31ef7..0ded7d251c7 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/config/PipelineDataSourceConfigurationFactoryTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/config/PipelineDataSourceConfigurationFactoryTest.java
@@ -22,8 +22,8 @@ import org.apache.shardingsphere.data.pipeline.api.type.StandardPipelineDataSour
import org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class PipelineDataSourceConfigurationFactoryTest {
@@ -31,13 +31,13 @@ class PipelineDataSourceConfigurationFactoryTest {
@Test
void assertNewInstanceForStandardPipelineDataSourceConfiguration() {
assertThat(PipelineDataSourceConfigurationFactory.newInstance(StandardPipelineDataSourceConfiguration.TYPE, "url: jdbc:mock://127.0.0.1/foo_db"),
- instanceOf(StandardPipelineDataSourceConfiguration.class));
+ isA(StandardPipelineDataSourceConfiguration.class));
}
@Test
void assertNewInstanceForShardingSpherePipelineDataSourceConfiguration() {
assertThat(PipelineDataSourceConfigurationFactory.newInstance(ShardingSpherePipelineDataSourceConfiguration.TYPE, "dataSources:\n" + " foo_ds:\n" + " url: jdbc:mock://127.0.0.1/foo_db"),
- instanceOf(ShardingSpherePipelineDataSourceConfiguration.class));
+ isA(ShardingSpherePipelineDataSourceConfiguration.class));
}
@Test
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/PlaceholderInventoryDataRecordPositionCreatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/PlaceholderInventoryDataRecordPositionCreatorTest.java
index 68d970f4a1c..76bf6d18131 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/PlaceholderInventoryDataRecordPositionCreatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/PlaceholderInventoryDataRecordPositionCreatorTest.java
@@ -23,14 +23,14 @@ import org.junit.jupiter.api.Test;
import java.sql.ResultSet;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class PlaceholderInventoryDataRecordPositionCreatorTest {
@Test
void assertCreate() {
- assertThat(new PlaceholderInventoryDataRecordPositionCreator().create(mock(InventoryDumperContext.class), mock(ResultSet.class)), instanceOf(IngestPlaceholderPosition.class));
+ assertThat(new PlaceholderInventoryDataRecordPositionCreator().create(mock(InventoryDumperContext.class), mock(ResultSet.class)), isA(IngestPlaceholderPosition.class));
}
}
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/UniqueKeyInventoryDataRecordPositionCreatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/UniqueKeyInventoryDataRecordPositionCreatorTest.java
index 2f3e4994af0..eb3a7753c17 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/UniqueKeyInventoryDataRecordPositionCreatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/dumper/inventory/position/type/UniqueKeyInventoryDataRecordPositionCreatorTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
import java.sql.ResultSet;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,7 +35,7 @@ class UniqueKeyInventoryDataRecordPositionCreatorTest {
@Test
void assertCreate() throws SQLException {
- assertThat(new UniqueKeyInventoryDataRecordPositionCreator().create(mockInventoryDumperContext(), mock(ResultSet.class)), instanceOf(UnsupportedKeyIngestPosition.class));
+ assertThat(new UniqueKeyInventoryDataRecordPositionCreator().create(mockInventoryDumperContext(), mock(ResultSet.class)), isA(UnsupportedKeyIngestPosition.class));
}
@SuppressWarnings("unchecked")
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java
index 1a6d2eda951..f202cc8b5dd 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/progress/TransmissionJobItemProgressTest.java
@@ -35,9 +35,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -59,16 +59,16 @@ class TransmissionJobItemProgressTest {
TransmissionJobItemProgress actual = getJobItemProgress(SystemResourceFileUtils.readFile("job-progress.yaml"));
Optional<IngestPosition> position = actual.getIncremental().getIncrementalPosition();
assertTrue(position.isPresent());
- assertThat(position.get(), instanceOf(IngestPlaceholderPosition.class));
+ assertThat(position.get(), isA(IngestPlaceholderPosition.class));
}
@Test
void assertGetInventoryPosition() {
TransmissionJobItemProgress actual = getJobItemProgress(SystemResourceFileUtils.readFile("job-progress.yaml"));
- assertThat(actual.getInventory().getInventoryPosition("t_1").get("ds0.t_1#1"), instanceOf(IngestFinishedPosition.class));
- assertThat(actual.getInventory().getInventoryPosition("t_1").get("ds1.t_1#1"), instanceOf(IngestPlaceholderPosition.class));
- assertThat(actual.getInventory().getInventoryPosition("t_2").get("ds0.t_2#2"), instanceOf(IngestFinishedPosition.class));
- assertThat(actual.getInventory().getInventoryPosition("t_2").get("ds1.t_2#2"), instanceOf(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(actual.getInventory().getInventoryPosition("t_1").get("ds0.t_1#1"), isA(IngestFinishedPosition.class));
+ assertThat(actual.getInventory().getInventoryPosition("t_1").get("ds1.t_1#1"), isA(IngestPlaceholderPosition.class));
+ assertThat(actual.getInventory().getInventoryPosition("t_2").get("ds0.t_2#2"), isA(IngestFinishedPosition.class));
+ assertThat(actual.getInventory().getInventoryPosition("t_2").get("ds1.t_2#2"), isA(IntegerPrimaryKeyIngestPosition.class));
}
@Test
@@ -91,14 +91,14 @@ class TransmissionJobItemProgressTest {
JobItemInventoryTasksProgress progress = new JobItemInventoryTasksProgress(progresses);
Map<String, IngestPosition> orderPosition = progress.getInventoryPosition("order");
assertThat(orderPosition.size(), is(1));
- assertThat(orderPosition.get("ds.order#0"), instanceOf(IngestFinishedPosition.class));
+ assertThat(orderPosition.get("ds.order#0"), isA(IngestFinishedPosition.class));
Map<String, IngestPosition> testOrderPosition = progress.getInventoryPosition("test_order");
assertThat(testOrderPosition.size(), is(1));
- assertThat(testOrderPosition.get("ds.test_order#0"), instanceOf(StringPrimaryKeyIngestPosition.class));
+ assertThat(testOrderPosition.get("ds.test_order#0"), isA(StringPrimaryKeyIngestPosition.class));
Map<String, IngestPosition> orderItemPosition = progress.getInventoryPosition("order_item");
assertThat(orderItemPosition.size(), is(2));
- assertThat(orderItemPosition.get("ds.order_item#0"), instanceOf(IntegerPrimaryKeyIngestPosition.class));
- assertThat(orderItemPosition.get("ds.order_item#1"), instanceOf(UnsupportedKeyIngestPosition.class));
+ assertThat(orderItemPosition.get("ds.order_item#0"), isA(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(orderItemPosition.get("ds.order_item#1"), isA(UnsupportedKeyIngestPosition.class));
}
private TransmissionJobItemProgress getJobItemProgress(final String data) {
diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryPositionCalculatorTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryPositionCalculatorTest.java
index 0e35d67d988..71899740fd8 100644
--- a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryPositionCalculatorTest.java
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/preparer/inventory/calculator/InventoryPositionCalculatorTest.java
@@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class InventoryPositionCalculatorTest {
@@ -35,7 +35,7 @@ class InventoryPositionCalculatorTest {
List<IngestPosition> actualPositions = (List<IngestPosition>) InventoryPositionCalculator.getPositionByIntegerUniqueKeyRange(200L, Range.between(1L, 600L), 100L);
assertThat(actualPositions.size(), is(2));
for (IngestPosition each : actualPositions) {
- assertThat(each, instanceOf(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(each, isA(IntegerPrimaryKeyIngestPosition.class));
}
assertPosition(new IntegerPrimaryKeyIngestPosition(1L, 300L), (IntegerPrimaryKeyIngestPosition) actualPositions.get(0));
assertPosition(new IntegerPrimaryKeyIngestPosition(301L, 600L), (IntegerPrimaryKeyIngestPosition) actualPositions.get(1));
@@ -50,7 +50,7 @@ class InventoryPositionCalculatorTest {
void assertGetPositionByIntegerUniqueKeyRangeWithZeroTotalRecordsCount() {
List<IngestPosition> actualPositions = (List<IngestPosition>) InventoryPositionCalculator.getPositionByIntegerUniqueKeyRange(0L, Range.between(0L, 0L), 1L);
assertThat(actualPositions.size(), is(1));
- assertThat(actualPositions.get(0), instanceOf(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(actualPositions.get(0), isA(IntegerPrimaryKeyIngestPosition.class));
assertPosition(new IntegerPrimaryKeyIngestPosition(0L, 0L), (IntegerPrimaryKeyIngestPosition) actualPositions.get(0));
}
@@ -58,7 +58,7 @@ class InventoryPositionCalculatorTest {
void assertGetPositionByIntegerUniqueKeyRangeWithTheSameMinMax() {
List<IngestPosition> actualPositions = (List<IngestPosition>) InventoryPositionCalculator.getPositionByIntegerUniqueKeyRange(200L, Range.between(5L, 5L), 100L);
assertThat(actualPositions.size(), is(1));
- assertThat(actualPositions.get(0), instanceOf(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(actualPositions.get(0), isA(IntegerPrimaryKeyIngestPosition.class));
assertPosition(new IntegerPrimaryKeyIngestPosition(5L, 5L), (IntegerPrimaryKeyIngestPosition) actualPositions.get(0));
}
@@ -72,7 +72,7 @@ class InventoryPositionCalculatorTest {
tableRecordsCount, Range.between(minimum, maximum), shardingSize);
assertThat(actualPositions.size(), is(2));
for (IngestPosition each : actualPositions) {
- assertThat(each, instanceOf(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(each, isA(IntegerPrimaryKeyIngestPosition.class));
}
assertPosition(new IntegerPrimaryKeyIngestPosition(minimum, 0L), (IntegerPrimaryKeyIngestPosition) actualPositions.get(0));
assertPosition(new IntegerPrimaryKeyIngestPosition(1L, maximum), (IntegerPrimaryKeyIngestPosition) actualPositions.get(1));
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/datasource/MySQLJdbcQueryPropertiesExtensionTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/datasource/MySQLJdbcQueryPropertiesExtensionTest.java
index abec4e7ecd5..15f1758534a 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/datasource/MySQLJdbcQueryPropertiesExtensionTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/datasource/MySQLJdbcQueryPropertiesExtensionTest.java
@@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
class MySQLJdbcQueryPropertiesExtensionTest {
@@ -48,7 +48,7 @@ class MySQLJdbcQueryPropertiesExtensionTest {
}
private void assertExtension(final JdbcQueryPropertiesExtension actual) {
- assertThat(actual, instanceOf(MySQLJdbcQueryPropertiesExtension.class));
+ assertThat(actual, isA(MySQLJdbcQueryPropertiesExtension.class));
assertThat(actual.getType(), is(TypedSPILoader.getService(DatabaseType.class, "MySQL")));
}
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLBinlogEventPacketDecoderTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLBinlogEventPacketDecoderTest.java
index bfc9f2e9dfc..b7f46e303a8 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLBinlogEventPacketDecoderTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLBinlogEventPacketDecoderTest.java
@@ -48,9 +48,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.junit.jupiter.api.Assertions.assertTrue;
@@ -120,7 +120,7 @@ class MySQLBinlogEventPacketDecoderTest {
binlogEventPacketDecoder.decode(channelHandlerContext, byteBuf, decodedEvents);
assertFalse(decodedEvents.isEmpty());
Object actual = decodedEvents.get(0);
- assertThat(actual, instanceOf(MySQLQueryBinlogEvent.class));
+ assertThat(actual, isA(MySQLQueryBinlogEvent.class));
assertThat(((MySQLQueryBinlogEvent) actual).getTimestamp(), is(1700193011L));
assertThat(((MySQLQueryBinlogEvent) actual).getPosition(), is(168785090L));
}
@@ -134,7 +134,7 @@ class MySQLBinlogEventPacketDecoderTest {
List<Object> decodedEvents = new LinkedList<>();
binlogEventPacketDecoder.decode(channelHandlerContext, byteBuf, decodedEvents);
assertThat(binlogContext.getTableMap().size(), is(1));
- assertThat(binlogContext.getTableMap().get(123L), instanceOf(MySQLBinlogTableMapEventPacket.class));
+ assertThat(binlogContext.getTableMap().get(123L), isA(MySQLBinlogTableMapEventPacket.class));
}
@Test
@@ -149,7 +149,7 @@ class MySQLBinlogEventPacketDecoderTest {
binlogEventPacketDecoder.decode(channelHandlerContext, byteBuf, decodedEvents);
assertThat(decodedEvents.size(), is(1));
LinkedList<?> actualEventList = (LinkedList<?>) decodedEvents.get(0);
- assertThat(actualEventList.get(0), instanceOf(MySQLWriteRowsBinlogEvent.class));
+ assertThat(actualEventList.get(0), isA(MySQLWriteRowsBinlogEvent.class));
MySQLWriteRowsBinlogEvent actual = (MySQLWriteRowsBinlogEvent) actualEventList.get(0);
assertThat(actual.getAfterRows().get(0), is(new Serializable[]{1L, 1, new MySQLBinaryString("SUCCESS".getBytes()), null}));
}
@@ -167,7 +167,7 @@ class MySQLBinlogEventPacketDecoderTest {
binlogEventPacketDecoder.decode(channelHandlerContext, byteBuf, decodedEvents);
assertThat(decodedEvents.size(), is(1));
LinkedList<?> actualEventList = (LinkedList<?>) decodedEvents.get(0);
- assertThat(actualEventList.get(0), instanceOf(MySQLUpdateRowsBinlogEvent.class));
+ assertThat(actualEventList.get(0), isA(MySQLUpdateRowsBinlogEvent.class));
MySQLUpdateRowsBinlogEvent actual = (MySQLUpdateRowsBinlogEvent) actualEventList.get(0);
assertThat(actual.getBeforeRows().get(0), is(new Serializable[]{1L, 1, new MySQLBinaryString("SUCCESS".getBytes()), null}));
assertThat(actual.getAfterRows().get(0), is(new Serializable[]{1L, 1, new MySQLBinaryString("updated".getBytes()), null}));
@@ -185,8 +185,8 @@ class MySQLBinlogEventPacketDecoderTest {
binlogEventPacketDecoder.decode(channelHandlerContext, byteBuf, decodedEvents);
assertThat(decodedEvents.size(), is(1));
LinkedList<?> actualEventList = (LinkedList<?>) decodedEvents.get(0);
- assertThat(actualEventList.get(0), instanceOf(MySQLDeleteRowsBinlogEvent.class));
- assertThat(actualEventList.get(1), instanceOf(MySQLXidBinlogEvent.class));
+ assertThat(actualEventList.get(0), isA(MySQLDeleteRowsBinlogEvent.class));
+ assertThat(actualEventList.get(1), isA(MySQLXidBinlogEvent.class));
MySQLDeleteRowsBinlogEvent actual = (MySQLDeleteRowsBinlogEvent) actualEventList.get(0);
assertThat(actual.getBeforeRows().get(0), is(new Serializable[]{1L, 1, new MySQLBinaryString("SUCCESS".getBytes()), null}));
}
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLCommandPacketDecoderTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLCommandPacketDecoderTest.java
index cdc5bd90e17..9af50c8b849 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLCommandPacketDecoderTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLCommandPacketDecoderTest.java
@@ -35,9 +35,9 @@ import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -118,6 +118,6 @@ class MySQLCommandPacketDecoderTest {
private void assertPacketByType(final List<Object> actual, final Class<?> clazz) {
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(clazz));
+ assertThat(actual.get(0), isA(clazz));
}
}
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiatePackageDecoderTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiatePackageDecoderTest.java
index 4db6864acaa..b3215553d0c 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiatePackageDecoderTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/client/netty/MySQLNegotiatePackageDecoderTest.java
@@ -37,9 +37,9 @@ import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
@@ -82,7 +82,7 @@ class MySQLNegotiatePackageDecoderTest {
private void assertHandshakePacket(final List<Object> actual) {
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(MySQLHandshakePacket.class));
+ assertThat(actual.get(0), isA(MySQLHandshakePacket.class));
MySQLHandshakePacket actualPacket = (MySQLHandshakePacket) actual.get(0);
assertThat(actualPacket.getProtocolVersion(), is(0x0a));
assertThat(actualPacket.getServerVersion(), is("5.7.21-log"));
@@ -127,6 +127,6 @@ class MySQLNegotiatePackageDecoderTest {
private void assertPacketByType(final List<Object> actual, final Class<?> clazz) {
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(clazz));
+ assertThat(actual.get(0), isA(clazz));
}
}
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperCreatorTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperCreatorTest.java
index ca5a689d7fa..1cf752de77f 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperCreatorTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperCreatorTest.java
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,6 +47,6 @@ class MySQLIncrementalDumperCreatorTest {
when(dumperContext.getCommonContext().getDataSourceConfig()).thenReturn(new StandardPipelineDataSourceConfiguration(Collections.singletonMap("url", "jdbc:mock://127.0.0.1/foo_ds")));
MySQLBinlogPosition position = mock(MySQLBinlogPosition.class, RETURNS_DEEP_STUBS);
CreateIncrementalDumperParameter param = new CreateIncrementalDumperParameter(dumperContext, position, null, null, null);
- assertThat(creator.create(param), instanceOf(MySQLIncrementalDumper.class));
+ assertThat(creator.create(param), isA(MySQLIncrementalDumper.class));
}
}
diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperTest.java
index 48d8d7a2afe..df899c688ab 100644
--- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperTest.java
+++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/dumper/MySQLIncrementalDumperTest.java
@@ -62,9 +62,9 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -136,7 +136,7 @@ class MySQLIncrementalDumperTest {
void assertWriteRowsEvent() throws ReflectiveOperationException {
List<Record> actual = getRecordsByWriteRowsEvent(new MySQLWriteRowsBinlogEvent("", 0, 0L, "", "t_order", Collections.singletonList(new Serializable[]{101, 1, "OK"})));
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(DataRecord.class));
+ assertThat(actual.get(0), isA(DataRecord.class));
assertThat(((DataRecord) actual.get(0)).getType(), is(PipelineSQLOperationType.INSERT));
assertThat(((DataRecord) actual.get(0)).getColumnCount(), is(3));
}
@@ -151,7 +151,7 @@ class MySQLIncrementalDumperTest {
List<Record> actual = getRecordsByUpdateRowsEvent(new MySQLUpdateRowsBinlogEvent(
"", 0, 0L, "test", "t_order", Collections.singletonList(new Serializable[]{101, 1, "OK"}), Collections.singletonList(new Serializable[]{101, 1, "OK2"})));
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(DataRecord.class));
+ assertThat(actual.get(0), isA(DataRecord.class));
assertThat(((DataRecord) actual.get(0)).getType(), is(PipelineSQLOperationType.UPDATE));
assertThat(((DataRecord) actual.get(0)).getColumnCount(), is(3));
}
@@ -165,7 +165,7 @@ class MySQLIncrementalDumperTest {
void assertDeleteRowsEvent() throws ReflectiveOperationException {
List<Record> actual = getRecordsByDeleteRowsEvent(new MySQLDeleteRowsBinlogEvent("", 0, 0L, "", "t_order", Collections.singletonList(new Serializable[]{101, 1, "OK"})));
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(DataRecord.class));
+ assertThat(actual.get(0), isA(DataRecord.class));
assertThat(((DataRecord) actual.get(0)).getType(), is(PipelineSQLOperationType.DELETE));
assertThat(((DataRecord) actual.get(0)).getColumnCount(), is(3));
}
@@ -187,6 +187,6 @@ class MySQLIncrementalDumperTest {
List<Record> actual = (List<Record>) Plugins.getMemberAccessor().invoke(MySQLIncrementalDumper.class.getDeclaredMethod("handleEvent", MySQLBaseBinlogEvent.class),
incrementalDumper, new MySQLWriteRowsBinlogEvent("", 0, 0L, "test", "t_order", Collections.singletonList(new Serializable[]{1})));
assertThat(actual.size(), is(1));
- assertThat(actual.get(0), instanceOf(DataRecord.class));
+ assertThat(actual.get(0), isA(DataRecord.class));
}
}
diff --git a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/datasource/OpenGaussJdbcQueryPropertiesExtensionTest.java b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/datasource/OpenGaussJdbcQueryPropertiesExtensionTest.java
index 0777a5fc6a0..dd5db36fa81 100644
--- a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/datasource/OpenGaussJdbcQueryPropertiesExtensionTest.java
+++ b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/datasource/OpenGaussJdbcQueryPropertiesExtensionTest.java
@@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
class OpenGaussJdbcQueryPropertiesExtensionTest {
@@ -41,7 +41,7 @@ class OpenGaussJdbcQueryPropertiesExtensionTest {
}
private void assertExtension(final JdbcQueryPropertiesExtension actual) {
- assertThat(actual, instanceOf(OpenGaussJdbcQueryPropertiesExtension.class));
+ assertThat(actual, isA(OpenGaussJdbcQueryPropertiesExtension.class));
assertThat(actual.getType(), is(TypedSPILoader.getService(DatabaseType.class, "openGauss")));
Properties props = new Properties();
actual.extendQueryProperties(props);
diff --git a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/dumper/OpenGaussIncrementalDumperCreatorTest.java b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/dumper/OpenGaussIncrementalDumperCreatorTest.java
index 6a1404f6bad..c87c012d69c 100644
--- a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/dumper/OpenGaussIncrementalDumperCreatorTest.java
+++ b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/dumper/OpenGaussIncrementalDumperCreatorTest.java
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,6 +47,6 @@ class OpenGaussIncrementalDumperCreatorTest {
when(dumperContext.getCommonContext().getDataSourceConfig()).thenReturn(new StandardPipelineDataSourceConfiguration(Collections.singletonMap("url", "jdbc:mock://127.0.0.1/foo_ds")));
WALPosition position = mock(WALPosition.class, RETURNS_DEEP_STUBS);
CreateIncrementalDumperParameter param = new CreateIncrementalDumperParameter(dumperContext, position, null, null, null);
- assertThat(creator.create(param), instanceOf(OpenGaussIncrementalDumper.class));
+ assertThat(creator.create(param), isA(OpenGaussIncrementalDumper.class));
}
}
diff --git a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java
index 5920cc52511..3a343cdd362 100644
--- a/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java
+++ b/kernel/data-pipeline/dialect/opengauss/src/test/java/org/apache/shardingsphere/data/pipeline/opengauss/ingest/incremental/wal/decode/MppdbDecodingPluginTest.java
@@ -41,9 +41,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.stream.IntStream;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
@@ -172,7 +172,7 @@ class MppdbDecodingPluginTest {
assertThat(actual.getLogSequenceNumber(), is(logSequenceNumber));
assertThat(actual.getTableName(), is("test"));
Object byteaObj = actual.getAfterRow().get(0);
- assertThat(byteaObj, instanceOf(byte[].class));
+ assertThat(byteaObj, isA(byte[].class));
assertThat(byteaObj, is(new byte[]{(byte) 0xff, (byte) 0, (byte) 0xab}));
}
@@ -189,14 +189,14 @@ class MppdbDecodingPluginTest {
assertThat(actual.getLogSequenceNumber(), is(logSequenceNumber));
assertThat(actual.getTableName(), is("test"));
Object byteaObj = actual.getAfterRow().get(0);
- assertThat(byteaObj, instanceOf(PGobject.class));
+ assertThat(byteaObj, isA(PGobject.class));
assertThat(byteaObj.toString(), is("7D"));
}
@Test
void assertDecodeUnknownTableType() {
ByteBuffer data = ByteBuffer.wrap("unknown".getBytes());
- assertThat(new MppdbDecodingPlugin(null, false, false).decode(data, logSequenceNumber), instanceOf(PlaceholderEvent.class));
+ assertThat(new MppdbDecodingPlugin(null, false, false).decode(data, logSequenceNumber), isA(PlaceholderEvent.class));
}
@Test
@@ -242,9 +242,9 @@ class MppdbDecodingPluginTest {
}
assertThat(expectedEvent.size(), is(4));
AbstractWALEvent actualFirstEvent = expectedEvent.get(0);
- assertThat(actualFirstEvent, instanceOf(BeginTXEvent.class));
+ assertThat(actualFirstEvent, isA(BeginTXEvent.class));
AbstractWALEvent actualLastEvent = expectedEvent.get(expectedEvent.size() - 1);
- assertThat(actualLastEvent, instanceOf(CommitTXEvent.class));
+ assertThat(actualLastEvent, isA(CommitTXEvent.class));
assertThat(((CommitTXEvent) actualLastEvent).getCsn(), is(3468L));
assertThat(((CommitTXEvent) actualLastEvent).getXid(), is(1L));
}
@@ -264,7 +264,7 @@ class MppdbDecodingPluginTest {
actual.add(mppdbDecodingPlugin.decode(ByteBuffer.wrap(each.getBytes()), logSequenceNumber));
}
assertThat(actual.size(), is(4));
- assertThat(actual.get(0), instanceOf(BeginTXEvent.class));
+ assertThat(actual.get(0), isA(BeginTXEvent.class));
assertThat(((BeginTXEvent) actual.get(0)).getCsn(), is(951909L));
assertThat(((WriteRowEvent) actual.get(1)).getAfterRow().get(0).toString(), is("7D"));
assertThat(((WriteRowEvent) actual.get(2)).getAfterRow().get(0).toString(), is("7D"));
@@ -283,7 +283,7 @@ class MppdbDecodingPluginTest {
ByteBuffer data = ByteBuffer.wrap(JsonUtils.toJsonString(tableData).getBytes());
WriteRowEvent actual = (WriteRowEvent) new MppdbDecodingPlugin(null, false, false).decode(data, logSequenceNumber);
Object byteaObj = actual.getAfterRow().get(0);
- assertThat(byteaObj, instanceOf(PGobject.class));
+ assertThat(byteaObj, isA(PGobject.class));
assertThat(byteaObj.toString(), is("[\"2020-01-01 00:00:00\",\"2021-01-01 00:00:00\")"));
}
@@ -298,7 +298,7 @@ class MppdbDecodingPluginTest {
ByteBuffer data = ByteBuffer.wrap(JsonUtils.toJsonString(tableData).getBytes());
WriteRowEvent actual = (WriteRowEvent) new MppdbDecodingPlugin(null, false, false).decode(data, logSequenceNumber);
Object byteaObj = actual.getAfterRow().get(0);
- assertThat(byteaObj, instanceOf(PGobject.class));
+ assertThat(byteaObj, isA(PGobject.class));
assertThat(byteaObj.toString(), is("[2020-01-02,2021-01-02)"));
}
diff --git a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/datasource/PostgreSQLJdbcQueryPropertiesExtensionTest.java b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/datasource/PostgreSQLJdbcQueryPropertiesExtensionTest.java
index 79b7ad0d994..a02c3a15d92 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/datasource/PostgreSQLJdbcQueryPropertiesExtensionTest.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/datasource/PostgreSQLJdbcQueryPropertiesExtensionTest.java
@@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -42,7 +42,7 @@ class PostgreSQLJdbcQueryPropertiesExtensionTest {
}
private void assertExtension(final JdbcQueryPropertiesExtension actual) {
- assertThat(actual, instanceOf(PostgreSQLJdbcQueryPropertiesExtension.class));
+ assertThat(actual, isA(PostgreSQLJdbcQueryPropertiesExtension.class));
assertThat(actual.getType(), is(TypedSPILoader.getService(DatabaseType.class, "PostgreSQL")));
Properties props = new Properties();
actual.extendQueryProperties(props);
diff --git a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/dumper/PostgreSQLIncrementalDumperCreatorTest.java b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/dumper/PostgreSQLIncrementalDumperCreatorTest.java
index 3374aa4da30..d2f31078f6b 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/dumper/PostgreSQLIncrementalDumperCreatorTest.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/dumper/PostgreSQLIncrementalDumperCreatorTest.java
@@ -29,8 +29,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,6 +47,6 @@ class PostgreSQLIncrementalDumperCreatorTest {
when(dumperContext.getCommonContext().getDataSourceConfig()).thenReturn(new StandardPipelineDataSourceConfiguration(Collections.singletonMap("url", "jdbc:mock://127.0.0.1/foo_ds")));
WALPosition position = mock(WALPosition.class, RETURNS_DEEP_STUBS);
CreateIncrementalDumperParameter param = new CreateIncrementalDumperParameter(dumperContext, position, null, null, null);
- assertThat(creator.create(param), instanceOf(PostgreSQLIncrementalDumper.class));
+ assertThat(creator.create(param), isA(PostgreSQLIncrementalDumper.class));
}
}
diff --git a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/WALEventConverterTest.java b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/WALEventConverterTest.java
index ed615d01024..8caa1c6403f 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/WALEventConverterTest.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/WALEventConverterTest.java
@@ -61,9 +61,9 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class WALEventConverterTest {
@@ -151,7 +151,7 @@ class WALEventConverterTest {
BeginTXEvent beginTXEvent = new BeginTXEvent(100L, null);
beginTXEvent.setLogSequenceNumber(new PostgreSQLLogSequenceNumber(logSequenceNumber));
Record record = walEventConverter.convert(beginTXEvent);
- assertThat(record, instanceOf(PlaceholderRecord.class));
+ assertThat(record, isA(PlaceholderRecord.class));
assertThat(((WALPosition) record.getPosition()).getLogSequenceNumber().asString(), is(logSequenceNumber.asString()));
}
@@ -160,40 +160,40 @@ class WALEventConverterTest {
CommitTXEvent commitTXEvent = new CommitTXEvent(1L, 3468L);
commitTXEvent.setLogSequenceNumber(new PostgreSQLLogSequenceNumber(logSequenceNumber));
Record record = walEventConverter.convert(commitTXEvent);
- assertThat(record, instanceOf(PlaceholderRecord.class));
+ assertThat(record, isA(PlaceholderRecord.class));
assertThat(((WALPosition) record.getPosition()).getLogSequenceNumber().asString(), is(logSequenceNumber.asString()));
}
@Test
void assertConvertWriteRowEvent() {
Record record = walEventConverter.convert(mockWriteRowEvent());
- assertThat(record, instanceOf(DataRecord.class));
+ assertThat(record, isA(DataRecord.class));
assertThat(((DataRecord) record).getType(), is(PipelineSQLOperationType.INSERT));
}
@Test
void assertConvertUpdateRowEvent() {
Record record = walEventConverter.convert(mockUpdateRowEvent());
- assertThat(record, instanceOf(DataRecord.class));
+ assertThat(record, isA(DataRecord.class));
assertThat(((DataRecord) record).getType(), is(PipelineSQLOperationType.UPDATE));
}
@Test
void assertConvertDeleteRowEvent() {
Record record = walEventConverter.convert(mockDeleteRowEvent());
- assertThat(record, instanceOf(DataRecord.class));
+ assertThat(record, isA(DataRecord.class));
assertThat(((DataRecord) record).getType(), is(PipelineSQLOperationType.DELETE));
}
@Test
void assertConvertPlaceholderEvent() {
Record record = walEventConverter.convert(new PlaceholderEvent());
- assertThat(record, instanceOf(PlaceholderRecord.class));
+ assertThat(record, isA(PlaceholderRecord.class));
}
@Test
void assertUnknownTable() {
- assertThat(walEventConverter.convert(mockUnknownTableEvent()), instanceOf(PlaceholderRecord.class));
+ assertThat(walEventConverter.convert(mockUnknownTableEvent()), isA(PlaceholderRecord.class));
}
@Test
diff --git a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/decode/TestDecodingPluginTest.java b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/decode/TestDecodingPluginTest.java
index 84a0b06ef35..ec3dbf692f1 100644
--- a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/decode/TestDecodingPluginTest.java
+++ b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/incremental/wal/decode/TestDecodingPluginTest.java
@@ -33,9 +33,9 @@ import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
@@ -109,7 +109,7 @@ class TestDecodingPluginTest {
@Test
void assertDecodeUnknownTableType() {
ByteBuffer data = ByteBuffer.wrap("unknown".getBytes(StandardCharsets.UTF_8));
- assertThat(new TestDecodingPlugin(null).decode(data, logSequenceNumber), instanceOf(PlaceholderEvent.class));
+ assertThat(new TestDecodingPlugin(null).decode(data, logSequenceNumber), isA(PlaceholderEvent.class));
}
@Test
@@ -131,7 +131,7 @@ class TestDecodingPluginTest {
ByteBuffer data = ByteBuffer.wrap("table public.test: INSERT: id[integer]:123 col0[integer]:null col1[character varying]:null col2[character varying]:'nonnull'"
.getBytes(StandardCharsets.UTF_8));
AbstractWALEvent actual = new TestDecodingPlugin(null).decode(data, logSequenceNumber);
- assertThat(actual, instanceOf(WriteRowEvent.class));
+ assertThat(actual, isA(WriteRowEvent.class));
WriteRowEvent actualWriteRowEvent = (WriteRowEvent) actual;
assertThat(actualWriteRowEvent.getAfterRow().get(0), is(123));
assertNull(actualWriteRowEvent.getAfterRow().get(1));
@@ -143,6 +143,6 @@ class TestDecodingPluginTest {
void assertDecodeJsonValue() {
ByteBuffer data = ByteBuffer.wrap("table public.test: INSERT: id[integer]:123 ".getBytes(StandardCharsets.UTF_8));
AbstractWALEvent actual = new TestDecodingPlugin(null).decode(data, logSequenceNumber);
- assertThat(actual, instanceOf(WriteRowEvent.class));
+ assertThat(actual, isA(WriteRowEvent.class));
}
}
diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobIdTest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobIdTest.java
index ba4fcc73857..91fc5885830 100644
--- a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobIdTest.java
+++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobIdTest.java
@@ -25,14 +25,14 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class CDCJobIdTest {
@Test
void assertParseJobType() {
String jobId = PipelineJobIdUtils.marshal(new CDCJobId(new PipelineContextKey("sharding_db", InstanceType.PROXY), Collections.singletonList("foo"), true, CDCSinkType.SOCKET));
- assertThat(PipelineJobIdUtils.parseJobType(jobId), instanceOf(CDCJobType.class));
+ assertThat(PipelineJobIdUtils.parseJobType(jobId), isA(CDCJobType.class));
}
}
diff --git a/kernel/data-pipeline/scenario/migration/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtilsTest.java b/kernel/data-pipeline/scenario/migration/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtilsTest.java
index 0445aa3dcb3..6e9d646079d 100644
--- a/kernel/data-pipeline/scenario/migration/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtilsTest.java
+++ b/kernel/data-pipeline/scenario/migration/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/job/id/PipelineJobIdUtilsTest.java
@@ -25,9 +25,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
class PipelineJobIdUtilsTest {
@@ -42,7 +42,7 @@ class PipelineJobIdUtilsTest {
void assertParseJobType() {
PipelineContextKey contextKey = new PipelineContextKey("foo_db", InstanceType.JDBC);
String jobId = PipelineJobIdUtils.marshal(new MigrationJobId(contextKey, Collections.singletonList("foo_tbl:foo_ds.foo_tbl_0,foo_ds.foo_tbl_1")));
- assertThat(PipelineJobIdUtils.parseJobType(jobId), instanceOf(MigrationJobType.class));
+ assertThat(PipelineJobIdUtils.parseJobType(jobId), isA(MigrationJobType.class));
}
@Test
diff --git a/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/rule/builder/GlobalClockRuleBuilderTest.java b/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/rule/builder/GlobalClockRuleBuilderTest.java
index caa4fed3040..9039967f30c 100644
--- a/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/rule/builder/GlobalClockRuleBuilderTest.java
+++ b/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/rule/builder/GlobalClockRuleBuilderTest.java
@@ -28,8 +28,8 @@ import java.util.Collections;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class GlobalClockRuleBuilderTest {
@@ -38,6 +38,6 @@ class GlobalClockRuleBuilderTest {
void assertBuild() {
GlobalClockRuleConfiguration ruleConfig = new GlobalClockRuleConfiguration("FIXTURE", "FIXTURE", false, new Properties());
Map<GlobalRuleConfiguration, GlobalRuleBuilder> builders = OrderedSPILoader.getServices(GlobalRuleBuilder.class, Collections.singleton(ruleConfig));
- assertThat(builders.get(ruleConfig).build(ruleConfig, Collections.emptyList(), null), instanceOf(GlobalClockRule.class));
+ assertThat(builders.get(ruleConfig).build(ruleConfig, Collections.emptyList(), null), isA(GlobalClockRule.class));
}
}
diff --git a/kernel/global-clock/type/tso/provider/local/src/test/java/org/apache/shardingsphere/globalclock/type/tso/provider/local/LocalTSOProviderTest.java b/kernel/global-clock/type/tso/provider/local/src/test/java/org/apache/shardingsphere/globalclock/type/tso/provider/local/LocalTSOProviderTest.java
index 5008bbc1412..7bf73ba7e17 100644
--- a/kernel/global-clock/type/tso/provider/local/src/test/java/org/apache/shardingsphere/globalclock/type/tso/provider/local/LocalTSOProviderTest.java
+++ b/kernel/global-clock/type/tso/provider/local/src/test/java/org/apache/shardingsphere/globalclock/type/tso/provider/local/LocalTSOProviderTest.java
@@ -22,9 +22,9 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class LocalTSOProviderTest {
@@ -44,6 +44,6 @@ class LocalTSOProviderTest {
@Test
void assertGetInstanceByDefault() {
- assertThat(TypedSPILoader.getService(GlobalClockProvider.class, null), instanceOf(LocalTSOProvider.class));
+ assertThat(TypedSPILoader.getService(GlobalClockProvider.class, null), isA(LocalTSOProvider.class));
}
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/DefaultSingleRuleConfigurationBuilderTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/DefaultSingleRuleConfigurationBuilderTest.java
index eea6921f1f1..6fd8a2679cb 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/DefaultSingleRuleConfigurationBuilderTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/DefaultSingleRuleConfigurationBuilderTest.java
@@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class DefaultSingleRuleConfigurationBuilderTest {
@@ -34,6 +34,6 @@ class DefaultSingleRuleConfigurationBuilderTest {
void assertBuild() {
DefaultDatabaseRuleConfigurationBuilder builder =
OrderedSPILoader.getServices(DefaultDatabaseRuleConfigurationBuilder.class, Collections.singleton(new SingleRuleBuilder())).values().iterator().next();
- assertThat(builder.build(), instanceOf(SingleRuleConfiguration.class));
+ assertThat(builder.build(), isA(SingleRuleConfiguration.class));
}
}
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java
index 177da339420..20ab6f60638 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java
@@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -39,7 +39,7 @@ class SingleRuleBuilderTest {
void assertBuild() {
DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class).iterator().next();
DatabaseRule actual = builder.build(mock(SingleRuleConfiguration.class), "", mock(), mock(), Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), mock());
- assertThat(actual, instanceOf(SingleRule.class));
+ assertThat(actual, isA(SingleRule.class));
}
@SuppressWarnings({"rawtypes", "unchecked"})
@@ -48,6 +48,6 @@ class SingleRuleBuilderTest {
DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class).iterator().next();
DatabaseRule actual = builder.build(
new SingleRuleConfiguration(Collections.emptyList(), "foo_ds"), "", mock(), mock(), Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), mock());
- assertThat(actual, instanceOf(SingleRule.class));
+ assertThat(actual, isA(SingleRule.class));
}
}
diff --git a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/context/CompilerContextTest.java b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/context/CompilerContextTest.java
index 408af78355d..ed14d71e896 100644
--- a/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/context/CompilerContextTest.java
+++ b/kernel/sql-federation/compiler/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/context/CompilerContextTest.java
@@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -38,19 +38,19 @@ class CompilerContextTest {
@Test
void assertGetSqlParserRule() {
CompilerContext actual = CompilerContextFactory.create(Collections.singleton(mockDatabase()));
- assertThat(actual.getSqlParserRule(), instanceOf(SQLParserRule.class));
+ assertThat(actual.getSqlParserRule(), isA(SQLParserRule.class));
}
@Test
void assertGetCalciteSchema() {
CompilerContext actual = CompilerContextFactory.create(Collections.singleton(mockDatabase()));
- assertThat(actual.getCalciteSchema(), instanceOf(CalciteSchema.class));
+ assertThat(actual.getCalciteSchema(), isA(CalciteSchema.class));
}
@Test
void assertGetConnectionConfig() {
CompilerContext actual = CompilerContextFactory.create(Collections.singleton(mockDatabase()));
- assertThat(actual.getConnectionConfig(), instanceOf(CalciteConnectionConfig.class));
+ assertThat(actual.getConnectionConfig(), isA(CalciteConnectionConfig.class));
}
private ShardingSphereDatabase mockDatabase() {
diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
index 4d7907e990e..8199505155a 100644
--- a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
+++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetTest.java
@@ -46,9 +46,9 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.junit.jupiter.api.Assertions.assertTrue;
@@ -446,14 +446,14 @@ class SQLFederationResultSetTest {
void assertGetArrayWithColumnIndex() throws SQLException {
when(enumerator.current()).thenReturn(new Object[]{mock(Array.class), 1, "OK", 1});
federationResultSet.next();
- assertThat(federationResultSet.getArray(1), instanceOf(Array.class));
+ assertThat(federationResultSet.getArray(1), isA(Array.class));
}
@Test
void assertGetArrayWithColumnLabel() throws SQLException {
when(enumerator.current()).thenReturn(new Object[]{mock(Array.class), 1, "OK", 1});
federationResultSet.next();
- assertThat(federationResultSet.getArray("order_id"), instanceOf(Array.class));
+ assertThat(federationResultSet.getArray("order_id"), isA(Array.class));
}
@Test
diff --git a/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/executor/EnumerableScanImplementorTest.java b/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/executor/EnumerableScanImplementorTest.java
index 5274c927015..a310e63c019 100644
--- a/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/executor/EnumerableScanImplementorTest.java
+++ b/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/executor/EnumerableScanImplementorTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.sqlfederation.executor.executor;
import org.apache.calcite.linq4j.Enumerable;
import org.apache.calcite.linq4j.Enumerator;
-import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.binder.context.statement.type.dml.SelectStatementContext;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.DatabaseStatistics;
@@ -40,9 +40,9 @@ import java.sql.Types;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
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 EnumerableScanImplementorTest {
try (Enumerator<Object> actual = enumerable.enumerator()) {
actual.moveNext();
Object row = actual.current();
- assertThat(row, instanceOf(Object[].class));
+ assertThat(row, isA(Object[].class));
assertThat(((Object[]) row)[0], is(1));
}
}
diff --git a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
index de2bbaaec19..c59ddc78a3b 100644
--- a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
+++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/ShardingSphereTransactionManagerEngineTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -36,7 +36,7 @@ class ShardingSphereTransactionManagerEngineTest {
@Test
void assertGetEngine() {
- assertThat(transactionManagerEngine.getTransactionManager(TransactionType.XA), instanceOf(ShardingSphereTransactionManagerFixture.class));
+ assertThat(transactionManagerEngine.getTransactionManager(TransactionType.XA), isA(ShardingSphereTransactionManagerFixture.class));
}
@Test
diff --git a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
index 5f125c91ed9..e3fed4e0ec3 100644
--- a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
+++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/core/ResourceDataSourceTest.java
@@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test;
import java.util.regex.Pattern;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -36,7 +36,7 @@ class ResourceDataSourceTest {
String originalName = "foo_db.foo_ds";
ResourceDataSource actual = new ResourceDataSource(originalName, new MockedDataSource());
assertThat(actual.getOriginalName(), is(originalName));
- assertThat(actual.getDataSource(), instanceOf(MockedDataSource.class));
+ assertThat(actual.getDataSource(), isA(MockedDataSource.class));
assertThat(actual.getUniqueResourceName(), matchesPattern(Pattern.compile("\\d+-foo_ds")));
}
diff --git a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java
index 63bc70b0b04..24f48682de1 100644
--- a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java
+++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/rule/TransactionRuleTest.java
@@ -41,8 +41,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -60,14 +60,14 @@ class TransactionRuleTest {
void assertRefreshWithNotDatabaseChange() {
TransactionRule actual = new TransactionRule(new TransactionRuleConfiguration("XA", "Atomikos", new Properties()), Collections.emptyList());
actual.refresh(Collections.singleton(createAddDatabase()), GlobalRuleChangedType.SCHEMA_CHANGED);
- assertThat(actual.getResource().getTransactionManager(TransactionType.XA), instanceOf(ShardingSphereTransactionManagerFixture.class));
+ assertThat(actual.getResource().getTransactionManager(TransactionType.XA), isA(ShardingSphereTransactionManagerFixture.class));
}
@Test
void assertRefreshWithDatabaseChange() {
TransactionRule actual = new TransactionRule(new TransactionRuleConfiguration("XA", "Atomikos", new Properties()), Collections.singleton(createDatabase()));
actual.refresh(Collections.singleton(createAddDatabase()), GlobalRuleChangedType.DATABASE_CHANGED);
- assertThat(actual.getResource().getTransactionManager(TransactionType.XA), instanceOf(ShardingSphereTransactionManagerFixture.class));
+ assertThat(actual.getResource().getTransactionManager(TransactionType.XA), isA(ShardingSphereTransactionManagerFixture.class));
}
@Test
@@ -120,7 +120,7 @@ class TransactionRuleTest {
void assertClose() {
TransactionRule actual = new TransactionRule(new TransactionRuleConfiguration("XA", "Atomikos", new Properties()), Collections.singleton(createDatabase()));
actual.close();
- assertThat(actual.getResource().getTransactionManager(TransactionType.XA), instanceOf(ShardingSphereTransactionManagerFixture.class));
+ assertThat(actual.getResource().getTransactionManager(TransactionType.XA), isA(ShardingSphereTransactionManagerFixture.class));
}
private ShardingSphereDatabase createDatabase() {
diff --git a/kernel/transaction/type/base/seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java b/kernel/transaction/type/base/seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java
index 36df6c2ac8f..da6f937c291 100644
--- a/kernel/transaction/type/base/seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java
+++ b/kernel/transaction/type/base/seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingSphereTransactionManagerTest.java
@@ -58,9 +58,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -118,14 +118,14 @@ class SeataATShardingSphereTransactionManagerTest {
void assertInit() {
Map<String, DataSource> actual = getDataSourceMap();
assertThat(actual.size(), is(1));
- assertThat(actual.get(DATA_SOURCE_UNIQUE_NAME), instanceOf(DataSourceProxy.class));
+ assertThat(actual.get(DATA_SOURCE_UNIQUE_NAME), isA(DataSourceProxy.class));
assertThat(seataTransactionManager.getTransactionType(), is(TransactionType.BASE));
}
@Test
void assertGetConnection() throws SQLException {
Connection actual = seataTransactionManager.getConnection("sharding_db", "ds_0");
- assertThat(actual, instanceOf(ConnectionProxy.class));
+ assertThat(actual, isA(ConnectionProxy.class));
}
@Test
@@ -181,15 +181,15 @@ class SeataATShardingSphereTransactionManagerTest {
Object requestPackage = requestQueue.poll();
Object responsePackage = responseQueue.poll();
if (requestPackage instanceof RegisterTMRequest) {
- assertThat(responsePackage, instanceOf(RegisterTMResponse.class));
+ assertThat(responsePackage, isA(RegisterTMResponse.class));
} else if (requestPackage instanceof RegisterRMRequest) {
- assertThat(responsePackage, instanceOf(RegisterRMResponse.class));
+ assertThat(responsePackage, isA(RegisterRMResponse.class));
} else if (requestPackage instanceof GlobalBeginRequest) {
- assertThat(responsePackage, instanceOf(GlobalBeginResponse.class));
+ assertThat(responsePackage, isA(GlobalBeginResponse.class));
} else if (requestPackage instanceof GlobalCommitRequest) {
- assertThat(responsePackage, instanceOf(GlobalCommitResponse.class));
+ assertThat(responsePackage, isA(GlobalCommitResponse.class));
} else if (requestPackage instanceof GlobalRollbackRequest) {
- assertThat(responsePackage, instanceOf(GlobalRollbackResponse.class));
+ assertThat(responsePackage, isA(GlobalRollbackResponse.class));
} else {
fail("Request package type error");
}
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java
index 0fd8f0a9779..df3d4ce2237 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/XAShardingSphereTransactionManagerTest.java
@@ -37,9 +37,9 @@ import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -84,9 +84,9 @@ class XAShardingSphereTransactionManagerTest {
Connection actual1 = xaTransactionManager.getConnection("sharding_db", "ds_0");
Connection actual2 = xaTransactionManager.getConnection("sharding_db", "ds_1");
Connection actual3 = xaTransactionManager.getConnection("sharding_db", "ds_2");
- assertThat(actual1, instanceOf(Connection.class));
- assertThat(actual2, instanceOf(Connection.class));
- assertThat(actual3, instanceOf(Connection.class));
+ assertThat(actual1, isA(Connection.class));
+ assertThat(actual2, isA(Connection.class));
+ assertThat(actual3, isA(Connection.class));
xaTransactionManager.commit(false);
}
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
index cb59fe21681..175e1f15d1d 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/FirebirdXAConnectionWrapperTest.java
@@ -35,8 +35,8 @@ import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,9 +47,9 @@ class FirebirdXAConnectionWrapperTest {
@Test
void assertWrap() throws SQLException {
XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection());
- assertThat(actual, instanceOf(FBXAConnection.class));
+ assertThat(actual, isA(FBXAConnection.class));
// TODO Fix the error with getting XAResource
- // assertThat(actual.getXAResource(), instanceOf(FBXAConnection.class));
+ // assertThat(actual.getXAResource(), isA(FBXAConnection.class));
}
private XADataSource createXADataSource() {
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
index e16277e0d80..84106ae634a 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapperTest.java
@@ -35,8 +35,8 @@ import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +47,7 @@ class H2XAConnectionWrapperTest {
@Test
void assertWrap() throws SQLException {
XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection());
- assertThat(actual.getXAResource(), instanceOf(JdbcXAConnection.class));
+ assertThat(actual.getXAResource(), isA(JdbcXAConnection.class));
}
private XADataSource createXADataSource() {
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
index 29c09d51753..7679d8b1831 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapperTest.java
@@ -35,8 +35,8 @@ import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +47,7 @@ class MariaDBXAConnectionWrapperTest {
@Test
void assertWrap() throws SQLException {
XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection());
- assertThat(actual.getXAResource(), instanceOf(MariaXaResource.class));
+ assertThat(actual.getXAResource(), isA(MariaXaResource.class));
}
private XADataSource createXADataSource() {
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
index f042630f4f1..733c69ba571 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OpenGaussXAConnectionWrapperTest.java
@@ -18,8 +18,8 @@
package org.apache.shardingsphere.transaction.xa.jta.connection.dialect;
import com.zaxxer.hikari.HikariDataSource;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.transaction.xa.fixture.DataSourceUtils;
import org.apache.shardingsphere.transaction.xa.jta.connection.XAConnectionWrapper;
@@ -35,8 +35,8 @@ import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +47,7 @@ class OpenGaussXAConnectionWrapperTest {
@Test
void assertWrap() throws SQLException {
XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection());
- assertThat(actual.getXAResource(), instanceOf(PGXAConnection.class));
+ assertThat(actual.getXAResource(), isA(PGXAConnection.class));
}
private XADataSource createXADataSource() {
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
index 3dfd783b7eb..29b5107399b 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapperTest.java
@@ -35,8 +35,8 @@ import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +47,7 @@ class OracleXAConnectionWrapperTest {
@Test
void assertWrap() throws SQLException {
XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection());
- assertThat(actual, instanceOf(OracleXAConnection.class));
+ assertThat(actual, isA(OracleXAConnection.class));
}
private XADataSource createXADataSource() {
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
index a8dbb54cddb..eab091f1170 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapperTest.java
@@ -35,8 +35,8 @@ import javax.sql.XADataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -47,7 +47,7 @@ class PostgreSQLXAConnectionWrapperTest {
@Test
void assertWrap() throws SQLException {
XAConnection actual = DatabaseTypedSPILoader.getService(XAConnectionWrapper.class, databaseType).wrap(createXADataSource(), mockConnection());
- assertThat(actual.getXAResource(), instanceOf(PGXAConnection.class));
+ assertThat(actual.getXAResource(), isA(PGXAConnection.class));
}
private XADataSource createXADataSource() {
diff --git a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
index 8fc487b2f7a..09ca636ade8 100644
--- a/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
+++ b/kernel/transaction/type/xa/core/src/test/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapperTest.java
@@ -29,9 +29,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import javax.sql.XADataSource;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -52,7 +52,7 @@ class DataSourceSwapperTest {
}
private void assertResult(final XADataSource xaDataSource) {
- assertThat(xaDataSource, instanceOf(JdbcDataSource.class));
+ assertThat(xaDataSource, isA(JdbcDataSource.class));
JdbcDataSource h2XADataSource = (JdbcDataSource) xaDataSource;
assertThat(h2XADataSource.getUrl(), is("jdbc:mock://127.0.0.1/foo_ds"));
assertThat(h2XADataSource.getUser(), is("root"));
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 5179f3b25dd..513d567f8f1 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
@@ -48,9 +48,9 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.any;
@@ -95,7 +95,7 @@ class MetaDataContextsFactoryTest {
when(repository.getChildrenKeys("/statistics/databases")).thenReturn(Collections.emptyList());
MetaDataContexts actual = new MetaDataContextsFactory(metaDataPersistFacade, computeNodeInstanceContext).create(createContextManagerBuilderParameter());
assertThat(actual.getMetaData().getGlobalRuleMetaData().getRules().size(), is(1));
- assertThat(actual.getMetaData().getGlobalRuleMetaData().getRules().iterator().next(), instanceOf(MockedRule.class));
+ assertThat(actual.getMetaData().getGlobalRuleMetaData().getRules().iterator().next(), isA(MockedRule.class));
assertTrue(actual.getMetaData().containsDatabase("foo_db"));
assertThat(actual.getMetaData().getAllDatabases().size(), is(1));
}
@@ -112,7 +112,7 @@ class MetaDataContextsFactoryTest {
when(repository.getChildrenKeys("/statistics/databases")).thenReturn(Collections.emptyList());
MetaDataContexts actual = new MetaDataContextsFactory(metaDataPersistFacade, computeNodeInstanceContext).create(createContextManagerBuilderParameter());
assertThat(actual.getMetaData().getGlobalRuleMetaData().getRules().size(), is(1));
- assertThat(actual.getMetaData().getGlobalRuleMetaData().getRules().iterator().next(), instanceOf(MockedRule.class));
+ assertThat(actual.getMetaData().getGlobalRuleMetaData().getRules().iterator().next(), isA(MockedRule.class));
assertTrue(actual.getMetaData().containsDatabase("foo_db"));
assertThat(actual.getMetaData().getAllDatabases().size(), is(1));
}
diff --git a/mode/type/cluster/repository/provider/etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java b/mode/type/cluster/repository/provider/etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java
index 72c9a3074d3..dd87ae1db1a 100644
--- a/mode/type/cluster/repository/provider/etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java
+++ b/mode/type/cluster/repository/provider/etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java
@@ -53,9 +53,9 @@ import java.util.Properties;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doAnswer;
@@ -226,7 +226,7 @@ class EtcdRepositoryTest {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- assertThat(ex, instanceOf(InterruptedException.class));
+ assertThat(ex, isA(InterruptedException.class));
}
}
@@ -238,7 +238,7 @@ class EtcdRepositoryTest {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- assertThat(ex, instanceOf(ExecutionException.class));
+ assertThat(ex, isA(ExecutionException.class));
}
}
@@ -250,7 +250,7 @@ class EtcdRepositoryTest {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- assertThat(ex, instanceOf(InterruptedException.class));
+ assertThat(ex, isA(InterruptedException.class));
}
}
@@ -262,7 +262,7 @@ class EtcdRepositoryTest {
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- assertThat(ex, instanceOf(ExecutionException.class));
+ assertThat(ex, isA(ExecutionException.class));
}
}
diff --git a/parser/sql/engine/core/src/test/java/org/apache/shardingsphere/sql/parser/core/SQLParserFactoryTest.java b/parser/sql/engine/core/src/test/java/org/apache/shardingsphere/sql/parser/core/SQLParserFactoryTest.java
index 2268eb79ee0..2e23fa9c4ed 100644
--- a/parser/sql/engine/core/src/test/java/org/apache/shardingsphere/sql/parser/core/SQLParserFactoryTest.java
+++ b/parser/sql/engine/core/src/test/java/org/apache/shardingsphere/sql/parser/core/SQLParserFactoryTest.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.sql.parser.fixture.LexerFixture;
import org.apache.shardingsphere.sql.parser.fixture.ParserFixture;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class SQLParserFactoryTest {
@@ -31,6 +31,6 @@ class SQLParserFactoryTest {
@Test
void assertNewInstance() {
- assertThat(SQLParserFactory.newInstance(SQL, mock(LexerFixture.class).getClass(), mock(ParserFixture.class).getClass()), instanceOf(ParserFixture.class));
+ assertThat(SQLParserFactory.newInstance(SQL, mock(LexerFixture.class).getClass(), mock(ParserFixture.class).getClass()), isA(ParserFixture.class));
}
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnectorFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnectorFactoryTest.java
index a650529808e..681d957b82b 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnectorFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/DatabaseConnectorFactoryTest.java
@@ -42,8 +42,8 @@ import java.util.Collections;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -69,7 +69,7 @@ class DatabaseConnectorFactoryTest {
ContextManager contextManager = mockContextManager(database);
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
DatabaseConnector engine = DatabaseConnectorFactory.getInstance().newInstance(queryContext, databaseConnectionManager, false);
- assertThat(engine, instanceOf(DatabaseConnector.class));
+ assertThat(engine, isA(DatabaseConnector.class));
}
private ConnectionContext mockConnectionContext() {
@@ -93,7 +93,7 @@ class DatabaseConnectorFactoryTest {
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
assertThat(DatabaseConnectorFactory.getInstance().newInstance(
new QueryContext(sqlStatementContext, "schemaName", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), metaData), databaseConnectionManager, false),
- instanceOf(DatabaseConnector.class));
+ isA(DatabaseConnector.class));
}
private ContextManager mockContextManager(final ShardingSphereDatabase database) {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/datasource/JDBCBackendDataSourceTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/datasource/JDBCBackendDataSourceTest.java
index 39807b182fe..9f274a01058 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/datasource/JDBCBackendDataSourceTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/datasource/JDBCBackendDataSourceTest.java
@@ -59,9 +59,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -131,7 +131,7 @@ class JDBCBackendDataSourceTest {
try {
actual.addAll(each.get());
} catch (final ExecutionException ex) {
- assertThat(ex.getCause(), instanceOf(OverallConnectionNotEnoughException.class));
+ assertThat(ex.getCause(), isA(OverallConnectionNotEnoughException.class));
}
}
assertTrue(actual.isEmpty());
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
index 84209d73d91..de0ce78eea6 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactoryTest.java
@@ -74,8 +74,8 @@ import java.util.Optional;
import java.util.Properties;
import java.util.stream.Stream;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -133,15 +133,15 @@ class ProxyBackendHandlerFactoryTest {
String sql = "set dist variable sql_show='true'";
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DistSQLUpdateBackendHandler.class));
+ assertThat(actual, isA(DistSQLUpdateBackendHandler.class));
sql = "show dist variable where name = sql_show";
sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DistSQLQueryBackendHandler.class));
+ assertThat(actual, isA(DistSQLQueryBackendHandler.class));
sql = "show dist variables";
sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DistSQLQueryBackendHandler.class));
+ assertThat(actual, isA(DistSQLQueryBackendHandler.class));
}
@ParameterizedTest(name = "{0}")
@@ -149,7 +149,7 @@ class ProxyBackendHandlerFactoryTest {
void assertNewInstanceWithTCL(final String sql) throws SQLException {
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(TCLBackendHandler.class));
+ assertThat(actual, isA(TCLBackendHandler.class));
}
@Test
@@ -157,19 +157,19 @@ class ProxyBackendHandlerFactoryTest {
String sql = "SHOW VARIABLES LIKE '%x%'";
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
+ assertThat(actual, isA(UnicastDatabaseBackendHandler.class));
sql = "SHOW VARIABLES WHERE Variable_name ='language'";
sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
+ assertThat(actual, isA(UnicastDatabaseBackendHandler.class));
sql = "SHOW CHARACTER SET";
sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
+ assertThat(actual, isA(UnicastDatabaseBackendHandler.class));
sql = "SHOW COLLATION";
sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
+ assertThat(actual, isA(UnicastDatabaseBackendHandler.class));
}
// TODO
@@ -182,18 +182,18 @@ class ProxyBackendHandlerFactoryTest {
when(proxyContext.getContextManager().getDatabase("db").containsDataSource()).thenReturn(true);
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DatabaseConnector.class));
+ assertThat(actual, isA(DatabaseConnector.class));
sql = "SELECT * FROM information_schema.schemata LIMIT 1";
sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DatabaseAdminQueryBackendHandler.class));
+ assertThat(actual, isA(DatabaseAdminQueryBackendHandler.class));
}
@Test
void assertNewInstanceWithEmptyString() throws SQLException {
String sql = "";
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, new EmptyStatement(databaseType), connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(SkipBackendHandler.class));
+ assertThat(actual, isA(SkipBackendHandler.class));
}
@Test
@@ -210,7 +210,7 @@ class ProxyBackendHandlerFactoryTest {
String sql = "SHOW TRANSACTION RULE;";
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DistSQLQueryBackendHandler.class));
+ assertThat(actual, isA(DistSQLQueryBackendHandler.class));
}
@Test
@@ -219,7 +219,7 @@ class ProxyBackendHandlerFactoryTest {
String sql = "SHOW DEFAULT SINGLE TABLE STORAGE UNIT";
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DistSQLQueryBackendHandler.class));
+ assertThat(actual, isA(DistSQLQueryBackendHandler.class));
}
@Test
@@ -228,7 +228,7 @@ class ProxyBackendHandlerFactoryTest {
String sql = "PREVIEW INSERT INTO account VALUES(1, 1, 1)";
SQLStatement sqlStatement = ProxySQLComQueryParser.parse(sql, databaseType, connectionSession);
ProxyBackendHandler actual = ProxyBackendHandlerFactory.newInstance(databaseType, sql, sqlStatement, connectionSession, new HintValueContext());
- assertThat(actual, instanceOf(DistSQLQueryBackendHandler.class));
+ assertThat(actual, isA(DistSQLQueryBackendHandler.class));
}
private static class TCLTestCaseArgumentsProvider implements ArgumentsProvider {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
index 45bd7cb3abc..63830dc41f9 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/DatabaseBackendHandlerFactoryTest.java
@@ -46,8 +46,8 @@ import org.mockito.quality.Strictness;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -68,7 +68,7 @@ class DatabaseBackendHandlerFactoryTest {
when(sqlStatementContext.getTablesContext().getDatabaseNames()).thenReturn(Collections.emptyList());
DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(
new QueryContext(sqlStatementContext, sql, Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock()), mock(), false);
- assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
+ assertThat(actual, isA(UnicastDatabaseBackendHandler.class));
}
private ConnectionContext mockConnectionContext() {
@@ -83,7 +83,7 @@ class DatabaseBackendHandlerFactoryTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SelectStatement(databaseType));
DatabaseBackendHandler actual = DatabaseBackendHandlerFactory.newInstance(
new QueryContext(sqlStatementContext, sql, Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock()), mock(), false);
- assertThat(actual, instanceOf(UnicastDatabaseBackendHandler.class));
+ assertThat(actual, isA(UnicastDatabaseBackendHandler.class));
}
@Test
@@ -97,7 +97,7 @@ class DatabaseBackendHandlerFactoryTest {
DatabaseBackendHandlerFactory.newInstance(
new QueryContext(sqlStatementContext, sql, Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class)),
connectionSession, false);
- assertThat(actual, instanceOf(StandardDatabaseConnector.class));
+ assertThat(actual, isA(StandardDatabaseConnector.class));
}
private SQLStatementContext mockSQLStatementContext() {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
index 37b8954b89c..8b7792612bf 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/data/impl/UnicastDatabaseBackendHandlerTest.java
@@ -55,9 +55,9 @@ import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -119,7 +119,7 @@ class UnicastDatabaseBackendHandlerTest {
ShardingSphereDatabase database = createDatabases().iterator().next();
when(contextManager.getDatabase("db_0")).thenReturn(database);
ResponseHeader actual = unicastDatabaseBackendHandler.execute();
- assertThat(actual, instanceOf(UpdateResponseHeader.class));
+ assertThat(actual, isA(UpdateResponseHeader.class));
}
@Test
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/CreateDatabaseBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/CreateDatabaseBackendHandlerTest.java
index 33a70bd9ce3..d198c79fed3 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/CreateDatabaseBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/CreateDatabaseBackendHandlerTest.java
@@ -33,8 +33,8 @@ import org.mockito.Mock;
import java.sql.SQLException;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -59,7 +59,7 @@ class CreateDatabaseBackendHandlerTest {
when(statement.getDatabaseName()).thenReturn("bar_db");
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- assertThat(handler.execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(handler.execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -77,7 +77,7 @@ class CreateDatabaseBackendHandlerTest {
when(statement.isIfNotExists()).thenReturn(true);
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- assertThat(handler.execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(handler.execute(), isA(UpdateResponseHeader.class));
}
private ContextManager mockContextManager() {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java
index 4e7c205b7a5..3df1d4cfe1f 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DatabaseOperateBackendHandlerFactoryTest.java
@@ -52,8 +52,8 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
@@ -94,7 +94,7 @@ class DatabaseOperateBackendHandlerFactoryTest {
when(sqlStatement.getDatabaseName()).thenReturn("new_db");
setGovernanceMetaDataContexts(true);
ResponseHeader response = DatabaseOperateBackendHandlerFactory.newInstance(sqlStatement, connectionSession).execute();
- assertThat(response, instanceOf(UpdateResponseHeader.class));
+ assertThat(response, isA(UpdateResponseHeader.class));
}
@Test
@@ -103,7 +103,7 @@ class DatabaseOperateBackendHandlerFactoryTest {
when(sqlStatement.getDatabaseName()).thenReturn("foo_db");
setGovernanceMetaDataContexts(true);
ResponseHeader response = DatabaseOperateBackendHandlerFactory.newInstance(sqlStatement, connectionSession).execute();
- assertThat(response, instanceOf(UpdateResponseHeader.class));
+ assertThat(response, isA(UpdateResponseHeader.class));
}
@Test
@@ -139,12 +139,12 @@ class DatabaseOperateBackendHandlerFactoryTest {
@Test
void assertDatabaseOperateBackendHandlerFactoryReturnCreateDatabaseBackendHandler() {
- assertThat(DatabaseOperateBackendHandlerFactory.newInstance(mock(CreateDatabaseStatement.class), mock(ConnectionSession.class)), instanceOf(CreateDatabaseBackendHandler.class));
+ assertThat(DatabaseOperateBackendHandlerFactory.newInstance(mock(CreateDatabaseStatement.class), mock(ConnectionSession.class)), isA(CreateDatabaseBackendHandler.class));
}
@Test
void assertDatabaseOperateBackendHandlerFactoryReturnDropDatabaseBackendHandler() {
- assertThat(DatabaseOperateBackendHandlerFactory.newInstance(mock(DropDatabaseStatement.class), mock(ConnectionSession.class)), instanceOf(DropDatabaseBackendHandler.class));
+ assertThat(DatabaseOperateBackendHandlerFactory.newInstance(mock(DropDatabaseStatement.class), mock(ConnectionSession.class)), isA(DropDatabaseBackendHandler.class));
}
@Test
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DropDatabaseBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DropDatabaseBackendHandlerTest.java
index aa49eee39dc..0f0e09b9661 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DropDatabaseBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/database/DropDatabaseBackendHandlerTest.java
@@ -44,8 +44,8 @@ import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -111,7 +111,7 @@ class DropDatabaseBackendHandlerTest {
when(sqlStatement.getDatabaseName()).thenReturn("foo_db");
ResponseHeader responseHeader = handler.execute();
verify(connectionSession, times(0)).setCurrentDatabaseName(null);
- assertThat(responseHeader, instanceOf(UpdateResponseHeader.class));
+ assertThat(responseHeader, isA(UpdateResponseHeader.class));
}
@Test
@@ -121,7 +121,7 @@ class DropDatabaseBackendHandlerTest {
when(sqlStatement.getDatabaseName()).thenReturn("foo_db");
ResponseHeader responseHeader = handler.execute();
verify(connectionSession).setCurrentDatabaseName(null);
- assertThat(responseHeader, instanceOf(UpdateResponseHeader.class));
+ assertThat(responseHeader, isA(UpdateResponseHeader.class));
}
@Test
@@ -138,6 +138,6 @@ class DropDatabaseBackendHandlerTest {
when(sqlStatement.getDatabaseName()).thenReturn("bar_db");
ResponseHeader responseHeader = handler.execute();
verify(connectionSession, times(0)).setCurrentDatabaseName(null);
- assertThat(responseHeader, instanceOf(UpdateResponseHeader.class));
+ assertThat(responseHeader, isA(UpdateResponseHeader.class));
}
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
index d9b8b6d2540..906067aa644 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -65,8 +65,8 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@@ -117,7 +117,7 @@ class DistSQLBackendHandlerFactoryTest {
void assertExecuteDataSourcesContext() throws SQLException {
RegisterStorageUnitStatement sqlStatement = mock(RegisterStorageUnitStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -125,21 +125,21 @@ class DistSQLBackendHandlerFactoryTest {
when(ProxyContext.getInstance().getContextManager().getDatabase("foo_db").getRuleMetaData()).thenReturn(new RuleMetaData(Collections.emptyList()));
CreateShardingTableRuleStatement sqlStatement = mock(CreateShardingTableRuleStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
void assertExecuteAddResourceContext() throws SQLException {
RegisterStorageUnitStatement sqlStatement = mock(RegisterStorageUnitStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
void assertExecuteAlterResourceContext() throws SQLException {
AlterStorageUnitStatement sqlStatement = mock(AlterStorageUnitStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -147,7 +147,7 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
AlterShadowRuleStatement sqlStatement = mock(AlterShadowRuleStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -155,7 +155,7 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
CreateShadowRuleStatement sqlStatement = mock(CreateShadowRuleStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -163,7 +163,7 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
DropShadowRuleStatement sqlStatement = mock(DropShadowRuleStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -171,13 +171,13 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
AlterDefaultShadowAlgorithmStatement statement = new AlterDefaultShadowAlgorithmStatement(
new ShadowAlgorithmSegment("foo", new AlgorithmSegment("SQL_HINT", PropertiesBuilder.build(new Property("type", "value")))));
- assertThat(new DistSQLUpdateBackendHandler(statement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(statement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
void assertExecuteShowShadowRulesContext() throws SQLException {
mockRuleMetaData();
- assertThat(new DistSQLQueryBackendHandler(mock(ShowShadowRulesStatement.class, RETURNS_DEEP_STUBS), connectionSession).execute(), instanceOf(QueryResponseHeader.class));
+ assertThat(new DistSQLQueryBackendHandler(mock(ShowShadowRulesStatement.class, RETURNS_DEEP_STUBS), connectionSession).execute(), isA(QueryResponseHeader.class));
}
@Test
@@ -185,7 +185,7 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
ShowShadowTableRulesStatement sqlStatement = mock(ShowShadowTableRulesStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLQueryBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(QueryResponseHeader.class));
+ assertThat(new DistSQLQueryBackendHandler(sqlStatement, connectionSession).execute(), isA(QueryResponseHeader.class));
}
@Test
@@ -193,7 +193,7 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
ShowShadowAlgorithmsStatement sqlStatement = mock(ShowShadowAlgorithmsStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLQueryBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(QueryResponseHeader.class));
+ assertThat(new DistSQLQueryBackendHandler(sqlStatement, connectionSession).execute(), isA(QueryResponseHeader.class));
}
@Test
@@ -201,14 +201,14 @@ class DistSQLBackendHandlerFactoryTest {
mockRuleMetaData();
DropShadowAlgorithmStatement sqlStatement = mock(DropShadowAlgorithmStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
void assertExecuteDropResourceContext() throws SQLException {
UnregisterStorageUnitStatement sqlStatement = mock(UnregisterStorageUnitStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
@@ -220,7 +220,7 @@ class DistSQLBackendHandlerFactoryTest {
void assertExecuteCreateReadwriteSplittingRuleContext() throws SQLException {
CreateReadwriteSplittingRuleStatement sqlStatement = mock(CreateReadwriteSplittingRuleStatement.class);
when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes());
- assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new DistSQLUpdateBackendHandler(sqlStatement, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
@Test
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateBackendHandlerTest.java
index 7d9b13bd06f..25450ddeab2 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/DistSQLUpdateBackendHandlerTest.java
@@ -44,8 +44,8 @@ import org.mockito.Mock;
import java.sql.SQLException;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -114,7 +114,7 @@ class DistSQLUpdateBackendHandlerTest {
when(database.getResourceMetaData()).thenReturn(resourceMetaData);
when(contextManager.getDatabase("foo_db")).thenReturn(database);
ResponseHeader actual = new DistSQLUpdateBackendHandler(new RefreshTableMetaDataStatement(), mockConnectionSession("foo_db")).execute();
- assertThat(actual, instanceOf(UpdateResponseHeader.class));
+ assertThat(actual, isA(UpdateResponseHeader.class));
}
private ConnectionSession mockConnectionSession(final String databaseName) {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java
index 0a9c59857db..df658fd44f0 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/export/ExportMetaDataExecutorTest.java
@@ -71,9 +71,9 @@ import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -194,7 +194,7 @@ class ExportMetaDataExecutorTest {
private void assertMetaData(final Object actual, final String expected) {
assertNotNull(actual);
- assertThat(actual, instanceOf(String.class));
+ assertThat(actual, isA(String.class));
assertMetaData(convertToExportedClusterInfo((String) actual), convertToExportedClusterInfo(expected));
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/skip/SkipBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/skip/SkipBackendHandlerTest.java
index 91705514375..0f9760f07af 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/skip/SkipBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/skip/SkipBackendHandlerTest.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class SkipBackendHandlerTest {
@@ -30,6 +30,6 @@ class SkipBackendHandlerTest {
void assertExecuteSkipBackendHandler() {
SkipBackendHandler skipBackendHandler = new SkipBackendHandler(null);
ResponseHeader actual = skipBackendHandler.execute();
- assertThat(actual, instanceOf(UpdateResponseHeader.class));
+ assertThat(actual, isA(UpdateResponseHeader.class));
}
}
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java
index 8dc9e8fc6d1..77b857a7c85 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerFactoryTest.java
@@ -51,9 +51,9 @@ import org.mockito.internal.configuration.plugins.Plugins;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.nullable;
@@ -78,7 +78,7 @@ class TCLBackendHandlerFactoryTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ProxyBackendHandler proxyBackendHandler = TCLBackendHandlerFactory.newInstance(new CommonSQLStatementContext(new CommitStatement(databaseType)), null, connectionSession);
- assertThat(proxyBackendHandler, instanceOf(TCLBackendHandler.class));
+ assertThat(proxyBackendHandler, isA(TCLBackendHandler.class));
TCLBackendHandler backendHandler = (TCLBackendHandler) proxyBackendHandler;
assertFieldOfInstance(backendHandler, "operationType", is(TransactionOperationType.COMMIT));
assertFieldOfInstance(getBackendTransactionManager(backendHandler), "connection", is(databaseConnectionManager));
@@ -96,7 +96,7 @@ class TCLBackendHandlerFactoryTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ProxyBackendHandler proxyBackendHandler = TCLBackendHandlerFactory.newInstance(new CommonSQLStatementContext(new RollbackStatement(databaseType)), null, connectionSession);
- assertThat(proxyBackendHandler, instanceOf(TCLBackendHandler.class));
+ assertThat(proxyBackendHandler, isA(TCLBackendHandler.class));
TCLBackendHandler backendHandler = (TCLBackendHandler) proxyBackendHandler;
assertFieldOfInstance(backendHandler, "operationType", is(TransactionOperationType.ROLLBACK));
assertFieldOfInstance(getBackendTransactionManager(backendHandler), "connection", is(databaseConnectionManager));
@@ -121,7 +121,7 @@ class TCLBackendHandlerFactoryTest {
ConnectionSession connectionSession = mock(ConnectionSession.class);
ConnectionContext connectionContext = mockConnectionContext();
when(connectionSession.getConnectionContext()).thenReturn(connectionContext);
- assertThat(TCLBackendHandlerFactory.newInstance(sqlStatementContext, null, connectionSession), instanceOf(DatabaseConnector.class));
+ assertThat(TCLBackendHandlerFactory.newInstance(sqlStatementContext, null, connectionSession), isA(DatabaseConnector.class));
}
private ConnectionContext mockConnectionContext() {
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerTest.java
index dd36ed0eba3..c053cb4fab3 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandlerTest.java
@@ -37,8 +37,8 @@ import org.junit.jupiter.api.extension.ExtendWith;
import java.sql.SQLException;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -59,7 +59,7 @@ class TCLBackendHandlerTest {
when(databaseConnectionManager.getConnectionSession()).thenReturn(connectionSession);
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
- assertThat(new TCLBackendHandler(mock(TCLStatement.class), TransactionOperationType.BEGIN, connectionSession).execute(), instanceOf(UpdateResponseHeader.class));
+ assertThat(new TCLBackendHandler(mock(TCLStatement.class), TransactionOperationType.BEGIN, connectionSession).execute(), isA(UpdateResponseHeader.class));
}
private ContextManager mockContextManager() {
diff --git a/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java b/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
index 214f668c265..5ee7eca7ad8 100644
--- a/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
+++ b/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/admin/FirebirdAdminExecutorCreatorTest.java
@@ -36,9 +36,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -57,7 +57,7 @@ class FirebirdAdminExecutorCreatorTest {
Optional<DatabaseAdminExecutor> actual = new FirebirdAdminExecutorCreator().create(
new CommonSQLStatementContext(new ShowStatement(databaseType, "server_version")));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(FirebirdShowVariableExecutor.class));
+ assertThat(actual.get(), isA(FirebirdShowVariableExecutor.class));
}
@Test
@@ -72,7 +72,7 @@ class FirebirdAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SetStatement(databaseType, Collections.emptyList()));
Optional<DatabaseAdminExecutor> actual = new FirebirdAdminExecutorCreator().create(sqlStatementContext, "SET NAMES utf8", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(FirebirdSetVariableAdminExecutor.class));
+ assertThat(actual.get(), isA(FirebirdSetVariableAdminExecutor.class));
}
@Test
diff --git a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/connector/sane/MySQLDialectSaneQueryResultEngineTest.java b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/connector/sane/MySQLDialectSaneQueryResultEngineTest.java
index a0fa9e27094..52ff0fcc6aa 100644
--- a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/connector/sane/MySQLDialectSaneQueryResultEngineTest.java
+++ b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/connector/sane/MySQLDialectSaneQueryResultEngineTest.java
@@ -38,9 +38,9 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -69,7 +69,7 @@ class MySQLDialectSaneQueryResultEngineTest {
selectStatement.getProjections().getProjections().add(new ExpressionProjectionSegment(0, 0, "unknown_variable"));
Optional<ExecuteResult> actual = new MySQLDialectSaneQueryResultEngine().getSaneQueryResult(selectStatement, new SQLException(""));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(RawMemoryQueryResult.class));
+ assertThat(actual.get(), isA(RawMemoryQueryResult.class));
RawMemoryQueryResult actualResult = (RawMemoryQueryResult) actual.get();
assertThat(actualResult.getRowCount(), is(1L));
assertTrue(actualResult.next());
@@ -89,14 +89,14 @@ class MySQLDialectSaneQueryResultEngineTest {
void assertGetSaneQueryResultForSetStatement() {
Optional<ExecuteResult> actual = new MySQLDialectSaneQueryResultEngine().getSaneQueryResult(new SetStatement(databaseType, Collections.emptyList()), new SQLException(""));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(UpdateResult.class));
+ assertThat(actual.get(), isA(UpdateResult.class));
}
@Test
void assertGetSaneQueryResultForShowOtherStatement() {
Optional<ExecuteResult> actual = new MySQLDialectSaneQueryResultEngine().getSaneQueryResult(new MySQLShowOtherStatement(databaseType), new SQLException(""));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(RawMemoryQueryResult.class));
+ assertThat(actual.get(), isA(RawMemoryQueryResult.class));
RawMemoryQueryResult actualResult = (RawMemoryQueryResult) actual.get();
assertThat(actualResult.getRowCount(), is(1L));
assertTrue(actualResult.next());
diff --git a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
index 84b1f62aa73..2b325c2ed7d 100644
--- a/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/MySQLAdminExecutorCreatorTest.java
@@ -78,9 +78,9 @@ import java.util.Collections;
import java.util.Optional;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -98,7 +98,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowFunctionStatusStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowFunctionStatusExecutor.class));
+ assertThat(actual.get(), isA(ShowFunctionStatusExecutor.class));
}
@Test
@@ -106,7 +106,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowProcedureStatusStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowProcedureStatusExecutor.class));
+ assertThat(actual.get(), isA(ShowProcedureStatusExecutor.class));
}
@Test
@@ -114,7 +114,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowTablesStatement(databaseType, null, null, false));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowTablesExecutor.class));
+ assertThat(actual.get(), isA(ShowTablesExecutor.class));
}
@Test
@@ -128,7 +128,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLUseStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "use db", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(UseDatabaseExecutor.class));
+ assertThat(actual.get(), isA(UseDatabaseExecutor.class));
}
@Test
@@ -136,7 +136,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowDatabasesStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowDatabasesExecutor.class));
+ assertThat(actual.get(), isA(ShowDatabasesExecutor.class));
}
@Test
@@ -144,7 +144,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowProcessListStatement(databaseType, false));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowProcessListExecutor.class));
+ assertThat(actual.get(), isA(ShowProcessListExecutor.class));
}
@Test
@@ -152,7 +152,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new MySQLShowCreateDatabaseStatement(databaseType, null));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowCreateDatabaseExecutor.class));
+ assertThat(actual.get(), isA(ShowCreateDatabaseExecutor.class));
}
@Test
@@ -160,7 +160,7 @@ class MySQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SetStatement(databaseType, Collections.emptyList()));
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLSetVariableAdminExecutor.class));
+ assertThat(actual.get(), isA(MySQLSetVariableAdminExecutor.class));
}
@Test
@@ -174,7 +174,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select CONNECTION_ID()", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowConnectionIdExecutor.class));
+ assertThat(actual.get(), isA(ShowConnectionIdExecutor.class));
}
@Test
@@ -188,7 +188,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select version()", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowVersionExecutor.class));
+ assertThat(actual.get(), isA(ShowVersionExecutor.class));
}
@Test
@@ -202,7 +202,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select CURRENT_USER()", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowCurrentUserExecutor.class));
+ assertThat(actual.get(), isA(ShowCurrentUserExecutor.class));
}
@Test
@@ -219,7 +219,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select @@session.transaction_read_only", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLSystemVariableQueryExecutor.class));
+ assertThat(actual.get(), isA(MySQLSystemVariableQueryExecutor.class));
}
@Test
@@ -235,7 +235,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select @@session.transaction_isolation", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(MySQLSystemVariableQueryExecutor.class));
+ assertThat(actual.get(), isA(MySQLSystemVariableQueryExecutor.class));
}
@Test
@@ -250,7 +250,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select DATABASE()", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(ShowCurrentDatabaseExecutor.class));
+ assertThat(actual.get(), isA(ShowCurrentDatabaseExecutor.class));
}
@Test
@@ -265,7 +265,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select CURRENT_DATE()", null, Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(NoResourceShowExecutor.class));
+ assertThat(actual.get(), isA(NoResourceShowExecutor.class));
}
@Test
@@ -302,7 +302,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select CURRENT_DATE()", null, Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(UnicastResourceShowExecutor.class));
+ assertThat(actual.get(), isA(UnicastResourceShowExecutor.class));
}
@Test
@@ -316,7 +316,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select ENGINE from ENGINES", "information_schema", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(DefaultDatabaseMetaDataExecutor.class));
+ assertThat(actual.get(), isA(DefaultDatabaseMetaDataExecutor.class));
}
@Test
@@ -330,7 +330,7 @@ class MySQLAdminExecutorCreatorTest {
when(sqlStatementContext.getSqlStatement()).thenReturn(selectStatement);
Optional<DatabaseAdminExecutor> actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select SCHEMA_NAME from SCHEMATA", "information_schema", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(SelectInformationSchemataExecutor.class));
+ assertThat(actual.get(), isA(SelectInformationSchemataExecutor.class));
when(ProxyContext.getInstance().getContextManager().getDatabase("information_schema").isComplete()).thenReturn(true);
actual = new MySQLAdminExecutorCreator().create(sqlStatementContext, "select SCHEMA_NAME from SCHEMATA", "information_schema", Collections.emptyList());
assertFalse(actual.isPresent());
diff --git a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java
index f4d34522aaf..3761385630b 100644
--- a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java
+++ b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java
@@ -45,7 +45,7 @@ import java.util.Collections;
import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
+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.anyMap;
@@ -65,7 +65,7 @@ class OpenGaussAdminExecutorCreatorTest {
SelectStatementContext selectStatementContext = mockSelectStatementContext("pg_catalog", "pg_database", "datcompatibility");
Optional<DatabaseAdminExecutor> actual = new OpenGaussAdminExecutorCreator().create(selectStatementContext, sql, databaseName, Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(OpenGaussSelectDatCompatibilityExecutor.class));
+ assertThat(actual.get(), isA(OpenGaussSelectDatCompatibilityExecutor.class));
}
@Test
@@ -85,7 +85,7 @@ class OpenGaussAdminExecutorCreatorTest {
SelectStatementContext selectStatementContext = mockSelectStatementContext("pg_catalog", "pg_type", null);
Optional<DatabaseAdminExecutor> actual = new OpenGaussAdminExecutorCreator().create(selectStatementContext, sql, "postgres", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(DefaultDatabaseMetaDataExecutor.class));
+ assertThat(actual.get(), isA(DefaultDatabaseMetaDataExecutor.class));
}
@Test
@@ -122,7 +122,7 @@ class OpenGaussAdminExecutorCreatorTest {
.thenReturn(Collections.singletonList(new ExpressionProjectionSegment(-1, -1, expression)));
Optional<DatabaseAdminExecutor> actual = new OpenGaussAdminExecutorCreator().create(selectStatementContext, sql, "postgres", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(type));
+ assertThat(actual.get(), isA(type));
}
private SelectStatementContext mockSelectStatementContext(final String schemaName, final String tableName, final String columnName) {
diff --git a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemFunctionQueryExecutorCreatorTest.java b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemFunctionQueryExecutorCreatorTest.java
index e7a1a3ce02d..dbe33914e23 100644
--- a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemFunctionQueryExecutorCreatorTest.java
+++ b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemFunctionQueryExecutorCreatorTest.java
@@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test;
import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -46,7 +46,7 @@ class OpenGaussSystemFunctionQueryExecutorCreatorTest {
assertTrue(creator.accept());
Optional<DatabaseAdminExecutor> actual = creator.create();
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(OpenGaussSelectVersionExecutor.class));
+ assertThat(actual.get(), isA(OpenGaussSelectVersionExecutor.class));
}
@Test
@@ -56,7 +56,7 @@ class OpenGaussSystemFunctionQueryExecutorCreatorTest {
assertTrue(creator.accept());
Optional<DatabaseAdminExecutor> actual = creator.create();
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(OpenGaussSelectPasswordDeadlineExecutor.class));
+ assertThat(actual.get(), isA(OpenGaussSelectPasswordDeadlineExecutor.class));
}
@Test
@@ -66,7 +66,7 @@ class OpenGaussSystemFunctionQueryExecutorCreatorTest {
assertTrue(creator.accept());
Optional<DatabaseAdminExecutor> actual = creator.create();
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(OpenGaussSelectPasswordNotifyTimeExecutor.class));
+ assertThat(actual.get(), isA(OpenGaussSelectPasswordNotifyTimeExecutor.class));
}
private SQLStatementContext mockSQLStatementContext(final String functionName) {
diff --git a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemTableQueryExecutorCreatorTest.java b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemTableQueryExecutorCreatorTest.java
index 196abc73917..e685bf2bdf4 100644
--- a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemTableQueryExecutorCreatorTest.java
+++ b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemTableQueryExecutorCreatorTest.java
@@ -35,7 +35,7 @@ import java.util.Collections;
import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -51,7 +51,7 @@ class OpenGaussSystemTableQueryExecutorCreatorTest {
assertTrue(creator.accept());
Optional<DatabaseAdminExecutor> actual = creator.create();
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(OpenGaussSelectDatCompatibilityExecutor.class));
+ assertThat(actual.get(), isA(OpenGaussSelectDatCompatibilityExecutor.class));
}
@Test
@@ -62,7 +62,7 @@ class OpenGaussSystemTableQueryExecutorCreatorTest {
assertTrue(creator.accept());
Optional<DatabaseAdminExecutor> actual = creator.create();
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(DefaultDatabaseMetaDataExecutor.class));
+ assertThat(actual.get(), isA(DefaultDatabaseMetaDataExecutor.class));
}
private SQLStatementContext mockSelectStatementContext(final String schemaName, final String tableName, final String columnName) {
diff --git a/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java b/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
index a9b3efcdbfc..80ade7f4331 100644
--- a/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
@@ -42,9 +42,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.mock;
@@ -94,7 +94,7 @@ class PostgreSQLAdminExecutorCreatorTest {
void assertCreateWithShowSQLStatement() {
Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator().create(new CommonSQLStatementContext(new ShowStatement(databaseType, "client_encoding")));
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(PostgreSQLShowVariableExecutor.class));
+ assertThat(actual.get(), isA(PostgreSQLShowVariableExecutor.class));
}
@Test
@@ -151,7 +151,7 @@ class PostgreSQLAdminExecutorCreatorTest {
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SetStatement(databaseType, Collections.emptyList()));
Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator().create(sqlStatementContext, "SET client_encoding = utf8", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(PostgreSQLSetVariableAdminExecutor.class));
+ assertThat(actual.get(), isA(PostgreSQLSetVariableAdminExecutor.class));
}
@Test
@@ -159,7 +159,7 @@ class PostgreSQLAdminExecutorCreatorTest {
Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator()
.create(new CommonSQLStatementContext(new PostgreSQLResetParameterStatement(databaseType, "client_encoding")), "RESET client_encoding", "", Collections.emptyList());
assertTrue(actual.isPresent());
- assertThat(actual.get(), instanceOf(PostgreSQLResetVariableAdminExecutor.class));
+ assertThat(actual.get(), isA(PostgreSQLResetVariableAdminExecutor.class));
}
@Test
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java
index 2159ef8fb5f..1604e31f14e 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/FirebirdCommandExecutorFactoryTest.java
@@ -48,8 +48,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
@ExtendWith(MockitoExtension.class)
@@ -60,66 +60,64 @@ class FirebirdCommandExecutorFactoryTest {
@Test
void assertNewInstanceWithInfoDatabase() throws SQLException {
- assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.INFO_DATABASE, mock(FirebirdInfoPacket.class), connectionSession),
- instanceOf(FirebirdDatabaseInfoExecutor.class));
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.INFO_DATABASE, mock(FirebirdInfoPacket.class), connectionSession), isA(FirebirdDatabaseInfoExecutor.class));
}
@Test
void assertNewInstanceWithTransaction() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.TRANSACTION, mock(FirebirdStartTransactionPacket.class), connectionSession),
- instanceOf(FirebirdStartTransactionCommandExecutor.class));
+ isA(FirebirdStartTransactionCommandExecutor.class));
}
@Test
void assertNewInstanceWithAllocateStatement() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.ALLOCATE_STATEMENT, mock(FirebirdAllocateStatementPacket.class), connectionSession),
- instanceOf(FirebirdAllocateStatementCommandExecutor.class));
+ isA(FirebirdAllocateStatementCommandExecutor.class));
}
@Test
void assertNewInstanceWithPrepareStatement() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.PREPARE_STATEMENT, mock(FirebirdPrepareStatementPacket.class), connectionSession),
- instanceOf(FirebirdPrepareStatementCommandExecutor.class));
+ isA(FirebirdPrepareStatementCommandExecutor.class));
}
@Test
void assertNewInstanceWithExecuteStatement() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.EXECUTE, mock(FirebirdExecuteStatementPacket.class), connectionSession),
- instanceOf(FirebirdExecuteStatementCommandExecutor.class));
+ isA(FirebirdExecuteStatementCommandExecutor.class));
}
@Test
void assertNewInstanceWithFetch() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.FETCH, mock(FirebirdFetchStatementPacket.class), connectionSession),
- instanceOf(FirebirdFetchStatementCommandExecutor.class));
+ isA(FirebirdFetchStatementCommandExecutor.class));
}
@Test
void assertNewInstanceWithInfoSQL() throws SQLException {
- assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.INFO_SQL, mock(FirebirdInfoPacket.class), connectionSession),
- instanceOf(FirebirdSQLInfoExecutor.class));
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.INFO_SQL, mock(FirebirdInfoPacket.class), connectionSession), isA(FirebirdSQLInfoExecutor.class));
}
@Test
void assertNewInstanceWithCommit() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.COMMIT, mock(FirebirdCommitTransactionPacket.class), connectionSession),
- instanceOf(FirebirdCommitTransactionCommandExecutor.class));
+ isA(FirebirdCommitTransactionCommandExecutor.class));
}
@Test
void assertNewInstanceWithRollback() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.ROLLBACK, mock(FirebirdRollbackTransactionPacket.class), connectionSession),
- instanceOf(FirebirdRollbackTransactionCommandExecutor.class));
+ isA(FirebirdRollbackTransactionCommandExecutor.class));
}
@Test
void assertNewInstanceWithFreeStatement() throws SQLException {
assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.FREE_STATEMENT, mock(FirebirdFreeStatementPacket.class), connectionSession),
- instanceOf(FirebirdFreeStatementCommandExecutor.class));
+ isA(FirebirdFreeStatementCommandExecutor.class));
}
@Test
void assertNewInstanceWithUnsupportedCommand() throws SQLException {
- assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.VOID, mock(CommandPacket.class), connectionSession), instanceOf(FirebirdUnsupportedCommandExecutor.class));
+ assertThat(FirebirdCommandExecutorFactory.newInstance(FirebirdCommandPacketType.VOID, mock(CommandPacket.class), connectionSession), isA(FirebirdUnsupportedCommandExecutor.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/admin/FirebirdUnsupportedCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/admin/FirebirdUnsupportedCommandExecutorTest.java
index 88931b75eff..4026a45276f 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/admin/FirebirdUnsupportedCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/admin/FirebirdUnsupportedCommandExecutorTest.java
@@ -20,14 +20,14 @@ package org.apache.shardingsphere.proxy.frontend.firebird.command.admin;
import org.apache.shardingsphere.database.protocol.firebird.packet.generic.FirebirdGenericResponsePacket;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class FirebirdUnsupportedCommandExecutorTest {
@Test
void assertExecute() {
FirebirdUnsupportedCommandExecutor executor = new FirebirdUnsupportedCommandExecutor();
- assertThat(executor.execute().iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(executor.execute().iterator().next(), isA(FirebirdGenericResponsePacket.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdDatabaseInfoExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdDatabaseInfoExecutorTest.java
index c31a8f3a6ac..12625b652d9 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdDatabaseInfoExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdDatabaseInfoExecutorTest.java
@@ -31,8 +31,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -49,8 +49,8 @@ class FirebirdDatabaseInfoExecutorTest {
when(packet.getInfoItems()).thenReturn(Collections.emptyList());
FirebirdDatabaseInfoExecutor executor = new FirebirdDatabaseInfoExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
FirebirdGenericResponsePacket responsePacket = (FirebirdGenericResponsePacket) actual.iterator().next();
- assertThat(responsePacket.getData(), instanceOf(FirebirdDatabaseInfoReturnPacket.class));
+ assertThat(responsePacket.getData(), isA(FirebirdDatabaseInfoReturnPacket.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdSQLInfoExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdSQLInfoExecutorTest.java
index 1c786004142..bcdaa2486cf 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdSQLInfoExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/info/FirebirdSQLInfoExecutorTest.java
@@ -31,8 +31,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -49,8 +49,8 @@ class FirebirdSQLInfoExecutorTest {
when(packet.getInfoItems()).thenReturn(Collections.emptyList());
FirebirdSQLInfoExecutor executor = new FirebirdSQLInfoExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
FirebirdGenericResponsePacket responsePacket = (FirebirdGenericResponsePacket) actual.iterator().next();
- assertThat(responsePacket.getData(), instanceOf(FirebirdSQLInfoReturnPacket.class));
+ assertThat(responsePacket.getData(), isA(FirebirdSQLInfoReturnPacket.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdAllocateStatementCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdAllocateStatementCommandExecutorTest.java
index ed1dea1a83e..b5abf036523 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdAllocateStatementCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdAllocateStatementCommandExecutorTest.java
@@ -32,9 +32,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -64,7 +64,7 @@ class FirebirdAllocateStatementCommandExecutorTest {
FirebirdAllocateStatementCommandExecutor executor = new FirebirdAllocateStatementCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
assertThat(((FirebirdGenericResponsePacket) actual.iterator().next()).getHandle(), is(1));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFetchStatementCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFetchStatementCommandExecutorTest.java
index 093f8ccd7e6..743f1ae5b6d 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFetchStatementCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFetchStatementCommandExecutorTest.java
@@ -30,8 +30,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
@ExtendWith(MockitoExtension.class)
class FirebirdFetchStatementCommandExecutorTest {
@@ -46,6 +46,6 @@ class FirebirdFetchStatementCommandExecutorTest {
void assertExecute() throws SQLException {
FirebirdFetchStatementCommandExecutor executor = new FirebirdFetchStatementCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdFetchResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdFetchResponsePacket.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFreeStatementCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFreeStatementCommandExecutorTest.java
index 25eda531bd5..bc995d57921 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFreeStatementCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdFreeStatementCommandExecutorTest.java
@@ -32,8 +32,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -57,7 +57,7 @@ class FirebirdFreeStatementCommandExecutorTest {
when(packet.getStatementId()).thenReturn(1);
FirebirdFreeStatementCommandExecutor executor = new FirebirdFreeStatementCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
verify(registry).removePreparedStatement(1);
}
@@ -68,7 +68,7 @@ class FirebirdFreeStatementCommandExecutorTest {
when(packet.getStatementId()).thenReturn(1);
FirebirdFreeStatementCommandExecutor executor = new FirebirdFreeStatementCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
verify(registry).removePreparedStatement(1);
}
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 e1c189e0f2f..764339bb6a5 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
@@ -60,9 +60,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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;
@@ -125,12 +125,12 @@ class FirebirdExecuteStatementCommandExecutorTest {
Collection<DatabasePacket> actual = executor.execute();
Iterator<DatabasePacket> iterator = actual.iterator();
assertThat(executor.getResponseType(), is(ResponseType.QUERY));
- assertThat(iterator.next(), instanceOf(FirebirdSQLResponsePacket.class));
- assertThat(iterator.next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(iterator.next(), isA(FirebirdSQLResponsePacket.class));
+ assertThat(iterator.next(), isA(FirebirdGenericResponsePacket.class));
assertFalse(iterator.hasNext());
assertTrue(executor.next());
FirebirdPacket rowPacket = executor.getQueryRowPacket();
- assertThat(rowPacket, instanceOf(FirebirdFetchResponsePacket.class));
+ assertThat(rowPacket, isA(FirebirdFetchResponsePacket.class));
executor.close();
verify(proxyBackendHandler).close();
}
@@ -145,6 +145,6 @@ class FirebirdExecuteStatementCommandExecutorTest {
when(ProxyBackendHandlerFactory.newInstance(eq(databaseType), any(QueryContext.class), eq(connectionSession), eq(true))).thenReturn(proxyBackendHandler);
Collection<DatabasePacket> actual = executor.execute();
assertThat(executor.getResponseType(), is(ResponseType.UPDATE));
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
index 999aa57ac69..b3c559e2946 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
@@ -57,9 +57,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(AutoMockExtension.class)
@@ -105,6 +105,6 @@ class FirebirdPrepareStatementCommandExecutorTest {
assertThat(returnPacket.getType(), is(FirebirdSQLInfoReturnValue.SELECT));
FirebirdServerPreparedStatement preparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(1);
assertThat(preparedStatement.getSql(), is("SELECT 1"));
- assertThat(preparedStatement.getSqlStatementContext(), instanceOf(SelectStatementContext.class));
+ assertThat(preparedStatement.getSqlStatementContext(), isA(SelectStatementContext.class));
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdCommitTransactionCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdCommitTransactionCommandExecutorTest.java
index 743b34734e0..4f48f420e62 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdCommitTransactionCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdCommitTransactionCommandExecutorTest.java
@@ -32,8 +32,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -54,7 +54,7 @@ class FirebirdCommitTransactionCommandExecutorTest {
})) {
FirebirdCommitTransactionCommandExecutor executor = new FirebirdCommitTransactionCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
verify(mocked.constructed().get(0)).commit();
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdRollbackTransactionCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdRollbackTransactionCommandExecutorTest.java
index be4e2921489..f3e6c4b09e2 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdRollbackTransactionCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdRollbackTransactionCommandExecutorTest.java
@@ -32,8 +32,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -54,7 +54,7 @@ class FirebirdRollbackTransactionCommandExecutorTest {
})) {
FirebirdRollbackTransactionCommandExecutor executor = new FirebirdRollbackTransactionCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
- assertThat(actual.iterator().next(), instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(FirebirdGenericResponsePacket.class));
verify(mocked.constructed().get(0)).rollback();
}
}
diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdStartTransactionCommandExecutorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdStartTransactionCommandExecutorTest.java
index ffe2344d452..ad1f6271a38 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdStartTransactionCommandExecutorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/transaction/FirebirdStartTransactionCommandExecutorTest.java
@@ -33,9 +33,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -69,7 +69,7 @@ class FirebirdStartTransactionCommandExecutorTest {
FirebirdStartTransactionCommandExecutor executor = new FirebirdStartTransactionCommandExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
DatabasePacket first = actual.iterator().next();
- assertThat(first, instanceOf(FirebirdGenericResponsePacket.class));
+ assertThat(first, isA(FirebirdGenericResponsePacket.class));
assertThat(((FirebirdGenericResponsePacket) first).getHandle(), is(1));
verify(connectionSession).setAutoCommit(true);
verify(connectionSession).setReadOnly(true);
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
index 5c1ca4c1574..8634ed1c3a2 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactoryTest.java
@@ -56,8 +56,8 @@ import org.mockito.quality.Strictness;
import java.sql.SQLException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -79,75 +79,73 @@ class MySQLCommandExecutorFactoryTest {
@Test
void assertNewInstanceWithComQuit() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUIT, mock(CommandPacket.class), connectionSession), instanceOf(MySQLComQuitExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUIT, mock(CommandPacket.class), connectionSession), isA(MySQLComQuitExecutor.class));
}
@Test
void assertNewInstanceWithComInitDb() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_INIT_DB, mock(MySQLComInitDbPacket.class), connectionSession), instanceOf(MySQLComInitDbExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_INIT_DB, mock(MySQLComInitDbPacket.class), connectionSession), isA(MySQLComInitDbExecutor.class));
}
@Test
void assertNewInstanceWithComFieldList() throws SQLException {
MySQLComFieldListPacket packet = mock(MySQLComFieldListPacket.class);
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_FIELD_LIST, packet, connectionSession), instanceOf(MySQLComFieldListPacketExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_FIELD_LIST, packet, connectionSession), isA(MySQLComFieldListPacketExecutor.class));
}
@Test
void assertNewInstanceWithComQuery() throws SQLException {
MySQLComQueryPacket packet = mock(MySQLComQueryPacket.class);
when(packet.getSQL()).thenReturn("");
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUERY, packet, connectionSession), instanceOf(MySQLComQueryPacketExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_QUERY, packet, connectionSession), isA(MySQLComQueryPacketExecutor.class));
}
@Test
void assertNewInstanceWithComPing() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_PING, mock(CommandPacket.class), connectionSession), instanceOf(MySQLComPingExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_PING, mock(CommandPacket.class), connectionSession), isA(MySQLComPingExecutor.class));
}
@Test
void assertNewInstanceWithComStmtPrepare() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(
- MySQLCommandPacketType.COM_STMT_PREPARE, mock(MySQLComStmtPreparePacket.class), connectionSession), instanceOf(MySQLComStmtPrepareExecutor.class));
+ MySQLCommandPacketType.COM_STMT_PREPARE, mock(MySQLComStmtPreparePacket.class), connectionSession), isA(MySQLComStmtPrepareExecutor.class));
}
@Test
void assertNewInstanceWithComStmtExecute() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE, mock(MySQLComStmtExecutePacket.class), connectionSession),
- instanceOf(MySQLComStmtExecuteExecutor.class));
+ isA(MySQLComStmtExecuteExecutor.class));
}
@Test
void assertNewInstanceWithComStmtSendLongData() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_SEND_LONG_DATA, mock(MySQLComStmtSendLongDataPacket.class), connectionSession),
- instanceOf(MySQLComStmtSendLongDataExecutor.class));
+ isA(MySQLComStmtSendLongDataExecutor.class));
}
@Test
void assertNewInstanceWithComStmtReset() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_RESET,
- mock(MySQLComStmtResetPacket.class), connectionSession), instanceOf(MySQLComStmtResetExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_RESET, mock(MySQLComStmtResetPacket.class), connectionSession), isA(MySQLComStmtResetExecutor.class));
}
@Test
void assertNewInstanceWithComStmtClose() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_CLOSE,
- mock(MySQLComStmtClosePacket.class), connectionSession), instanceOf(MySQLComStmtCloseExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_STMT_CLOSE, mock(MySQLComStmtClosePacket.class), connectionSession), isA(MySQLComStmtCloseExecutor.class));
}
@Test
void assertNewInstanceWithComSetOption() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_SET_OPTION, mock(MySQLComSetOptionPacket.class), connectionSession), instanceOf(MySQLComSetOptionExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_SET_OPTION, mock(MySQLComSetOptionPacket.class), connectionSession), isA(MySQLComSetOptionExecutor.class));
}
@Test
void assertNewInstanceWithComResetConnection() throws SQLException {
assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_RESET_CONNECTION, mock(MySQLComSetOptionPacket.class), connectionSession),
- instanceOf(MySQLComResetConnectionExecutor.class));
+ isA(MySQLComResetConnectionExecutor.class));
}
@Test
void assertNewInstanceWithUnsupportedCommand() throws SQLException {
- assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_REFRESH, mock(CommandPacket.class), connectionSession), instanceOf(MySQLUnsupportedCommandExecutor.class));
+ assertThat(MySQLCommandExecutorFactory.newInstance(MySQLCommandPacketType.COM_REFRESH, mock(CommandPacket.class), connectionSession), isA(MySQLUnsupportedCommandExecutor.class));
}
}
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
index e58ffe4687b..4d1d4f64b51 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandPacketFactoryTest.java
@@ -50,8 +50,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
@@ -68,29 +68,29 @@ class MySQLCommandPacketFactoryTest {
@Test
void assertNewInstanceWithComQuitPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_QUIT, payload, connectionSession), instanceOf(MySQLComQuitPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_QUIT, payload, connectionSession), isA(MySQLComQuitPacket.class));
}
@Test
void assertNewInstanceWithComInitDbPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_INIT_DB, payload, connectionSession), instanceOf(MySQLComInitDbPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_INIT_DB, payload, connectionSession), isA(MySQLComInitDbPacket.class));
}
@Test
void assertNewInstanceWithComFieldListPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_FIELD_LIST, payload, connectionSession), instanceOf(MySQLComFieldListPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_FIELD_LIST, payload, connectionSession), isA(MySQLComFieldListPacket.class));
}
@Test
void assertNewInstanceWithComQueryPacket() {
when(payload.readStringEOF()).thenReturn("SHOW TABLES");
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_QUERY, payload, connectionSession), instanceOf(MySQLComQueryPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_QUERY, payload, connectionSession), isA(MySQLComQueryPacket.class));
}
@Test
void assertNewInstanceWithComStmtPreparePacket() {
when(payload.readStringEOF()).thenReturn("");
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_PREPARE, payload, connectionSession), instanceOf(MySQLComStmtPreparePacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_PREPARE, payload, connectionSession), isA(MySQLComStmtPreparePacket.class));
}
@Test
@@ -102,136 +102,136 @@ class MySQLCommandPacketFactoryTest {
when(connectionSession.getServerPreparedStatementRegistry()).thenReturn(serverPreparedStatementRegistry);
SQLStatementContext sqlStatementContext = new CommonSQLStatementContext(new SelectStatement(databaseType));
serverPreparedStatementRegistry.addPreparedStatement(1, new MySQLServerPreparedStatement("select 1", sqlStatementContext, new HintValueContext(), Collections.emptyList()));
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE, payload, connectionSession), instanceOf(MySQLComStmtExecutePacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_EXECUTE, payload, connectionSession), isA(MySQLComStmtExecutePacket.class));
}
@Test
void assertNewInstanceWithComStmtClosePacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_CLOSE, payload, connectionSession), instanceOf(MySQLComStmtClosePacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_CLOSE, payload, connectionSession), isA(MySQLComStmtClosePacket.class));
}
@Test
void assertNewInstanceWithComPingPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_PING, payload, connectionSession), instanceOf(MySQLComPingPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_PING, payload, connectionSession), isA(MySQLComPingPacket.class));
}
@Test
void assertNewInstanceWithComResetConnectionPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_RESET_CONNECTION, payload, connectionSession), instanceOf(MySQLComResetConnectionPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_RESET_CONNECTION, payload, connectionSession), isA(MySQLComResetConnectionPacket.class));
}
@Test
void assertNewInstanceWithComSleepPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_SLEEP, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_SLEEP, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComCreateDbPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CREATE_DB, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CREATE_DB, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComDropDbPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DROP_DB, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DROP_DB, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComRefreshPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_REFRESH, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_REFRESH, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComShutDownPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_SHUTDOWN, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_SHUTDOWN, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComStatisticsPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STATISTICS, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STATISTICS, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComProcessInfoPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_PROCESS_INFO, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_PROCESS_INFO, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComConnectPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CONNECT, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CONNECT, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComProcessKillPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_PROCESS_KILL, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_PROCESS_KILL, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComDebugPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DEBUG, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DEBUG, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComTimePacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_TIME, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_TIME, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComDelayedInsertPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DELAYED_INSERT, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DELAYED_INSERT, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComChangeUserPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CHANGE_USER, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CHANGE_USER, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComBinlogDumpPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_BINLOG_DUMP, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_BINLOG_DUMP, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComTableDumpPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_TABLE_DUMP, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_TABLE_DUMP, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComConnectOutPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CONNECT_OUT, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_CONNECT_OUT, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComRegisterSlavePacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_REGISTER_SLAVE, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_REGISTER_SLAVE, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComStmtSendLongDataPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_SEND_LONG_DATA, payload, connectionSession), instanceOf(MySQLComStmtSendLongDataPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_SEND_LONG_DATA, payload, connectionSession), isA(MySQLComStmtSendLongDataPacket.class));
}
@Test
void assertNewInstanceWithComStmtResetPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_RESET, payload, connectionSession), instanceOf(MySQLComStmtResetPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_RESET, payload, connectionSession), isA(MySQLComStmtResetPacket.class));
}
@Test
void assertNewInstanceWithComSetOptionPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_SET_OPTION, payload, connectionSession), instanceOf(MySQLComSetOptionPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_SET_OPTION, payload, connectionSession), isA(MySQLComSetOptionPacket.class));
}
@Test
void assertNewInstanceWithComStmtFetchPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_FETCH, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_STMT_FETCH, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComDaemonPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DAEMON, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_DAEMON, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
@Test
void assertNewInstanceWithComBinlogDumpGTIDPacket() {
- assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_BINLOG_DUMP_GTID, payload, connectionSession), instanceOf(MySQLUnsupportedCommandPacket.class));
+ assertThat(MySQLCommandPacketFactory.newInstance(MySQLCommandPacketType.COM_BINLOG_DUMP_GTID, payload, connectionSession), isA(MySQLUnsupportedCommandPacket.class));
}
}
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java
index e0d55b001e4..3884ad84906 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComResetConnectionExecutorTest.java
@@ -35,9 +35,9 @@ import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -58,7 +58,7 @@ class MySQLComResetConnectionExecutorTest {
connectionSession.getServerPreparedStatementRegistry().addPreparedStatement(statementId, new MySQLServerPreparedStatement("", null, new HintValueContext(), Collections.emptyList()));
Collection<DatabasePacket> actual = new MySQLComResetConnectionExecutor(connectionSession).execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(MySQLOKPacket.class));
+ assertThat(actual.iterator().next(), isA(MySQLOKPacket.class));
verify(connectionSession).setAutoCommit(true);
verify(connectionSession).setDefaultIsolationLevel(null);
verify(connectionSession).setIsolationLevel(null);
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutorTest.java
index 889f64baf0b..53c304f1b1b 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutorTest.java
@@ -32,9 +32,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -59,7 +59,7 @@ class MySQLComSetOptionExecutorTest {
when(connectionSession.getAttributeMap().attr(MySQLConstants.OPTION_MULTI_STATEMENTS_ATTRIBUTE_KEY)).thenReturn(attribute);
Collection<DatabasePacket> actual = executor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(MySQLOKPacket.class));
+ assertThat(actual.iterator().next(), isA(MySQLOKPacket.class));
verify(attribute).set(MySQLComSetOptionPacket.MYSQL_OPTION_MULTI_STATEMENTS_ON);
}
}
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 d415b8bff21..75fd5c45016 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
@@ -75,9 +75,9 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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;
@@ -164,13 +164,13 @@ class MySQLComStmtExecuteExecutorTest {
when(ProxyBackendHandlerFactory.newInstance(eq(databaseType), any(QueryContext.class), eq(connectionSession), anyBoolean())).thenReturn(proxyBackendHandler);
Iterator<DatabasePacket> actual = executor.execute().iterator();
assertThat(executor.getResponseType(), is(ResponseType.QUERY));
- assertThat(actual.next(), instanceOf(MySQLFieldCountPacket.class));
- assertThat(actual.next(), instanceOf(MySQLColumnDefinition41Packet.class));
- assertThat(actual.next(), instanceOf(MySQLEofPacket.class));
+ assertThat(actual.next(), isA(MySQLFieldCountPacket.class));
+ assertThat(actual.next(), isA(MySQLColumnDefinition41Packet.class));
+ assertThat(actual.next(), isA(MySQLEofPacket.class));
assertFalse(actual.hasNext());
assertTrue(executor.next());
MySQLPacket actualQueryRowPacket = executor.getQueryRowPacket();
- assertThat(actualQueryRowPacket, instanceOf(MySQLBinaryResultSetRowPacket.class));
+ assertThat(actualQueryRowPacket, isA(MySQLBinaryResultSetRowPacket.class));
executor.close();
verify(proxyBackendHandler).close();
}
@@ -185,7 +185,7 @@ class MySQLComStmtExecuteExecutorTest {
when(ProxyBackendHandlerFactory.newInstance(eq(databaseType), any(QueryContext.class), eq(connectionSession), anyBoolean())).thenReturn(proxyBackendHandler);
Iterator<DatabasePacket> actual = executor.execute().iterator();
assertThat(executor.getResponseType(), is(ResponseType.UPDATE));
- assertThat(actual.next(), instanceOf(MySQLOKPacket.class));
+ assertThat(actual.next(), isA(MySQLOKPacket.class));
assertFalse(actual.hasNext());
}
@@ -199,7 +199,7 @@ class MySQLComStmtExecuteExecutorTest {
when(ProxyBackendHandlerFactory.newInstance(eq(databaseType), any(QueryContext.class), eq(connectionSession), eq(true))).thenReturn(proxyBackendHandler);
Iterator<DatabasePacket> actual = executor.execute().iterator();
assertThat(executor.getResponseType(), is(ResponseType.UPDATE));
- assertThat(actual.next(), instanceOf(MySQLOKPacket.class));
+ assertThat(actual.next(), isA(MySQLOKPacket.class));
assertFalse(actual.hasNext());
executor.close();
verify(proxyBackendHandler).close();
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 9896fb853eb..da99d23be99 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
@@ -70,9 +70,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -117,16 +117,16 @@ class MySQLComStmtPrepareExecutorTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
Iterator<DatabasePacket> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator();
- assertThat(actualIterator.next(), instanceOf(MySQLComStmtPrepareOKPacket.class));
- assertThat(actualIterator.next(), instanceOf(MySQLColumnDefinition41Packet.class));
- assertThat(actualIterator.next(), instanceOf(MySQLEofPacket.class));
- assertThat(actualIterator.next(), instanceOf(MySQLColumnDefinition41Packet.class));
- assertThat(actualIterator.next(), instanceOf(MySQLEofPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLComStmtPrepareOKPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLColumnDefinition41Packet.class));
+ assertThat(actualIterator.next(), isA(MySQLEofPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLColumnDefinition41Packet.class));
+ assertThat(actualIterator.next(), isA(MySQLEofPacket.class));
assertFalse(actualIterator.hasNext());
MySQLServerPreparedStatement actualPreparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(1);
assertThat(actualPreparedStatement.getSql(), is(sql));
- assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(SelectStatementContext.class));
- assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(SelectStatement.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext(), isA(SelectStatementContext.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), isA(SelectStatement.class));
MySQLStatementIdGenerator.getInstance().unregisterConnection(1);
}
@@ -142,24 +142,24 @@ class MySQLComStmtPrepareExecutorTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
Iterator<DatabasePacket> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator();
- assertThat(actualIterator.next(), instanceOf(MySQLComStmtPrepareOKPacket.class));
- assertThat(actualIterator.next(), instanceOf(MySQLColumnDefinition41Packet.class));
+ assertThat(actualIterator.next(), isA(MySQLComStmtPrepareOKPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLColumnDefinition41Packet.class));
DatabasePacket firstAgeColumnDefinitionPacket = actualIterator.next();
- assertThat(firstAgeColumnDefinitionPacket, instanceOf(MySQLColumnDefinition41Packet.class));
+ assertThat(firstAgeColumnDefinitionPacket, isA(MySQLColumnDefinition41Packet.class));
assertThat(getColumnDefinitionFlag((MySQLColumnDefinition41Packet) firstAgeColumnDefinitionPacket), is(MySQLColumnDefinitionFlag.UNSIGNED.getValue()));
DatabasePacket idColumnDefinitionPacket = actualIterator.next();
- assertThat(idColumnDefinitionPacket, instanceOf(MySQLColumnDefinition41Packet.class));
+ assertThat(idColumnDefinitionPacket, isA(MySQLColumnDefinition41Packet.class));
assertThat(getColumnDefinitionFlag((MySQLColumnDefinition41Packet) idColumnDefinitionPacket),
is(MySQLColumnDefinitionFlag.PRIMARY_KEY.getValue() | MySQLColumnDefinitionFlag.UNSIGNED.getValue()));
DatabasePacket secondAgeColumnDefinitionPacket = actualIterator.next();
- assertThat(secondAgeColumnDefinitionPacket, instanceOf(MySQLColumnDefinition41Packet.class));
+ assertThat(secondAgeColumnDefinitionPacket, isA(MySQLColumnDefinition41Packet.class));
assertThat(getColumnDefinitionFlag((MySQLColumnDefinition41Packet) secondAgeColumnDefinitionPacket), is(MySQLColumnDefinitionFlag.UNSIGNED.getValue()));
- assertThat(actualIterator.next(), instanceOf(MySQLEofPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLEofPacket.class));
assertFalse(actualIterator.hasNext());
MySQLServerPreparedStatement actualPreparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(1);
assertThat(actualPreparedStatement.getSql(), is(sql));
- assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(InsertStatementContext.class));
- assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(InsertStatement.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext(), isA(InsertStatementContext.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), isA(InsertStatement.class));
MySQLStatementIdGenerator.getInstance().unregisterConnection(connectionId);
}
@@ -202,16 +202,16 @@ class MySQLComStmtPrepareExecutorTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
Iterator<DatabasePacket> actualIterator = new MySQLComStmtPrepareExecutor(packet, connectionSession).execute().iterator();
- assertThat(actualIterator.next(), instanceOf(MySQLComStmtPrepareOKPacket.class));
- assertThat(actualIterator.next(), instanceOf(MySQLColumnDefinition41Packet.class));
- assertThat(actualIterator.next(), instanceOf(MySQLColumnDefinition41Packet.class));
- assertThat(actualIterator.next(), instanceOf(MySQLColumnDefinition41Packet.class));
- assertThat(actualIterator.next(), instanceOf(MySQLEofPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLComStmtPrepareOKPacket.class));
+ assertThat(actualIterator.next(), isA(MySQLColumnDefinition41Packet.class));
+ assertThat(actualIterator.next(), isA(MySQLColumnDefinition41Packet.class));
+ assertThat(actualIterator.next(), isA(MySQLColumnDefinition41Packet.class));
+ assertThat(actualIterator.next(), isA(MySQLEofPacket.class));
assertFalse(actualIterator.hasNext());
MySQLServerPreparedStatement actualPreparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(1);
assertThat(actualPreparedStatement.getSql(), is(sql));
- assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(UpdateStatementContext.class));
- assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(UpdateStatement.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext(), isA(UpdateStatementContext.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), isA(UpdateStatement.class));
MySQLStatementIdGenerator.getInstance().unregisterConnection(1);
}
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
index f6399da61d0..80bfb99b5d3 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
@@ -31,9 +31,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -53,7 +53,7 @@ class MySQLComStmtResetExecutorTest {
MySQLComStmtResetExecutor executor = new MySQLComStmtResetExecutor(packet, connectionSession);
Collection<DatabasePacket> actual = executor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(MySQLOKPacket.class));
+ assertThat(actual.iterator().next(), isA(MySQLOKPacket.class));
assertTrue(preparedStatement.getLongData().isEmpty());
}
}
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
index 095f0ea0211..d9c5914d47f 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
@@ -36,9 +36,9 @@ import java.util.Collection;
import java.util.List;
import static org.hamcrest.CoreMatchers.anyOf;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -53,7 +53,7 @@ class ResponsePacketBuilderTest {
QueryResponseHeader queryResponseHeader = new QueryResponseHeader(queryHeaders);
Collection<DatabasePacket> actual = ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 255, 0);
assertTrue(actual.stream().findAny().isPresent());
- assertThat(actual.stream().findAny().get(), anyOf(instanceOf(MySQLFieldCountPacket.class), instanceOf(MySQLColumnDefinition41Packet.class), instanceOf(MySQLEofPacket.class)));
+ assertThat(actual.stream().findAny().get(), anyOf(isA(MySQLFieldCountPacket.class), isA(MySQLColumnDefinition41Packet.class), isA(MySQLEofPacket.class)));
}
@Test
@@ -64,7 +64,7 @@ class ResponsePacketBuilderTest {
Collection<DatabasePacket> actual = ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, 0);
assertTrue(actual.stream().findAny().isPresent());
MySQLOKPacket actualItem = (MySQLOKPacket) actual.stream().findAny().get();
- assertThat(actualItem, instanceOf(MySQLOKPacket.class));
+ assertThat(actualItem, isA(MySQLOKPacket.class));
assertThat(actualItem.getAffectedRows(), is(10L));
assertThat(actualItem.getLastInsertId(), is(100L));
}
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
index 14199a2d85b..f7a1f0215fa 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
@@ -66,9 +66,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.RETURNS_DEEP_STUBS;
@@ -133,7 +133,7 @@ class MySQLComQueryPacketExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(new UpdateResponseHeader(mock(SQLStatement.class)));
Collection<DatabasePacket> actualPackets = actual.execute();
assertThat(actualPackets.size(), is(1));
- assertThat(actualPackets.iterator().next(), instanceOf(MySQLOKPacket.class));
+ assertThat(actualPackets.iterator().next(), isA(MySQLOKPacket.class));
}
@Test
@@ -154,8 +154,8 @@ class MySQLComQueryPacketExecutorTest {
Collection<DatabasePacket> actualPackets = actual.execute();
assertThat(actualPackets.size(), is(2));
Iterator<DatabasePacket> iterator = actualPackets.iterator();
- assertThat(iterator.next(), instanceOf(MySQLOKPacket.class));
- assertThat(iterator.next(), instanceOf(MySQLOKPacket.class));
+ assertThat(iterator.next(), isA(MySQLOKPacket.class));
+ assertThat(iterator.next(), isA(MySQLOKPacket.class));
}
private MetaDataContexts mockMetaDataContexts() {
@@ -187,7 +187,7 @@ class MySQLComQueryPacketExecutorTest {
@Test
void assertGetQueryRowPacket() throws SQLException {
- assertThat(new MySQLComQueryPacketExecutor(packet, connectionSession).getQueryRowPacket(), instanceOf(MySQLTextResultSetRowPacket.class));
+ assertThat(new MySQLComQueryPacketExecutor(packet, connectionSession).getQueryRowPacket(), isA(MySQLTextResultSetRowPacket.class));
}
@Test
diff --git a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
index ebdd78f91fe..ee91711e83f 100644
--- a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
+++ b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
@@ -55,9 +55,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -79,7 +79,7 @@ class MySQLMultiStatementsHandlerTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ResponseHeader actual = new MySQLMultiStatementsHandler(connectionSession, expectedStatement, sql).execute();
- assertThat(actual, instanceOf(MultiStatementsUpdateResponseHeader.class));
+ assertThat(actual, isA(MultiStatementsUpdateResponseHeader.class));
MultiStatementsUpdateResponseHeader actualHeader = (MultiStatementsUpdateResponseHeader) actual;
assertThat(actualHeader.getUpdateResponseHeaders().size(), is(3));
Iterator<UpdateResponseHeader> iterator = actualHeader.getUpdateResponseHeaders().iterator();
@@ -105,7 +105,7 @@ class MySQLMultiStatementsHandlerTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ResponseHeader actual = new MySQLMultiStatementsHandler(connectionSession, expectedStatement, sql).execute();
- assertThat(actual, instanceOf(MultiStatementsUpdateResponseHeader.class));
+ assertThat(actual, isA(MultiStatementsUpdateResponseHeader.class));
MultiStatementsUpdateResponseHeader actualHeader = (MultiStatementsUpdateResponseHeader) actual;
assertThat(actualHeader.getUpdateResponseHeaders().size(), is(3));
Iterator<UpdateResponseHeader> iterator = actualHeader.getUpdateResponseHeaders().iterator();
@@ -133,7 +133,7 @@ class MySQLMultiStatementsHandlerTest {
ContextManager contextManager = mockContextManager();
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
ResponseHeader actual = new MySQLMultiStatementsHandler(connectionSession, expectedStatement, sql).execute();
- assertThat(actual, instanceOf(MultiStatementsUpdateResponseHeader.class));
+ assertThat(actual, isA(MultiStatementsUpdateResponseHeader.class));
MultiStatementsUpdateResponseHeader actualHeader = (MultiStatementsUpdateResponseHeader) actual;
assertThat(actualHeader.getUpdateResponseHeaders().size(), is(3));
Iterator<UpdateResponseHeader> iterator = actualHeader.getUpdateResponseHeaders().iterator();
diff --git a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
index 5f6fa5c8b6d..f834de67081 100644
--- a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
+++ b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
@@ -29,8 +29,8 @@ import org.mockito.Mock;
import org.mockito.internal.configuration.plugins.Plugins;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -49,17 +49,17 @@ class OpenGaussFrontendEngineTest {
@Test
void assertGetCommandExecuteEngine() {
- assertThat(openGaussFrontendEngine.getCommandExecuteEngine(), instanceOf(OpenGaussCommandExecuteEngine.class));
+ assertThat(openGaussFrontendEngine.getCommandExecuteEngine(), isA(OpenGaussCommandExecuteEngine.class));
}
@Test
void assertGetCodecEngine() {
- assertThat(openGaussFrontendEngine.getCodecEngine(), instanceOf(OpenGaussPacketCodecEngine.class));
+ assertThat(openGaussFrontendEngine.getCodecEngine(), isA(OpenGaussPacketCodecEngine.class));
}
@Test
void assertGetAuthenticationEngine() {
- assertThat(openGaussFrontendEngine.getAuthenticationEngine(), instanceOf(OpenGaussAuthenticationEngine.class));
+ assertThat(openGaussFrontendEngine.getAuthenticationEngine(), isA(OpenGaussAuthenticationEngine.class));
}
@Test
diff --git a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactoryTest.java b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactoryTest.java
index ac90edc0706..595e0442068 100644
--- a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactoryTest.java
+++ b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecutorFactoryTest.java
@@ -60,8 +60,8 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -79,7 +79,7 @@ class OpenGaussCommandExecutorFactoryTest {
void assertNewOpenGaussBatchBindExecutor() throws SQLException {
OpenGaussComBatchBindPacket batchBindPacket = mock(OpenGaussComBatchBindPacket.class);
CommandExecutor actual = OpenGaussCommandExecutorFactory.newInstance(OpenGaussCommandPacketType.BATCH_BIND_COMMAND, batchBindPacket, connectionSession, portalContext);
- assertThat(actual, instanceOf(OpenGaussComBatchBindExecutor.class));
+ assertThat(actual, isA(OpenGaussComBatchBindExecutor.class));
}
@Test
@@ -87,7 +87,7 @@ class OpenGaussCommandExecutorFactoryTest {
PostgreSQLComQueryPacket queryPacket = mock(PostgreSQLComQueryPacket.class);
when(queryPacket.getSQL()).thenReturn("");
CommandExecutor actual = OpenGaussCommandExecutorFactory.newInstance(PostgreSQLCommandPacketType.SIMPLE_QUERY, queryPacket, connectionSession, portalContext);
- assertThat(actual, instanceOf(OpenGaussComQueryExecutor.class));
+ assertThat(actual, isA(OpenGaussComQueryExecutor.class));
}
@Test
@@ -107,14 +107,14 @@ class OpenGaussCommandExecutorFactoryTest {
when(packet.isContainsBatchedStatements()).thenReturn(false);
when(packet.getPackets()).thenReturn(Arrays.asList(parsePacket, flushPacket, bindPacket, describePacket, executePacket, syncPacket));
CommandExecutor actual = OpenGaussCommandExecutorFactory.newInstance(null, packet, connectionSession, portalContext);
- assertThat(actual, instanceOf(PostgreSQLAggregatedCommandExecutor.class));
+ assertThat(actual, isA(PostgreSQLAggregatedCommandExecutor.class));
Iterator<CommandExecutor> actualPacketsIterator = getExecutorsFromAggregatedCommandExecutor((PostgreSQLAggregatedCommandExecutor) actual).iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComParseExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComFlushExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComBindExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComDescribeExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComExecuteExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComSyncExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComParseExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComFlushExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComBindExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComDescribeExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComExecuteExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComSyncExecutor.class));
assertFalse(actualPacketsIterator.hasNext());
}
@@ -138,13 +138,13 @@ class OpenGaussCommandExecutorFactoryTest {
when(packet.getBatchPacketBeginIndex()).thenReturn(1);
when(packet.getBatchPacketEndIndex()).thenReturn(6);
CommandExecutor actual = OpenGaussCommandExecutorFactory.newInstance(null, packet, connectionSession, portalContext);
- assertThat(actual, instanceOf(PostgreSQLAggregatedCommandExecutor.class));
+ assertThat(actual, isA(PostgreSQLAggregatedCommandExecutor.class));
Iterator<CommandExecutor> actualPacketsIterator = getExecutorsFromAggregatedCommandExecutor((PostgreSQLAggregatedCommandExecutor) actual).iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComParseExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLAggregatedBatchedStatementsCommandExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComCloseExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComSyncExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComTerminationExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComParseExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLAggregatedBatchedStatementsCommandExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComCloseExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComSyncExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComTerminationExecutor.class));
assertFalse(actualPacketsIterator.hasNext());
}
diff --git a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
index cb330fe013a..1aa05021418 100644
--- a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
+++ b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
@@ -60,9 +60,9 @@ import java.sql.Types;
import java.util.Collections;
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -95,7 +95,7 @@ class OpenGaussComBatchBindExecutorTest {
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
Iterator<DatabasePacket> actualPacketsIterator = new OpenGaussComBatchBindExecutor(mockComBatchBindPacket(), connectionSession).execute().iterator();
assertThat(actualPacketsIterator.next(), is(PostgreSQLBindCompletePacket.getInstance()));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLCommandCompletePacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLCommandCompletePacket.class));
assertFalse(actualPacketsIterator.hasNext());
}
diff --git a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutorTest.java b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutorTest.java
index 0e7fc339b7d..14df5362ff7 100644
--- a/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutorTest.java
+++ b/proxy/frontend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/simple/OpenGaussComQueryExecutorTest.java
@@ -44,9 +44,9 @@ import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.mock;
@@ -84,7 +84,7 @@ class OpenGaussComQueryExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(queryResponseHeader);
Collection actual = queryExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLRowDescriptionPacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLRowDescriptionPacket.class)));
assertThat(queryExecutor.getResponseType(), is(ResponseType.QUERY));
verify(queryResponseHeader).getQueryHeaders();
}
@@ -96,7 +96,7 @@ class OpenGaussComQueryExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(queryResponseHeader);
Collection actual = queryExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLRowDescriptionPacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLRowDescriptionPacket.class)));
assertThat(queryExecutor.getResponseType(), is(ResponseType.QUERY));
verify(queryResponseHeader).getQueryHeaders();
}
@@ -106,7 +106,7 @@ class OpenGaussComQueryExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(new UpdateResponseHeader(mock(InsertStatement.class)));
Collection<DatabasePacket> actual = queryExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLCommandCompletePacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLCommandCompletePacket.class)));
assertThat(queryExecutor.getResponseType(), is(ResponseType.UPDATE));
}
@@ -121,6 +121,6 @@ class OpenGaussComQueryExecutorTest {
void assertGetQueryRowPacket() throws SQLException {
when(proxyBackendHandler.getRowData()).thenReturn(new QueryResponseRow(Collections.emptyList()));
PostgreSQLPacket actual = queryExecutor.getQueryRowPacket();
- assertThat(actual, is(instanceOf(PostgreSQLDataRowPacket.class)));
+ assertThat(actual, is(isA(PostgreSQLDataRowPacket.class)));
}
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
index 061ec9441db..af11fa02619 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecutorFactoryTest.java
@@ -57,8 +57,8 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -91,7 +91,7 @@ class PostgreSQLCommandExecutorFactoryTest {
}
PostgreSQLCommandPacket packet = preparePacket(commandPacketClass);
CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(each.getCommandPacketType(), packet, connectionSession, portalContext);
- assertThat(actual, instanceOf(each.getResultClass()));
+ assertThat(actual, isA(each.getResultClass()));
}
}
@@ -119,13 +119,13 @@ class PostgreSQLCommandExecutorFactoryTest {
when(packet.isContainsBatchedStatements()).thenReturn(false);
when(packet.getPackets()).thenReturn(Arrays.asList(parsePacket, bindPacket, describePacket, executePacket, syncPacket));
CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(null, packet, connectionSession, portalContext);
- assertThat(actual, instanceOf(PostgreSQLAggregatedCommandExecutor.class));
+ assertThat(actual, isA(PostgreSQLAggregatedCommandExecutor.class));
Iterator<CommandExecutor> actualPacketsIterator = getExecutorsFromAggregatedCommandExecutor((PostgreSQLAggregatedCommandExecutor) actual).iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComParseExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComBindExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComDescribeExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComExecuteExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComSyncExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComParseExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComBindExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComDescribeExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComExecuteExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComSyncExecutor.class));
assertFalse(actualPacketsIterator.hasNext());
}
@@ -144,11 +144,11 @@ class PostgreSQLCommandExecutorFactoryTest {
when(packet.getBatchPacketBeginIndex()).thenReturn(1);
when(packet.getBatchPacketEndIndex()).thenReturn(6);
CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(null, packet, connectionSession, portalContext);
- assertThat(actual, instanceOf(PostgreSQLAggregatedCommandExecutor.class));
+ assertThat(actual, isA(PostgreSQLAggregatedCommandExecutor.class));
Iterator<CommandExecutor> actualPacketsIterator = getExecutorsFromAggregatedCommandExecutor((PostgreSQLAggregatedCommandExecutor) actual).iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComParseExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLAggregatedBatchedStatementsCommandExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComSyncExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComParseExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLAggregatedBatchedStatementsCommandExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComSyncExecutor.class));
assertFalse(actualPacketsIterator.hasNext());
}
@@ -161,10 +161,10 @@ class PostgreSQLCommandExecutorFactoryTest {
PostgreSQLAggregatedCommandPacket packet = mock(PostgreSQLAggregatedCommandPacket.class);
when(packet.getPackets()).thenReturn(Arrays.asList(flushPacket, syncPacket));
CommandExecutor actual = PostgreSQLCommandExecutorFactory.newInstance(null, packet, connectionSession, portalContext);
- assertThat(actual, instanceOf(PostgreSQLAggregatedCommandExecutor.class));
+ assertThat(actual, isA(PostgreSQLAggregatedCommandExecutor.class));
Iterator<CommandExecutor> actualPacketsIterator = getExecutorsFromAggregatedCommandExecutor((PostgreSQLAggregatedCommandExecutor) actual).iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComFlushExecutor.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLComSyncExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComFlushExecutor.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLComSyncExecutor.class));
assertFalse(actualPacketsIterator.hasNext());
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutorTest.java
index c69f24b9112..fcaabc89ce8 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/generic/PostgreSQLUnsupportedCommandExecutorTest.java
@@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
class PostgreSQLUnsupportedCommandExecutorTest {
@@ -34,6 +34,6 @@ class PostgreSQLUnsupportedCommandExecutorTest {
PostgreSQLUnsupportedCommandExecutor commandExecutor = new PostgreSQLUnsupportedCommandExecutor();
Collection<DatabasePacket> actual = commandExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), instanceOf(PostgreSQLErrorResponsePacket.class));
+ assertThat(actual.iterator().next(), isA(PostgreSQLErrorResponsePacket.class));
}
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
index b3204bb3ef3..336b3a77433 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
@@ -78,9 +78,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -167,7 +167,7 @@ class PortalTest {
Portal portal = new Portal("", preparedStatement, Collections.emptyList(), resultFormats, databaseConnectionManager);
portal.bind();
PostgreSQLPacket portalDescription = portal.describe();
- assertThat(portalDescription, instanceOf(PostgreSQLRowDescriptionPacket.class));
+ assertThat(portalDescription, isA(PostgreSQLRowDescriptionPacket.class));
Collection<PostgreSQLColumnDescription> columnDescriptions = (Collection<PostgreSQLColumnDescription>) Plugins.getMemberAccessor()
.get(PostgreSQLRowDescriptionPacket.class.getDeclaredField("columnDescriptions"), portalDescription);
Iterator<PostgreSQLColumnDescription> columnDescriptionIterator = columnDescriptions.iterator();
@@ -178,9 +178,9 @@ class PortalTest {
List<DatabasePacket> actualPackets = portal.execute(0);
assertThat(actualPackets.size(), is(3));
Iterator<DatabasePacket> actualPacketsIterator = actualPackets.iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLDataRowPacket.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLDataRowPacket.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLCommandCompletePacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLDataRowPacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLDataRowPacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLCommandCompletePacket.class));
}
@Test
@@ -201,13 +201,13 @@ class PortalTest {
List<PostgreSQLValueFormat> resultFormats = new ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, PostgreSQLValueFormat.BINARY));
Portal portal = new Portal("", preparedStatement, Collections.emptyList(), resultFormats, databaseConnectionManager);
portal.bind();
- assertThat(portal.describe(), instanceOf(PostgreSQLRowDescriptionPacket.class));
+ assertThat(portal.describe(), isA(PostgreSQLRowDescriptionPacket.class));
List<DatabasePacket> actualPackets = portal.execute(2);
assertThat(actualPackets.size(), is(3));
Iterator<DatabasePacket> actualPacketsIterator = actualPackets.iterator();
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLDataRowPacket.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLDataRowPacket.class));
- assertThat(actualPacketsIterator.next(), instanceOf(PostgreSQLPortalSuspendedPacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLDataRowPacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLDataRowPacket.class));
+ assertThat(actualPacketsIterator.next(), isA(PostgreSQLPortalSuspendedPacket.class));
}
@Test
@@ -223,7 +223,7 @@ class PortalTest {
portal.bind();
assertThat(portal.describe(), is(PostgreSQLNoDataPacket.getInstance()));
List<DatabasePacket> actualPackets = portal.execute(0);
- assertThat(actualPackets.iterator().next(), instanceOf(PostgreSQLCommandCompletePacket.class));
+ assertThat(actualPackets.iterator().next(), isA(PostgreSQLCommandCompletePacket.class));
}
@Test
@@ -236,7 +236,7 @@ class PortalTest {
portal.bind();
assertThat(portal.describe(), is(PostgreSQLNoDataPacket.getInstance()));
List<DatabasePacket> actualPackets = portal.execute(0);
- assertThat(actualPackets.iterator().next(), instanceOf(PostgreSQLEmptyQueryResponsePacket.class));
+ assertThat(actualPackets.iterator().next(), isA(PostgreSQLEmptyQueryResponsePacket.class));
}
@Test
@@ -251,8 +251,8 @@ class PortalTest {
portal.bind();
List<DatabasePacket> actualPackets = portal.execute(0);
assertThat(actualPackets.size(), is(2));
- assertThat(actualPackets.get(0), instanceOf(PostgreSQLCommandCompletePacket.class));
- assertThat(actualPackets.get(1), instanceOf(PostgreSQLParameterStatusPacket.class));
+ assertThat(actualPackets.get(0), isA(PostgreSQLCommandCompletePacket.class));
+ assertThat(actualPackets.get(1), isA(PostgreSQLParameterStatusPacket.class));
}
@Test
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
index 26a60f5db85..c9cd6d84b4d 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
@@ -65,9 +65,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.nullable;
@@ -103,7 +103,7 @@ class PostgreSQLAggregatedBatchedStatementsCommandExecutorTest {
for (int i = 0; i < BATCH_SIZE; i++) {
assertThat(actualPackets.get(i * 3), is(PostgreSQLBindCompletePacket.getInstance()));
assertThat(actualPackets.get(i * 3 + 1), is(PostgreSQLNoDataPacket.getInstance()));
- assertThat(actualPackets.get(i * 3 + 2), instanceOf(PostgreSQLCommandCompletePacket.class));
+ assertThat(actualPackets.get(i * 3 + 2), isA(PostgreSQLCommandCompletePacket.class));
}
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedCommandExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedCommandExecutorTest.java
index bf9ebab89bc..c2ae9baf6d2 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedCommandExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedCommandExecutorTest.java
@@ -29,9 +29,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -49,6 +49,6 @@ class PostgreSQLAggregatedCommandExecutorTest {
PostgreSQLAggregatedCommandExecutor actualExecutor = new PostgreSQLAggregatedCommandExecutor(executors);
Collection<DatabasePacket> actualPackets = actualExecutor.execute();
assertThat(actualPackets.size(), is(1));
- assertThat(actualPackets.iterator().next(), instanceOf(PostgreSQLAggregatedResponsesPacket.class));
+ assertThat(actualPackets.iterator().next(), isA(PostgreSQLAggregatedResponsesPacket.class));
}
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
index 72d745524be..5ccb59161cc 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/close/PostgreSQLComCloseExecutorTest.java
@@ -31,9 +31,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.sql.SQLException;
import java.util.Collection;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -57,7 +57,7 @@ class PostgreSQLComCloseExecutorTest {
PostgreSQLComCloseExecutor closeExecutor = new PostgreSQLComCloseExecutor(portalContext, packet, connectionSession);
Collection<DatabasePacket> actual = closeExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLCloseCompletePacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLCloseCompletePacket.class)));
}
@Test
@@ -68,7 +68,7 @@ class PostgreSQLComCloseExecutorTest {
PostgreSQLComCloseExecutor closeExecutor = new PostgreSQLComCloseExecutor(portalContext, packet, connectionSession);
Collection<DatabasePacket> actual = closeExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLCloseCompletePacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLCloseCompletePacket.class)));
verify(portalContext).close(portalName);
}
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index 461aa7febb1..60839595778 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -82,9 +82,9 @@ import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -273,7 +273,7 @@ class PostgreSQLComDescribeExecutorTest {
verify(mockPayload).writeInt4(23);
verify(mockPayload, times(2)).writeInt4(18);
DatabasePacket actualRowDescriptionPacket = actualPacketsIterator.next();
- assertThat(actualRowDescriptionPacket, is(instanceOf(PostgreSQLRowDescriptionPacket.class)));
+ assertThat(actualRowDescriptionPacket, is(isA(PostgreSQLRowDescriptionPacket.class)));
assertRowDescriptions((PostgreSQLRowDescriptionPacket) actualRowDescriptionPacket);
}
@@ -349,7 +349,7 @@ class PostgreSQLComDescribeExecutorTest {
assertThat(actual.size(), is(2));
Iterator<DatabasePacket> actualPacketsIterator = actual.iterator();
PostgreSQLParameterDescriptionPacket actualParameterDescription = (PostgreSQLParameterDescriptionPacket) actualPacketsIterator.next();
- assertThat(actualParameterDescription, instanceOf(PostgreSQLParameterDescriptionPacket.class));
+ assertThat(actualParameterDescription, isA(PostgreSQLParameterDescriptionPacket.class));
PostgreSQLPacketPayload mockPayload = mock(PostgreSQLPacketPayload.class);
actualParameterDescription.write(mockPayload);
verify(mockPayload).writeInt2(1);
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
index 16f07a13515..422cea54921 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
@@ -59,9 +59,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -102,8 +102,8 @@ class PostgreSQLComParseExecutorTest {
assertThat(actualPackets.size(), is(1));
assertThat(actualPackets.iterator().next(), is(PostgreSQLParseCompletePacket.getInstance()));
PostgreSQLServerPreparedStatement actualPreparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(statementId);
- assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(CommonSQLStatementContext.class));
- assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(EmptyStatement.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext(), isA(CommonSQLStatementContext.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), isA(EmptyStatement.class));
assertThat(actualPreparedStatement.getSql(), is(expectedSQL));
assertThat(actualPreparedStatement.getParameterTypes(), is(Collections.emptyList()));
}
@@ -125,8 +125,8 @@ class PostgreSQLComParseExecutorTest {
assertThat(actualPackets.size(), is(1));
assertThat(actualPackets.iterator().next(), is(PostgreSQLParseCompletePacket.getInstance()));
PostgreSQLServerPreparedStatement actualPreparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(statementId);
- assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(InsertStatementContext.class));
- assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(InsertStatement.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext(), isA(InsertStatementContext.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), isA(InsertStatement.class));
assertThat(actualPreparedStatement.getSql(), is(expectedSQL));
assertThat(actualPreparedStatement.getParameterTypes(), is(Arrays.asList(PostgreSQLColumnType.INT4, PostgreSQLColumnType.UNSPECIFIED)));
}
@@ -179,8 +179,8 @@ class PostgreSQLComParseExecutorTest {
assertThat(actualPackets.iterator().next(), is(PostgreSQLParseCompletePacket.getInstance()));
PostgreSQLServerPreparedStatement actualPreparedStatement = connectionSession.getServerPreparedStatementRegistry().getPreparedStatement(statementId);
assertThat(actualPreparedStatement.getSql(), is(sql));
- assertThat(actualPreparedStatement.getSqlStatementContext(), instanceOf(DistSQLStatementContext.class));
- assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), instanceOf(ShowDistVariableStatement.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext(), isA(DistSQLStatementContext.class));
+ assertThat(actualPreparedStatement.getSqlStatementContext().getSqlStatement(), isA(ShowDistVariableStatement.class));
assertThat(actualPreparedStatement.getParameterTypes(), is(Collections.emptyList()));
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java
index fecbb90f158..9541e492172 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/sync/PostgreSQLComSyncExecutorTest.java
@@ -25,9 +25,9 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -40,6 +40,6 @@ class PostgreSQLComSyncExecutorTest {
void assertNewInstance() {
when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus());
PostgreSQLComSyncExecutor actual = new PostgreSQLComSyncExecutor(connectionSession);
- assertThat(actual.execute().iterator().next(), is(instanceOf(PostgreSQLReadyForQueryPacket.class)));
+ assertThat(actual.execute().iterator().next(), is(isA(PostgreSQLReadyForQueryPacket.class)));
}
}
diff --git a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java
index 9c94261308b..9131fe582f9 100644
--- a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java
+++ b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/simple/PostgreSQLComQueryExecutorTest.java
@@ -44,9 +44,9 @@ import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+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.Mockito.mock;
@@ -84,7 +84,7 @@ class PostgreSQLComQueryExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(queryResponseHeader);
Collection<DatabasePacket> actual = queryExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLRowDescriptionPacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLRowDescriptionPacket.class)));
assertThat(queryExecutor.getResponseType(), is(ResponseType.QUERY));
verify(queryResponseHeader).getQueryHeaders();
}
@@ -96,7 +96,7 @@ class PostgreSQLComQueryExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(queryResponseHeader);
Collection<DatabasePacket> actual = queryExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLRowDescriptionPacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLRowDescriptionPacket.class)));
assertThat(queryExecutor.getResponseType(), is(ResponseType.QUERY));
verify(queryResponseHeader).getQueryHeaders();
}
@@ -106,7 +106,7 @@ class PostgreSQLComQueryExecutorTest {
when(proxyBackendHandler.execute()).thenReturn(new UpdateResponseHeader(mock(InsertStatement.class)));
Collection<DatabasePacket> actual = queryExecutor.execute();
assertThat(actual.size(), is(1));
- assertThat(actual.iterator().next(), is(instanceOf(PostgreSQLCommandCompletePacket.class)));
+ assertThat(actual.iterator().next(), is(isA(PostgreSQLCommandCompletePacket.class)));
assertThat(queryExecutor.getResponseType(), is(ResponseType.UPDATE));
}
@@ -121,6 +121,6 @@ class PostgreSQLComQueryExecutorTest {
void assertGetQueryRowPacket() throws SQLException {
when(proxyBackendHandler.getRowData()).thenReturn(new QueryResponseRow(Collections.emptyList()));
PostgreSQLPacket actual = queryExecutor.getQueryRowPacket();
- assertThat(actual, is(instanceOf(PostgreSQLDataRowPacket.class)));
+ assertThat(actual, is(isA(PostgreSQLDataRowPacket.class)));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/projection/ProjectionAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/projection/ProjectionAssert.java
index 1417b51edca..a298f96c74c 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/projection/ProjectionAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/segment/projection/ProjectionAssert.java
@@ -52,9 +52,9 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.cases.sql.type.SQLC
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -95,22 +95,22 @@ public final class ProjectionAssert {
*/
public static void assertProjection(final SQLCaseAssertContext assertContext, final ProjectionSegment actual, final ExpectedProjection expected) {
if (actual instanceof ShorthandProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedShorthandProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedShorthandProjection.class));
assertShorthandProjection(assertContext, (ShorthandProjectionSegment) actual, (ExpectedShorthandProjection) expected);
} else if (actual instanceof ColumnProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedColumnProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedColumnProjection.class));
assertColumnProjection(assertContext, (ColumnProjectionSegment) actual, (ExpectedColumnProjection) expected);
} else if (actual instanceof AggregationProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedAggregationProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedAggregationProjection.class));
assertAggregationProjection(assertContext, (AggregationProjectionSegment) actual, (ExpectedAggregationProjection) expected);
} else if (actual instanceof ExpressionProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedExpressionProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedExpressionProjection.class));
assertExpressionProjection(assertContext, (ExpressionProjectionSegment) actual, (ExpectedExpressionProjection) expected);
} else if (actual instanceof TopProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedTopProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedTopProjection.class));
assertTopProjection(assertContext, (TopProjectionSegment) actual, (ExpectedTopProjection) expected);
} else if (actual instanceof SubqueryProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedSubqueryProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedSubqueryProjection.class));
assertSubqueryProjection(assertContext, (SubqueryProjectionSegment) actual, (ExpectedSubqueryProjection) expected);
}
SQLSegmentAssert.assertIs(assertContext, actual, expected);
@@ -193,7 +193,7 @@ public final class ProjectionAssert {
assertThat(assertContext.getText("Aggregation projection alias assertion error: "), actual.getAliasName().orElse(null), is(expected.getAlias()));
assertThat(assertContext.getText("Aggregation projection separator assertion error: "), actual.getSeparator().orElse(null), is(expected.getSeparator()));
if (actual instanceof AggregationDistinctProjectionSegment) {
- assertThat(assertContext.getText("Projection type assertion error: "), expected, instanceOf(ExpectedAggregationDistinctProjection.class));
+ assertThat(assertContext.getText("Projection type assertion error: "), expected, isA(ExpectedAggregationDistinctProjection.class));
assertThat(assertContext.getText("Aggregation projection distinct inner expression assertion error: "),
((AggregationDistinctProjectionSegment) actual).getDistinctInnerExpression(), is(((ExpectedAggregationDistinctProjection) expected).getDistinctInnerExpression()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/comment/CommentAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/comment/CommentAssert.java
index 6d249f73ea3..87ab0ae3727 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/comment/CommentAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/comment/CommentAssert.java
@@ -27,9 +27,9 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.s
import java.util.Iterator;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
@@ -58,7 +58,7 @@ public final class CommentAssert {
}
private static void assertCorrectComment(final SQLCaseAssertContext assertContext, final SQLStatement actual, final SQLParserTestCase expected) {
- assertThat(assertContext.getText("Comment should exist."), actual, instanceOf(SQLStatement.class));
+ assertThat(assertContext.getText("Comment should exist."), actual, isA(SQLStatement.class));
assertThat(assertContext.getText("Comments size assertion error: "), actual.getComments().size(), is(expected.getComments().size()));
Iterator<CommentSegment> actualIterator = actual.getComments().iterator();
for (ExpectedComment each : expected.getComments()) {
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowRulesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowRulesStatementAssert.java
index 9af89819647..f1911a45680 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowRulesStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowRulesStatementAssert.java
@@ -25,8 +25,8 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.dat
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.DatabaseContainedTestCase;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
@@ -43,7 +43,7 @@ public final class ShowRulesStatementAssert {
* @param expected expected show rules statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowDatabaseRulesStatement actual, final SQLParserTestCase expected) {
- assertThat("Expected value should be DatabaseContainedTestCase", expected, instanceOf(DatabaseContainedTestCase.class));
+ assertThat("Expected value should be DatabaseContainedTestCase", expected, isA(DatabaseContainedTestCase.class));
assertIs(assertContext, actual, (DatabaseContainedTestCase) expected);
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowStorageUnitsStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowStorageUnitsStatementAssert.java
index 6518cec51b9..c48b5079be2 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowStorageUnitsStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowStorageUnitsStatementAssert.java
@@ -25,9 +25,9 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.dat
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.storage.unit.ShowStorageUnitsStatementTestCase;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -46,7 +46,7 @@ public final class ShowStorageUnitsStatementAssert {
* @param expected expected show storage units statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowStorageUnitsStatement actual, final SQLParserTestCase expected) {
- assertThat("Expected value should be ShowStorageUnitsStatementTestCase", expected, instanceOf(ShowStorageUnitsStatementTestCase.class));
+ assertThat("Expected value should be ShowStorageUnitsStatementTestCase", expected, isA(ShowStorageUnitsStatementTestCase.class));
assertIs(assertContext, actual, (ShowStorageUnitsStatementTestCase) expected);
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowTablesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowTablesStatementAssert.java
index 125f8d10756..7816429d079 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowTablesStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rql/type/ShowTablesStatementAssert.java
@@ -25,9 +25,9 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.dat
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rql.table.ShowTableStatementTestCase;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -46,7 +46,7 @@ public final class ShowTablesStatementAssert {
* @param expected expected show tables statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowTablesStatement actual, final SQLParserTestCase expected) {
- assertThat("Expected value should be ShowTableStatementTestCase", expected, instanceOf(ShowTableStatementTestCase.class));
+ assertThat("Expected value should be ShowTableStatementTestCase", expected, isA(ShowTableStatementTestCase.class));
assertIs(assertContext, actual, (ShowTableStatementTestCase) expected);
}
diff --git a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/PipelineDataSourceManagerTest.java b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/PipelineDataSourceManagerTest.java
index 7823070d914..37f1b64ccbc 100644
--- a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/PipelineDataSourceManagerTest.java
+++ b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/PipelineDataSourceManagerTest.java
@@ -30,9 +30,9 @@ import org.mockito.internal.configuration.plugins.Plugins;
import javax.sql.DataSource;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.junit.jupiter.api.Assertions.assertTrue;
class PipelineDataSourceManagerTest {
@@ -54,7 +54,7 @@ class PipelineDataSourceManagerTest {
try (PipelineDataSourceManager dataSourceManager = new PipelineDataSourceManager()) {
PipelineDataSourceConfiguration source = jobConfig.getSources().values().iterator().next();
DataSource actual = dataSourceManager.getDataSource(PipelineDataSourceConfigurationFactory.newInstance(source.getType(), source.getParameter()));
- assertThat(actual, instanceOf(PipelineDataSource.class));
+ assertThat(actual, isA(PipelineDataSource.class));
}
}
diff --git a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/IncrementalTaskTest.java b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/IncrementalTaskTest.java
index d9eba5e8b6f..de7d2a158dd 100644
--- a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/IncrementalTaskTest.java
+++ b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/IncrementalTaskTest.java
@@ -35,9 +35,9 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
class IncrementalTaskTest {
@@ -66,6 +66,6 @@ class IncrementalTaskTest {
void assertStart() throws ExecutionException, InterruptedException, TimeoutException {
CompletableFuture.allOf(incrementalTask.start().toArray(new CompletableFuture[0])).get(10L, TimeUnit.SECONDS);
assertThat(incrementalTask.getTaskId(), is("ds_0"));
- assertThat(incrementalTask.getTaskProgress().getPosition(), instanceOf(IngestPlaceholderPosition.class));
+ assertThat(incrementalTask.getTaskProgress().getPosition(), isA(IngestPlaceholderPosition.class));
}
}
diff --git a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java
index 8d19a4611c6..368f3dc1852 100644
--- a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java
+++ b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/task/InventoryTaskTest.java
@@ -43,8 +43,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
-import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -78,7 +78,7 @@ class InventoryTaskTest {
InventoryTask inventoryTask = new InventoryTask(PipelineTaskUtils.generateInventoryTaskId(inventoryDumperContext),
PipelineContextUtils.getExecuteEngine(), PipelineContextUtils.getExecuteEngine(), mock(Dumper.class), mock(Importer.class), position);
CompletableFuture.allOf(inventoryTask.start().toArray(new CompletableFuture[0])).get(10L, TimeUnit.SECONDS);
- assertThat(inventoryTask.getTaskProgress().getPosition(), instanceOf(IntegerPrimaryKeyIngestPosition.class));
+ assertThat(inventoryTask.getTaskProgress().getPosition(), isA(IntegerPrimaryKeyIngestPosition.class));
}
private void initTableData(final IncrementalDumperContext dumperContext) throws SQLException {