From 4ca78387c0c695a5f32d8768ac39d6d1441bfb1a Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sun, 24 Sep 2023 16:43:04 +0800 Subject: [PATCH] Merge FixtureDatabaseRule and FixtureRule --- .../database/DatabaseRulesBuilderTest.java | 6 ++-- .../builder/fixture/FixtureDatabaseRule.java | 31 ------------------- .../fixture/FixtureDatabaseRuleBuilder.java | 7 +++-- 3 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRule.java diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java index 8c5880b85f1ff..39d501814807b 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/database/DatabaseRulesBuilderTest.java @@ -18,18 +18,18 @@ package org.apache.shardingsphere.infra.rule.builder.database; import org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration; +import org.apache.shardingsphere.infra.fixture.FixtureRule; import org.apache.shardingsphere.infra.fixture.FixtureRuleConfiguration; import org.apache.shardingsphere.infra.instance.InstanceContext; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; -import org.apache.shardingsphere.infra.rule.builder.fixture.FixtureDatabaseRule; import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.Iterator; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.mock; class DatabaseRulesBuilderTest { @@ -38,7 +38,7 @@ class DatabaseRulesBuilderTest { void assertBuild() { Iterator actual = DatabaseRulesBuilder.build( "foo_db", new DataSourceProvidedDatabaseConfiguration(Collections.emptyMap(), Collections.singleton(new FixtureRuleConfiguration())), mock(InstanceContext.class)).iterator(); - assertThat(actual.next(), instanceOf(FixtureDatabaseRule.class)); + assertThat(actual.next(), instanceOf(FixtureRule.class)); assertFalse(actual.hasNext()); } } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRule.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRule.java deleted file mode 100644 index 86775ce9c2acf..0000000000000 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRule.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.rule.builder.fixture; - -import org.apache.shardingsphere.infra.config.rule.RuleConfiguration; -import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule; - -import static org.mockito.Mockito.mock; - -public final class FixtureDatabaseRule implements DatabaseRule { - - @Override - public RuleConfiguration getConfiguration() { - return mock(RuleConfiguration.class); - } -} diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRuleBuilder.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRuleBuilder.java index 00d9627d6602e..5ba9d3fad2d70 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRuleBuilder.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureDatabaseRuleBuilder.java @@ -17,6 +17,7 @@ package org.apache.shardingsphere.infra.rule.builder.fixture; +import org.apache.shardingsphere.infra.fixture.FixtureRule; import org.apache.shardingsphere.infra.instance.InstanceContext; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRuleBuilder; @@ -28,9 +29,9 @@ public final class FixtureDatabaseRuleBuilder implements DatabaseRuleBuilder { @Override - public FixtureDatabaseRule build(final FixtureDatabaseRuleConfiguration config, final String databaseName, - final Map dataSources, final Collection builtRules, final InstanceContext instanceContext) { - return new FixtureDatabaseRule(); + public FixtureRule build(final FixtureDatabaseRuleConfiguration config, final String databaseName, + final Map dataSources, final Collection builtRules, final InstanceContext instanceContext) { + return new FixtureRule(); } @Override