This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 1b155bd5d76 Remove useless ShardingConditionEngineFactory (#23716)
1b155bd5d76 is described below

commit 1b155bd5d7627218c99b13cf3d9a5ce5b1571be5
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jan 24 21:27:21 2023 +0800

    Remove useless ShardingConditionEngineFactory (#23716)
---
 ...MLShardingConditionsShardingAuditAlgorithm.java |   5 +-
 .../decider/ShardingSQLFederationDecider.java      |   6 +-
 .../sharding/route/engine/ShardingSQLRouter.java   |   5 +-
 .../{impl => }/DefaultShardingConditionEngine.java |  19 +---
 .../InsertClauseShardingConditionEngine.java       |   2 +-
 .../engine/ShardingConditionEngineFactory.java     |  44 ---------
 .../WhereClauseShardingConditionEngine.java        |   2 +-
 .../decider/ShardingSQLFederationDeciderTest.java  |  33 +------
 .../InsertClauseShardingConditionEngineTest.java   |   1 -
 .../engine/ShardingConditionEngineFactoryTest.java | 109 ---------------------
 .../WhereClauseShardingConditionEngineTest.java    |   1 -
 .../checker/ShardingRouteCacheableChecker.java     |   4 +-
 12 files changed, 18 insertions(+), 213 deletions(-)

diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithm.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithm.java
index 1a4c9cea8ea..0278081e01c 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithm.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithm.java
@@ -23,8 +23,7 @@ import 
org.apache.shardingsphere.infra.executor.check.exception.SQLCheckExceptio
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.user.Grantee;
 import 
org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngineFactory;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.DefaultShardingConditionEngine;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.DefaultShardingConditionEngine;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.spi.ShardingAuditAlgorithm;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DMLStatement;
@@ -53,7 +52,7 @@ public final class 
DMLShardingConditionsShardingAuditAlgorithm implements Shardi
                     || 
sqlStatementContext.getTablesContext().getTableNames().stream().noneMatch(rule::isShardingTable))
 {
                 return;
             }
-            DefaultShardingConditionEngine shardingConditionEngine = 
ShardingConditionEngineFactory.createShardingConditionEngine(database, rule);
+            DefaultShardingConditionEngine shardingConditionEngine = new 
DefaultShardingConditionEngine(rule, database);
             
ShardingSpherePreconditions.checkState(!shardingConditionEngine.createShardingConditions(sqlStatementContext,
 params).isEmpty(),
                     () -> new SQLCheckException("Not allow DML operation 
without sharding conditions"));
         }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
index 7b93fc77c47..cd93dc8e3d6 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
@@ -26,8 +26,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingConditions;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngineFactory;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.DefaultShardingConditionEngine;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.DefaultShardingConditionEngine;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
 import java.util.Collection;
@@ -69,8 +68,7 @@ public final class ShardingSQLFederationDecider implements 
SQLFederationDecider<
     }
     
     private static ShardingConditions getMergedShardingConditions(final 
QueryContext queryContext, final ShardingSphereDatabase database, final 
ShardingRule rule) {
-        DefaultShardingConditionEngine shardingConditionEngine = 
ShardingConditionEngineFactory.createShardingConditionEngine(database, rule);
-        List<ShardingCondition> shardingConditions = 
shardingConditionEngine.createShardingConditions(queryContext.getSqlStatementContext(),
 queryContext.getParameters());
+        List<ShardingCondition> shardingConditions = new 
DefaultShardingConditionEngine(rule, 
database).createShardingConditions(queryContext.getSqlStatementContext(), 
queryContext.getParameters());
         ShardingConditions result = new ShardingConditions(shardingConditions, 
queryContext.getSqlStatementContext(), rule);
         if (result.isNeedMerge()) {
             result.merge();
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
index 315de10a376..e770174e647 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/ShardingSQLRouter.java
@@ -27,8 +27,7 @@ import 
org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingConditions;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngineFactory;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.DefaultShardingConditionEngine;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.DefaultShardingConditionEngine;
 import 
org.apache.shardingsphere.sharding.route.engine.type.ShardingRouteEngineFactory;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ShardingStatementValidator;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ShardingStatementValidatorFactory;
@@ -64,7 +63,7 @@ public final class ShardingSQLRouter implements 
SQLRouter<ShardingRule> {
     private ShardingConditions createShardingConditions(final QueryContext 
queryContext, final ShardingSphereDatabase database, final ShardingRule rule) {
         List<ShardingCondition> shardingConditions;
         if (queryContext.getSqlStatementContext().getSqlStatement() instanceof 
DMLStatement || queryContext.getSqlStatementContext() instanceof 
CursorAvailable) {
-            DefaultShardingConditionEngine shardingConditionEngine = 
ShardingConditionEngineFactory.createShardingConditionEngine(database, rule);
+            DefaultShardingConditionEngine shardingConditionEngine = new 
DefaultShardingConditionEngine(rule, database);
             shardingConditions = 
shardingConditionEngine.createShardingConditions(queryContext.getSqlStatementContext(),
 queryContext.getParameters());
         } else {
             shardingConditions = Collections.emptyList();
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/DefaultShardingConditionEngine.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/DefaultShardingConditionEngine.java
similarity index 82%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/DefaultShardingConditionEngine.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/DefaultShardingConditionEngine.java
index 0ba853db0b2..c5efc176fea 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/DefaultShardingConditionEngine.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/DefaultShardingConditionEngine.java
@@ -15,8 +15,9 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.route.engine.condition.engine.impl;
+package org.apache.shardingsphere.sharding.route.engine.condition.engine;
 
+import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -28,22 +29,12 @@ import java.util.List;
 /**
  * Default sharding condition engine.
  */
+@RequiredArgsConstructor
 public final class DefaultShardingConditionEngine {
     
-    private ShardingRule shardingRule;
+    private final ShardingRule shardingRule;
     
-    private ShardingSphereDatabase database;
-    
-    /**
-     * Initialize sharding condition engine.
-     *
-     * @param shardingRule sharding rule
-     * @param database sharding database
-     */
-    public void init(final ShardingRule shardingRule, final 
ShardingSphereDatabase database) {
-        this.shardingRule = shardingRule;
-        this.database = database;
-    }
+    private final ShardingSphereDatabase database;
     
     /**
      * Create sharding conditions.
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
similarity index 99%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
index 5b646123026..c7683087100 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngine.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.route.engine.condition.engine.impl;
+package org.apache.shardingsphere.sharding.route.engine.condition.engine;
 
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.dialect.exception.data.InsertColumnsAndValuesMismatchedException;
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java
deleted file mode 100644
index aa22add2119..00000000000
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.sharding.route.engine.condition.engine;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.DefaultShardingConditionEngine;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-
-/**
- * Sharding condition engine factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingConditionEngineFactory {
-    
-    /**
-     * Create new instance of sharding condition engine.
-     *
-     * @param database database
-     * @param rule sharding rule
-     * @return created instance
-     */
-    public static DefaultShardingConditionEngine 
createShardingConditionEngine(final ShardingSphereDatabase database, final 
ShardingRule rule) {
-        DefaultShardingConditionEngine result = new 
DefaultShardingConditionEngine();
-        result.init(rule, database);
-        return result;
-    }
-}
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/WhereClauseShardingConditionEngine.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
similarity index 99%
rename from 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/WhereClauseShardingConditionEngine.java
rename to 
features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
index 0ba695c3b27..58dcefd8ff6 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/WhereClauseShardingConditionEngine.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngine.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.route.engine.condition.engine.impl;
+package org.apache.shardingsphere.sharding.route.engine.condition.engine;
 
 import com.google.common.collect.Range;
 import lombok.RequiredArgsConstructor;
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
index 32e19cf73d5..74f6a91465c 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
@@ -25,20 +25,13 @@ import 
org.apache.shardingsphere.infra.database.DefaultDatabase;
 import 
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngineFactory;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.DefaultShardingConditionEngine;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
 import org.apache.shardingsphere.sharding.rule.BindingTableRule;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.rule.TableRule;
 import org.junit.Test;
-import org.mockito.MockedStatic;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.List;
 import java.util.Optional;
 import java.util.Properties;
 
@@ -46,10 +39,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.mockStatic;
 import static org.mockito.Mockito.when;
 
 public final class ShardingSQLFederationDeciderTest {
@@ -72,27 +63,9 @@ public final class ShardingSQLFederationDeciderTest {
         SelectStatementContext select = createStatementContext();
         when(select.isContainsSubquery()).thenReturn(true);
         QueryContext queryContext = new QueryContext(select, "", 
Collections.emptyList());
-        SQLFederationDeciderContext actual = new SQLFederationDeciderContext();
-        ShardingSQLFederationDecider federationDecider = new 
ShardingSQLFederationDecider();
-        try (MockedStatic<ShardingConditionEngineFactory> 
shardingConditionEngineFactory = 
mockStatic(ShardingConditionEngineFactory.class)) {
-            DefaultShardingConditionEngine shardingConditionEngine = 
mock(DefaultShardingConditionEngine.class);
-            when(shardingConditionEngine.createShardingConditions(any(), 
any())).thenReturn(createShardingConditions());
-            shardingConditionEngineFactory.when(() -> 
ShardingConditionEngineFactory.createShardingConditionEngine(any(), 
any())).thenReturn(shardingConditionEngine);
-            federationDecider.decide(actual, queryContext, createDatabase(), 
createShardingRule(), new ConfigurationProperties(new Properties()));
-        }
-        assertThat(actual.getDataNodes().size(), is(4));
-        assertFalse(actual.isUseSQLFederation());
-    }
-    
-    private List<ShardingCondition> createShardingConditions() {
-        List<ShardingCondition> result = new ArrayList<>();
-        ShardingCondition shardingCondition1 = new ShardingCondition();
-        shardingCondition1.getValues().add(new 
ListShardingConditionValue<>("order_id", "t_order", 
Collections.singletonList(1)));
-        result.add(shardingCondition1);
-        ShardingCondition shardingCondition2 = new ShardingCondition();
-        shardingCondition2.getValues().add(new 
ListShardingConditionValue<>("order_id", "t_order_item", 
Collections.singletonList(1)));
-        result.add(shardingCondition2);
-        return result;
+        SQLFederationDeciderContext deciderContext = new 
SQLFederationDeciderContext();
+        new ShardingSQLFederationDecider().decide(deciderContext, 
queryContext, createDatabase(), createShardingRule(), new 
ConfigurationProperties(new Properties()));
+        assertThat(deciderContext.getDataNodes().size(), is(4));
     }
     
     @Test
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
index cd6f2993414..aa5d6ddb876 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/InsertClauseShardingConditionEngineTest.java
@@ -24,7 +24,6 @@ import 
org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueC
 import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.InsertClauseShardingConditionEngine;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.rule.TableRule;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.complex.CommonExpressionSegment;
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactoryTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactoryTest.java
deleted file mode 100644
index 85251e7a60a..00000000000
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactoryTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.sharding.route.engine.condition.engine;
-
-import org.apache.groovy.util.Maps;
-import org.apache.shardingsphere.infra.binder.QueryContext;
-import 
org.apache.shardingsphere.infra.binder.segment.insert.values.InsertValueContext;
-import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
-import 
org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext;
-import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.DefaultShardingConditionEngine;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.value.RangeShardingConditionValue;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BetweenExpression;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyCollection;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ShardingConditionEngineFactoryTest {
-    
-    @Mock
-    private QueryContext queryContext;
-    
-    @Mock
-    private ShardingRule shardingRule;
-    
-    @Test
-    public void assertCreateInsertClauseShardingConditionEngine() {
-        ShardingSphereDatabase database = 
ShardingSphereDatabase.create("test_db", 
DatabaseTypeEngine.getDatabaseType("MySQL"));
-        InsertStatementContext insertStatementContext = 
mock(InsertStatementContext.class);
-        InsertStatement insertStatement = mock(InsertStatement.class);
-        InsertValueContext insertValueContext = new 
InsertValueContext(Collections.singletonList(new LiteralExpressionSegment(0, 
10, "1")), Collections.emptyList(), 0);
-        when(insertStatement.getTable()).thenReturn(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("foo_table"))));
-        
when(insertStatementContext.getSqlStatement()).thenReturn(insertStatement);
-        
when(insertStatementContext.getColumnNames()).thenReturn(Collections.singletonList("foo_col"));
-        
when(insertStatementContext.getInsertValueContexts()).thenReturn(Collections.singletonList(insertValueContext));
-        
when(insertStatementContext.getGeneratedKeyContext()).thenReturn(Optional.empty());
-        DefaultShardingConditionEngine engine = 
ShardingConditionEngineFactory.createShardingConditionEngine(database, 
shardingRule);
-        assertThat(engine, instanceOf(DefaultShardingConditionEngine.class));
-        List<ShardingCondition> shardingConditions = 
engine.createShardingConditions(insertStatementContext, 
Collections.emptyList());
-        assertThat(shardingConditions.get(0).getStartIndex(), is(0));
-        assertTrue(shardingConditions.get(0).getValues().isEmpty());
-    }
-    
-    @Test
-    public void assertCreateWhereClauseShardingConditionEngine() {
-        ShardingSphereDatabase database = 
ShardingSphereDatabase.create("test_db", 
DatabaseTypeEngine.getDatabaseType("MySQL"));
-        SelectStatementContext sqlStatementContext = 
mock(SelectStatementContext.class);
-        WhereSegment whereSegment = mock(WhereSegment.class);
-        TablesContext tablesContext = mock(TablesContext.class);
-        int betweenStart = 1;
-        int betweenEnd = 100;
-        ColumnSegment left = new ColumnSegment(0, 0, new 
IdentifierValue("foo_sharding_col"));
-        ExpressionSegment betweenSegment = new LiteralExpressionSegment(0, 0, 
betweenStart);
-        ExpressionSegment andSegment = new LiteralExpressionSegment(0, 0, 
betweenEnd);
-        BetweenExpression betweenExpression = new BetweenExpression(0, 0, 
left, betweenSegment, andSegment, false);
-        when(whereSegment.getExpr()).thenReturn(betweenExpression);
-        when(shardingRule.findShardingColumn(any(), 
any())).thenReturn(Optional.of("foo_sharding_col"));
-        
when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.singleton(whereSegment));
-        when(sqlStatementContext.getTablesContext()).thenReturn(tablesContext);
-        when(tablesContext.findTableNamesByColumnSegment(anyCollection(), 
any())).thenReturn(Maps.of("foo_sharding_col", "table_1"));
-        DefaultShardingConditionEngine engine = 
ShardingConditionEngineFactory.createShardingConditionEngine(database, 
shardingRule);
-        assertThat(engine, instanceOf(DefaultShardingConditionEngine.class));
-        List<ShardingCondition> shardingConditions = 
engine.createShardingConditions(sqlStatementContext, Collections.emptyList());
-        assertThat(shardingConditions.get(0).getStartIndex(), is(0));
-        assertTrue(shardingConditions.get(0).getValues().get(0) instanceof 
RangeShardingConditionValue);
-    }
-}
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
index d62ab6bcf9e..1637dd50b35 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
@@ -23,7 +23,6 @@ import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementConte
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.RangeShardingConditionValue;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
diff --git 
a/features/sharding/plugin/cache/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
 
b/features/sharding/plugin/cache/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
index 3b4e1e56084..96cc693852a 100644
--- 
a/features/sharding/plugin/cache/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
+++ 
b/features/sharding/plugin/cache/src/main/java/org/apache/shardingsphere/sharding/cache/checker/ShardingRouteCacheableChecker.java
@@ -34,8 +34,8 @@ import 
org.apache.shardingsphere.sharding.cache.checker.algorithm.CacheableShard
 import org.apache.shardingsphere.sharding.cache.api.ShardingCacheOptions;
 import org.apache.shardingsphere.sharding.cache.rule.ShardingCacheRule;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.InsertClauseShardingConditionEngine;
-import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.InsertClauseShardingConditionEngine;
+import 
org.apache.shardingsphere.sharding.route.engine.condition.engine.WhereClauseShardingConditionEngine;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.RangeShardingConditionValue;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;

Reply via email to