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 80e028fbcea Add more test cases on ViewPushDownMetaDataRefresherTest 
(#37203)
80e028fbcea is described below

commit 80e028fbcea69b33bcdcc7fe6528afd5c62f6ae1
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Nov 27 22:28:50 2025 +0800

    Add more test cases on ViewPushDownMetaDataRefresherTest (#37203)
    
    * Add more test cases on ViewPushDownMetaDataRefresherTest
    
    * Add more test cases on ViewPushDownMetaDataRefresherTest
---
 AGENTS.md                                          |   1 +
 .../AlterViewPushDownMetaDataRefresherTest.java    | 128 +++++++++++++++++++++
 .../CreateViewPushDownMetaDataRefresherTest.java   | 107 +++++++++++++++++
 .../DropViewPushDownMetaDataRefresherTest.java     |  64 +++++++++++
 4 files changed, 300 insertions(+)

diff --git a/AGENTS.md b/AGENTS.md
index c5a74c061b9..5ecaf52a2de 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -248,6 +248,7 @@ Always state which topology, registry, and engine versions 
(e.g., MySQL 5.7 vs 8
 - Do not mix Mockito matchers with raw arguments; choose a single style per 
invocation, and ensure the Mockito extension aligns with the mocking approach.
 - Never leave fully-qualified class names in production or test code; if a 
class is referenced, add an import and verify via a quick scan (`rg "\\." 
<path>`) before finishing.
 - When the user requires full branch/line coverage, treat 100% coverage as a 
blocking condition: enumerate branches, map tests, and keep adding cases until 
all branches are covered or explicitly waived; record the coverage requirement 
in the plan and self-check before concluding.
+- Compliance is mandatory: before any coding, re-read AGENTS.md and convert 
all hard requirements (SPI usage, no FQCN, mocking rules, coverage targets, 
planning steps) into a checklist in the plan; do not proceed or report 
completion until every item is satisfied or explicitly waived by the user.
 
 ## Brevity & Signal
 - Prefer tables/bullets over prose walls; cite file paths (`kernel/src/...`) 
directly.
diff --git 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/AlterViewPushDownMetaDataRefresherTest.java
 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/AlterViewPushDownMetaDataRefresherTest.java
new file mode 100644
index 00000000000..8c5ba067e48
--- /dev/null
+++ 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/AlterViewPushDownMetaDataRefresherTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mode.metadata.refresher.pushdown.type.view;
+
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
+import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereView;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
+import 
org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import 
org.apache.shardingsphere.mode.metadata.refresher.pushdown.PushDownMetaDataRefresher;
+import 
org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils;
+import 
org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.AlterViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import 
org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
+import 
org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(AutoMockExtension.class)
+@StaticMockSettings({TableRefreshUtils.class, GenericSchemaBuilder.class})
+@MockitoSettings(strictness = Strictness.LENIENT)
+class AlterViewPushDownMetaDataRefresherTest {
+    
+    private final DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
+    
+    private final AlterViewPushDownMetaDataRefresher refresher = 
(AlterViewPushDownMetaDataRefresher) 
TypedSPILoader.getService(PushDownMetaDataRefresher.class, 
AlterViewStatement.class);
+    
+    @Mock
+    private MetaDataManagerPersistService metaDataManagerPersistService;
+    
+    @Mock
+    private MutableDataNodeRuleAttribute mutableDataNodeRuleAttribute;
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    void assertRefreshRenameView() throws Exception {
+        ShardingSphereRule rule = mock(ShardingSphereRule.class);
+        when(rule.getAttributes()).thenReturn(new 
RuleAttributes(mutableDataNodeRuleAttribute));
+        AlterViewStatement sqlStatement = new AlterViewStatement(databaseType);
+        sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, 
new IdentifierValue("foo_view"))));
+        sqlStatement.setRenameView(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("bar_view"))));
+        
when(TableRefreshUtils.getTableName(sqlStatement.getView().getTableName().getIdentifier(),
 databaseType)).thenReturn("foo_view");
+        ShardingSphereView existingView = new ShardingSphereView("foo_view", 
"SELECT 1");
+        ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", 
databaseType, new ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.singleton(rule)),
+                Collections.singleton(new ShardingSphereSchema("foo_schema", 
Collections.emptyList(), Collections.singleton(existingView))));
+        when(TableRefreshUtils.isSingleTable(eq("bar_view"), 
eq(database))).thenReturn(true);
+        ShardingSphereTable renamedTable = new ShardingSphereTable("bar_view", 
Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
+        Map<String, ShardingSphereSchema> schemas = 
Collections.singletonMap("foo_schema", new ShardingSphereSchema("foo_schema", 
Collections.singleton(renamedTable), Collections.emptyList()));
+        
when(GenericSchemaBuilder.build(eq(Collections.singletonList("bar_view")), 
eq(database.getProtocolType()), any())).thenReturn(schemas);
+        refresher.refresh(metaDataManagerPersistService, database, "logic_ds", 
"foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new 
Properties()));
+        ArgumentCaptor<Collection<ShardingSphereTable>> alteredCaptor = 
ArgumentCaptor.forClass(Collection.class);
+        ArgumentCaptor<Collection<String>> droppedCaptor = 
ArgumentCaptor.forClass(Collection.class);
+        verify(mutableDataNodeRuleAttribute).put("logic_ds", "foo_schema", 
"bar_view");
+        verify(metaDataManagerPersistService).alterTables(eq(database), 
eq("foo_schema"), alteredCaptor.capture());
+        verify(metaDataManagerPersistService).dropTables(eq(database), 
eq("foo_schema"), droppedCaptor.capture());
+        assertThat(alteredCaptor.getValue().iterator().next().getName(), 
is("bar_view"));
+        assertThat(droppedCaptor.getValue().iterator().next(), is("foo_view"));
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    void assertRefreshUpdatesViewDefinitionWithoutRename() throws Exception {
+        ShardingSphereRule rule = mock(ShardingSphereRule.class);
+        when(rule.getAttributes()).thenReturn(new 
RuleAttributes(mutableDataNodeRuleAttribute));
+        AlterViewStatement sqlStatement = new AlterViewStatement(databaseType);
+        sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, 
new IdentifierValue("foo_view"))));
+        sqlStatement.setViewDefinition("SELECT * FROM t_order");
+        
when(TableRefreshUtils.getTableName(sqlStatement.getView().getTableName().getIdentifier(),
 databaseType)).thenReturn("foo_view");
+        ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", 
databaseType, new ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.singleton(rule)),
+                Collections.singleton(new ShardingSphereSchema("foo_schema", 
Collections.emptyList(), Collections.emptyList())));
+        ShardingSphereTable table = new ShardingSphereTable("foo_view", 
Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
+        Map<String, ShardingSphereSchema> schemas = 
Collections.singletonMap("foo_schema", new ShardingSphereSchema("foo_schema", 
Collections.singleton(table), Collections.emptyList()));
+        
when(GenericSchemaBuilder.build(eq(Collections.singletonList("foo_view")), 
eq(database.getProtocolType()), any())).thenReturn(schemas);
+        refresher.refresh(metaDataManagerPersistService, database, "logic_ds", 
"foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new 
Properties()));
+        ArgumentCaptor<Collection<ShardingSphereTable>> alteredCaptor = 
ArgumentCaptor.forClass(Collection.class);
+        ArgumentCaptor<Collection<String>> droppedCaptor = 
ArgumentCaptor.forClass(Collection.class);
+        verify(mutableDataNodeRuleAttribute, never()).put("logic_ds", 
"foo_schema", "foo_view");
+        verify(metaDataManagerPersistService).alterTables(eq(database), 
eq("foo_schema"), alteredCaptor.capture());
+        verify(metaDataManagerPersistService).dropTables(eq(database), 
eq("foo_schema"), droppedCaptor.capture());
+        assertThat(alteredCaptor.getValue().iterator().next().getName(), 
is("foo_view"));
+        assertTrue(droppedCaptor.getValue().isEmpty());
+    }
+}
diff --git 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
new file mode 100644
index 00000000000..f8e9b3cd3f5
--- /dev/null
+++ 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/CreateViewPushDownMetaDataRefresherTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mode.metadata.refresher.pushdown.type.view;
+
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
+import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
+import 
org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import 
org.apache.shardingsphere.mode.metadata.refresher.pushdown.PushDownMetaDataRefresher;
+import 
org.apache.shardingsphere.mode.metadata.refresher.util.TableRefreshUtils;
+import 
org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.CreateViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import 
org.apache.shardingsphere.test.infra.framework.extension.mock.AutoMockExtension;
+import 
org.apache.shardingsphere.test.infra.framework.extension.mock.StaticMockSettings;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(AutoMockExtension.class)
+@StaticMockSettings({TableRefreshUtils.class, GenericSchemaBuilder.class})
+@MockitoSettings(strictness = Strictness.LENIENT)
+class CreateViewPushDownMetaDataRefresherTest {
+    
+    private final DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
+    
+    private final CreateViewPushDownMetaDataRefresher refresher = 
(CreateViewPushDownMetaDataRefresher) 
TypedSPILoader.getService(PushDownMetaDataRefresher.class, 
CreateViewStatement.class);
+    
+    @Mock
+    private MetaDataManagerPersistService metaDataManagerPersistService;
+    
+    @Mock
+    private MutableDataNodeRuleAttribute mutableDataNodeRuleAttribute;
+    
+    @Test
+    void assertRefreshCreateViewWithSingleTableMapping() throws Exception {
+        ShardingSphereRule rule = mock(ShardingSphereRule.class);
+        when(rule.getAttributes()).thenReturn(new 
RuleAttributes(mutableDataNodeRuleAttribute));
+        ShardingSphereDatabase database = new ShardingSphereDatabase(
+                "foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
+        CreateViewStatement sqlStatement = new 
CreateViewStatement(databaseType);
+        sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, 
new IdentifierValue("foo_view"))));
+        
when(TableRefreshUtils.getTableName(sqlStatement.getView().getTableName().getIdentifier(),
 databaseType)).thenReturn("foo_view");
+        when(TableRefreshUtils.isSingleTable("foo_view", 
database)).thenReturn(true);
+        ShardingSphereTable loadedTable = new ShardingSphereTable("foo_view", 
Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
+        Map<String, ShardingSphereSchema> schemas = 
Collections.singletonMap("foo_schema", new ShardingSphereSchema("foo_schema", 
Collections.singleton(loadedTable), Collections.emptyList()));
+        
when(GenericSchemaBuilder.build(eq(Collections.singletonList("foo_view")), 
eq(database.getProtocolType()), any())).thenReturn(schemas);
+        refresher.refresh(metaDataManagerPersistService, database, "logic_ds", 
"foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new 
Properties()));
+        verify(mutableDataNodeRuleAttribute).put("logic_ds", "foo_schema", 
"foo_view");
+        verify(metaDataManagerPersistService).alterTables(database, 
"foo_schema", Collections.singleton(loadedTable));
+    }
+    
+    @Test
+    void assertRefreshCreateViewWithoutSingleTableMapping() throws Exception {
+        ShardingSphereRule rule = mock(ShardingSphereRule.class);
+        when(rule.getAttributes()).thenReturn(new 
RuleAttributes(mutableDataNodeRuleAttribute));
+        ShardingSphereDatabase database = new ShardingSphereDatabase(
+                "foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
+        CreateViewStatement sqlStatement = new 
CreateViewStatement(databaseType);
+        sqlStatement.setView(new SimpleTableSegment(new TableNameSegment(0, 0, 
new IdentifierValue("foo_view"))));
+        
when(TableRefreshUtils.getTableName(sqlStatement.getView().getTableName().getIdentifier(),
 databaseType)).thenReturn("foo_view");
+        ShardingSphereTable loadedTable = new ShardingSphereTable("foo_view", 
Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
+        Map<String, ShardingSphereSchema> schemas = 
Collections.singletonMap("foo_schema", new ShardingSphereSchema("foo_schema", 
Collections.singleton(loadedTable), Collections.emptyList()));
+        
when(GenericSchemaBuilder.build(eq(Collections.singletonList("foo_view")), 
eq(database.getProtocolType()), any())).thenReturn(schemas);
+        refresher.refresh(metaDataManagerPersistService, database, "logic_ds", 
"foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new 
Properties()));
+        verify(mutableDataNodeRuleAttribute, never()).put("logic_ds", 
"foo_schema", "foo_view");
+        verify(metaDataManagerPersistService).alterTables(database, 
"foo_schema", Collections.singleton(loadedTable));
+    }
+}
diff --git 
a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/DropViewPushDownMetaDataRefresherTest.java
 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/DropViewPushDownMetaDataRefresherTest.java
new file mode 100644
index 00000000000..3237065ed48
--- /dev/null
+++ 
b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/pushdown/type/view/DropViewPushDownMetaDataRefresherTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mode.metadata.refresher.pushdown.type.view;
+
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import 
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
+import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import 
org.apache.shardingsphere.mode.metadata.refresher.pushdown.PushDownMetaDataRefresher;
+import 
org.apache.shardingsphere.mode.persist.service.MetaDataManagerPersistService;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.view.DropViewStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Properties;
+
+import static org.mockito.Mockito.verify;
+
+@ExtendWith(MockitoExtension.class)
+class DropViewPushDownMetaDataRefresherTest {
+    
+    private final DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
+    
+    private final DropViewPushDownMetaDataRefresher refresher = 
(DropViewPushDownMetaDataRefresher) 
TypedSPILoader.getService(PushDownMetaDataRefresher.class, 
DropViewStatement.class);
+    
+    @Mock
+    private MetaDataManagerPersistService metaDataManagerPersistService;
+    
+    @Test
+    void assertRefresh() {
+        ShardingSphereDatabase database = new ShardingSphereDatabase(
+                "foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.emptyList()), Collections.emptyList());
+        DropViewStatement sqlStatement = new DropViewStatement(databaseType);
+        sqlStatement.getViews().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("foo_view"))));
+        sqlStatement.getViews().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("bar_view"))));
+        refresher.refresh(metaDataManagerPersistService, database, "logic_ds", 
"foo_schema", databaseType, sqlStatement, new ConfigurationProperties(new 
Properties()));
+        verify(metaDataManagerPersistService).dropTables(database, 
"foo_schema", Arrays.asList("foo_view", "bar_view"));
+        verify(metaDataManagerPersistService).dropViews(database, 
"foo_schema", Arrays.asList("foo_view", "bar_view"));
+    }
+}

Reply via email to