You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/05/27 04:35:17 UTC

[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #10481: refactor renew AuthorityChangedEvent,add test unit.

menghaoranss commented on a change in pull request #10481:
URL: https://github.com/apache/shardingsphere/pull/10481#discussion_r640278676



##########
File path: shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
##########
@@ -216,10 +217,27 @@ public void assertGlobalRuleConfigurationsChanged() {
     }
 
     private Collection<RuleConfiguration> getChangedGlobalRuleConfigurations() {
+        RuleConfiguration authorityRuleConfig = new AuthorityRuleConfiguration(getShardingSphereUsers(), new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
+        return Collections.singleton(authorityRuleConfig);
+    }
+    
+    private Collection<ShardingSphereUser> getShardingSphereUsers() {
         Collection<ShardingSphereUser> users = new LinkedList<>();

Review comment:
       users -> result

##########
File path: shardingsphere-governance/shardingsphere-governance-context/src/test/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContextsTest.java
##########
@@ -92,15 +93,15 @@
     
     private GovernanceMetaDataContexts governanceMetaDataContexts;
     
-    @Mock
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)

Review comment:
       does this option work?

##########
File path: shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/metadata/GovernanceMetaDataContexts.java
##########
@@ -418,5 +422,29 @@ private boolean isModifiedDataSource(final Map<String, DataSource> oldDataSource
         return result;
     }
     
+    private ShardingSphereRuleMetaData getChangedGlobalRuleMetaData(final AuthorityChangedEvent event) {
+        Optional<AuthorityRuleConfiguration> authorityRuleConfig = metaDataContexts.getGlobalRuleMetaData().getConfigurations().stream().filter(each -> each instanceof AuthorityRuleConfiguration)
+                .findAny().map(each -> (AuthorityRuleConfiguration) each);
+        Collection<RuleConfiguration> globalRuleConfigs = new LinkedList<>(metaDataContexts.getGlobalRuleMetaData().getConfigurations());
+        globalRuleConfigs.remove(authorityRuleConfig.get());

Review comment:
       I‘m not sure authorityRuleConfig needs to be confirmed isPresent




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org