You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/08/26 14:39:54 UTC

[shardingsphere] branch master updated: For code format (#20574)

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 43a40543459 For code format (#20574)
43a40543459 is described below

commit 43a40543459b80339e056a0a191b7c9522ae3954
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Aug 26 22:39:43 2022 +0800

    For code format (#20574)
---
 .../generator/ConditionValueGeneratorFactory.java  | 12 ++---
 .../WhereClauseShardingConditionEngineTest.java    | 53 ++++++++++------------
 2 files changed, 31 insertions(+), 34 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
index 9c32f9ed3ce..00ef5baea0e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/ConditionValueGeneratorFactory.java
@@ -37,18 +37,18 @@ import java.util.Optional;
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class ConditionValueGeneratorFactory {
-
+    
     private static final ConditionValueCompareOperatorGenerator COMPARE_OPERATOR_GENERATOR = new ConditionValueCompareOperatorGenerator();
-
+    
     private static final ConditionValueInOperatorGenerator IN_OPERATOR_GENERATOR = new ConditionValueInOperatorGenerator();
-
+    
     private static final ConditionValueBetweenOperatorGenerator BETWEEN_OPERATOR_GENERATOR = new ConditionValueBetweenOperatorGenerator();
-
+    
     /**
      * Generate condition value.
      *
-     * @param predicate  predicate right value
-     * @param column     column
+     * @param predicate predicate right value
+     * @param column column
      * @param parameters SQL parameters
      * @return route value
      */
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
index 3b307506e82..9f58aeecd67 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/WhereClauseShardingConditionEngineTest.java
@@ -17,13 +17,6 @@
 
 package org.apache.shardingsphere.sharding.route.engine.condition.engine;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyCollection;
-import static org.mockito.Mockito.when;
-
 import org.apache.groovy.util.Maps;
 import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
 import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
@@ -53,35 +46,40 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.Mockito.when;
+
 @RunWith(MockitoJUnitRunner.class)
 public final class WhereClauseShardingConditionEngineTest {
-
+    
     private WhereClauseShardingConditionEngine shardingConditionEngine;
-
+    
     @Mock
     private ShardingRule shardingRule;
-
+    
     @Mock
     private SelectStatementContext sqlStatementContext;
-
+    
     @Mock
     private WhereSegment whereSegment;
-
+    
     @Mock
     private TablesContext tablesContext;
-
+    
     @Before
     public void setUp() throws SQLException {
-        ShardingSphereDatabase database = ShardingSphereDatabase.create("test_db", DatabaseTypeEngine.getDatabaseType("MySQL"));
-        shardingConditionEngine = new WhereClauseShardingConditionEngine(shardingRule, database);
-
-        when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.singletonList(whereSegment));
+        shardingConditionEngine = new WhereClauseShardingConditionEngine(shardingRule, ShardingSphereDatabase.create("test_db", DatabaseTypeEngine.getDatabaseType("MySQL")));
+        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"));
     }
-
+    
     @Test
-    public void assertCreateShardingConditionsSelectRangeStatement() {
+    public void assertCreateShardingConditionsForSelectRangeStatement() {
         int between = 1;
         int and = 100;
         ColumnSegment left = new ColumnSegment(0, 0, new IdentifierValue("foo_sharding_col"));
@@ -90,13 +88,13 @@ public final class WhereClauseShardingConditionEngineTest {
         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"));
-        List<ShardingCondition> shardingConditions = shardingConditionEngine.createShardingConditions(sqlStatementContext, Collections.emptyList());
-        assertThat(shardingConditions.get(0).getStartIndex(), is(0));
-        assertTrue(shardingConditions.get(0).getValues().get(0) instanceof RangeShardingConditionValue);
+        List<ShardingCondition> actual = shardingConditionEngine.createShardingConditions(sqlStatementContext, Collections.emptyList());
+        assertThat(actual.get(0).getStartIndex(), is(0));
+        assertTrue(actual.get(0).getValues().get(0) instanceof RangeShardingConditionValue);
     }
-
+    
     @Test
-    public void assertCreateShardingConditionsSelectInStatement() {
+    public void assertCreateShardingConditionsForSelectInStatement() {
         ColumnSegment left = new ColumnSegment(0, 0, new IdentifierValue("foo_sharding_col"));
         ListExpression right = new ListExpression(0, 0);
         LiteralExpressionSegment literalExpressionSegment = new LiteralExpressionSegment(0, 0, 5);
@@ -104,9 +102,8 @@ public final class WhereClauseShardingConditionEngineTest {
         InExpression inExpression = new InExpression(0, 0, left, right, false);
         when(whereSegment.getExpr()).thenReturn(inExpression);
         when(shardingRule.findShardingColumn(any(), any())).thenReturn(Optional.of("foo_sharding_col"));
-        List<ShardingCondition> shardingConditions = shardingConditionEngine.createShardingConditions(sqlStatementContext, Collections.emptyList());
-        assertThat(shardingConditions.get(0).getStartIndex(), is(0));
-        assertTrue(shardingConditions.get(0).getValues().get(0) instanceof ListShardingConditionValue);
+        List<ShardingCondition> actual = shardingConditionEngine.createShardingConditions(sqlStatementContext, Collections.emptyList());
+        assertThat(actual.get(0).getStartIndex(), is(0));
+        assertTrue(actual.get(0).getValues().get(0) instanceof ListShardingConditionValue);
     }
-
 }