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 3245d0d2018 17519 (#18923)
3245d0d2018 is described below

commit 3245d0d20186d3f1521904df08c3bf8c4af2133a
Author: lushaorong <[email protected]>
AuthorDate: Sun Jul 10 02:05:27 2022 -0500

    17519 (#18923)
    
    * Refactor ClusterContextManagerCoordinatorTest
    
    * Add unit test for ClusterContextManagerCoordinator.renew(final 
SchemaDeletedEvent event)
---
 .../coordinator/ClusterContextManagerCoordinatorTest.java      | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
index 7e54e2ee929..e0bf433d4e3 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/cluster/coordinator/ClusterContextManagerCoordinatorTest.java
@@ -60,6 +60,7 @@ import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.confi
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseAddedEvent;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.DatabaseDeletedEvent;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaAddedEvent;
+import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.event.SchemaDeletedEvent;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.ShowProcessListManager;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.process.lock.ShowProcessListSimpleLock;
 import 
org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.status.compute.event.InstanceOfflineEvent;
@@ -187,7 +188,7 @@ public final class ClusterContextManagerCoordinatorTest {
     }
     
     @Test
-    public void assertSchemaDelete() {
+    public void assertDatabaseDelete() {
         coordinator.renew(new DatabaseDeletedEvent("db"));
         
assertNull(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db"));
     }
@@ -207,6 +208,13 @@ public final class ClusterContextManagerCoordinatorTest {
         
verify(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db").getSchemas()).put(argThat(argument
 -> argument.equals("foo_schema")), any(ShardingSphereSchema.class));
     }
     
+    @Test
+    public void assertSchemaDelete() {
+        
when(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db").getSchemas().containsKey("foo_schema")).thenReturn(true);
+        coordinator.renew(new SchemaDeletedEvent("db", "foo_schema"));
+        
verify(contextManager.getMetaDataContexts().getMetaData().getDatabases().get("db").getSchemas()).remove("foo_schema");
+    }
+    
     @Test
     public void assertSchemaChanged() {
         ShardingSphereTable changedTableMetaData = new 
ShardingSphereTable("t_order", Collections.emptyList(), 
Collections.emptyList(), Collections.emptyList());

Reply via email to