You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/27 13:47:45 UTC

[GitHub] [shardingsphere] strongduanmu commented on a change in pull request #15130: ShardingConditions and test cases (#13821)

strongduanmu commented on a change in pull request #15130:
URL: https://github.com/apache/shardingsphere/pull/15130#discussion_r793619072



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java
##########
@@ -0,0 +1,65 @@
+package org.apache.shardingsphere.sharding.route.engine.condition;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
+import org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ShardingConditionsTest {
+
+    @Mock
+    private ShardingConditions shardingConditions;
+
+    @Before
+    public void setUp() {
+        when(shardingConditions.isAlwaysFalse()).thenReturn(false);
+        when(shardingConditions.isNeedMerge()).thenReturn(true);
+        when(shardingConditions.isSameShardingCondition()).thenReturn(false);
+    }
+
+    @Test
+    public void assertIsAlwaysFalse(){
+        assertFalse(shardingConditions.isAlwaysFalse());
+    }
+
+    @Test
+    public void assertIsNeedMerge(){
+        assertTrue(shardingConditions.isNeedMerge());
+    }
+
+    @Test
+    public void  isSameShardingCondition(){
+        assertFalse(shardingConditions.isSameShardingCondition());
+    }
+
+    @Test
+    public void assertMerge(){
+       createShardingConditions("t_order").merge();
+    }
+
+    protected final ShardingConditions createShardingConditions(final String tableName) {

Review comment:
       private may be better.

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java
##########
@@ -0,0 +1,65 @@
+package org.apache.shardingsphere.sharding.route.engine.condition;

Review comment:
       @farmer-liuz1024 Please add licenses header. 

##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/ShardingConditionsTest.java
##########
@@ -0,0 +1,65 @@
+package org.apache.shardingsphere.sharding.route.engine.condition;
+
+import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import org.apache.shardingsphere.sharding.route.engine.condition.value.ListShardingConditionValue;
+import org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
+import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ShardingConditionsTest {

Review comment:
       @farmer-liuz1024 Add final for ShardingConditionsTest.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org