This is an automated email from the ASF dual-hosted git repository.
wuweijie 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 f9732c2 Add more assertion for YamlRuleConfigurationSwapperEngineTest
(#9393)
f9732c2 is described below
commit f9732c243746217feffddf2c520681eb496ac7d5
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Feb 8 23:22:42 2021 +0800
Add more assertion for YamlRuleConfigurationSwapperEngineTest (#9393)
* Add more assertion for YamlRuleConfigurationSwapperEngineTest
* Rename YamlConfigurationSwapper
* Refactor YamlRuleConfigurationSwapperEngine
* Rename YamlRuleConfigurationSwapperFixture
* Rename RuleConfigurationFixture
* Refactor YamlRuleConfigurationFixture
* Rename YamlPropsRuleConfigurationFixture
---
.../EncryptColumnRuleConfigurationYamlSwapper.java | 4 +--
.../EncryptTableRuleConfigurationYamlSwapper.java | 4 +--
...rdingAutoTableRuleConfigurationYamlSwapper.java | 4 +--
.../ShardingTableRuleConfigurationYamlSwapper.java | 4 +--
...eyGenerateStrategyConfigurationYamlSwapper.java | 4 +--
.../ShardingStrategyConfigurationYamlSwapper.java | 4 +--
.../ShardingRuleConfigurationYamlSwapperTest.java | 4 +--
...gAutoTableRuleConfigurationYamlSwapperTest.java | 4 +--
.../TableRuleConfigurationYamlSwapperTest.java | 4 +--
.../governance/core/config/ConfigCenter.java | 2 +-
.../DataSourceConfigurationYamlSwapper.java | 4 +--
.../GovernanceCenterConfigurationYamlSwapper.java | 4 +--
.../GovernanceConfigurationYamlSwapper.java | 4 +--
.../core/yaml/swapper/SchemaYamlSwapper.java | 4 +--
.../builtin/yaml/swapper/UserRuleYamlSwapper.java | 4 +--
...lSwapper.java => YamlConfigurationSwapper.java} | 2 +-
.../yaml/swapper/YamlRuleConfigurationSwapper.java | 2 +-
.../YamlRuleConfigurationSwapperEngine.java | 32 ++++++++--------------
...ingSphereAlgorithmConfigurationYamlSwapper.java | 4 +--
.../infra/yaml/engine/YamlEngineTest.java | 22 +++++++--------
.../YamlPropsRuleConfigurationFixture.java} | 10 +++----
.../YamlRuleConfigurationSwapperEngineTest.java | 16 ++++++-----
...guration.java => RuleConfigurationFixture.java} | 2 +-
...tion.java => YamlRuleConfigurationFixture.java} | 7 ++---
...va => YamlRuleConfigurationSwapperFixture.java} | 14 +++++-----
...infra.yaml.swapper.YamlRuleConfigurationSwapper | 2 +-
.../rdl/AlterShardingRuleBackendHandler.java | 2 +-
.../impl/DropReplicaQueryRuleBackendHandler.java | 2 +-
.../distsql/rql/impl/RuleQueryBackendHandler.java | 2 +-
.../yaml/ServerConfigurationYamlSwapper.java | 4 +--
30 files changed, 87 insertions(+), 94 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
index 4785d88..bca52ce 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptColumnRuleConfigurationYamlSwapper.java
@@ -19,12 +19,12 @@ package org.apache.shardingsphere.encrypt.yaml.swapper.rule;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnRuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
/**
* Encrypt column rule configuration YAML swapper.
*/
-public final class EncryptColumnRuleConfigurationYamlSwapper implements
YamlSwapper<YamlEncryptColumnRuleConfiguration, EncryptColumnRuleConfiguration>
{
+public final class EncryptColumnRuleConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlEncryptColumnRuleConfiguration,
EncryptColumnRuleConfiguration> {
@Override
public YamlEncryptColumnRuleConfiguration swapToYamlConfiguration(final
EncryptColumnRuleConfiguration data) {
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapper.java
index 8ad4e3b..7d345b3 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/EncryptTableRuleConfigurationYamlSwapper.java
@@ -21,7 +21,7 @@ import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfig
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnRuleConfiguration;
import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import java.util.Collection;
import java.util.LinkedList;
@@ -30,7 +30,7 @@ import java.util.Map.Entry;
/**
* Encrypt table configuration YAML swapper.
*/
-public final class EncryptTableRuleConfigurationYamlSwapper implements
YamlSwapper<YamlEncryptTableRuleConfiguration, EncryptTableRuleConfiguration> {
+public final class EncryptTableRuleConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlEncryptTableRuleConfiguration,
EncryptTableRuleConfiguration> {
private final EncryptColumnRuleConfigurationYamlSwapper columnYamlSwapper
= new EncryptColumnRuleConfigurationYamlSwapper();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapper.java
index 1c9ec79..d54897b 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapper.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.yaml.swapper.rule;
import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.yaml.swapper.strategy.KeyGenerateStrategyConfigurationYamlSwapper;
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.sharding.yaml.swapper.strategy.ShardingStrategy
/**
* Sharding auto table rule configuration YAML swapper.
*/
-public final class ShardingAutoTableRuleConfigurationYamlSwapper implements
YamlSwapper<YamlShardingAutoTableRuleConfiguration,
ShardingAutoTableRuleConfiguration> {
+public final class ShardingAutoTableRuleConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlShardingAutoTableRuleConfiguration,
ShardingAutoTableRuleConfiguration> {
private final ShardingStrategyConfigurationYamlSwapper
shardingStrategyYamlSwapper = new ShardingStrategyConfigurationYamlSwapper();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingTableRuleConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingTableRuleConfigurationYamlSwapper.java
index 893f3e3..8c0e041 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingTableRuleConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingTableRuleConfigurationYamlSwapper.java
@@ -20,14 +20,14 @@ package
org.apache.shardingsphere.sharding.yaml.swapper.rule;
import com.google.common.base.Preconditions;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.sharding.yaml.swapper.strategy.KeyGenerateStrategyConfigurationYamlSwapper;
import
org.apache.shardingsphere.sharding.yaml.swapper.strategy.ShardingStrategyConfigurationYamlSwapper;
/**
* Sharding table rule configuration YAML swapper.
*/
-public final class ShardingTableRuleConfigurationYamlSwapper implements
YamlSwapper<YamlTableRuleConfiguration, ShardingTableRuleConfiguration> {
+public final class ShardingTableRuleConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlTableRuleConfiguration,
ShardingTableRuleConfiguration> {
private final ShardingStrategyConfigurationYamlSwapper
shardingStrategyYamlSwapper = new ShardingStrategyConfigurationYamlSwapper();
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/KeyGenerateStrategyConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/KeyGenerateStrategyConfigurationYamlSwapper.java
index df7f0f7..927c661 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/KeyGenerateStrategyConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/KeyGenerateStrategyConfigurationYamlSwapper.java
@@ -17,14 +17,14 @@
package org.apache.shardingsphere.sharding.yaml.swapper.strategy;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
/**
* Key generate strategy configuration YAML swapper.
*/
-public final class KeyGenerateStrategyConfigurationYamlSwapper implements
YamlSwapper<YamlKeyGenerateStrategyConfiguration,
KeyGenerateStrategyConfiguration> {
+public final class KeyGenerateStrategyConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlKeyGenerateStrategyConfiguration,
KeyGenerateStrategyConfiguration> {
@Override
public YamlKeyGenerateStrategyConfiguration swapToYamlConfiguration(final
KeyGenerateStrategyConfiguration data) {
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/ShardingStrategyConfigurationYamlSwapper.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/ShardingStrategyConfigurationYamlSwapper.java
index 3277364..88948ab 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/ShardingStrategyConfigurationYamlSwapper.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/ShardingStrategyConfigurationYamlSwapper.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.yaml.swapper.strategy;
import com.google.common.base.Preconditions;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
@@ -33,7 +33,7 @@ import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStan
/**
* Sharding strategy configuration YAML swapper.
*/
-public final class ShardingStrategyConfigurationYamlSwapper implements
YamlSwapper<YamlShardingStrategyConfiguration, ShardingStrategyConfiguration> {
+public final class ShardingStrategyConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlShardingStrategyConfiguration,
ShardingStrategyConfiguration> {
@Override
public YamlShardingStrategyConfiguration swapToYamlConfiguration(final
ShardingStrategyConfiguration data) {
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationYamlSwapperTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationYamlSwapperTest.java
index dd29cb5..0ae1a6f 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationYamlSwapperTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/ShardingRuleConfigurationYamlSwapperTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.yaml.swapper;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
@@ -73,7 +73,7 @@ public final class ShardingRuleConfigurationYamlSwapperTest {
when(keyGenerateStrategyConfigurationYamlSwapper.swapToObject(ArgumentMatchers.any())).thenReturn(mock(KeyGenerateStrategyConfiguration.class));
}
- private void setSwapper(final String swapperFieldName, final YamlSwapper
swapperFieldValue) throws ReflectiveOperationException {
+ private void setSwapper(final String swapperFieldName, final
YamlConfigurationSwapper swapperFieldValue) throws ReflectiveOperationException
{
Field field =
ShardingRuleConfigurationYamlSwapper.class.getDeclaredField(swapperFieldName);
field.setAccessible(true);
field.set(shardingRuleConfigurationYamlSwapper, swapperFieldValue);
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapperTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapperTest.java
index ee86456..0af1e18 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapperTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/ShardingAutoTableRuleConfigurationYamlSwapperTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.yaml.swapper.rule;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
@@ -61,7 +61,7 @@ public final class
ShardingAutoTableRuleConfigurationYamlSwapperTest {
when(keyGenerateStrategyYamlSwapper.swapToYamlConfiguration(ArgumentMatchers.any())).thenReturn(mock(YamlKeyGenerateStrategyConfiguration.class));
}
- private void setSwapper(final String swapperFieldName, final YamlSwapper
swapperFieldValue) throws ReflectiveOperationException {
+ private void setSwapper(final String swapperFieldName, final
YamlConfigurationSwapper swapperFieldValue) throws ReflectiveOperationException
{
Field field =
ShardingAutoTableRuleConfigurationYamlSwapper.class.getDeclaredField(swapperFieldName);
field.setAccessible(true);
field.set(tableYamlSwapper, swapperFieldValue);
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/TableRuleConfigurationYamlSwapperTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/TableRuleConfigurationYamlSwapperTest.java
index 5e290ce..580bd19 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/TableRuleConfigurationYamlSwapperTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/TableRuleConfigurationYamlSwapperTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.sharding.yaml.swapper.rule;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
@@ -64,7 +64,7 @@ public final class TableRuleConfigurationYamlSwapperTest {
when(keyGenerateStrategyYamlSwapper.swapToObject(ArgumentMatchers.any())).thenReturn(mock(KeyGenerateStrategyConfiguration.class));
}
- private void setSwapper(final String swapperFieldName, final YamlSwapper
swapperFieldValue) throws ReflectiveOperationException {
+ private void setSwapper(final String swapperFieldName, final
YamlConfigurationSwapper swapperFieldValue) throws ReflectiveOperationException
{
Field field =
ShardingTableRuleConfigurationYamlSwapper.class.getDeclaredField(swapperFieldName);
field.setAccessible(true);
field.set(tableYamlSwapper, swapperFieldValue);
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
index d2fae59..f61b89a 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCenter.java
@@ -274,7 +274,7 @@ public final class ConfigCenter {
}
}
YamlRootRuleConfigurations result = new YamlRootRuleConfigurations();
- result.setRules(new
YamlRuleConfigurationSwapperEngine().swapToYamlConfigurations(configs));
+ result.setRules(new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(configs));
return result;
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/DataSourceConfigurationYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/DataSourceConfigurationYamlSwapper.java
index 29aebc7..91ad7d2 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/DataSourceConfigurationYamlSwapper.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/DataSourceConfigurationYamlSwapper.java
@@ -19,12 +19,12 @@ package
org.apache.shardingsphere.governance.core.yaml.swapper;
import
org.apache.shardingsphere.governance.core.yaml.config.YamlDataSourceConfiguration;
import
org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
/**
* Data source configuration YAML swapper.
*/
-public final class DataSourceConfigurationYamlSwapper implements
YamlSwapper<YamlDataSourceConfiguration, DataSourceConfiguration> {
+public final class DataSourceConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlDataSourceConfiguration, DataSourceConfiguration> {
@Override
public YamlDataSourceConfiguration swapToYamlConfiguration(final
DataSourceConfiguration config) {
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceCenterConfigurationYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceCenterConfigurationYamlSwapper.java
index 330d60c..2a521fd 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceCenterConfigurationYamlSwapper.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceCenterConfigurationYamlSwapper.java
@@ -19,12 +19,12 @@ package
org.apache.shardingsphere.governance.core.yaml.swapper;
import
org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceCenterConfiguration;
import
org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
/**
* Governance center configuration YAML swapper.
*/
-public final class GovernanceCenterConfigurationYamlSwapper implements
YamlSwapper<YamlGovernanceCenterConfiguration, GovernanceCenterConfiguration> {
+public final class GovernanceCenterConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlGovernanceCenterConfiguration,
GovernanceCenterConfiguration> {
@Override
public YamlGovernanceCenterConfiguration swapToYamlConfiguration(final
GovernanceCenterConfiguration config) {
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
index 72df952..e302f6a 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/GovernanceConfigurationYamlSwapper.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.governance.core.yaml.swapper;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import
org.apache.shardingsphere.governance.core.yaml.config.YamlGovernanceConfiguration;
import
org.apache.shardingsphere.governance.repository.api.config.GovernanceCenterConfiguration;
import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConfiguration;
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.governance.repository.api.config.GovernanceConf
/**
* Governance configuration YAML swapper.
*/
-public final class GovernanceConfigurationYamlSwapper implements
YamlSwapper<YamlGovernanceConfiguration, GovernanceConfiguration> {
+public final class GovernanceConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlGovernanceConfiguration, GovernanceConfiguration> {
private final GovernanceCenterConfigurationYamlSwapper
governanceCenterConfigurationSwapper = new
GovernanceCenterConfigurationYamlSwapper();
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapper.java
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapper.java
index f78d8ae..164d675 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapper.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapper.java
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.schema.model.ColumnMetaData;
import org.apache.shardingsphere.infra.metadata.schema.model.IndexMetaData;
import org.apache.shardingsphere.infra.metadata.schema.model.TableMetaData;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import java.util.Collection;
import java.util.Collections;
@@ -40,7 +40,7 @@ import java.util.stream.Collectors;
/**
* ShardingSphere schema YAML swapper.
*/
-public final class SchemaYamlSwapper implements YamlSwapper<YamlSchema,
ShardingSphereSchema> {
+public final class SchemaYamlSwapper implements
YamlConfigurationSwapper<YamlSchema, ShardingSphereSchema> {
@Override
public YamlSchema swapToYamlConfiguration(final ShardingSphereSchema
schema) {
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builtin/yaml/swapper/UserRuleYamlSwapper.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builtin/yaml/swapper/UserRuleYamlSwapper.java
index 99e7aa5..e64b569 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builtin/yaml/swapper/UserRuleYamlSwapper.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/auth/builtin/yaml/swapper/UserRuleYamlSwapper.java
@@ -20,7 +20,7 @@ package
org.apache.shardingsphere.infra.metadata.auth.builtin.yaml.swapper;
import
org.apache.shardingsphere.infra.metadata.auth.builtin.yaml.config.YamlUserConfiguration;
import
org.apache.shardingsphere.infra.metadata.auth.builtin.yaml.config.YamlUserRuleConfiguration;
import
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -31,7 +31,7 @@ import java.util.Map.Entry;
/**
* User rule YAML swapper.
*/
-public final class UserRuleYamlSwapper implements
YamlSwapper<YamlUserRuleConfiguration, Collection<ShardingSphereUser>> {
+public final class UserRuleYamlSwapper implements
YamlConfigurationSwapper<YamlUserRuleConfiguration,
Collection<ShardingSphereUser>> {
@Override
public YamlUserRuleConfiguration swapToYamlConfiguration(final
Collection<ShardingSphereUser> data) {
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlSwapper.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlConfigurationSwapper.java
similarity index 94%
rename from
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlSwapper.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlConfigurationSwapper.java
index 755302e..04dc51e 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlSwapper.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlConfigurationSwapper.java
@@ -25,7 +25,7 @@ import
org.apache.shardingsphere.infra.yaml.config.YamlConfiguration;
* @param <Y> type of YAML configuration
* @param <T> type of swapped object
*/
-public interface YamlSwapper<Y extends YamlConfiguration, T> {
+public interface YamlConfigurationSwapper<Y extends YamlConfiguration, T> {
/**
* Swap to YAML configuration.
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapper.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapper.java
index 9c420df..38e8e46 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapper.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapper.java
@@ -27,7 +27,7 @@ import
org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
* @param <Y> type of YAML rule configuration
* @param <T> type of rule configuration
*/
-public interface YamlRuleConfigurationSwapper<Y extends YamlRuleConfiguration,
T extends RuleConfiguration> extends YamlSwapper<Y, T>, OrderedSPI<T> {
+public interface YamlRuleConfigurationSwapper<Y extends YamlRuleConfiguration,
T extends RuleConfiguration> extends YamlConfigurationSwapper<Y, T>,
OrderedSPI<T> {
/**
* Get YAML rule tag name.
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
index 9dff4af..4612774 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
@@ -43,16 +43,13 @@ public final class YamlRuleConfigurationSwapperEngine {
/**
* Swap to YAML rule configurations.
*
- * @param ruleConfigurations rule configurations
+ * @param ruleConfigs rule configurations
* @return YAML rule configurations
*/
- @SuppressWarnings({"unchecked", "rawtypes"})
- public Collection<YamlRuleConfiguration> swapToYamlConfigurations(final
Collection<RuleConfiguration> ruleConfigurations) {
- Collection<YamlRuleConfiguration> result = new LinkedList<>();
- for (Entry<RuleConfiguration, YamlRuleConfigurationSwapper> entry :
OrderedSPIRegistry.getRegisteredServices(ruleConfigurations,
YamlRuleConfigurationSwapper.class).entrySet()) {
- result.add((YamlRuleConfiguration)
entry.getValue().swapToYamlConfiguration(entry.getKey()));
- }
- return result;
+ @SuppressWarnings("unchecked")
+ public Collection<YamlRuleConfiguration>
swapToYamlRuleConfigurations(final Collection<RuleConfiguration> ruleConfigs) {
+ return OrderedSPIRegistry.getRegisteredServices(ruleConfigs,
YamlRuleConfigurationSwapper.class).entrySet().stream().map(
+ entry -> (YamlRuleConfiguration)
entry.getValue().swapToYamlConfiguration(entry.getKey())).collect(Collectors.toList());
}
/**
@@ -64,23 +61,18 @@ public final class YamlRuleConfigurationSwapperEngine {
@SuppressWarnings("rawtypes")
public Collection<RuleConfiguration> swapToRuleConfigurations(final
Collection<YamlRuleConfiguration> yamlRuleConfigs) {
Collection<RuleConfiguration> result = new LinkedList<>();
- Collection<Class<?>> ruleConfigurationTypes =
yamlRuleConfigs.stream().map(YamlRuleConfiguration::getRuleConfigurationType).collect(Collectors.toList());
- for (Entry<Class<?>, YamlRuleConfigurationSwapper> entry :
OrderedSPIRegistry.getRegisteredServicesByClass(ruleConfigurationTypes,
YamlRuleConfigurationSwapper.class).entrySet()) {
+ Collection<Class<?>> ruleConfigTypes =
yamlRuleConfigs.stream().map(YamlRuleConfiguration::getRuleConfigurationType).collect(Collectors.toList());
+ for (Entry<Class<?>, YamlRuleConfigurationSwapper> entry :
OrderedSPIRegistry.getRegisteredServicesByClass(ruleConfigTypes,
YamlRuleConfigurationSwapper.class).entrySet()) {
result.addAll(swapToRuleConfigurations(yamlRuleConfigs,
entry.getKey(), entry.getValue()));
}
return result;
}
- @SuppressWarnings("unchecked")
- private Collection<RuleConfiguration> swapToRuleConfigurations(final
Collection<YamlRuleConfiguration> yamlRuleConfigurations,
- final
Class<?> ruleConfigurationType, final YamlRuleConfigurationSwapper swapper) {
- Collection<RuleConfiguration> result = new LinkedList<>();
- for (YamlRuleConfiguration each : yamlRuleConfigurations) {
- if (each.getRuleConfigurationType().equals(ruleConfigurationType))
{
- result.add((RuleConfiguration) swapper.swapToObject(each));
- }
- }
- return result;
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private Collection<RuleConfiguration> swapToRuleConfigurations(final
Collection<YamlRuleConfiguration> yamlRuleConfigs,
+ final
Class<?> ruleConfigType, final YamlRuleConfigurationSwapper swapper) {
+ return yamlRuleConfigs.stream().filter(
+ each ->
each.getRuleConfigurationType().equals(ruleConfigType)).map(each ->
(RuleConfiguration) swapper.swapToObject(each)).collect(Collectors.toList());
}
/**
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/algorithm/ShardingSphereAlgorithmConfigurationYamlSwapper.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/algorithm/ShardingSphereAlgorithmConfigurationYamlSwapper.java
index eea09b2..11d0767 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/algorithm/ShardingSphereAlgorithmConfigurationYamlSwapper.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/algorithm/ShardingSphereAlgorithmConfigurationYamlSwapper.java
@@ -19,12 +19,12 @@ package
org.apache.shardingsphere.infra.yaml.swapper.algorithm;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import
org.apache.shardingsphere.infra.yaml.config.algorithm.YamlShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
/**
* ShardingSphere algorithm configuration YAML swapper.
*/
-public final class ShardingSphereAlgorithmConfigurationYamlSwapper implements
YamlSwapper<YamlShardingSphereAlgorithmConfiguration,
ShardingSphereAlgorithmConfiguration> {
+public final class ShardingSphereAlgorithmConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlShardingSphereAlgorithmConfiguration,
ShardingSphereAlgorithmConfiguration> {
@Override
public YamlShardingSphereAlgorithmConfiguration
swapToYamlConfiguration(final ShardingSphereAlgorithmConfiguration data) {
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
index d342beb..afb5888 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/YamlEngineTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.infra.yaml.engine;
-import
org.apache.shardingsphere.infra.yaml.swapper.fixture.FixtureYamlPropsRuleConfiguration;
-import
org.apache.shardingsphere.infra.yaml.swapper.fixture.FixtureYamlRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.engine.fixture.YamlPropsRuleConfigurationFixture;
+import
org.apache.shardingsphere.infra.yaml.swapper.fixture.YamlRuleConfigurationFixture;
import org.junit.Test;
import org.yaml.snakeyaml.constructor.ConstructorException;
@@ -44,7 +44,7 @@ public final class YamlEngineTest {
public void assertUnmarshalWithFile() throws IOException {
URL url =
getClass().getClassLoader().getResource("yaml/fixture-rule.yaml");
assertNotNull(url);
- FixtureYamlRuleConfiguration actual = YamlEngine.unmarshal(new
File(url.getFile()), FixtureYamlRuleConfiguration.class);
+ YamlRuleConfigurationFixture actual = YamlEngine.unmarshal(new
File(url.getFile()), YamlRuleConfigurationFixture.class);
assertThat(actual.getName(), is("test"));
}
@@ -61,13 +61,13 @@ public final class YamlEngineTest {
yamlContent.append(line).append("\n");
}
}
- FixtureYamlRuleConfiguration actual =
YamlEngine.unmarshal(yamlContent.toString().getBytes(),
FixtureYamlRuleConfiguration.class);
+ YamlRuleConfigurationFixture actual =
YamlEngine.unmarshal(yamlContent.toString().getBytes(),
YamlRuleConfigurationFixture.class);
assertThat(actual.getName(), is("test"));
}
@Test
public void assertUnmarshalWithYamlContentClassType() {
- FixtureYamlRuleConfiguration actual = YamlEngine.unmarshal("name:
test", FixtureYamlRuleConfiguration.class);
+ YamlRuleConfigurationFixture actual = YamlEngine.unmarshal("name:
test", YamlRuleConfigurationFixture.class);
assertThat(actual.getName(), is("test"));
}
@@ -86,7 +86,7 @@ public final class YamlEngineTest {
@Test
public void assertMarshal() {
- FixtureYamlRuleConfiguration actual = new
FixtureYamlRuleConfiguration();
+ YamlRuleConfigurationFixture actual = new
YamlRuleConfigurationFixture();
actual.setName("test");
assertThat(YamlEngine.marshal(actual), is("name: test\n"));
}
@@ -121,9 +121,9 @@ public final class YamlEngineTest {
Collection<Class<?>> acceptClasses = new LinkedList<>();
acceptClasses.add(URLClassLoader.class);
acceptClasses.add(URL.class);
- acceptClasses.add(FixtureYamlPropsRuleConfiguration.class);
- FixtureYamlPropsRuleConfiguration actual =
YamlEngine.unmarshal(yamlContent.toString(),
- FixtureYamlPropsRuleConfiguration.class, acceptClasses);
+ acceptClasses.add(YamlPropsRuleConfigurationFixture.class);
+ YamlPropsRuleConfigurationFixture actual =
YamlEngine.unmarshal(yamlContent.toString(),
+ YamlPropsRuleConfigurationFixture.class, acceptClasses);
assertThat(actual.getName(), is("test"));
}
@@ -140,8 +140,8 @@ public final class YamlEngineTest {
yamlContent.append(line).append("\n");
}
}
- FixtureYamlPropsRuleConfiguration actual =
YamlEngine.unmarshalWithFilter(yamlContent.toString(),
- FixtureYamlPropsRuleConfiguration.class);
+ YamlPropsRuleConfigurationFixture actual =
YamlEngine.unmarshalWithFilter(yamlContent.toString(),
+ YamlPropsRuleConfigurationFixture.class);
assertThat(actual.getName(), is("test"));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureYamlPropsRuleConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/fixture/YamlPropsRuleConfigurationFixture.java
similarity index 76%
rename from
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureYamlPropsRuleConfiguration.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/fixture/YamlPropsRuleConfigurationFixture.java
index f168ed5..e9e6a32 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureYamlPropsRuleConfiguration.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/engine/fixture/YamlPropsRuleConfigurationFixture.java
@@ -15,25 +15,25 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.yaml.swapper.fixture;
+package org.apache.shardingsphere.infra.yaml.engine.fixture;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.swapper.fixture.RuleConfigurationFixture;
import java.util.Properties;
@Getter
@Setter
-public final class FixtureYamlPropsRuleConfiguration implements
YamlRuleConfiguration {
+public final class YamlPropsRuleConfigurationFixture implements
YamlRuleConfiguration {
private String name;
private Properties props;
@Override
- public Class<? extends RuleConfiguration> getRuleConfigurationType() {
- return FixtureRuleConfiguration.class;
+ public Class<RuleConfigurationFixture> getRuleConfigurationType() {
+ return RuleConfigurationFixture.class;
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngineTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngineTest.java
index 7297142..4f1656f 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngineTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngineTest.java
@@ -19,8 +19,8 @@ package org.apache.shardingsphere.infra.yaml.swapper;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
-import
org.apache.shardingsphere.infra.yaml.swapper.fixture.FixtureRuleConfiguration;
-import
org.apache.shardingsphere.infra.yaml.swapper.fixture.FixtureYamlRuleConfiguration;
+import
org.apache.shardingsphere.infra.yaml.swapper.fixture.RuleConfigurationFixture;
+import
org.apache.shardingsphere.infra.yaml.swapper.fixture.YamlRuleConfigurationFixture;
import org.junit.Test;
import java.util.Collection;
@@ -29,30 +29,32 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class YamlRuleConfigurationSwapperEngineTest {
@Test
public void assertSwapToYamlConfigurations() {
- FixtureRuleConfiguration ruleConfig = new FixtureRuleConfiguration();
+ RuleConfigurationFixture ruleConfig = new RuleConfigurationFixture();
ruleConfig.setName("test");
- Collection<YamlRuleConfiguration> actual = new
YamlRuleConfigurationSwapperEngine().swapToYamlConfigurations(Collections.singletonList(ruleConfig));
+ Collection<YamlRuleConfiguration> actual = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singletonList(ruleConfig));
assertThat(actual.size(), is(1));
- assertThat(((FixtureYamlRuleConfiguration)
actual.iterator().next()).getName(), is("test"));
+ assertThat(((YamlRuleConfigurationFixture)
actual.iterator().next()).getName(), is("test"));
}
@Test
public void assertSwapToRuleConfigurations() {
- FixtureYamlRuleConfiguration yamlRuleConfig = new
FixtureYamlRuleConfiguration();
+ YamlRuleConfigurationFixture yamlRuleConfig = new
YamlRuleConfigurationFixture();
yamlRuleConfig.setName("test");
Collection<RuleConfiguration> actual = new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(Collections.singletonList(yamlRuleConfig));
assertThat(actual.size(), is(1));
- assertThat(((FixtureRuleConfiguration)
actual.iterator().next()).getName(), is("test"));
+ assertThat(((RuleConfigurationFixture)
actual.iterator().next()).getName(), is("test"));
}
@Test
public void assertGetYamlShortcuts() {
Map<String, Class<?>> actual =
YamlRuleConfigurationSwapperEngine.getYamlShortcuts();
assertThat(actual.size(), is(1));
+ assertTrue(actual.containsKey("!FIXTURE"));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureRuleConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/RuleConfigurationFixture.java
similarity index 94%
rename from
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureRuleConfiguration.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/RuleConfigurationFixture.java
index 3dc9098..9a8a3b8 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureRuleConfiguration.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/RuleConfigurationFixture.java
@@ -23,7 +23,7 @@ import
org.apache.shardingsphere.infra.config.RuleConfiguration;
@Getter
@Setter
-public final class FixtureRuleConfiguration implements RuleConfiguration {
+public final class RuleConfigurationFixture implements RuleConfiguration {
private String name;
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureYamlRuleConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/YamlRuleConfigurationFixture.java
similarity index 81%
rename from
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureYamlRuleConfiguration.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/YamlRuleConfigurationFixture.java
index cd1546f..c72f200 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureYamlRuleConfiguration.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/YamlRuleConfigurationFixture.java
@@ -19,17 +19,16 @@ package
org.apache.shardingsphere.infra.yaml.swapper.fixture;
import lombok.Getter;
import lombok.Setter;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration;
@Getter
@Setter
-public final class FixtureYamlRuleConfiguration implements
YamlRuleConfiguration {
+public final class YamlRuleConfigurationFixture implements
YamlRuleConfiguration {
private String name;
@Override
- public Class<? extends RuleConfiguration> getRuleConfigurationType() {
- return FixtureRuleConfiguration.class;
+ public Class<RuleConfigurationFixture> getRuleConfigurationType() {
+ return RuleConfigurationFixture.class;
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureConfigurationYamlSwapper.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
similarity index 68%
rename from
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureConfigurationYamlSwapper.java
rename to
shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
index 1a10553..736dfaf 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/FixtureConfigurationYamlSwapper.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.infra.yaml.swapper.fixture;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper;
-public final class FixtureConfigurationYamlSwapper implements
YamlRuleConfigurationSwapper<FixtureYamlRuleConfiguration,
FixtureRuleConfiguration> {
+public final class YamlRuleConfigurationSwapperFixture implements
YamlRuleConfigurationSwapper<YamlRuleConfigurationFixture,
RuleConfigurationFixture> {
@Override
public String getRuleTagName() {
@@ -32,20 +32,20 @@ public final class FixtureConfigurationYamlSwapper
implements YamlRuleConfigurat
}
@Override
- public Class<FixtureRuleConfiguration> getTypeClass() {
- return FixtureRuleConfiguration.class;
+ public Class<RuleConfigurationFixture> getTypeClass() {
+ return RuleConfigurationFixture.class;
}
@Override
- public FixtureYamlRuleConfiguration swapToYamlConfiguration(final
FixtureRuleConfiguration data) {
- FixtureYamlRuleConfiguration result = new
FixtureYamlRuleConfiguration();
+ public YamlRuleConfigurationFixture swapToYamlConfiguration(final
RuleConfigurationFixture data) {
+ YamlRuleConfigurationFixture result = new
YamlRuleConfigurationFixture();
result.setName(data.getName());
return result;
}
@Override
- public FixtureRuleConfiguration swapToObject(final
FixtureYamlRuleConfiguration yamlConfig) {
- FixtureRuleConfiguration result = new FixtureRuleConfiguration();
+ public RuleConfigurationFixture swapToObject(final
YamlRuleConfigurationFixture yamlConfig) {
+ RuleConfigurationFixture result = new RuleConfigurationFixture();
result.setName(yamlConfig.getName());
return result;
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper
b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper
index 8d7b0d3..5798259 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.infra.yaml.swapper.fixture.FixtureConfigurationYamlSwapper
+org.apache.shardingsphere.infra.yaml.swapper.fixture.YamlRuleConfigurationSwapperFixture
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/AlterShardingRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/AlterShardingRuleBackendHandler.java
index 3a52b35..58335c4 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/AlterShardingRuleBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/AlterShardingRuleBackendHandler.java
@@ -64,7 +64,7 @@ public final class AlterShardingRuleBackendHandler extends
SchemaRequiredBackend
throw new ShardingRuleNotExistedException();
}
check(shardingRuleConfig.get(), sqlStatement);
- Optional<YamlShardingRuleConfiguration> yamlShardingRuleConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlConfigurations(Collections.singleton(shardingRuleConfig.get())).stream()
+ Optional<YamlShardingRuleConfiguration> yamlShardingRuleConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singleton(shardingRuleConfig.get())).stream()
.filter(each -> each instanceof
YamlShardingRuleConfiguration).map(each -> (YamlShardingRuleConfiguration)
each).findFirst();
if (!yamlShardingRuleConfig.isPresent()) {
throw new ShardingRuleNotExistedException();
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
index 0c2b18e..157ae83 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/impl/DropReplicaQueryRuleBackendHandler.java
@@ -56,7 +56,7 @@ public final class DropReplicaQueryRuleBackendHandler extends
SchemaRequiredBack
throw new ReplicaQueryRuleNotExistedException();
}
check(replicaQueryRuleConfig.get(), ruleNames);
- Optional<YamlReplicaQueryRuleConfiguration> yamlConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlConfigurations(Collections.singletonList(replicaQueryRuleConfig.get())).stream()
+ Optional<YamlReplicaQueryRuleConfiguration> yamlConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singletonList(replicaQueryRuleConfig.get())).stream()
.map(each -> (YamlReplicaQueryRuleConfiguration)
each).findFirst();
if (!yamlConfig.isPresent()) {
throw new ReplicaQueryRuleNotExistedException();
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/RuleQueryBackendHandler.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/RuleQueryBackendHandler.java
index f6ba658..160ffc1 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/RuleQueryBackendHandler.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/impl/RuleQueryBackendHandler.java
@@ -88,7 +88,7 @@ public final class RuleQueryBackendHandler extends
SchemaRequiredBackendHandler<
@Override
public Collection<Object> getRowData() {
RuleConfiguration ruleConfig = data.next();
- YamlRuleConfiguration yamlRuleConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlConfigurations(Collections.singleton(ruleConfig)).iterator().next();
+ YamlRuleConfiguration yamlRuleConfig = new
YamlRuleConfigurationSwapperEngine().swapToYamlRuleConfigurations(Collections.singleton(ruleConfig)).iterator().next();
return Collections.singleton(YamlEngine.marshal(yamlRuleConfig));
}
}
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java
index 578316b..3f5a796 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/yaml/ServerConfigurationYamlSwapper.java
@@ -18,13 +18,13 @@
package org.apache.shardingsphere.scaling.core.config.yaml;
import
org.apache.shardingsphere.governance.core.yaml.swapper.GovernanceConfigurationYamlSwapper;
-import org.apache.shardingsphere.infra.yaml.swapper.YamlSwapper;
+import org.apache.shardingsphere.infra.yaml.swapper.YamlConfigurationSwapper;
import org.apache.shardingsphere.scaling.core.config.ServerConfiguration;
/**
* Server configuration yaml swapper.
*/
-public final class ServerConfigurationYamlSwapper implements
YamlSwapper<YamlServerConfiguration, ServerConfiguration> {
+public final class ServerConfigurationYamlSwapper implements
YamlConfigurationSwapper<YamlServerConfiguration, ServerConfiguration> {
private final GovernanceConfigurationYamlSwapper
governanceConfigurationYamlSwapper = new GovernanceConfigurationYamlSwapper();