From 91fa90583f4383a4b01cf65d923e77189c7ba61d Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 4 Nov 2024 15:54:28 +0800 Subject: [PATCH 1/3] Rename ShadowCondition --- ...standardize_and_format_code_We_use_Spotless.en.md | 6 +++--- docs/blog/content/material/spotless.cn.md | 6 +++--- ...wDetermineCondition.java => ShadowCondition.java} | 12 ++++++------ .../determiner/ColumnShadowAlgorithmDeterminer.java | 8 ++++---- .../determiner/HintShadowAlgorithmDeterminer.java | 10 +++++----- ...ctShadowDMLStatementDataSourceMappingsFinder.java | 10 +++++----- ...hadowNonDMLStatementDataSourceMappingsFinder.java | 6 +++--- .../ColumnShadowAlgorithmDeterminerTest.java | 6 +++--- .../HintShadowAlgorithmDeterminerTest.java | 6 +++--- 9 files changed, 35 insertions(+), 35 deletions(-) rename features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/{ShadowDetermineCondition.java => ShadowCondition.java} (75%) diff --git a/docs/blog/content/material/2022_06_08_How_does_Apache_ShardingSphere_standardize_and_format_code_We_use_Spotless.en.md b/docs/blog/content/material/2022_06_08_How_does_Apache_ShardingSphere_standardize_and_format_code_We_use_Spotless.en.md index 1871401d76582..91ce3f3b055ac 100644 --- a/docs/blog/content/material/2022_06_08_How_does_Apache_ShardingSphere_standardize_and_format_code_We_use_Spotless.en.md +++ b/docs/blog/content/material/2022_06_08_How_does_Apache_ShardingSphere_standardize_and_format_code_We_use_Spotless.en.md @@ -193,12 +193,12 @@ In extreme circumstances, Spotless formatted code cannot pass Checkstyle checkin The underlying cause is a conflict between the checking mechanism and formatting configurations set by both. For example, Spotless formats a newline with a 16-space indent, while Checkstyle checks for a 12-space newline. ```java -private static Collection>> createNoteShadowValues(final ShadowDetermineCondition shadowDetermineCondition) { +private static Collection>> createNoteShadowValues(final ShadowDetermineCondition shadowCondition) { // format that can pass Checkstyle - return shadowDetermineCondition.getSqlComments().stream().>>map( + return shadowCondition.getSqlComments().stream().>>map( each -> new PreciseHintShadowValue<>(tableName, shadowOperationType, each)).collect(Collectors.toList()); // After being formatted by Spotless - return shadowDetermineCondition.getSqlComments().stream().>>map( + return shadowCondition.getSqlComments().stream().>>map( each -> new PreciseHintShadowValue<>(tableName, shadowOperationType, each)).collect(Collectors.toList()); } ``` diff --git a/docs/blog/content/material/spotless.cn.md b/docs/blog/content/material/spotless.cn.md index 941e2fb32c571..4e5a43f08b370 100644 --- a/docs/blog/content/material/spotless.cn.md +++ b/docs/blog/content/material/spotless.cn.md @@ -221,12 +221,12 @@ user@machine repo % mvn spotless:check 根本原因在于两者设定的检查配置和格式化配置冲突。举个例子,Spotless 格式化后换行缩进了 16 个空格,而 Checkstyle 的换行检查是 12 个空格。 ```java -private static Collection>> createNoteShadowValues(final ShadowDetermineCondition shadowDetermineCondition) { +private static Collection>> createNoteShadowValues(final ShadowDetermineCondition shadowCondition) { // Checkstyle 可以通过的格式 - return shadowDetermineCondition.getSqlComments().stream().>>map( + return shadowCondition.getSqlComments().stream().>>map( each -> new PreciseHintShadowValue<>(tableName, shadowOperationType, each)).collect(Collectors.toList()); // Spotless 格式化后 - return shadowDetermineCondition.getSqlComments().stream().>>map( + return shadowCondition.getSqlComments().stream().>>map( each -> new PreciseHintShadowValue<>(tableName, shadowOperationType, each)).collect(Collectors.toList()); } ``` diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/ShadowDetermineCondition.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/ShadowCondition.java similarity index 75% rename from features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/ShadowDetermineCondition.java rename to features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/ShadowCondition.java index 7619691b60ce0..2806b92dfaaf5 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/ShadowDetermineCondition.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/condition/ShadowCondition.java @@ -22,19 +22,19 @@ import org.apache.shardingsphere.shadow.spi.ShadowOperationType; /** - * Shadow determine condition. + * Shadow condition. */ @RequiredArgsConstructor @Getter -public final class ShadowDetermineCondition { +public final class ShadowCondition { private final String tableName; - private final ShadowOperationType shadowOperationType; + private final ShadowOperationType operationType; - private final ShadowColumnCondition shadowColumnCondition; + private final ShadowColumnCondition columnCondition; - public ShadowDetermineCondition(final String tableName, final ShadowOperationType shadowOperationType) { - this(tableName, shadowOperationType, null); + public ShadowCondition(final String tableName, final ShadowOperationType operationType) { + this(tableName, operationType, null); } } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminer.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminer.java index f1ffac30c7cf7..a1a3dfc162d3c 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminer.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/ColumnShadowAlgorithmDeterminer.java @@ -19,11 +19,11 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; +import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.spi.ShadowOperationType; import org.apache.shardingsphere.shadow.spi.column.ColumnShadowAlgorithm; import org.apache.shardingsphere.shadow.spi.column.PreciseColumnShadowValue; import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition; -import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition; import java.util.Collection; import java.util.LinkedList; @@ -41,10 +41,10 @@ public final class ColumnShadowAlgorithmDeterminer { * @param shadowCondition shadow determine condition * @return is shadow or not */ - public static boolean isShadow(final ColumnShadowAlgorithm> shadowAlgorithm, final ShadowDetermineCondition shadowCondition) { - ShadowColumnCondition shadowColumnCondition = shadowCondition.getShadowColumnCondition(); + public static boolean isShadow(final ColumnShadowAlgorithm> shadowAlgorithm, final ShadowCondition shadowCondition) { + ShadowColumnCondition shadowColumnCondition = shadowCondition.getColumnCondition(); String tableName = shadowCondition.getTableName(); - ShadowOperationType operationType = shadowCondition.getShadowOperationType(); + ShadowOperationType operationType = shadowCondition.getOperationType(); for (PreciseColumnShadowValue> each : createColumnShadowValues(shadowColumnCondition.getColumn(), shadowColumnCondition.getValues(), tableName, operationType)) { if (!tableName.equals(shadowColumnCondition.getOwner()) || !shadowAlgorithm.isShadow(each)) { return false; diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminer.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminer.java index 037bea3c3d2b7..49ee22092038f 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminer.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminer.java @@ -19,7 +19,7 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition; +import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.rule.ShadowRule; import org.apache.shardingsphere.shadow.spi.ShadowOperationType; import org.apache.shardingsphere.shadow.spi.hint.HintShadowAlgorithm; @@ -40,14 +40,14 @@ public final class HintShadowAlgorithmDeterminer { * @param useShadow use shadow or not * @return is shadow or not */ - public static boolean isShadow(final HintShadowAlgorithm> shadowAlgorithm, final ShadowDetermineCondition shadowCondition, final ShadowRule shadowRule, final boolean useShadow) { + public static boolean isShadow(final HintShadowAlgorithm> shadowAlgorithm, final ShadowCondition shadowCondition, final ShadowRule shadowRule, final boolean useShadow) { PreciseHintShadowValue> shadowValue = createHintShadowValues(shadowCondition, useShadow); return shadowAlgorithm.isShadow(shadowRule.getAllShadowTableNames(), shadowValue); } - private static PreciseHintShadowValue> createHintShadowValues(final ShadowDetermineCondition shadowDetermineCondition, final boolean useShadow) { - ShadowOperationType shadowOperationType = shadowDetermineCondition.getShadowOperationType(); - String tableName = shadowDetermineCondition.getTableName(); + private static PreciseHintShadowValue> createHintShadowValues(final ShadowCondition shadowCondition, final boolean useShadow) { + ShadowOperationType shadowOperationType = shadowCondition.getOperationType(); + String tableName = shadowCondition.getTableName(); return new PreciseHintShadowValue<>(tableName, shadowOperationType, useShadow); } } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java index adeed4b4fdf45..6f6bf6e859d61 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java @@ -23,7 +23,7 @@ import org.apache.shardingsphere.infra.binder.context.type.TableAvailable; import org.apache.shardingsphere.infra.hint.HintValueContext; import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition; -import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition; +import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.route.determiner.ColumnShadowAlgorithmDeterminer; import org.apache.shardingsphere.shadow.route.determiner.HintShadowAlgorithmDeterminer; import org.apache.shardingsphere.shadow.route.finder.ShadowDataSourceMappingsFinder; @@ -83,7 +83,7 @@ public Map find(final ShadowRule rule) { private boolean isMatchDefaultAlgorithm(final ShadowRule rule) { Optional defaultAlgorithm = rule.getDefaultShadowAlgorithm(); if (defaultAlgorithm.isPresent() && defaultAlgorithm.get() instanceof HintShadowAlgorithm) { - ShadowDetermineCondition determineCondition = new ShadowDetermineCondition("", ShadowOperationType.HINT_MATCH); + ShadowCondition determineCondition = new ShadowCondition("", ShadowOperationType.HINT_MATCH); return HintShadowAlgorithmDeterminer.isShadow((HintShadowAlgorithm>) defaultAlgorithm.get(), determineCondition, rule, isShadow); } return false; @@ -92,7 +92,7 @@ private boolean isMatchDefaultAlgorithm(final ShadowRule rule) { private Map findBySQLHints(final ShadowRule rule, final Collection relatedShadowTables) { Map result = new LinkedHashMap<>(); for (String each : relatedShadowTables) { - if (isContainsShadowInSQLHints(rule, each, new ShadowDetermineCondition(each, operationType))) { + if (isContainsShadowInSQLHints(rule, each, new ShadowCondition(each, operationType))) { result.putAll(rule.getShadowDataSourceMappings(each)); return result; } @@ -100,7 +100,7 @@ private Map findBySQLHints(final ShadowRule rule, final Collecti return result; } - private boolean isContainsShadowInSQLHints(final ShadowRule rule, final String tableName, final ShadowDetermineCondition shadowCondition) { + private boolean isContainsShadowInSQLHints(final ShadowRule rule, final String tableName, final ShadowCondition shadowCondition) { for (HintShadowAlgorithm> each : rule.getHintShadowAlgorithms(tableName)) { if (HintShadowAlgorithmDeterminer.isShadow(each, shadowCondition, rule, isShadow)) { return true; @@ -143,7 +143,7 @@ private boolean isMatchAnyColumnShadowAlgorithms(final ShadowRule rule, final St private boolean isMatchColumnShadowAlgorithm(final String shadowTable, final Collection>> algorithms, final ShadowColumnCondition condition) { for (ColumnShadowAlgorithm> each : algorithms) { - if (ColumnShadowAlgorithmDeterminer.isShadow(each, new ShadowDetermineCondition(shadowTable, operationType, condition))) { + if (ColumnShadowAlgorithmDeterminer.isShadow(each, new ShadowCondition(shadowTable, operationType, condition))) { return true; } } diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java index f055cc1dbf197..401cdbb085905 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/other/ShadowNonDMLStatementDataSourceMappingsFinder.java @@ -19,7 +19,7 @@ import lombok.RequiredArgsConstructor; import org.apache.shardingsphere.infra.hint.HintValueContext; -import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition; +import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.route.determiner.HintShadowAlgorithmDeterminer; import org.apache.shardingsphere.shadow.route.finder.ShadowDataSourceMappingsFinder; import org.apache.shardingsphere.shadow.rule.ShadowRule; @@ -41,13 +41,13 @@ public Map find(final ShadowRule rule) { if (!hintValueContext.isShadow()) { return Collections.emptyMap(); } - if (isMatchAnyHintShadowAlgorithms(rule, new ShadowDetermineCondition("", ShadowOperationType.HINT_MATCH))) { + if (isMatchAnyHintShadowAlgorithms(rule, new ShadowCondition("", ShadowOperationType.HINT_MATCH))) { return rule.getAllShadowDataSourceMappings(); } return Collections.emptyMap(); } - private boolean isMatchAnyHintShadowAlgorithms(final ShadowRule rule, final ShadowDetermineCondition shadowCondition) { + private boolean isMatchAnyHintShadowAlgorithms(final ShadowRule rule, final ShadowCondition shadowCondition) { return rule.getAllHintShadowAlgorithms().stream().anyMatch(each -> HintShadowAlgorithmDeterminer.isShadow(each, shadowCondition, rule, hintValueContext.isShadow())); } } 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 4e3ab6c08a8e4..bc0f792fffa90 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 @@ -19,7 +19,7 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.shadow.condition.ShadowColumnCondition; -import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition; +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; @@ -42,7 +42,7 @@ void assertIsShadow() { (ColumnShadowAlgorithm) TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH", props), createShadowDetermineCondition())); } - private ShadowDetermineCondition createShadowDetermineCondition() { - return new ShadowDetermineCondition("t_order", ShadowOperationType.INSERT, new ShadowColumnCondition("t_order", "user_id", Collections.singleton(1))); + private ShadowCondition createShadowDetermineCondition() { + return new ShadowCondition("t_order", ShadowOperationType.INSERT, new ShadowColumnCondition("t_order", "user_id", Collections.singleton(1))); } } diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java index b51d023c45572..e21f25a38c1a4 100644 --- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java +++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java @@ -20,7 +20,7 @@ import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration; import org.apache.shardingsphere.infra.hint.HintValueContext; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.shadow.condition.ShadowDetermineCondition; +import org.apache.shardingsphere.shadow.condition.ShadowCondition; import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration; import org.apache.shardingsphere.shadow.config.datasource.ShadowDataSourceConfiguration; import org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration; @@ -68,7 +68,7 @@ private Collection createDataSources() { return result; } - private ShadowDetermineCondition createShadowDetermineCondition() { - return new ShadowDetermineCondition("t_order", ShadowOperationType.INSERT); + private ShadowCondition createShadowDetermineCondition() { + return new ShadowCondition("t_order", ShadowOperationType.INSERT); } } From 51542d8860b174de78d5ba1ba8791784375ba266 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 4 Nov 2024 15:56:52 +0800 Subject: [PATCH 2/3] Rename ShadowCondition --- .../AbstractShadowDMLStatementDataSourceMappingsFinder.java | 4 ++-- .../route/determiner/ColumnShadowAlgorithmDeterminerTest.java | 4 ++-- .../route/determiner/HintShadowAlgorithmDeterminerTest.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java index 6f6bf6e859d61..8c95b2674156f 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/finder/dml/AbstractShadowDMLStatementDataSourceMappingsFinder.java @@ -83,8 +83,8 @@ public Map find(final ShadowRule rule) { private boolean isMatchDefaultAlgorithm(final ShadowRule rule) { Optional defaultAlgorithm = rule.getDefaultShadowAlgorithm(); if (defaultAlgorithm.isPresent() && defaultAlgorithm.get() instanceof HintShadowAlgorithm) { - ShadowCondition determineCondition = new ShadowCondition("", ShadowOperationType.HINT_MATCH); - return HintShadowAlgorithmDeterminer.isShadow((HintShadowAlgorithm>) defaultAlgorithm.get(), determineCondition, rule, isShadow); + ShadowCondition shadowCondition = new ShadowCondition("", ShadowOperationType.HINT_MATCH); + return HintShadowAlgorithmDeterminer.isShadow((HintShadowAlgorithm>) defaultAlgorithm.get(), shadowCondition, rule, isShadow); } return false; } 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 bc0f792fffa90..0872b5a0e12aa 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 @@ -39,10 +39,10 @@ class ColumnShadowAlgorithmDeterminerTest { 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), createShadowDetermineCondition())); + (ColumnShadowAlgorithm) TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH", props), createShadowCondition())); } - private ShadowCondition createShadowDetermineCondition() { + private ShadowCondition createShadowCondition() { return new ShadowCondition("t_order", ShadowOperationType.INSERT, new ShadowColumnCondition("t_order", "user_id", Collections.singleton(1))); } } diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java index e21f25a38c1a4..51f58c3799c16 100644 --- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java +++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/route/determiner/HintShadowAlgorithmDeterminerTest.java @@ -44,7 +44,7 @@ class HintShadowAlgorithmDeterminerTest { void assertIsShadow() { HintShadowAlgorithm hintShadowAlgorithm = (HintShadowAlgorithm) TypedSPILoader.getService(ShadowAlgorithm.class, "SQL_HINT", new Properties()); HintValueContext hintValueContext = createHintValueContext(); - assertTrue(HintShadowAlgorithmDeterminer.isShadow(hintShadowAlgorithm, createShadowDetermineCondition(), new ShadowRule(createShadowRuleConfiguration()), hintValueContext.isShadow())); + assertTrue(HintShadowAlgorithmDeterminer.isShadow(hintShadowAlgorithm, createShadowCondition(), new ShadowRule(createShadowRuleConfiguration()), hintValueContext.isShadow())); } private HintValueContext createHintValueContext() { @@ -68,7 +68,7 @@ private Collection createDataSources() { return result; } - private ShadowCondition createShadowDetermineCondition() { + private ShadowCondition createShadowCondition() { return new ShadowCondition("t_order", ShadowOperationType.INSERT); } } From 73fc71fb8b3723b8505e67ad510a6464dfcff9ca Mon Sep 17 00:00:00 2001 From: zhangliang Date: Mon, 4 Nov 2024 15:58:16 +0800 Subject: [PATCH 3/3] Rename ShadowCondition --- .../route/determiner/ColumnShadowAlgorithmDeterminerTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 0872b5a0e12aa..4933415f70338 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 @@ -38,8 +38,7 @@ class ColumnShadowAlgorithmDeterminerTest { @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())); + assertTrue(ColumnShadowAlgorithmDeterminer.isShadow((ColumnShadowAlgorithm) TypedSPILoader.getService(ShadowAlgorithm.class, "REGEX_MATCH", props), createShadowCondition())); } private ShadowCondition createShadowCondition() {