From d53ace2d823eedbfbe0f41f0f9f156a1223eb05e Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 18 Nov 2024 12:45:22 +0800 Subject: [PATCH 1/3] Add more test cases on InlineShardingAlgorithm --- .../inline/InlineShardingAlgorithmTest.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java index b1d62e0d84269..de66ea1d69fe8 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.Range; import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException; import org.apache.shardingsphere.infra.datanode.DataNodeInfo; +import org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue; import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue; @@ -35,6 +36,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Optional; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -48,16 +50,12 @@ class InlineShardingAlgorithmTest { private InlineShardingAlgorithm inlineShardingAlgorithm; - private InlineShardingAlgorithm inlineShardingAlgorithmWithSimplified; - private InlineShardingAlgorithm negativeNumberInlineShardingAlgorithm; @BeforeEach void setUp() { inlineShardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", PropertiesBuilder.build(new Property("algorithm-expression", "t_order_$->{order_id % 4}"), new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString()))); - inlineShardingAlgorithmWithSimplified = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", - PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${order_id % 4}"))); negativeNumberInlineShardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", PropertiesBuilder.build(new Property("algorithm-expression", "t_order_$->{(order_id % 4).abs()}"), new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString()))); } @@ -82,19 +80,10 @@ void assertDoSharding() { () -> inlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "non_existent_column1", DATA_NODE_INFO, 0))); } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Test - void assertDoShardingWithRangeShardingConditionValue() { - List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); - Collection actual = inlineShardingAlgorithm.doSharding(availableTargetNames, new RangeShardingValue<>("t_order", "order_id", DATA_NODE_INFO, mock(Range.class))); - assertTrue(actual.containsAll(availableTargetNames)); - } - @Test void assertDoShardingWithNonExistNodes() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1"); assertThat(inlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 0)), is("t_order_0")); - assertThat(inlineShardingAlgorithmWithSimplified.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 0)), is("t_order_0")); } @Test @@ -111,9 +100,28 @@ void assertDoShardingWithLargeValues() { new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 787694822390497280L)), is("t_order_0")); assertThat(inlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, new BigInteger("787694822390497280787694822390497280"))), is("t_order_0")); - assertThat(inlineShardingAlgorithmWithSimplified.doSharding(availableTargetNames, - new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 787694822390497280L)), is("t_order_0")); - assertThat(inlineShardingAlgorithmWithSimplified.doSharding(availableTargetNames, - new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, new BigInteger("787694822390497280787694822390497280"))), is("t_order_0")); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Test + void assertDoShardingWithRangeShardingConditionValue() { + List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); + Collection actual = inlineShardingAlgorithm.doSharding(availableTargetNames, new RangeShardingValue<>("t_order", "order_id", DATA_NODE_INFO, mock(Range.class))); + assertTrue(actual.containsAll(availableTargetNames)); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + @Test + void assertDoShardingWithNotAllowRangeQuery() { + InlineShardingAlgorithm inlineShardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", + PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${order_id % 4}"))); + List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); + assertThrows(UnsupportedSQLOperationException.class, + () -> inlineShardingAlgorithm.doSharding(availableTargetNames, new RangeShardingValue<>("t_order", "order_id", DATA_NODE_INFO, mock(Range.class)))); + } + + @Test + void assertGetAlgorithmStructure() { + assertThat(inlineShardingAlgorithm.getAlgorithmStructure("foo_ds", "foo_col"), is(Optional.of("t_order_${order_id%4}"))); } } From ac40abe16f8cae6758fd4e6040feca76ae093220 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 18 Nov 2024 13:20:10 +0800 Subject: [PATCH 2/3] Add more test cases on ComplexInlineShardingAlgorithm --- .../hint/HintInlineShardingAlgorithmTest.java | 10 ++-- .../ComplexInlineShardingAlgorithmTest.java | 60 ++++++++++++++----- .../inline/InlineShardingAlgorithmTest.java | 26 ++++---- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithmTest.java index 7e3c4530fbd70..3a67e12b788a6 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithmTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/hint/HintInlineShardingAlgorithmTest.java @@ -36,11 +36,11 @@ class HintInlineShardingAlgorithmTest { - private HintInlineShardingAlgorithm hintInlineShardingAlgorithm; + private HintInlineShardingAlgorithm shardingAlgorithm; @BeforeEach void setUp() { - hintInlineShardingAlgorithm = (HintInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, + shardingAlgorithm = (HintInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "HINT_INLINE", PropertiesBuilder.build(new Property("algorithm-expression", "t_order_$->{value % 4}"))); } @@ -48,7 +48,7 @@ void setUp() { void assertDoShardingWithEmptyValue() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); HintShardingValue> shardingValue = new HintShardingValue<>("t_order", "order_id", Collections.emptyList()); - Collection actual = hintInlineShardingAlgorithm.doSharding(availableTargetNames, shardingValue); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, shardingValue); assertThat(actual, is(availableTargetNames)); } @@ -56,7 +56,7 @@ void assertDoShardingWithEmptyValue() { void assertDoShardingWithSingleValue() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); HintShardingValue> shardingValue = new HintShardingValue<>("t_order", "order_id", Collections.singleton(4)); - Collection actual = hintInlineShardingAlgorithm.doSharding(availableTargetNames, shardingValue); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, shardingValue); assertThat(actual, is(Collections.singletonList("t_order_0"))); } @@ -64,7 +64,7 @@ void assertDoShardingWithSingleValue() { void assertDoShardingWithMultiValues() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); HintShardingValue> shardingValue = new HintShardingValue<>("t_order", "order_id", Arrays.asList(1, 2, 3, 4)); - Collection actual = hintInlineShardingAlgorithm.doSharding(availableTargetNames, shardingValue); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, shardingValue); assertTrue(actual.containsAll(availableTargetNames)); } } diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java index 954cdab28cba2..6ad1b4e8252bf 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java @@ -19,11 +19,14 @@ import com.google.common.collect.Range; import org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException; +import org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingValue; +import org.apache.shardingsphere.sharding.exception.algorithm.MismatchedComplexInlineShardingAlgorithmColumnAndValueSizeException; import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm; import org.apache.shardingsphere.test.util.PropertiesBuilder; import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -39,10 +42,18 @@ class ComplexInlineShardingAlgorithmTest { + private ComplexInlineShardingAlgorithm shardingAlgorithm; + + @BeforeEach + void setUp() { + Properties props = PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${type % 2}_${order_id % 2}"), new Property("sharding-columns", "type,order_id"), + new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString())); + shardingAlgorithm = (ComplexInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", props); + } + @Test void assertInitWithNullClass() { - assertThrows(AlgorithmInitializationException.class, - () -> TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", PropertiesBuilder.build(new Property("wrong", "")))); + assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", PropertiesBuilder.build(new Property("wrong", "")))); } @Test @@ -52,20 +63,16 @@ void assertInitWithEmptyClassName() { } @Test - void assertDoSharding() { - Properties props = PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${type % 2}_${order_id % 2}"), new Property("sharding-columns", "type,order_id")); - ComplexInlineShardingAlgorithm algorithm = (ComplexInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", props); + void assertDoShardingWithSingleValue() { List availableTargetNames = Arrays.asList("t_order_0_0", "t_order_0_1", "t_order_1_0", "t_order_1_1"); - Collection actual = algorithm.doSharding(availableTargetNames, createComplexKeysShardingValue(Collections.singletonList(2))); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, createComplexKeysShardingValue(Collections.singletonList(2))); assertTrue(1 == actual.size() && actual.contains("t_order_0_0")); } @Test - void assertDoShardingWithMultiValue() { - Properties props = PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${type % 2}_${order_id % 2}"), new Property("sharding-columns", "type,order_id")); - ComplexInlineShardingAlgorithm algorithm = (ComplexInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", props); + void assertDoShardingWithMultiValues() { List availableTargetNames = Arrays.asList("t_order_0_0", "t_order_0_1", "t_order_1_0", "t_order_1_1"); - Collection actual = algorithm.doSharding(availableTargetNames, createComplexKeysShardingValue(Arrays.asList(1, 2))); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, createComplexKeysShardingValue(Arrays.asList(1, 2))); assertTrue(actual.containsAll(availableTargetNames)); } @@ -78,11 +85,36 @@ private ComplexKeysShardingValue> createComplexKeysShardingValue(f @Test void assertDoShardingWithRangeValue() { - Properties props = PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${type % 2}_${order_id % 2}"), - new Property("sharding-columns", "type,order_id"), new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString())); - ComplexInlineShardingAlgorithm algorithm = (ComplexInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", props); List availableTargetNames = Arrays.asList("t_order_0_0", "t_order_0_1", "t_order_1_0", "t_order_1_1"); - Collection actual = algorithm.doSharding(availableTargetNames, new ComplexKeysShardingValue<>("t_order", Collections.emptyMap(), Collections.singletonMap("type", Range.all()))); + Collection actual = shardingAlgorithm.doSharding( + availableTargetNames, new ComplexKeysShardingValue<>("t_order", Collections.emptyMap(), Collections.singletonMap("type", Range.all()))); assertTrue(actual.containsAll(availableTargetNames)); } + + @Test + void assertDoShardingWithRangeValueAndEmptyColumns() { + List availableTargetNames = Arrays.asList("t_order_0_0", "t_order_0_1", "t_order_1_0", "t_order_1_1"); + Properties props = PropertiesBuilder.build( + new Property("algorithm-expression", "t_order_${type % 2}_${order_id % 2}"), new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString())); + shardingAlgorithm = (ComplexInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", props); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, new ComplexKeysShardingValue<>("t_order", Collections.emptyMap(), Collections.emptyMap())); + assertTrue(actual.isEmpty()); + } + + @Test + void assertDoShardingWithRangeValueButNotAllowRangeQuery() { + List availableTargetNames = Arrays.asList("t_order_0_0", "t_order_0_1", "t_order_1_0", "t_order_1_1"); + Map>> columnNameAndShardingValuesMap = Collections.singletonMap("type", Arrays.asList(1, 2)); + Properties props = PropertiesBuilder.build(new Property("algorithm-expression", "t_order_${type % 2}_${order_id % 2}"), new Property("sharding-columns", "type,order_id")); + shardingAlgorithm = (ComplexInlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", props); + assertThrows(UnsupportedSQLOperationException.class, + () -> shardingAlgorithm.doSharding(availableTargetNames, new ComplexKeysShardingValue<>("t_order", columnNameAndShardingValuesMap, Collections.singletonMap("type", Range.all())))); + } + + @Test + void assertDoShardingWithRangeValueAndMismatchedComplexInlineShardingAlgorithmColumnAndValueSize() { + List availableTargetNames = Arrays.asList("t_order_0_0", "t_order_0_1", "t_order_1_0", "t_order_1_1"); + assertThrows(MismatchedComplexInlineShardingAlgorithmColumnAndValueSizeException.class, + () -> shardingAlgorithm.doSharding(availableTargetNames, new ComplexKeysShardingValue<>("t_order", Collections.emptyMap(), Collections.emptyMap()))); + } } diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java index de66ea1d69fe8..428489f37b3bf 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/InlineShardingAlgorithmTest.java @@ -48,15 +48,15 @@ class InlineShardingAlgorithmTest { private static final DataNodeInfo DATA_NODE_INFO = new DataNodeInfo("t_order_", 1, '0'); - private InlineShardingAlgorithm inlineShardingAlgorithm; + private InlineShardingAlgorithm shardingAlgorithm; - private InlineShardingAlgorithm negativeNumberInlineShardingAlgorithm; + private InlineShardingAlgorithm negativeNumberShardingAlgorithm; @BeforeEach void setUp() { - inlineShardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", + shardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", PropertiesBuilder.build(new Property("algorithm-expression", "t_order_$->{order_id % 4}"), new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString()))); - negativeNumberInlineShardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", + negativeNumberShardingAlgorithm = (InlineShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "INLINE", PropertiesBuilder.build(new Property("algorithm-expression", "t_order_$->{(order_id % 4).abs()}"), new Property("allow-range-query-with-inline-sharding", Boolean.TRUE.toString()))); } @@ -75,30 +75,30 @@ void assertInitWithEmptyClassName() { @Test void assertDoSharding() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); - assertThat(inlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 0)), is("t_order_0")); + assertThat(shardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 0)), is("t_order_0")); assertThrows(MismatchedInlineShardingAlgorithmExpressionAndColumnException.class, - () -> inlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "non_existent_column1", DATA_NODE_INFO, 0))); + () -> shardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "non_existent_column1", DATA_NODE_INFO, 0))); } @Test void assertDoShardingWithNonExistNodes() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1"); - assertThat(inlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 0)), is("t_order_0")); + assertThat(shardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 0)), is("t_order_0")); } @Test void assertDoShardingWithNegative() { List availableTargetNames = Lists.newArrayList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); - assertThat(negativeNumberInlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, -1)), is("t_order_1")); - assertThat(negativeNumberInlineShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, -4)), is("t_order_0")); + assertThat(negativeNumberShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, -1)), is("t_order_1")); + assertThat(negativeNumberShardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, -4)), is("t_order_0")); } @Test void assertDoShardingWithLargeValues() { List availableTargetNames = Lists.newArrayList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); - assertThat(inlineShardingAlgorithm.doSharding(availableTargetNames, + assertThat(shardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, 787694822390497280L)), is("t_order_0")); - assertThat(inlineShardingAlgorithm.doSharding(availableTargetNames, + assertThat(shardingAlgorithm.doSharding(availableTargetNames, new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, new BigInteger("787694822390497280787694822390497280"))), is("t_order_0")); } @@ -106,7 +106,7 @@ void assertDoShardingWithLargeValues() { @Test void assertDoShardingWithRangeShardingConditionValue() { List availableTargetNames = Arrays.asList("t_order_0", "t_order_1", "t_order_2", "t_order_3"); - Collection actual = inlineShardingAlgorithm.doSharding(availableTargetNames, new RangeShardingValue<>("t_order", "order_id", DATA_NODE_INFO, mock(Range.class))); + Collection actual = shardingAlgorithm.doSharding(availableTargetNames, new RangeShardingValue<>("t_order", "order_id", DATA_NODE_INFO, mock(Range.class))); assertTrue(actual.containsAll(availableTargetNames)); } @@ -122,6 +122,6 @@ void assertDoShardingWithNotAllowRangeQuery() { @Test void assertGetAlgorithmStructure() { - assertThat(inlineShardingAlgorithm.getAlgorithmStructure("foo_ds", "foo_col"), is(Optional.of("t_order_${order_id%4}"))); + assertThat(shardingAlgorithm.getAlgorithmStructure("foo_ds", "foo_col"), is(Optional.of("t_order_${order_id%4}"))); } } From ad76b8f8330f87303e561000ee6edfdc9c6c3d6a Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 18 Nov 2024 13:21:18 +0800 Subject: [PATCH 3/3] Add more test cases on ComplexInlineShardingAlgorithm --- .../sharding/inline/ComplexInlineShardingAlgorithmTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java index e3443bf9d210d..6ad1b4e8252bf 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/inline/ComplexInlineShardingAlgorithmTest.java @@ -52,7 +52,7 @@ void setUp() { } @Test - void assertInitWithNullClass() { + void assertInitWithNullClass() { assertThrows(AlgorithmInitializationException.class, () -> TypedSPILoader.getService(ShardingAlgorithm.class, "COMPLEX_INLINE", PropertiesBuilder.build(new Property("wrong", "")))); }