You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/08/07 14:19:24 UTC
[shardingsphere] branch master updated: add test (#19945)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 dec05e9b68f add test (#19945)
dec05e9b68f is described below
commit dec05e9b68faefadc00086bf6c0e0a0580348502
Author: Da Xiang Huang <lo...@foxmail.com>
AuthorDate: Sun Aug 7 22:19:18 2022 +0800
add test (#19945)
---
...rdingAutoTableRuleConfigurationSwapperTest.java | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java
index c0f4ff065d2..d5ed5e6011f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java
@@ -22,6 +22,9 @@ import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerate
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration;
import org.junit.Before;
import org.junit.Test;
@@ -89,4 +92,26 @@ public final class YamlShardingAutoTableRuleConfigurationSwapperTest {
public void assertSwapToObjectWithoutLogicTable() {
new YamlShardingAutoTableRuleConfigurationSwapper(Collections.emptyMap(), Collections.emptyMap()).swapToObject(new YamlShardingAutoTableRuleConfiguration());
}
+
+ @Test
+ public void assertSwapToObject() {
+ YamlShardingStrategyConfiguration yamlShardingStrategyConfiguration = new YamlShardingStrategyConfiguration();
+ YamlStandardShardingStrategyConfiguration standard = new YamlStandardShardingStrategyConfiguration();
+ standard.setShardingColumn("col");
+ standard.setShardingAlgorithmName("foo_algorithm");
+ yamlShardingStrategyConfiguration.setStandard(standard);
+ YamlShardingAutoTableRuleConfiguration configuration = swapper.swapToYamlConfiguration(
+ new ShardingAutoTableRuleConfiguration("tbl", "ds0,ds1"));
+ configuration.setShardingStrategy(yamlShardingStrategyConfiguration);
+ YamlKeyGenerateStrategyConfiguration keyGenerateStrategy = new YamlKeyGenerateStrategyConfiguration();
+ keyGenerateStrategy.setColumn("col");
+ configuration.setKeyGenerateStrategy(keyGenerateStrategy);
+ configuration.setActualTablePrefix("tmp_");
+ ShardingAutoTableRuleConfiguration actual = new YamlShardingAutoTableRuleConfigurationSwapper(Collections.emptyMap(), Collections.emptyMap()).swapToObject(configuration);
+ assertThat(actual.getLogicTable(), is("tbl"));
+ assertThat(actual.getActualDataSources(), is("ds0,ds1"));
+ assertThat(actual.getActualTablePrefix(), is("tmp_"));
+ assertNotNull(actual.getShardingStrategy());
+ assertNotNull(actual.getKeyGenerateStrategy());
+ }
}