This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 264a907b324 Add RepositoryTupleKeyListNameGenerator test cases on
RepositoryTupleSwapperEngine (#32462)
264a907b324 is described below
commit 264a907b3244a29f63edbe84f26481cd0b35096a
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Aug 11 11:14:54 2024 +0800
Add RepositoryTupleKeyListNameGenerator test cases on
RepositoryTupleSwapperEngine (#32462)
---
.../mode/tuple/RepositoryTupleSwapperEngineTest.java | 5 ++++-
.../tuple/fixture/node/NodeYamlRuleConfiguration.java | 5 +++++
...=> RepositoryTupleKeyListNameGeneratorFixture.java} | 18 ++++--------------
.../fixture/node/RuleNodePathProviderFixture.java | 4 ++--
4 files changed, 15 insertions(+), 17 deletions(-)
diff --git
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/RepositoryTupleSwapperEngineTest.java
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/RepositoryTupleSwapperEngineTest.java
index 6264914a1de..a8aa753b3e1 100644
---
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/RepositoryTupleSwapperEngineTest.java
+++
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/RepositoryTupleSwapperEngineTest.java
@@ -67,8 +67,9 @@ class RepositoryTupleSwapperEngineTest {
LeafYamlRuleConfiguration leaf = new LeafYamlRuleConfiguration();
leaf.setValue("leaf");
yamlRuleConfig.setLeaf(leaf);
+ yamlRuleConfig.setGens(Collections.singleton("value"));
List<RepositoryTuple> actual = new ArrayList<>(new
RepositoryTupleSwapperEngine().swapToRepositoryTuples(yamlRuleConfig));
- assertThat(actual.size(), is(8));
+ assertThat(actual.size(), is(9));
assertThat(actual.get(0).getKey(), is("map_value/k"));
assertThat(actual.get(0).getValue(), is("value: v" +
System.lineSeparator()));
assertThat(actual.get(1).getKey(), is("collection_value"));
@@ -85,5 +86,7 @@ class RepositoryTupleSwapperEngineTest {
assertThat(actual.get(6).getValue(), is("FOO"));
assertThat(actual.get(7).getKey(), is("leaf"));
assertThat(actual.get(7).getValue(), is("value: leaf" +
System.lineSeparator()));
+ assertThat(actual.get(8).getKey(), is("gens/gen: value"));
+ assertThat(actual.get(8).getValue(), is("value"));
}
}
diff --git
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/NodeYamlRuleConfiguration.java
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/NodeYamlRuleConfiguration.java
index 70488f7fa67..a390cc0ca60 100644
---
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/NodeYamlRuleConfiguration.java
+++
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/NodeYamlRuleConfiguration.java
@@ -24,6 +24,7 @@ import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfigurati
import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleEntity;
import org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleField;
import
org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleField.Type;
+import
org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleKeyListNameGenerator;
import
org.apache.shardingsphere.mode.tuple.fixture.leaf.LeafYamlRuleConfiguration;
import java.util.Collection;
@@ -59,6 +60,10 @@ public final class NodeYamlRuleConfiguration implements
YamlRuleConfiguration {
@RepositoryTupleField(type = Type.OTHER)
private LeafYamlRuleConfiguration leaf;
+ @RepositoryTupleField(type = Type.OTHER)
+
@RepositoryTupleKeyListNameGenerator(RepositoryTupleKeyListNameGeneratorFixture.class)
+ private Collection<String> gens;
+
@Override
public Class<? extends RuleConfiguration> getRuleConfigurationType() {
return RuleConfiguration.class;
diff --git
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RepositoryTupleKeyListNameGeneratorFixture.java
similarity index 56%
copy from
mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
copy to
mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RepositoryTupleKeyListNameGeneratorFixture.java
index 91b9db178c9..20e838297d9 100644
---
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
+++
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RepositoryTupleKeyListNameGeneratorFixture.java
@@ -17,22 +17,12 @@
package org.apache.shardingsphere.mode.tuple.fixture.node;
-import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.mode.path.rule.RuleNodePath;
-import org.apache.shardingsphere.mode.spi.RuleNodePathProvider;
+import
org.apache.shardingsphere.mode.tuple.annotation.RepositoryTupleKeyListNameGenerator;
-import java.util.Arrays;
-import java.util.Collections;
-
-public final class RuleNodePathProviderFixture implements RuleNodePathProvider
{
-
- @Override
- public RuleNodePath getRuleNodePath() {
- return new RuleNodePath("node", Collections.singleton("map_value"),
Arrays.asList("collection_value", "string_value", "boolean_value",
"integer_value", "long_value", "enum_value", "leaf"));
- }
+public final class RepositoryTupleKeyListNameGeneratorFixture implements
RepositoryTupleKeyListNameGenerator.Generator {
@Override
- public Class<? extends RuleConfiguration> getType() {
- return RuleConfiguration.class;
+ public String generate(final Object tupleValue) {
+ return String.format("gen: %s", tupleValue);
}
}
diff --git
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
index 91b9db178c9..95ad9b501d4 100644
---
a/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
+++
b/mode/api/src/test/java/org/apache/shardingsphere/mode/tuple/fixture/node/RuleNodePathProviderFixture.java
@@ -22,13 +22,13 @@ import
org.apache.shardingsphere.mode.path.rule.RuleNodePath;
import org.apache.shardingsphere.mode.spi.RuleNodePathProvider;
import java.util.Arrays;
-import java.util.Collections;
public final class RuleNodePathProviderFixture implements RuleNodePathProvider
{
@Override
public RuleNodePath getRuleNodePath() {
- return new RuleNodePath("node", Collections.singleton("map_value"),
Arrays.asList("collection_value", "string_value", "boolean_value",
"integer_value", "long_value", "enum_value", "leaf"));
+ return new RuleNodePath("node", Arrays.asList("map_value", "gens"),
+ Arrays.asList("collection_value", "string_value",
"boolean_value", "integer_value", "long_value", "enum_value", "leaf"));
}
@Override