You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2022/07/29 12:27:41 UTC
[shardingsphere] branch master updated: Refactor FixtureRuleConfiguration (#19698)
This is an automated email from the ASF dual-hosted git repository.
totalo 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 4d0e3bd2117 Refactor FixtureRuleConfiguration (#19698)
4d0e3bd2117 is described below
commit 4d0e3bd2117cdf33cf9a7790820632abc099d166
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Jul 29 20:27:33 2022 +0800
Refactor FixtureRuleConfiguration (#19698)
---
.../shardingsphere/infra/fixture/FixtureRuleConfiguration.java | 10 +++++++---
.../config/swapper/YamlRuleConfigurationSwapperEngineTest.java | 6 ++----
.../swapper/YamlRuleConfigurationSwapperFactoryTest.java | 6 +++---
.../swapper/fixture/YamlRuleConfigurationSwapperFixture.java | 4 +---
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java
index 0041b79e758..8da3053d7eb 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java
@@ -18,12 +18,16 @@
package org.apache.shardingsphere.infra.fixture;
import lombok.Getter;
-import lombok.Setter;
+import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
+@RequiredArgsConstructor
@Getter
-@Setter
public final class FixtureRuleConfiguration implements RuleConfiguration {
- private String name;
+ private final String name;
+
+ public FixtureRuleConfiguration() {
+ this("");
+ }
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperEngineTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperEngineTest.java
index 99bdd15fcb1..040c6e5c89a 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperEngineTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperEngineTest.java
@@ -35,9 +35,7 @@ public final class YamlRuleConfigurationSwapperEngineTest {
@Test
public void assertSwapToYamlConfigurations() {
- FixtureRuleConfiguration ruleConfig = new FixtureRuleConfiguration();
- ruleConfig.setName("test");
- Collection<YamlRuleConfiguration> actual = new YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singletonList(ruleConfig));
+ Collection<YamlRuleConfiguration> actual = new YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singleton(new FixtureRuleConfiguration("test")));
assertThat(actual.size(), is(1));
assertThat(((YamlRuleConfigurationFixture) actual.iterator().next()).getName(), is("test"));
}
@@ -46,7 +44,7 @@ public final class YamlRuleConfigurationSwapperEngineTest {
public void assertSwapToRuleConfigurations() {
YamlRuleConfigurationFixture yamlRuleConfig = new YamlRuleConfigurationFixture();
yamlRuleConfig.setName("test");
- Collection<RuleConfiguration> actual = new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singletonList(yamlRuleConfig));
+ Collection<RuleConfiguration> actual = new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singleton(yamlRuleConfig));
assertThat(actual.size(), is(1));
assertThat(((FixtureRuleConfiguration) actual.iterator().next()).getName(), is("test"));
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperFactoryTest.java
index 571dad8230d..323cd3b8cfe 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperFactoryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlRuleConfigurationSwapperFactoryTest.java
@@ -36,9 +36,9 @@ public final class YamlRuleConfigurationSwapperFactoryTest {
@SuppressWarnings("rawtypes")
@Test
public void assertGetInstanceMapByRuleConfigurations() {
- FixtureRuleConfiguration ruleConfigurationFixture = new FixtureRuleConfiguration();
- Map<RuleConfiguration, YamlRuleConfigurationSwapper> actual = YamlRuleConfigurationSwapperFactory.getInstanceMapByRuleConfigurations(Collections.singletonList(ruleConfigurationFixture));
- assertThat(actual.get(ruleConfigurationFixture), instanceOf(YamlRuleConfigurationSwapperFixture.class));
+ FixtureRuleConfiguration ruleConfig = new FixtureRuleConfiguration();
+ Map<RuleConfiguration, YamlRuleConfigurationSwapper> actual = YamlRuleConfigurationSwapperFactory.getInstanceMapByRuleConfigurations(Collections.singletonList(ruleConfig));
+ assertThat(actual.get(ruleConfig), instanceOf(YamlRuleConfigurationSwapperFixture.class));
}
@SuppressWarnings("rawtypes")
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
index aadecbb25df..417cf19eed8 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -36,9 +36,7 @@ public final class YamlRuleConfigurationSwapperFixture implements YamlRuleConfig
@Override
public FixtureRuleConfiguration swapToObject(final YamlRuleConfigurationFixture yamlConfig) {
- FixtureRuleConfiguration result = new FixtureRuleConfiguration();
- result.setName(yamlConfig.getName());
- return result;
+ return new FixtureRuleConfiguration(yamlConfig.getName());
}
@Override