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 2025/11/12 17:11:55 UTC
(shardingsphere) branch master updated: Refactor RuleMetaDataTest (#37085)
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 a0df90464a3 Refactor RuleMetaDataTest (#37085)
a0df90464a3 is described below
commit a0df90464a3b2198e2e4c45c6e1811bacebe8652
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Nov 13 01:11:50 2025 +0800
Refactor RuleMetaDataTest (#37085)
---
.../infra/metadata/database/rule/RuleMetaDataTest.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java
index eb549ed4baa..01d3241d28c 100644
--- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java
+++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/rule/RuleMetaDataTest.java
@@ -125,17 +125,17 @@ class RuleMetaDataTest {
}
private RuleMetaDataShardingSphereRuleFixture mockRuleMetaDataShardingSphereRuleFixture(final String storageUnitName) {
- RuleMetaDataShardingSphereRuleFixture result = mock(RuleMetaDataShardingSphereRuleFixture.class, RETURNS_DEEP_STUBS);
- DataSourceMapperRuleAttribute ruleAttribute = mock(DataSourceMapperRuleAttribute.class);
- when(ruleAttribute.getDataSourceMapper()).thenReturn(Collections.singletonMap("logic_db", Collections.singleton(storageUnitName)));
- when(result.getAttributes()).thenReturn(new RuleAttributes(ruleAttribute));
- return result;
+ return mockDataSourceMapperRuleAttributeRule(RuleMetaDataShardingSphereRuleFixture.class, storageUnitName);
}
private ShardingSphereRule mockShardingSphereRule() {
- ShardingSphereRule result = mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS);
+ return mockDataSourceMapperRuleAttributeRule(ShardingSphereRule.class, "shared_ds");
+ }
+
+ private <T extends ShardingSphereRule> T mockDataSourceMapperRuleAttributeRule(final Class<T> type, final String storageUnitName) {
+ T result = mock(type, RETURNS_DEEP_STUBS);
DataSourceMapperRuleAttribute ruleAttribute = mock(DataSourceMapperRuleAttribute.class);
- when(ruleAttribute.getDataSourceMapper()).thenReturn(Collections.singletonMap("logic_db", Collections.singleton("shared_ds")));
+ when(ruleAttribute.getDataSourceMapper()).thenReturn(Collections.singletonMap("logic_db", Collections.singleton(storageUnitName)));
when(result.getAttributes()).thenReturn(new RuleAttributes(ruleAttribute));
return result;
}