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

zhaojinchao 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 d0cb87a2fb4 Minor changes for test cases and code format (#17718)
d0cb87a2fb4 is described below

commit d0cb87a2fb4c2a9578195548075140fbf861f684
Author: Liang Zhang <[email protected]>
AuthorDate: Tue May 17 04:40:29 2022 +0800

    Minor changes for test cases and code format (#17718)
    
    * Remove useless test case
    
    * Remove useless assertions
    
    * Remove useless assertions
    
    * Remove useless assertions
    
    * For code format
    
    * Fix test cases
---
 .../RuleBasedSchemaMetaDataBuilderFactoryTest.java | 13 +--
 .../fixture/FixtureExecutionPrepareDecorator.java  |  8 +-
 .../ExecutionPrepareDecoratorFactoryTest.java      | 12 +--
 .../SQLRewriteContextDecoratorFactoryTest.java     | 13 +--
 .../fixture/FixtureSQLRewriteContextDecorator.java |  3 +-
 .../SingleTableMetadataValidatorFactory.java       |  5 +-
 ...ingleTableDatabaseBroadcastRouteEngineTest.java |  9 +-
 .../engine/SingleTableRouteEngineFactoryTest.java  | 95 ++++------------------
 .../SingleTableMetadataValidatorFactoryTest.java   | 30 ++-----
 .../persist/MetaDataPersistServiceTest.java        | 23 ++----
 .../proxy/arguments/BootstrapArgumentsTest.java    | 21 -----
 11 files changed, 43 insertions(+), 189 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/RuleBasedSchemaMetaDataBuilderFactoryTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/RuleBasedSchemaMetaDataBuilderFactoryTest.java
index 17498a287c3..306ffc1ace3 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/RuleBasedSchemaMetaDataBuilderFactoryTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/schema/builder/RuleBasedSchemaMetaDataBuilderFactoryTest.java
@@ -17,31 +17,20 @@
 
 package org.apache.shardingsphere.infra.metadata.schema.builder;
 
-import 
org.apache.shardingsphere.infra.metadata.schema.builder.spi.RuleBasedSchemaMetaDataBuilder;
 import 
org.apache.shardingsphere.infra.metadata.schema.fixture.loader.CommonFixtureSchemaMetaDataBuilder;
 import 
org.apache.shardingsphere.infra.metadata.schema.fixture.rule.CommonFixtureRule;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.junit.Test;
 
 import java.util.Collections;
-import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 
 public final class RuleBasedSchemaMetaDataBuilderFactoryTest {
     
-    @SuppressWarnings("rawtypes")
     @Test
     public void assertGetInstances() {
         CommonFixtureRule rule = new CommonFixtureRule();
-        Map<ShardingSphereRule, RuleBasedSchemaMetaDataBuilder> actual = 
RuleBasedSchemaMetaDataBuilderFactory.getInstances(Collections.singleton(rule));
-        assertNotNull(actual);
-        assertFalse(actual.isEmpty());
-        assertTrue(actual.containsKey(rule));
-        assertThat(actual.get(rule), 
instanceOf(CommonFixtureSchemaMetaDataBuilder.class));
+        
assertThat(RuleBasedSchemaMetaDataBuilderFactory.getInstances(Collections.singleton(rule)).get(rule),
 instanceOf(CommonFixtureSchemaMetaDataBuilder.class));
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureExecutionPrepareDecorator.java
 
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureExecutionPrepareDecorator.java
index 17fe7646834..05c7d7749b4 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureExecutionPrepareDecorator.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureExecutionPrepareDecorator.java
@@ -17,17 +17,17 @@
 
 package org.apache.shardingsphere.infra.executor.sql.fixture;
 
-import java.util.Collection;
-import java.util.Collections;
 import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroup;
 import 
org.apache.shardingsphere.infra.executor.sql.prepare.ExecutionPrepareDecorator;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 
+import java.util.Collection;
+import java.util.Collections;
+
 public final class FixtureExecutionPrepareDecorator implements 
ExecutionPrepareDecorator<Object, FixtureRule> {
     
     @Override
-    public Collection<ExecutionGroup<Object>> decorate(final RouteContext 
routeContext, final FixtureRule rule,
-                                                       final 
Collection<ExecutionGroup<Object>> executionGroups) {
+    public Collection<ExecutionGroup<Object>> decorate(final RouteContext 
routeContext, final FixtureRule rule, final Collection<ExecutionGroup<Object>> 
executionGroups) {
         return Collections.emptyList();
     }
     
diff --git 
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareDecoratorFactoryTest.java
 
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareDecoratorFactoryTest.java
index 8485e3373ef..cc0bebe2a7d 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareDecoratorFactoryTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareDecoratorFactoryTest.java
@@ -19,28 +19,18 @@ package 
org.apache.shardingsphere.infra.executor.sql.prepare;
 
 import 
org.apache.shardingsphere.infra.executor.sql.fixture.FixtureExecutionPrepareDecorator;
 import org.apache.shardingsphere.infra.executor.sql.fixture.FixtureRule;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.junit.Test;
 
 import java.util.Collections;
-import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 
 public final class ExecutionPrepareDecoratorFactoryTest {
     
     @Test
-    @SuppressWarnings("rawtypes")
     public void assertGetInstance() {
         FixtureRule rule = new FixtureRule();
-        Map<ShardingSphereRule, ExecutionPrepareDecorator> actual = 
ExecutionPrepareDecoratorFactory.getInstance(Collections.singleton(rule));
-        assertNotNull(actual);
-        assertFalse(actual.isEmpty());
-        assertTrue(actual.containsKey(rule));
-        assertThat(actual.get(rule), 
instanceOf(FixtureExecutionPrepareDecorator.class));
+        
assertThat(ExecutionPrepareDecoratorFactory.getInstance(Collections.singleton(rule)).get(rule),
 instanceOf(FixtureExecutionPrepareDecorator.class));
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextDecoratorFactoryTest.java
 
b/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextDecoratorFactoryTest.java
index e744083f471..b62098ae970 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextDecoratorFactoryTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/context/SQLRewriteContextDecoratorFactoryTest.java
@@ -19,29 +19,18 @@ package org.apache.shardingsphere.infra.rewrite.context;
 
 import org.apache.shardingsphere.infra.rewrite.fixture.FixtureRule;
 import 
org.apache.shardingsphere.infra.rewrite.fixture.FixtureSQLRewriteContextDecorator;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.junit.Test;
 
 import java.util.Collections;
-import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 
 public final class SQLRewriteContextDecoratorFactoryTest {
     
     @Test
-    @SuppressWarnings("rawtypes")
     public void assertGetInstance() {
         FixtureRule rule = new FixtureRule();
-        Map<ShardingSphereRule, SQLRewriteContextDecorator> actual = 
SQLRewriteContextDecoratorFactory.getInstance(
-                Collections.singleton(rule));
-        assertNotNull(actual);
-        assertFalse(actual.isEmpty());
-        assertTrue(actual.containsKey(rule));
-        assertThat(actual.get(rule), 
instanceOf(FixtureSQLRewriteContextDecorator.class));
+        
assertThat(SQLRewriteContextDecoratorFactory.getInstance(Collections.singleton(rule)).get(rule),
 instanceOf(FixtureSQLRewriteContextDecorator.class));
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/fixture/FixtureSQLRewriteContextDecorator.java
 
b/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/fixture/FixtureSQLRewriteContextDecorator.java
index 6bbfab53c23..c855ca6793e 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/fixture/FixtureSQLRewriteContextDecorator.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-rewrite/src/test/java/org/apache/shardingsphere/infra/rewrite/fixture/FixtureSQLRewriteContextDecorator.java
@@ -25,8 +25,7 @@ import 
org.apache.shardingsphere.infra.route.context.RouteContext;
 public final class FixtureSQLRewriteContextDecorator implements 
SQLRewriteContextDecorator<FixtureRule> {
     
     @Override
-    public void decorate(final FixtureRule rule, final ConfigurationProperties 
props, final SQLRewriteContext sqlRewriteContext,
-                         final RouteContext routeContext) {
+    public void decorate(final FixtureRule rule, final ConfigurationProperties 
props, final SQLRewriteContext sqlRewriteContext, final RouteContext 
routeContext) {
     }
     
     @Override
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactory.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactory.java
index 39f61faa0bc..a03de28feeb 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactory.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactory.java
@@ -39,9 +39,6 @@ public final class SingleTableMetadataValidatorFactory {
      */
     @SuppressWarnings("rawtypes")
     public static Optional<SingleTableMetadataValidator> newInstance(final 
SQLStatement sqlStatement) {
-        if (sqlStatement instanceof DropSchemaStatement) {
-            return Optional.of(new SingleTableDropSchemaMetadataValidator());
-        }
-        return Optional.empty();
+        return sqlStatement instanceof DropSchemaStatement ? Optional.of(new 
SingleTableDropSchemaMetadataValidator()) : Optional.empty();
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableDatabaseBroadcastRouteEngineTest.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableDatabaseBroadcastRouteEngineTest.java
index a2d3993c2b8..d2e99b159b2 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableDatabaseBroadcastRouteEngineTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableDatabaseBroadcastRouteEngineTest.java
@@ -36,6 +36,7 @@ import java.util.Properties;
 
 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,17 +44,17 @@ public final class 
SingleTableDatabaseBroadcastRouteEngineTest {
     
     @Test
     public void assertRoute() {
-        SingleTableRule singleTableRule = new SingleTableRule(new 
SingleTableRuleConfiguration(), DefaultDatabase.LOGIC_NAME, 
mock(DatabaseType.class),
-                createDataSourceMap(), Collections.emptyList(), new 
ConfigurationProperties(new Properties()));
+        SingleTableRule singleTableRule = new SingleTableRule(new 
SingleTableRuleConfiguration(), 
+                DefaultDatabase.LOGIC_NAME, mock(DatabaseType.class), 
createDataSourceMap(), Collections.emptyList(), new ConfigurationProperties(new 
Properties()));
         RouteContext routeContext = new RouteContext();
         SingleTableDatabaseBroadcastRouteEngine engine = new 
SingleTableDatabaseBroadcastRouteEngine();
         engine.route(routeContext, singleTableRule);
         List<RouteUnit> routeUnits = new 
ArrayList<>(routeContext.getRouteUnits());
         assertThat(routeContext.getRouteUnits().size(), is(2));
         assertThat(routeUnits.get(0).getDataSourceMapper().getActualName(), 
is("ds_0"));
-        assertThat(routeUnits.get(0).getTableMappers().size(), is(0));
+        assertTrue(routeUnits.get(0).getTableMappers().isEmpty());
         assertThat(routeUnits.get(1).getDataSourceMapper().getActualName(), 
is("ds_1"));
-        assertThat(routeUnits.get(1).getTableMappers().size(), is(0));
+        assertTrue(routeUnits.get(1).getTableMappers().isEmpty());
     }
     
     private Map<String, DataSource> createDataSourceMap() {
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableRouteEngineFactoryTest.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableRouteEngineFactoryTest.java
index d833114f587..6a054330d83 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableRouteEngineFactoryTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/engine/SingleTableRouteEngineFactoryTest.java
@@ -18,105 +18,42 @@
 package org.apache.shardingsphere.singletable.route.engine;
 
 import org.apache.shardingsphere.infra.metadata.schema.QualifiedTable;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussAlterSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussCreateSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLCreateSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLDropSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerAlterSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerCreateSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerDropSchemaStatement;
-import org.junit.Before;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterSchemaStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateSchemaStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropSchemaStatement;
 import org.junit.Test;
 
-import java.util.Collection;
 import java.util.Collections;
-import java.util.Optional;
 
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
 
 public final class SingleTableRouteEngineFactoryTest {
     
-    private Collection<QualifiedTable> emptySingleTableNames;
-    
-    private Collection<QualifiedTable> nonEmptySingleTableNames;
-    
-    @Before
-    public void setup() {
-        emptySingleTableNames = Collections.emptyList();
-        nonEmptySingleTableNames = Collections.singleton(new 
QualifiedTable("demo_ds", "t_order"));
-    }
-    
-    @Test
-    public void assertNewInstanceWithCreateSchemaStatementForPostgreSQL() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
PostgreSQLCreateSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
PostgreSQLCreateSchemaStatement());
-        assertTrue(actual.isPresent());
-    }
-    
-    @Test
-    public void assertNewInstanceWithAlterSchemaStatementForPostgreSQL() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
PostgreSQLAlterSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
PostgreSQLAlterSchemaStatement());
-        assertTrue(actual.isPresent());
-    }
-    
-    @Test
-    public void assertNewInstanceWithDropSchemaStatementForPostgreSQL() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
PostgreSQLDropSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
PostgreSQLDropSchemaStatement());
-        assertTrue(actual.isPresent());
-    }
-    
-    @Test
-    public void assertNewInstanceWithCreateSchemaStatementForSQLServer() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
SQLServerCreateSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
SQLServerCreateSchemaStatement());
-        assertTrue(actual.isPresent());
-    }
-    
     @Test
-    public void assertNewInstanceWithAlterSchemaStatementForSQLServer() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
SQLServerAlterSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
SQLServerAlterSchemaStatement());
-        assertTrue(actual.isPresent());
+    public void assertNewInstanceWithNotEmptySingleTableNames() {
+        
assertTrue(SingleTableRouteEngineFactory.newInstance(Collections.singleton(new 
QualifiedTable("demo_ds", "t_order")), mock(SQLStatement.class)).isPresent());
     }
     
     @Test
-    public void assertNewInstanceWithDropSchemaStatementForSQLServer() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
SQLServerDropSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
SQLServerDropSchemaStatement());
-        assertTrue(actual.isPresent());
+    public void 
assertNewInstanceWithEmptySingleTableNameAndCreateSchemaStatement() {
+        
assertTrue(SingleTableRouteEngineFactory.newInstance(Collections.emptyList(), 
mock(CreateSchemaStatement.class)).isPresent());
     }
     
     @Test
-    public void assertNewInstanceWithCreateSchemaStatementForOpenGauss() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
OpenGaussCreateSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
OpenGaussCreateSchemaStatement());
-        assertTrue(actual.isPresent());
+    public void 
assertNewInstanceWithEmptySingleTableNameAndAlterSchemaStatement() {
+        
assertTrue(SingleTableRouteEngineFactory.newInstance(Collections.emptyList(), 
mock(AlterSchemaStatement.class)).isPresent());
     }
     
     @Test
-    public void assertNewInstanceWithAlterSchemaStatementForOpenGauss() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
OpenGaussAlterSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
OpenGaussAlterSchemaStatement());
-        assertTrue(actual.isPresent());
+    public void 
assertNewInstanceWithEmptySingleTableNameAndDropSchemaStatement() {
+        
assertTrue(SingleTableRouteEngineFactory.newInstance(Collections.emptyList(), 
mock(DropSchemaStatement.class)).isPresent());
     }
     
     @Test
-    public void assertNewInstanceWithDropSchemaStatementForOpenGauss() {
-        Optional<SingleTableRouteEngine> actual = 
SingleTableRouteEngineFactory.newInstance(emptySingleTableNames, new 
OpenGaussDropSchemaStatement());
-        assertTrue(actual.isPresent());
-        actual = 
SingleTableRouteEngineFactory.newInstance(nonEmptySingleTableNames, new 
OpenGaussDropSchemaStatement());
-        assertTrue(actual.isPresent());
+    public void assertNewInstanceWithEmptySingleTableNameAndOtherStatement() {
+        
assertFalse(SingleTableRouteEngineFactory.newInstance(Collections.emptyList(), 
mock(SQLStatement.class)).isPresent());
     }
 }
diff --git 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactoryTest.java
 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactoryTest.java
index 7118df0d488..89fe6495af8 100644
--- 
a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactoryTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/test/java/org/apache/shardingsphere/singletable/route/validator/SingleTableMetadataValidatorFactoryTest.java
@@ -18,38 +18,22 @@
 package org.apache.shardingsphere.singletable.route.validator;
 
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLDropSchemaStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerDropSchemaStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropSchemaStatement;
 import org.junit.Test;
 
-import java.util.Optional;
-
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
 
 public final class SingleTableMetadataValidatorFactoryTest {
     
     @Test
-    @SuppressWarnings("rawtypes")
-    public void assertNewInstanceForPostgreSQL() {
-        SQLStatement statement = new PostgreSQLDropSchemaStatement();
-        Optional<SingleTableMetadataValidator> actual = 
SingleTableMetadataValidatorFactory.newInstance(statement);
-        assertTrue(actual.isPresent());
-    }
-    
-    @Test
-    @SuppressWarnings("rawtypes")
-    public void assertNewInstanceForSQLServer() {
-        SQLStatement statement = new SQLServerDropSchemaStatement();
-        Optional<SingleTableMetadataValidator> actual = 
SingleTableMetadataValidatorFactory.newInstance(statement);
-        assertTrue(actual.isPresent());
+    public void assertNewInstanceForDropSchemaStatement() {
+        
assertTrue(SingleTableMetadataValidatorFactory.newInstance(mock(DropSchemaStatement.class)).isPresent());
     }
     
     @Test
-    @SuppressWarnings("rawtypes")
-    public void assertNewInstanceForOpenGauss() {
-        SQLStatement statement = new OpenGaussDropSchemaStatement();
-        Optional<SingleTableMetadataValidator> actual = 
SingleTableMetadataValidatorFactory.newInstance(statement);
-        assertTrue(actual.isPresent());
+    public void assertNewInstanceForNotDropSchemaStatement() {
+        
assertFalse(SingleTableMetadataValidatorFactory.newInstance(mock(SQLStatement.class)).isPresent());
     }
 }
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
index 48c0b7ac2e2..5cb4d668d04 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/MetaDataPersistServiceTest.java
@@ -173,12 +173,12 @@ public final class MetaDataPersistServiceTest {
     
     @Test
     public void assertPersistTransactionRule() {
-        mockGlobalRulePersistServiceForLoad();
-        Properties properties = createTransactionProperties();
-        metaDataPersistService.persistTransactionRule(properties, true);
-        Collection<RuleConfiguration> ruleConfigs = globalRuleService.load();
-        Optional<RuleConfiguration> ruleConfig = 
ruleConfigs.stream().filter(each -> each instanceof 
TransactionRuleConfiguration).findFirst();
-        assertThat(ruleConfig.get(), 
is(createAssertTransactionRuleConfiguration()));
+        when(globalRuleService.load()).thenReturn(Collections.singleton(new 
TransactionRuleConfiguration(TransactionType.LOCAL.name(), null, new 
Properties())));
+        Properties props = createTransactionProperties();
+        metaDataPersistService.persistTransactionRule(props, true);
+        Optional<RuleConfiguration> actual = 
globalRuleService.load().stream().filter(each -> each instanceof 
TransactionRuleConfiguration).findFirst();
+        assertTrue(actual.isPresent());
+        assertThat(actual.get(), is(new 
TransactionRuleConfiguration(TransactionType.LOCAL.name(), null, 
createTransactionProperties())));
     }
     
     private Properties createTransactionProperties() {
@@ -186,15 +186,4 @@ public final class MetaDataPersistServiceTest {
         result.setProperty("type", TransactionType.LOCAL.name());
         return result;
     }
-    
-    private void mockGlobalRulePersistServiceForLoad() {
-        RuleConfiguration ruleConfiguration = new 
TransactionRuleConfiguration(TransactionType.LOCAL.name(), null, new 
Properties());
-        
when(globalRuleService.load()).thenReturn(Collections.singleton(ruleConfiguration));
-    }
-    
-    private RuleConfiguration createAssertTransactionRuleConfiguration() {
-        RuleConfiguration result = new 
TransactionRuleConfiguration(TransactionType.LOCAL.name(), null, 
createTransactionProperties());
-        return result;
-    }
-    
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
index 8895ae4d1cb..368b7e20800 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/arguments/BootstrapArgumentsTest.java
@@ -17,15 +17,9 @@
 
 package org.apache.shardingsphere.proxy.arguments;
 
-import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader;
-import org.apache.shardingsphere.proxy.backend.config.YamlProxyConfiguration;
 import org.junit.Test;
 
-import java.io.IOException;
 import java.util.Optional;
-import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertFalse;
@@ -68,19 +62,4 @@ public final class BootstrapArgumentsTest {
         assertThat(new BootstrapArguments(new String[]{"3306", 
"test_conf/"}).getConfigurationPath(), is("/test_conf/"));
         assertThat(new BootstrapArguments(new String[]{"3306", 
"/test_conf/"}).getConfigurationPath(), is("/test_conf/"));
     }
-
-    private Properties createProperties() {
-        Properties result = new Properties();
-        result.setProperty("proxy-default-port", "3306");
-        return result;
-    }
-
-    @Test
-    public void assertGetPortWithConfiguration() throws IOException {
-        BootstrapArguments bootstrapArgs = new BootstrapArguments(new 
String[]{});
-        YamlProxyConfiguration yamlConfig = 
ProxyConfigurationLoader.load("/conf/local");
-        yamlConfig.getServerConfiguration().setProps(createProperties());
-        int port = bootstrapArgs.getPort().orElseGet(() -> new 
ConfigurationProperties(yamlConfig.getServerConfiguration().getProps()).getValue(ConfigurationPropertyKey.PROXY_DEFAULT_PORT));
-        assertThat(port, is(3306));
-    }
 }

Reply via email to