You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/02 10:09:53 UTC
[shardingsphere] branch master updated: Remove useless static code assert (#17267)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e2171dbebd2 Remove useless static code assert (#17267)
e2171dbebd2 is described below
commit e2171dbebd251cf06603cc37908f68842365d8f0
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon May 2 18:09:46 2022 +0800
Remove useless static code assert (#17267)
---
.../core/plugin/loader/ApmPluginLoaderTest.java | 4 +-
.../JaegerPluginDefinitionServiceTest.java | 12 +--
...elemetryTracingPluginDefinitionServiceTest.java | 13 +---
.../OpenTracingPluginDefinitionServiceTest.java | 12 +--
.../service/OpenTracingPluginBootServiceTest.java | 7 --
.../ZipkinPluginDefinitionServiceTest.java | 12 +--
...orithmProviderConfigurationYamlSwapperTest.java | 33 ++------
.../EncryptSQLRewriteContextDecoratorTest.java | 22 +-----
...orithmProviderConfigurationYamlSwapperTest.java | 19 +----
.../ColumnRegexMatchShadowAlgorithmTest.java | 29 +++----
.../ColumnValueMatchShadowAlgorithmTest.java | 33 +++-----
.../shadow/hint/SimpleHintShadowAlgorithmTest.java | 45 +++--------
...ProvidedShadowRuleConfigurationCheckerTest.java | 32 ++------
.../ShadowRuleConfigurationCheckerTest.java | 35 ++-------
.../shadow/route/ShadowSQLRouterTest.java | 89 +---------------------
.../ShardingSQLRewriteContextDecoratorTest.java | 25 +-----
.../RandomTrafficLoadBalanceAlgorithmTest.java | 16 +---
.../RoundRobinTrafficLoadBalanceAlgorithmTest.java | 14 +---
.../traffic/hint/SQLHintTrafficAlgorithmTest.java | 7 --
.../segment/SQLMatchTrafficAlgorithmTest.java | 7 --
.../segment/SQLRegexTrafficAlgorithmTest.java | 7 --
.../transaction/FirstSQLTrafficAlgorithmTest.java | 19 +----
.../transaction/JDBCTrafficAlgorithmTest.java | 19 +----
.../transaction/ProxyTrafficAlgorithmTest.java | 19 +----
.../TrafficRuleConfigurationYamlSwapperTest.java | 25 +-----
.../cluster/etcd/EtcdRepositoryTest.java | 7 --
.../standalone/file/FileRepositoryTest.java | 5 --
.../repository/standalone/h2/H2RepositoryTest.java | 5 --
...StatementMemoryStrictlyFetchSizeSetterTest.java | 26 ++-----
...StatementMemoryStrictlyFetchSizeSetterTest.java | 26 ++-----
...StatementMemoryStrictlyFetchSizeSetterTest.java | 7 --
.../OpenGaussAdminExecutorFactoryTest.java | 8 +-
.../PostgreSQLAdminExecutorFactoryTest.java | 12 +--
.../opengauss/OpenGaussFrontendEngineTest.java | 6 --
.../state/impl/ReactiveOKProxyStateTest.java | 11 +--
...uleAlteredJobCompletionDetectAlgorithmTest.java | 9 ---
36 files changed, 94 insertions(+), 583 deletions(-)
diff --git a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/ApmPluginLoaderTest.java b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/ApmPluginLoaderTest.java
index 7af78cbbb8d..a302836c931 100644
--- a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/ApmPluginLoaderTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/ApmPluginLoaderTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.agent.core.plugin.loader;
-import lombok.SneakyThrows;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatchers;
import net.bytebuddy.pool.TypePool;
@@ -51,9 +50,8 @@ public final class ApmPluginLoaderTest {
private static final TypeDescription MATERIAL = POOL.describe("org.apache.shardingsphere.agent.core.mock.material.Material").resolve();
@BeforeClass
- @SneakyThrows
@SuppressWarnings("unchecked")
- public static void setup() {
+ public static void setup() throws NoSuchFieldException {
FieldReader objectPoolReader = new FieldReader(LOADER, LOADER.getClass().getDeclaredField("objectPool"));
Map<String, Object> objectPool = (Map<String, Object>) objectPoolReader.read();
objectPool.put(MockConstructorAdvice.class.getTypeName(), new MockConstructorAdvice());
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java
index 280de67031c..91d7debcd0f 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/definition/JaegerPluginDefinitionServiceTest.java
@@ -17,8 +17,6 @@
package org.apache.shardingsphere.agent.plugin.tracing.jaeger.definition;
-import java.util.Collection;
-import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -26,16 +24,8 @@ import static org.junit.Assert.assertThat;
public final class JaegerPluginDefinitionServiceTest {
- private final JaegerPluginDefinitionService jaegerPluginDefinitionService = new JaegerPluginDefinitionService();
-
@Test
public void assertDefine() {
- Collection<PluginInterceptorPoint> interceptorPointList = jaegerPluginDefinitionService.install();
- assertThat(interceptorPointList.size(), is(3));
- }
-
- @Test
- public void assertType() {
- assertThat(jaegerPluginDefinitionService.getType(), is("Jaeger"));
+ assertThat(new JaegerPluginDefinitionService().install().size(), is(3));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/definition/OpenTelemetryTracingPluginDefinitionServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/defini [...]
index 85ad9590821..c349760db83 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/definition/OpenTelemetryTracingPluginDefinitionServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentelemetry/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentelemetry/definition/OpenTelemetryTracingPluginDefinitionServiceTest.java
@@ -17,26 +17,15 @@
package org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.definition;
-import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
import org.junit.Test;
-import java.util.Collection;
-
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class OpenTelemetryTracingPluginDefinitionServiceTest {
- private final OpenTelemetryTracingPluginDefinitionService definitionService = new OpenTelemetryTracingPluginDefinitionService();
-
@Test
public void assertDefine() {
- Collection<PluginInterceptorPoint> interceptorPointList = definitionService.install();
- assertThat(interceptorPointList.size(), is(3));
- }
-
- @Test
- public void assertType() {
- assertThat(definitionService.getType(), is("OpenTelemetry"));
+ assertThat(new OpenTelemetryTracingPluginDefinitionService().install().size(), is(3));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingPluginDefinitionServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingP [...]
index f3ff0c01cd1..493689211f8 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingPluginDefinitionServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/definition/OpenTracingPluginDefinitionServiceTest.java
@@ -17,8 +17,6 @@
package org.apache.shardingsphere.agent.plugin.tracing.opentracing.definition;
-import java.util.Collection;
-import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -26,16 +24,8 @@ import static org.junit.Assert.assertThat;
public final class OpenTracingPluginDefinitionServiceTest {
- private final OpenTracingPluginDefinitionService openTracingPluginDefinitionService = new OpenTracingPluginDefinitionService();
-
@Test
public void assertDefine() {
- Collection<PluginInterceptorPoint> interceptorPointList = openTracingPluginDefinitionService.install();
- assertThat(interceptorPointList.size(), is(3));
- }
-
- @Test
- public void assertType() {
- assertThat(openTracingPluginDefinitionService.getType(), is("OpenTracing"));
+ assertThat(new OpenTracingPluginDefinitionService().install().size(), is(3));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootSer [...]
index 3435235a76c..8c8f7d8efb7 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
@@ -24,8 +24,6 @@ import org.junit.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class OpenTracingPluginBootServiceTest {
@@ -40,11 +38,6 @@ public final class OpenTracingPluginBootServiceTest {
assertTrue(GlobalTracer.isRegistered());
}
- @Test
- public void assertType() {
- assertThat(openTracingPluginBootService.getType(), is("OpenTracing"));
- }
-
@After
public void close() {
openTracingPluginBootService.close();
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java
index e9f6d19b7cd..ccfc52d9731 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/definition/ZipkinPluginDefinitionServiceTest.java
@@ -17,8 +17,6 @@
package org.apache.shardingsphere.agent.plugin.tracing.zipkin.definition;
-import java.util.Collection;
-import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
@@ -26,16 +24,8 @@ import static org.junit.Assert.assertThat;
public final class ZipkinPluginDefinitionServiceTest {
- private final ZipkinPluginDefinitionService zipkinPluginDefinitionService = new ZipkinPluginDefinitionService();
-
@Test
public void assertDefine() {
- Collection<PluginInterceptorPoint> interceptorPointList = zipkinPluginDefinitionService.install();
- assertThat(interceptorPointList.size(), is(3));
- }
-
- @Test
- public void assertType() {
- assertThat(zipkinPluginDefinitionService.getType(), is("Zipkin"));
+ assertThat(new ZipkinPluginDefinitionService().install().size(), is(3));
}
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index 30fbf4db68a..f7457ebc4a4 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/yaml/swapper/DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableMap;
import org.apache.shardingsphere.dbdiscovery.algorithm.config.AlgorithmProvidedDatabaseDiscoveryRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryHeartBeatConfiguration;
-import org.apache.shardingsphere.dbdiscovery.constant.DatabaseDiscoveryOrder;
import org.apache.shardingsphere.dbdiscovery.mysql.type.MGRMySQLDatabaseDiscoveryProviderAlgorithm;
import org.apache.shardingsphere.dbdiscovery.yaml.config.YamlDatabaseDiscoveryRuleConfiguration;
import org.junit.Test;
@@ -31,7 +30,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -43,49 +41,28 @@ public final class DatabaseDiscoveryRuleAlgorithmProviderConfigurationYamlSwappe
@Test
public void assertSwapToYamlConfiguration() {
- YamlDatabaseDiscoveryRuleConfiguration actual = createYamlHARuleConfiguration();
- assertNotNull(actual);
- assertNotNull(actual.getDataSources());
+ YamlDatabaseDiscoveryRuleConfiguration actual = createYamlRuleConfiguration();
assertThat(actual.getDataSources().keySet(), is(Collections.singleton("name")));
- assertNotNull(actual.getDiscoveryHeartbeats());
assertThat(actual.getDiscoveryHeartbeats().keySet(), is(Collections.singleton("mgr_heartbeat")));
}
@Test
public void assertSwapToObject() {
- AlgorithmProvidedDatabaseDiscoveryRuleConfiguration actual = swapper.swapToObject(createYamlHARuleConfiguration());
+ AlgorithmProvidedDatabaseDiscoveryRuleConfiguration actual = swapper.swapToObject(createYamlRuleConfiguration());
assertNotNull(actual);
assertNotNull(actual.getDataSources());
assertTrue(actual.getDataSources().iterator().hasNext());
DatabaseDiscoveryDataSourceRuleConfiguration ruleConfig = actual.getDataSources().iterator().next();
- assertNotNull(ruleConfig);
assertThat(ruleConfig.getGroupName(), is("name"));
- assertNotNull(actual.getDiscoveryHeartbeats());
assertThat(actual.getDiscoveryHeartbeats().keySet(), is(Collections.singleton("mgr_heartbeat")));
}
- @Test
- public void assertGetTypeClass() {
- assertThat(swapper.getTypeClass(), equalTo(AlgorithmProvidedDatabaseDiscoveryRuleConfiguration.class));
- }
-
- @Test
- public void assertGetRuleTagName() {
- assertThat(swapper.getRuleTagName(), is("DB_DISCOVERY"));
- }
-
- @Test
- public void assertGetOrder() {
- assertThat(swapper.getOrder(), is(DatabaseDiscoveryOrder.ALGORITHM_PROVIDER_ORDER));
- }
-
- private YamlDatabaseDiscoveryRuleConfiguration createYamlHARuleConfiguration() {
+ private YamlDatabaseDiscoveryRuleConfiguration createYamlRuleConfiguration() {
DatabaseDiscoveryDataSourceRuleConfiguration ruleConfig = new DatabaseDiscoveryDataSourceRuleConfiguration("name",
Collections.singletonList("dataSourceNames"), "mgr_heartbeat", "discoveryTypeName");
Map<String, DatabaseDiscoveryHeartBeatConfiguration> heartBeatConfig = new LinkedHashMap<>();
heartBeatConfig.put("mgr_heartbeat", new DatabaseDiscoveryHeartBeatConfiguration(new Properties()));
- return swapper.swapToYamlConfiguration(
- new AlgorithmProvidedDatabaseDiscoveryRuleConfiguration(Collections.singletonList(ruleConfig), heartBeatConfig,
- ImmutableMap.of("mgr", new MGRMySQLDatabaseDiscoveryProviderAlgorithm())));
+ return swapper.swapToYamlConfiguration(new AlgorithmProvidedDatabaseDiscoveryRuleConfiguration(
+ Collections.singletonList(ruleConfig), heartBeatConfig, ImmutableMap.of("mgr", new MGRMySQLDatabaseDiscoveryProviderAlgorithm())));
}
}
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java
index 91bcabdb7e3..3d92bc0258e 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java
@@ -17,7 +17,6 @@
package org.apache.shardingsphere.encrypt.rewrite.impl;
-import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
import org.apache.shardingsphere.encrypt.rewrite.context.EncryptSQLRewriteContextDecorator;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
@@ -27,11 +26,7 @@ import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.junit.Test;
import java.util.Collections;
-import java.util.Objects;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -43,24 +38,11 @@ public final class EncryptSQLRewriteContextDecoratorTest {
@Test
public void assertDecorate() {
- EncryptRule encryptRule = mock(EncryptRule.class);
- ConfigurationProperties configurationProperties = mock(ConfigurationProperties.class);
SQLRewriteContext sqlRewriteContext = mock(SQLRewriteContext.class);
CommonSQLStatementContext sqlStatementContext = mock(CommonSQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlRewriteContext.getSqlStatementContext()).thenReturn(sqlStatementContext);
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.emptyList());
- RouteContext routeContext = mock(RouteContext.class);
- encryptSQLRewriteContextDecorator.decorate(encryptRule, configurationProperties, sqlRewriteContext, routeContext);
- assertTrue(Objects.nonNull(sqlRewriteContext.getSqlTokens()));
- }
-
- @Test
- public void assertOrder() {
- assertThat(encryptSQLRewriteContextDecorator.getOrder(), is(EncryptOrder.ORDER));
- }
-
- @Test
- public void assertTypeClass() {
- assertThat(encryptSQLRewriteContextDecorator.getTypeClass(), equalTo(EncryptRule.class));
+ encryptSQLRewriteContextDecorator.decorate(mock(EncryptRule.class), mock(ConfigurationProperties.class), sqlRewriteContext, mock(RouteContext.class));
+ assertTrue(sqlRewriteContext.getSqlTokens().isEmpty());
}
}
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/ReadwriteSplittingRuleAlgorithmProviderConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/ReadwriteSplittingRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index 3b140143fdf..064eaf684be 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/ReadwriteSplittingRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/swapper/ReadwriteSplittingRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -18,10 +18,9 @@
package org.apache.shardingsphere.readwritesplitting.swapper;
import com.google.common.collect.ImmutableMap;
-import org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RandomReplicaLoadBalanceAlgorithm;
import org.apache.shardingsphere.readwritesplitting.algorithm.config.AlgorithmProvidedReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RandomReplicaLoadBalanceAlgorithm;
import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
-import org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder;
import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
import org.apache.shardingsphere.readwritesplitting.yaml.swapper.ReadwriteSplittingRuleAlgorithmProviderConfigurationYamlSwapper;
import org.junit.Test;
@@ -29,7 +28,6 @@ import org.junit.Test;
import java.util.Collections;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -72,21 +70,6 @@ public final class ReadwriteSplittingRuleAlgorithmProviderConfigurationYamlSwapp
assertThat(actual.getLoadBalanceAlgorithms(), is(Collections.emptyMap()));
}
- @Test
- public void assertGetTypeClass() {
- assertThat(swapper.getTypeClass(), equalTo(AlgorithmProvidedReadwriteSplittingRuleConfiguration.class));
- }
-
- @Test
- public void assertGetRuleTagName() {
- assertThat(swapper.getRuleTagName(), is("READWRITE_SPLITTING"));
- }
-
- @Test
- public void assertGetOrder() {
- assertThat(swapper.getOrder(), is(ReadwriteSplittingOrder.ALGORITHM_PROVIDER_ORDER));
- }
-
private YamlReadwriteSplittingRuleConfiguration createYamlReadwriteSplittingRuleConfiguration() {
Properties props = new Properties();
props.setProperty("write-data-source-name", "writeDataSourceName");
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java
index 274829cc522..a8ba79933c2 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnRegexMatchShadowAlgorithmTest.java
@@ -24,7 +24,9 @@ import org.junit.Test;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class ColumnRegexMatchShadowAlgorithmTest extends AbstractColumnShadowAlgorithmTest {
@@ -33,35 +35,22 @@ public final class ColumnRegexMatchShadowAlgorithmTest extends AbstractColumnSha
@Before
public void init() {
shadowAlgorithm = new ColumnRegexMatchShadowAlgorithm();
- Properties properties = new Properties();
- properties.setProperty("column", SHADOW_COLUMN);
- properties.setProperty("operation", "insert");
- properties.setProperty("regex", "[1]");
- shadowAlgorithm.setProps(properties);
+ Properties props = new Properties();
+ props.setProperty("column", SHADOW_COLUMN);
+ props.setProperty("operation", "insert");
+ props.setProperty("regex", "[1]");
+ shadowAlgorithm.setProps(props);
shadowAlgorithm.init();
}
@Test
public void assertIsShadow() {
- assertTrueCase();
- assertFalseCase();
- }
-
- private void assertFalseCase() {
- createPreciseColumnShadowValuesFalseCase().forEach(each -> assertThat(shadowAlgorithm.isShadow(each), is(false)));
- }
-
- private void assertTrueCase() {
- createPreciseColumnShadowValuesTrueCase().forEach(each -> assertThat(shadowAlgorithm.isShadow(each), is(true)));
+ createPreciseColumnShadowValuesFalseCase().forEach(each -> assertFalse(shadowAlgorithm.isShadow(each)));
+ createPreciseColumnShadowValuesTrueCase().forEach(each -> assertTrue(shadowAlgorithm.isShadow(each)));
}
@Test(expected = ShadowAlgorithmException.class)
public void assertExceptionCase() {
createPreciseColumnShadowValuesExceptionCase().forEach(each -> assertThat(shadowAlgorithm.isShadow(each), is(false)));
}
-
- @Test
- public void assertGetType() {
- assertThat(shadowAlgorithm.getType(), is("REGEX_MATCH"));
- }
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
index 119b84d7a03..8923bb1018c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
@@ -23,8 +23,8 @@ import org.junit.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public final class ColumnValueMatchShadowAlgorithmTest extends AbstractColumnShadowAlgorithmTest {
@@ -33,35 +33,22 @@ public final class ColumnValueMatchShadowAlgorithmTest extends AbstractColumnSha
@Before
public void init() {
shadowAlgorithm = new ColumnValueMatchShadowAlgorithm();
- Properties properties = new Properties();
- properties.setProperty("column", SHADOW_COLUMN);
- properties.setProperty("operation", "insert");
- properties.setProperty("value", "1");
- shadowAlgorithm.setProps(properties);
+ Properties props = new Properties();
+ props.setProperty("column", SHADOW_COLUMN);
+ props.setProperty("operation", "insert");
+ props.setProperty("value", "1");
+ shadowAlgorithm.setProps(props);
shadowAlgorithm.init();
}
@Test
public void assertIsShadow() {
- assertTrueCase();
- assertFalseCase();
- }
-
- private void assertTrueCase() {
- createPreciseColumnShadowValuesTrueCase().forEach(each -> assertThat(shadowAlgorithm.isShadow(each), is(true)));
- }
-
- private void assertFalseCase() {
- createPreciseColumnShadowValuesFalseCase().forEach(each -> assertThat(shadowAlgorithm.isShadow(each), is(false)));
+ createPreciseColumnShadowValuesTrueCase().forEach(each -> assertTrue(shadowAlgorithm.isShadow(each)));
+ createPreciseColumnShadowValuesFalseCase().forEach(each -> assertFalse(shadowAlgorithm.isShadow(each)));
}
@Test(expected = ShadowAlgorithmException.class)
public void assertExceptionCase() {
- createPreciseColumnShadowValuesExceptionCase().forEach(each -> assertThat(shadowAlgorithm.isShadow(each), is(false)));
- }
-
- @Test
- public void assertGetType() {
- assertThat(shadowAlgorithm.getType(), is("VALUE_MATCH"));
+ createPreciseColumnShadowValuesExceptionCase().forEach(each -> assertFalse(shadowAlgorithm.isShadow(each)));
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithmTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithmTest.java
index 4d9f515a500..6c0a91ae44a 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/hint/SimpleHintShadowAlgorithmTest.java
@@ -22,12 +22,11 @@ import org.apache.shardingsphere.shadow.api.shadow.hint.PreciseHintShadowValue;
import org.junit.Before;
import org.junit.Test;
-import java.util.Collection;
-import java.util.LinkedList;
+import java.util.Arrays;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public final class SimpleHintShadowAlgorithmTest {
@@ -44,38 +43,18 @@ public final class SimpleHintShadowAlgorithmTest {
@Test
public void assertIsShadow() {
- assertTrueCase();
- assertFalseCase();
- }
-
- private void assertFalseCase() {
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), new PreciseHintShadowValue<>("t_auto", ShadowOperationType.INSERT, "/*shadow:true*/")), is(false));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue("/**/")), is(false));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue("/*")), is(false));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue("aaa = bbb")), is(false));
- }
-
- private void assertTrueCase() {
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue("/* shadow: true */")), is(true));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue(" shadow :true */")), is(true));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue("/* shadow : true ")), is(true));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue(" shadow:true ")), is(true));
- assertThat(shadowAlgorithm.isShadow(createShadowTableNames(), createNoteShadowValue(" shadow:true, aaa:bbb ")), is(true));
+ assertFalse(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), new PreciseHintShadowValue<>("t_auto", ShadowOperationType.INSERT, "/*shadow:true*/")));
+ assertFalse(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue("/**/")));
+ assertFalse(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue("/*")));
+ assertFalse(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue("aaa = bbb")));
+ assertTrue(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue("/* shadow: true */")));
+ assertTrue(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue(" shadow :true */")));
+ assertTrue(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue("/* shadow : true ")));
+ assertTrue(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue(" shadow:true ")));
+ assertTrue(shadowAlgorithm.isShadow(Arrays.asList("t_user", "t_order"), createNoteShadowValue(" shadow:true, aaa:bbb ")));
}
private PreciseHintShadowValue<String> createNoteShadowValue(final String sqlNote) {
return new PreciseHintShadowValue<>("t_user", ShadowOperationType.HINT_MATCH, sqlNote);
}
-
- private Collection<String> createShadowTableNames() {
- Collection<String> shadowTableNames = new LinkedList<>();
- shadowTableNames.add("t_user");
- shadowTableNames.add("t_order");
- return shadowTableNames;
- }
-
- @Test
- public void assertGetType() {
- assertThat(shadowAlgorithm.getType(), is("SIMPLE_HINT"));
- }
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/AlgorithmProvidedShadowRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/AlgorithmProvidedShadowRuleConfigurationCheckerTest.java
index e0f6de9f8bd..4475a6778d3 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/AlgorithmProvidedShadowRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/AlgorithmProvidedShadowRuleConfigurationCheckerTest.java
@@ -22,9 +22,7 @@ import org.apache.shardingsphere.shadow.algorithm.config.AlgorithmProvidedShadow
import org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchShadowAlgorithm;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import org.apache.shardingsphere.shadow.constant.ShadowOrder;
import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
-import org.junit.Before;
import org.junit.Test;
import java.util.Collection;
@@ -33,17 +31,9 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
public final class AlgorithmProvidedShadowRuleConfigurationCheckerTest {
- private RuleConfigurationChecker<AlgorithmProvidedShadowRuleConfiguration> checker;
-
- @Before
- public void init() {
- checker = new AlgorithmProvidedShadowRuleConfigurationChecker();
- }
+ private final RuleConfigurationChecker<AlgorithmProvidedShadowRuleConfiguration> checker = new AlgorithmProvidedShadowRuleConfigurationChecker();
@Test
public void assertCheck() {
@@ -87,20 +77,10 @@ public final class AlgorithmProvidedShadowRuleConfigurationCheckerTest {
}
private Properties createProperties() {
- Properties properties = new Properties();
- properties.setProperty("column", "shadow");
- properties.setProperty("operation", "insert");
- properties.setProperty("regex", "[1]");
- return properties;
- }
-
- @Test
- public void assertGetOrder() {
- assertThat(checker.getOrder() == ShadowOrder.ALGORITHM_PROVIDER_ORDER, is(true));
- }
-
- @Test
- public void assertGetTypeClass() {
- assertThat(checker.getTypeClass() == AlgorithmProvidedShadowRuleConfiguration.class, is(true));
+ Properties result = new Properties();
+ result.setProperty("column", "shadow");
+ result.setProperty("operation", "insert");
+ result.setProperty("regex", "[1]");
+ return result;
}
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
index ae5e98fe569..2ec912b02c5 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
@@ -18,12 +18,9 @@
package org.apache.shardingsphere.shadow.checker;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import org.apache.shardingsphere.shadow.constant.ShadowOrder;
-import org.junit.Before;
import org.junit.Test;
import java.util.Collection;
@@ -32,21 +29,11 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
public final class ShadowRuleConfigurationCheckerTest {
- private RuleConfigurationChecker<ShadowRuleConfiguration> checker;
-
- @Before
- public void init() {
- checker = new ShadowRuleConfigurationChecker();
- }
-
@Test
public void assertCheck() {
- checker.check("", createShadowRuleConfiguration());
+ new ShadowRuleConfigurationChecker().check("", createShadowRuleConfiguration());
}
private ShadowRuleConfiguration createShadowRuleConfiguration() {
@@ -68,11 +55,11 @@ public final class ShadowRuleConfigurationCheckerTest {
}
private Properties createProperties() {
- Properties properties = new Properties();
- properties.setProperty("column", "shadow");
- properties.setProperty("operation", "insert");
- properties.setProperty("regex", "[1]");
- return properties;
+ Properties result = new Properties();
+ result.setProperty("column", "shadow");
+ result.setProperty("operation", "insert");
+ result.setProperty("regex", "[1]");
+ return result;
}
private Map<String, ShadowTableConfiguration> createTables() {
@@ -89,14 +76,4 @@ public final class ShadowRuleConfigurationCheckerTest {
result.put("shadow-data-source", new ShadowDataSourceConfiguration("ds", "ds_shadow"));
return result;
}
-
- @Test
- public void assertGetOrder() {
- assertThat(checker.getOrder() == ShadowOrder.ORDER, is(true));
- }
-
- @Test
- public void assertGetTypeClass() {
- assertThat(checker.getTypeClass() == ShadowRuleConfiguration.class, is(true));
- }
}
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouterTest.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouterTest.java
index 7a0c6728989..6c7264d38ed 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouterTest.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouterTest.java
@@ -20,103 +20,16 @@ package org.apache.shardingsphere.shadow.route;
import org.apache.shardingsphere.infra.binder.LogicSQL;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.infra.route.context.RouteMapper;
-import org.apache.shardingsphere.infra.route.context.RouteUnit;
-import org.apache.shardingsphere.shadow.algorithm.config.AlgorithmProvidedShadowRuleConfiguration;
-import org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchShadowAlgorithm;
-import org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
-import org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import org.apache.shardingsphere.shadow.constant.ShadowOrder;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
-import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
-import org.junit.Before;
import org.junit.Test;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public final class ShadowSQLRouterTest {
- private ShadowSQLRouter router;
-
- @Before
- public void init() {
- router = new ShadowSQLRouter();
- }
-
@Test
public void assertCreateRouteContext() {
- RouteContext routeContext = router.createRouteContext(mock(LogicSQL.class), mock(ShardingSphereMetaData.class), mock(ShadowRule.class), mock(ConfigurationProperties.class));
- assertNotNull(routeContext);
- }
-
- private AlgorithmProvidedShadowRuleConfiguration createAlgorithmProvidedShadowRuleConfiguration() {
- AlgorithmProvidedShadowRuleConfiguration result = new AlgorithmProvidedShadowRuleConfiguration();
- result.setDataSources(createDataSources());
- result.setTables(createTables());
- result.setShadowAlgorithms(createShadowAlgorithms());
- return result;
- }
-
- private Map<String, ShadowAlgorithm> createShadowAlgorithms() {
- Map<String, ShadowAlgorithm> result = new LinkedHashMap<>();
- result.put("user-id-insert-regex-algorithm", createColumnShadowAlgorithm());
- return result;
- }
-
- private ShadowAlgorithm createColumnShadowAlgorithm() {
- final ColumnRegexMatchShadowAlgorithm columnRegexMatchShadowAlgorithm = new ColumnRegexMatchShadowAlgorithm();
- Properties properties = new Properties();
- properties.setProperty("column", "user_id");
- properties.setProperty("operation", "insert");
- properties.setProperty("regex", "[1]");
- columnRegexMatchShadowAlgorithm.setProps(properties);
- columnRegexMatchShadowAlgorithm.init();
- return columnRegexMatchShadowAlgorithm;
- }
-
- private Map<String, ShadowTableConfiguration> createTables() {
- Map<String, ShadowTableConfiguration> result = new LinkedHashMap<>();
- Collection<String> shadowAlgorithmNames = new LinkedList<>();
- shadowAlgorithmNames.add("user-id-insert-regex-algorithm");
- result.put("t_order", new ShadowTableConfiguration(Collections.singletonList("shadow-data-source"), shadowAlgorithmNames));
- return result;
- }
-
- private Map<String, ShadowDataSourceConfiguration> createDataSources() {
- Map<String, ShadowDataSourceConfiguration> result = new LinkedHashMap<>();
- result.put("shadow-data-source", new ShadowDataSourceConfiguration("ds", "ds_shadow"));
- return result;
- }
-
- private RouteContext createRouteContext() {
- RouteContext result = mock(RouteContext.class);
- Collection<RouteUnit> routeUnits = new LinkedList<>();
- Collection<RouteMapper> tableRouteMappers = new LinkedList<>();
- tableRouteMappers.add(new RouteMapper("t_order", "t_order"));
- routeUnits.add(new RouteUnit(new RouteMapper("shadow-data-source", "shadow-data-source"), tableRouteMappers));
- when(result.getRouteUnits()).thenReturn(routeUnits);
- return result;
- }
-
- @Test
- public void assertGetOrder() {
- assertThat(router.getOrder(), is(ShadowOrder.ORDER));
- }
-
- @Test
- public void getTypeClass() {
- assertThat(router.getTypeClass() == ShadowRule.class, is(true));
+ assertNotNull(new ShadowSQLRouter().createRouteContext(mock(LogicSQL.class), mock(ShardingSphereMetaData.class), mock(ShadowRule.class), mock(ConfigurationProperties.class)));
}
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java
index a2c53c53286..3e2fc5decf9 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/context/ShardingSQLRewriteContextDecoratorTest.java
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.sharding.rewrite.context;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
import org.apache.shardingsphere.infra.route.context.RouteContext;
-import org.apache.shardingsphere.sharding.constant.ShardingOrder;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.junit.Test;
@@ -28,8 +27,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -40,16 +37,16 @@ public final class ShardingSQLRewriteContextDecoratorTest {
public void assertDecorateForRouteContextWhenIsFederated() {
ShardingSQLRewriteContextDecorator shardingSQLRewriteContextDecorator = new ShardingSQLRewriteContextDecorator();
ShardingRule shardingRule = mock(ShardingRule.class);
- ConfigurationProperties configurationProperties = mock(ConfigurationProperties.class);
+ ConfigurationProperties configurationProps = mock(ConfigurationProperties.class);
SQLRewriteContext sqlRewriteContext = mock(SQLRewriteContext.class);
RouteContext routeContext = mock(RouteContext.class);
when(routeContext.isFederated()).thenReturn(true);
- shardingSQLRewriteContextDecorator.decorate(shardingRule, configurationProperties, sqlRewriteContext, routeContext);
+ shardingSQLRewriteContextDecorator.decorate(shardingRule, configurationProps, sqlRewriteContext, routeContext);
assertTrue(sqlRewriteContext.getSchemas().isEmpty());
assertTrue(Objects.isNull(sqlRewriteContext.getSqlStatementContext()));
- assertThat(sqlRewriteContext.getParameters().size(), is(0));
+ assertTrue(sqlRewriteContext.getParameters().isEmpty());
assertTrue(Objects.isNull(sqlRewriteContext.getParameterBuilder()));
- assertThat(sqlRewriteContext.getSqlTokens().size(), is(0));
+ assertTrue(sqlRewriteContext.getSqlTokens().isEmpty());
}
@Test
@@ -66,18 +63,4 @@ public final class ShardingSQLRewriteContextDecoratorTest {
shardingSQLRewriteContextDecorator.decorate(shardingRule, configurationProperties, sqlRewriteContext, routeContext);
assertTrue(Objects.nonNull(sqlRewriteContext.getSqlTokens()));
}
-
- @Test
- public void assertGetOrder() {
- ShardingSQLRewriteContextDecorator shardingSQLRewriteContextDecorator = new ShardingSQLRewriteContextDecorator();
- int actual = shardingSQLRewriteContextDecorator.getOrder();
- assertThat(actual, is(ShardingOrder.ORDER));
- }
-
- @Test
- public void assertGetTypeClass() {
- ShardingSQLRewriteContextDecorator shardingSQLRewriteContextDecorator = new ShardingSQLRewriteContextDecorator();
- Class<ShardingRule> actual = shardingSQLRewriteContextDecorator.getTypeClass();
- assertThat(actual.getName(), is(ShardingRule.class.getName()));
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java
index b6d12b1f57e..e1d56c47dd6 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RandomTrafficLoadBalanceAlgorithmTest.java
@@ -23,30 +23,16 @@ import org.junit.Test;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class RandomTrafficLoadBalanceAlgorithmTest {
- private final RandomTrafficLoadBalanceAlgorithm randomAlgorithm = new RandomTrafficLoadBalanceAlgorithm();
-
@Test
public void assertGetInstanceId() {
List<InstanceId> instanceIds = Arrays.asList(new InstanceId("127.0.0.1@3307"), new InstanceId("127.0.0.1@3308"));
+ RandomTrafficLoadBalanceAlgorithm randomAlgorithm = new RandomTrafficLoadBalanceAlgorithm();
assertTrue(instanceIds.contains(randomAlgorithm.getInstanceId("simple_traffic", instanceIds)));
assertTrue(instanceIds.contains(randomAlgorithm.getInstanceId("simple_traffic", instanceIds)));
assertTrue(instanceIds.contains(randomAlgorithm.getInstanceId("simple_traffic", instanceIds)));
}
-
- @Test
- public void assertGetType() {
- assertThat(randomAlgorithm.getType(), is("RANDOM"));
- }
-
- @Test
- public void assertIsDefault() {
- assertFalse(randomAlgorithm.isDefault());
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java
index 8854a915fa9..eeab1ebf79f 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/loadbalance/RoundRobinTrafficLoadBalanceAlgorithmTest.java
@@ -29,12 +29,9 @@ import java.util.concurrent.ConcurrentHashMap;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
public final class RoundRobinTrafficLoadBalanceAlgorithmTest {
- private final RoundRobinTrafficLoadBalanceAlgorithm roundRobinAlgorithm = new RoundRobinTrafficLoadBalanceAlgorithm();
-
@Before
@After
public void reset() throws NoSuchFieldException, IllegalAccessException {
@@ -48,18 +45,9 @@ public final class RoundRobinTrafficLoadBalanceAlgorithmTest {
InstanceId instanceId1 = new InstanceId("127.0.0.1@3307");
InstanceId instanceId2 = new InstanceId("127.0.0.1@3308");
List<InstanceId> instanceIds = Arrays.asList(instanceId1, instanceId2);
+ RoundRobinTrafficLoadBalanceAlgorithm roundRobinAlgorithm = new RoundRobinTrafficLoadBalanceAlgorithm();
assertThat(roundRobinAlgorithm.getInstanceId("simple_traffic", instanceIds), is(instanceId1));
assertThat(roundRobinAlgorithm.getInstanceId("simple_traffic", instanceIds), is(instanceId2));
assertThat(roundRobinAlgorithm.getInstanceId("simple_traffic", instanceIds), is(instanceId1));
}
-
- @Test
- public void assertGetType() {
- assertThat(roundRobinAlgorithm.getType(), is("ROUND_ROBIN"));
- }
-
- @Test
- public void assertIsDefault() {
- assertTrue(roundRobinAlgorithm.isDefault());
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithmTest.java
index 3592cbc9e6c..88578ae45cb 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/hint/SQLHintTrafficAlgorithmTest.java
@@ -24,9 +24,7 @@ import org.junit.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class SQLHintTrafficAlgorithmTest {
@@ -52,9 +50,4 @@ public final class SQLHintTrafficAlgorithmTest {
props.put("useTraffic", "false");
assertFalse(sqlHintAlgorithm.match(new HintTrafficValue(new SQLHintProperties(props))));
}
-
- @Test
- public void assertGetType() {
- assertThat(sqlHintAlgorithm.getType(), is("SQL_HINT"));
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithmTest.java
index 8fa1042d83c..8edd4337c0d 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLMatchTrafficAlgorithmTest.java
@@ -23,9 +23,7 @@ import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -58,9 +56,4 @@ public final class SQLMatchTrafficAlgorithmTest {
assertFalse(sqlMatchAlgorithm.match(new SegmentTrafficValue(sqlStatement, "UPDATE `t_order` SET `order_id` = ?;")));
assertFalse(sqlMatchAlgorithm.match(new SegmentTrafficValue(sqlStatement, "UPDATE `t_order_item` SET `order_id` = ? WHERE user_id = ?;")));
}
-
- @Test
- public void assertGetType() {
- assertThat(sqlMatchAlgorithm.getType(), is("SQL_MATCH"));
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithmTest.java
index 08487ee8faf..47200b6ed72 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/segment/SQLRegexTrafficAlgorithmTest.java
@@ -23,9 +23,7 @@ import org.apache.shardingsphere.traffic.api.traffic.segment.SegmentTrafficValue
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -58,9 +56,4 @@ public final class SQLRegexTrafficAlgorithmTest {
assertFalse(sqlRegexAlgorithm.match(new SegmentTrafficValue(sqlStatement, "TRUNCATE TABLE `t_order` ")));
assertFalse(sqlRegexAlgorithm.match(new SegmentTrafficValue(sqlStatement, "UPDATE `t_order` SET `order_id` = ?;")));
}
-
- @Test
- public void assertGetType() {
- assertThat(sqlRegexAlgorithm.getType(), is("SQL_REGEX"));
- }
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithmTest.java
index 5e911494b32..328be09852b 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/FirstSQLTrafficAlgorithmTest.java
@@ -18,34 +18,19 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.transaction;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
-import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
public final class FirstSQLTrafficAlgorithmTest {
- private FirstSQLTrafficAlgorithm firstSQLTrafficAlgorithm;
-
- @Before
- public void setUp() {
- firstSQLTrafficAlgorithm = new FirstSQLTrafficAlgorithm();
- }
-
@Test
public void assertMatchWhenInTransaction() {
- assertFalse(firstSQLTrafficAlgorithm.match(new TransactionTrafficValue(true)));
+ assertFalse(new FirstSQLTrafficAlgorithm().match(new TransactionTrafficValue(true)));
}
@Test
public void assertMatchWhenNotInTransaction() {
- assertFalse(firstSQLTrafficAlgorithm.match(new TransactionTrafficValue(false)));
- }
-
- @Test
- public void assertGetType() {
- assertThat(firstSQLTrafficAlgorithm.getType(), is("FIRST_SQL"));
+ assertFalse(new FirstSQLTrafficAlgorithm().match(new TransactionTrafficValue(false)));
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithmTest.java
index 8d536c28210..5c7f1a3da4d 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/JDBCTrafficAlgorithmTest.java
@@ -18,35 +18,20 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.transaction;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
-import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class JDBCTrafficAlgorithmTest {
- private JDBCTrafficAlgorithm jdbcTrafficAlgorithm;
-
- @Before
- public void setUp() {
- jdbcTrafficAlgorithm = new JDBCTrafficAlgorithm();
- }
-
@Test
public void assertMatchWhenInTransaction() {
- assertTrue(jdbcTrafficAlgorithm.match(new TransactionTrafficValue(true)));
+ assertTrue(new JDBCTrafficAlgorithm().match(new TransactionTrafficValue(true)));
}
@Test
public void assertMatchWhenNotInTransaction() {
- assertFalse(jdbcTrafficAlgorithm.match(new TransactionTrafficValue(false)));
- }
-
- @Test
- public void assertGetType() {
- assertThat(jdbcTrafficAlgorithm.getType(), is("JDBC"));
+ assertFalse(new JDBCTrafficAlgorithm().match(new TransactionTrafficValue(false)));
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithmTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithmTest.java
index a332707e6ce..69a0de6cb62 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithmTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/algorithm/traffic/transaction/ProxyTrafficAlgorithmTest.java
@@ -18,35 +18,20 @@
package org.apache.shardingsphere.traffic.algorithm.traffic.transaction;
import org.apache.shardingsphere.traffic.api.traffic.transaction.TransactionTrafficValue;
-import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class ProxyTrafficAlgorithmTest {
- private ProxyTrafficAlgorithm proxyTrafficAlgorithm;
-
- @Before
- public void setUp() {
- proxyTrafficAlgorithm = new ProxyTrafficAlgorithm();
- }
-
@Test
public void assertMatchWhenInTransaction() {
- assertTrue(proxyTrafficAlgorithm.match(new TransactionTrafficValue(true)));
+ assertTrue(new ProxyTrafficAlgorithm().match(new TransactionTrafficValue(true)));
}
@Test
public void assertMatchWhenNotInTransaction() {
- assertFalse(proxyTrafficAlgorithm.match(new TransactionTrafficValue(false)));
- }
-
- @Test
- public void assertGetType() {
- assertThat(proxyTrafficAlgorithm.getType(), is("PROXY"));
+ assertFalse(new ProxyTrafficAlgorithm().match(new TransactionTrafficValue(false)));
}
}
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationYamlSwapperTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationYamlSwapperTest.java
index b134983be47..394d99c6093 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-core/src/test/java/org/apache/shardingsphere/traffic/yaml/swapper/TrafficRuleConfigurationYamlSwapperTest.java
@@ -24,26 +24,20 @@ import org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration
import org.apache.shardingsphere.traffic.yaml.config.YamlTrafficRuleConfiguration;
import org.apache.shardingsphere.traffic.yaml.config.YamlTrafficStrategyConfiguration;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
import java.util.Arrays;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public final class TrafficRuleConfigurationYamlSwapperTest {
- private final TrafficRuleConfigurationYamlSwapper swapper = new TrafficRuleConfigurationYamlSwapper();
-
@Test
public void assertSwapToYamlConfiguration() {
- YamlTrafficRuleConfiguration actual = swapper.swapToYamlConfiguration(createTrafficRuleConfiguration());
+ YamlTrafficRuleConfiguration actual = new TrafficRuleConfigurationYamlSwapper().swapToYamlConfiguration(createTrafficRuleConfiguration());
assertThat(actual.getTrafficStrategies().size(), is(1));
assertTrue(actual.getTrafficStrategies().containsKey("group_by_traffic"));
assertThat(actual.getTrafficAlgorithms().size(), is(1));
@@ -74,7 +68,7 @@ public final class TrafficRuleConfigurationYamlSwapperTest {
@Test
public void assertSwapToObject() {
- TrafficRuleConfiguration actual = swapper.swapToObject(createYamlTrafficRuleConfiguration());
+ TrafficRuleConfiguration actual = new TrafficRuleConfigurationYamlSwapper().swapToObject(createYamlTrafficRuleConfiguration());
assertThat(actual.getTrafficStrategies().size(), is(1));
TrafficStrategyConfiguration strategyConfig = actual.getTrafficStrategies().iterator().next();
assertThat(strategyConfig.getName(), is("group_by_traffic"));
@@ -110,19 +104,4 @@ public final class TrafficRuleConfigurationYamlSwapperTest {
when(result.getType()).thenReturn("RANDOM");
return result;
}
-
- @Test
- public void assertGetTypeClass() {
- assertThat(swapper.getTypeClass(), equalTo(TrafficRuleConfiguration.class));
- }
-
- @Test
- public void assertGetRuleTagName() {
- assertThat(swapper.getRuleTagName(), is("TRAFFIC"));
- }
-
- @Test
- public void assertGetOrder() {
- assertThat(swapper.getOrder(), is(800));
- }
}
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluste [...]
index ecfc4aa40d5..4c13942fcce 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-repository/shardingsphere-cluster-mode-repository-provider/shardingsphere-cluster-mode-repository-etcd/src/test/java/org/apache/shardingsphere/mode/repository/cluster/etcd/EtcdRepositoryTest.java
@@ -67,8 +67,6 @@ import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public final class EtcdRepositoryTest {
- private static final String CENTER_TYPE = "etcd";
-
@Mock
private Client client;
@@ -229,11 +227,6 @@ public final class EtcdRepositoryTest {
verify(client).close();
}
- @Test
- public void assertGetType() {
- assertThat(repository.getType(), is(CENTER_TYPE));
- }
-
@Test
public void assertProperties() {
Properties props = new Properties();
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/test/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provid [...]
index 116e37b4144..b17de558fd6 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/test/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepositoryTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-file/src/test/java/org/apache/shardingsphere/mode/repository/standalone/file/FileRepositoryTest.java
@@ -40,11 +40,6 @@ public final class FileRepositoryTest {
fileRepository.setProps(props);
}
- @Test
- public void assertType() {
- assertThat(fileRepository.getType(), is("File"));
- }
-
@Test
public void assertPersistAndGet() {
fileRepository.persist(getFilePath(), "test1_content");
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/sha [...]
index 4b3c28ca07f..4b16bd02731 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-repository/shardingsphere-standalone-mode-repository-provider/shardingsphere-standalone-mode-repository-h2/src/test/java/org/apache/shardingsphere/mode/repository/standalone/h2/H2RepositoryTest.java
@@ -43,11 +43,6 @@ public final class H2RepositoryTest {
h2Repository.setProps(props);
}
- @Test
- public void assertType() {
- assertThat(h2Repository.getType(), is("H2"));
- }
-
@Test
public void assertPersistAndGet() {
h2Repository.persist("/testPath/test1", "test1_content");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
index 3f88e2f0611..7d33b485b10 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
@@ -24,21 +24,16 @@ import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.sql.Statement;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public final class MySQLStatementMemoryStrictlyFetchSizeSetterTest {
private static ContextManager originContextManager;
@@ -48,19 +43,6 @@ public final class MySQLStatementMemoryStrictlyFetchSizeSetterTest {
originContextManager = swapContextManager(mock(ContextManager.class, RETURNS_DEEP_STUBS));
}
- @Test
- public void assertSetFetchSize() throws SQLException {
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_BACKEND_QUERY_FETCH_SIZE)).thenReturn(-1);
- Statement statement = mock(Statement.class);
- new MySQLStatementMemoryStrictlyFetchSizeSetter().setFetchSize(statement);
- verify(statement).setFetchSize(Integer.MIN_VALUE);
- }
-
- @Test
- public void assertGetType() {
- assertThat(new MySQLStatementMemoryStrictlyFetchSizeSetter().getType(), is("MySQL"));
- }
-
@AfterClass
public static void tearDown() {
swapContextManager(originContextManager);
@@ -74,4 +56,12 @@ public final class MySQLStatementMemoryStrictlyFetchSizeSetterTest {
contextManagerField.set(ProxyContext.getInstance(), newContextManager);
return result;
}
+
+ @Test
+ public void assertSetFetchSize() throws SQLException {
+ when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_BACKEND_QUERY_FETCH_SIZE)).thenReturn(-1);
+ Statement statement = mock(Statement.class);
+ new MySQLStatementMemoryStrictlyFetchSizeSetter().setFetchSize(statement);
+ verify(statement).setFetchSize(Integer.MIN_VALUE);
+ }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetterTest.java
index d8f760f7a00..e1d024e00d8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/OpenGaussStatementMemoryStrictlyFetchSizeSetterTest.java
@@ -24,21 +24,16 @@ import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
import java.lang.reflect.Field;
import java.sql.SQLException;
import java.sql.Statement;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
public final class OpenGaussStatementMemoryStrictlyFetchSizeSetterTest {
private static ContextManager originContextManager;
@@ -48,19 +43,6 @@ public final class OpenGaussStatementMemoryStrictlyFetchSizeSetterTest {
originContextManager = swapContextManager(mock(ContextManager.class, RETURNS_DEEP_STUBS));
}
- @Test
- public void assertSetFetchSize() throws SQLException {
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_BACKEND_QUERY_FETCH_SIZE)).thenReturn(-1);
- Statement statement = mock(Statement.class);
- new OpenGaussStatementMemoryStrictlyFetchSizeSetter().setFetchSize(statement);
- verify(statement).setFetchSize(1);
- }
-
- @Test
- public void assertGetType() {
- assertThat(new OpenGaussStatementMemoryStrictlyFetchSizeSetter().getType(), is("openGauss"));
- }
-
@AfterClass
public static void tearDown() {
swapContextManager(originContextManager);
@@ -74,4 +56,12 @@ public final class OpenGaussStatementMemoryStrictlyFetchSizeSetterTest {
contextManagerField.set(ProxyContext.getInstance(), newContextManager);
return result;
}
+
+ @Test
+ public void assertSetFetchSize() throws SQLException {
+ when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_BACKEND_QUERY_FETCH_SIZE)).thenReturn(-1);
+ Statement statement = mock(Statement.class);
+ new OpenGaussStatementMemoryStrictlyFetchSizeSetter().setFetchSize(statement);
+ verify(statement).setFetchSize(1);
+ }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
index bd581d2620c..02f1eef8618 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
@@ -31,8 +31,6 @@ import java.lang.reflect.Field;
import java.sql.SQLException;
import java.sql.Statement;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -56,11 +54,6 @@ public final class PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest {
verify(statement).setFetchSize(1);
}
- @Test
- public void assertGetType() {
- assertThat(new PostgreSQLStatementMemoryStrictlyFetchSizeSetter().getType(), is("PostgreSQL"));
- }
-
@AfterClass
public static void tearDown() {
swapContextManager(originContextManager);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/opengauss/OpenGaussAdminExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/opengauss/OpenGaussAdminExecutorFactoryTest.java
index df02d1355c8..7fcde5cc550 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/opengauss/OpenGaussAdminExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/opengauss/OpenGaussAdminExecutorFactoryTest.java
@@ -61,6 +61,7 @@ public final class OpenGaussAdminExecutorFactoryTest {
DatabaseAdminExecutor expected = mock(DatabaseAdminExecutor.class);
when(postgreSQLAdminExecutorFactory.newInstance(sqlStatementContext)).thenReturn(Optional.of(expected));
Optional<DatabaseAdminExecutor> actual = openGaussAdminExecutorFactory.newInstance(sqlStatementContext);
+ assertTrue(actual.isPresent());
assertThat(actual.get(), is(expected));
}
@@ -69,6 +70,7 @@ public final class OpenGaussAdminExecutorFactoryTest {
SQLStatementContext<?> sqlStatementContext = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("pg_database"));
Optional<DatabaseAdminExecutor> actual = openGaussAdminExecutorFactory.newInstance(sqlStatementContext, "select datcompatibility from pg_database where datname = 'sharding_db'", "");
+ assertTrue(actual.isPresent());
assertTrue(actual.get() instanceof OpenGaussSelectDatabaseExecutor);
}
@@ -79,11 +81,7 @@ public final class OpenGaussAdminExecutorFactoryTest {
DatabaseAdminExecutor expected = mock(DatabaseAdminExecutor.class);
when(postgreSQLAdminExecutorFactory.newInstance(sqlStatementContext, "", "")).thenReturn(Optional.of(expected));
Optional<DatabaseAdminExecutor> actual = openGaussAdminExecutorFactory.newInstance(sqlStatementContext, "", "");
+ assertTrue(actual.isPresent());
assertThat(actual.get(), is(expected));
}
-
- @Test
- public void assertGetType() {
- assertThat(openGaussAdminExecutorFactory.getType(), is("openGauss"));
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLAdminExecutorFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLAdminExecutorFactoryTest.java
index 979df9cfa1f..45ac80730ff 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLAdminExecutorFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/PostgreSQLAdminExecutorFactoryTest.java
@@ -38,7 +38,6 @@ import java.sql.SQLException;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -73,11 +72,6 @@ public final class PostgreSQLAdminExecutorFactoryTest {
assertFalse(postgreSQLAdminExecutorFactory.newInstance(mock(SQLStatementContext.class), null, null).isPresent());
}
- @Test
- public void assertType() {
- assertThat(postgreSQLAdminExecutorFactory.getType(), is("PostgreSQL"));
- }
-
@Test
public void assertNewInstanceWithSetClientEncoding() {
SetStatement setStatement = createSetStatement("client_encoding");
@@ -114,8 +108,8 @@ public final class PostgreSQLAdminExecutorFactoryTest {
variableSegment.setVariable(configurationParameter);
VariableAssignSegment variableAssignSegment = new VariableAssignSegment();
variableAssignSegment.setVariable(variableSegment);
- SetStatement setStatement = new PostgreSQLSetStatement();
- setStatement.getVariableAssigns().add(variableAssignSegment);
- return setStatement;
+ SetStatement result = new PostgreSQLSetStatement();
+ result.getVariableAssigns().add(variableAssignSegment);
+ return result;
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
index 100ed944bae..9c63bd5cab0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/OpenGaussFrontendEngineTest.java
@@ -32,7 +32,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.lang.reflect.Field;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -85,9 +84,4 @@ public final class OpenGaussFrontendEngineTest {
openGaussFrontendEngine.release(connection);
verify(mockPostgreSQLFrontendEngine).release(connection);
}
-
- @Test
- public void assertGetDatabaseType() {
- assertThat(openGaussFrontendEngine.getType(), is("openGauss"));
- }
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java
index 1e5099fe390..d8a82aafeb9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-core/src/test/java/org/apache/shardingsphere/proxy/frontend/reactive/state/impl/ReactiveOKProxyStateTest.java
@@ -29,8 +29,6 @@ import org.apache.shardingsphere.proxy.frontend.reactive.spi.ReactiveDatabasePro
import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -38,8 +36,6 @@ import static org.mockito.Mockito.when;
public final class ReactiveOKProxyStateTest {
- private final ReactiveOKProxyState state = new ReactiveOKProxyState();
-
@SuppressWarnings("unchecked")
@Test
public void assertExecute() {
@@ -53,13 +49,8 @@ public final class ReactiveOKProxyStateTest {
DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine = mock(DatabaseProtocolFrontendEngine.class);
when(databaseProtocolFrontendEngine.getType()).thenReturn("Dummy");
ConnectionSession connectionSession = mock(ConnectionSession.class);
- state.execute(channelHandlerContext, null, databaseProtocolFrontendEngine, connectionSession);
+ new ReactiveOKProxyState().execute(channelHandlerContext, null, databaseProtocolFrontendEngine, connectionSession);
verify(attribute).setIfAbsent(any(DummyReactiveDatabaseProtocolFrontendEngine.class));
verify(eventExecutor).execute(any(ReactiveCommandExecuteTask.class));
}
-
- @Test
- public void assertGetType() {
- assertThat(state.getType(), is("ExperimentalVertx"));
- }
}
diff --git a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java
index 62a4e03008c..6387ec70b5d 100644
--- a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java
+++ b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/IdleRuleAlteredJobCompletionDetectAlgorithmTest.java
@@ -29,7 +29,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Collection;
@@ -40,9 +39,7 @@ import java.util.Properties;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@@ -56,7 +53,6 @@ public final class IdleRuleAlteredJobCompletionDetectAlgorithmTest {
@Before
public void setup() throws Exception {
- MockitoAnnotations.initMocks(this);
ReflectionUtil.setFieldValue(detectAlgorithm, "props", propsMock);
}
@@ -87,11 +83,6 @@ public final class IdleRuleAlteredJobCompletionDetectAlgorithmTest {
detectAlgorithm.init();
}
- @Test
- public void assertGetType() {
- assertThat(detectAlgorithm.getType(), is("IDLE"));
- }
-
@Test
public void assertFalseOnFewJobProgresses() {
int jobShardingCount = 2;