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 2575b12e305 Add more test cases on 
BroadcastSchemaTableAggregationReviserTest (#38226)
2575b12e305 is described below

commit 2575b12e30555ca057848d476abd8e0343e72d48
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Feb 26 23:57:33 2026 +0800

    Add more test cases on BroadcastSchemaTableAggregationReviserTest (#38226)
---
 .../ColumnShadowAlgorithmDeterminerTest.java       | 42 ++++++++++++++--------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git 
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminerTest.java
 
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminerTest.java
index db959e3bd12..9e207104720 100644
--- 
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminerTest.java
+++ 
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminerTest.java
@@ -17,31 +17,45 @@
 
 package org.apache.shardingsphere.shadow.route.determiner;
 
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.infra.util.props.PropertiesBuilder;
-import org.apache.shardingsphere.infra.util.props.PropertiesBuilder.Property;
 import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition;
 import org.apache.shardingsphere.shadow.condition.ShadowCondition;
-import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
 import org.apache.shardingsphere.shadow.spi.ShadowOperationType;
 import org.apache.shardingsphere.shadow.spi.column.ColumnShadowAlgorithm;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 
+import java.util.Collection;
 import java.util.Collections;
-import java.util.Properties;
+import java.util.stream.Stream;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 class ColumnShadowAlgorithmDeterminerTest {
     
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    @Test
-    void assertIsShadow() {
-        Properties props = PropertiesBuilder.build(new Property("column", 
"user_id"), new Property("operation", "insert"), new Property("regex", "[1]"));
-        
assertTrue(ColumnShadowAlgorithmDeterminer.isShadow((ColumnShadowAlgorithm) 
TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH", props), 
createShadowCondition()));
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("isShadowCases")
+    @SuppressWarnings("unchecked")
+    void assertIsShadow(final String name, final String tableName, final 
String columnConditionTable, final Collection<Comparable<?>> values,
+                        final boolean algorithmShadowResult, final int 
expectedAlgorithmCallCount, final boolean expected) {
+        ColumnShadowAlgorithm<Comparable<?>> shadowAlgorithm = 
mock(ColumnShadowAlgorithm.class);
+        
when(shadowAlgorithm.isShadow(any())).thenReturn(algorithmShadowResult);
+        assertThat(ColumnShadowAlgorithmDeterminer.isShadow(shadowAlgorithm,
+                new ShadowCondition(tableName, ShadowOperationType.INSERT, new 
ShadowColumnCondition(columnConditionTable, "user_id", values))), is(expected));
+        verify(shadowAlgorithm, 
times(expectedAlgorithmCallCount)).isShadow(any());
     }
     
-    private ShadowCondition createShadowCondition() {
-        return new ShadowCondition("t_order", ShadowOperationType.INSERT, new 
ShadowColumnCondition("t_order", "user_id", Collections.singleton(1)));
+    private static Stream<Arguments> isShadowCases() {
+        return Stream.of(
+                Arguments.of("table mismatch returns false", "t_order", 
"t_order_item", Collections.singleton(1), true, 0, false),
+                Arguments.of("algorithm returns false", "t_order", "t_order", 
Collections.singleton(1), false, 1, false),
+                Arguments.of("algorithm returns true", "t_order", "t_order", 
Collections.singleton(1), true, 1, true),
+                Arguments.of("empty values returns true", "t_order", 
"t_order", Collections.emptyList(), false, 0, true));
     }
 }

Reply via email to