You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/11/16 02:46:58 UTC

(shardingsphere) branch master updated: Add more test cases on DistinctProjectionPrefixToken (#33684)

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

zhangliang 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 abbf473a994 Add more test cases on DistinctProjectionPrefixToken (#33684)
abbf473a994 is described below

commit abbf473a994b2711371f33d6e2d27d8ff971d821
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Nov 16 10:46:51 2024 +0800

    Add more test cases on DistinctProjectionPrefixToken (#33684)
---
 .../token/pojo/DistinctProjectionPrefixToken.java  |  8 +++----
 .../pojo/DistinctProjectionPrefixTokenTest.java}   | 27 +++++++++-------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java
index eedbc5a0b93..b4cf8055deb 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java
@@ -30,12 +30,12 @@ public final class DistinctProjectionPrefixToken extends SQLToken implements Att
     }
     
     @Override
-    public String toString() {
-        return "DISTINCT ";
+    public int getStopIndex() {
+        return getStartIndex();
     }
     
     @Override
-    public int getStopIndex() {
-        return getStartIndex();
+    public String toString() {
+        return "DISTINCT ";
     }
 }
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixTokenTest.java
similarity index 61%
copy from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java
copy to features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixTokenTest.java
index eedbc5a0b93..bb827d701c3 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixToken.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/DistinctProjectionPrefixTokenTest.java
@@ -17,25 +17,20 @@
 
 package org.apache.shardingsphere.sharding.rewrite.token.pojo;
 
-import org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.Attachable;
-import org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.SQLToken;
+import org.junit.jupiter.api.Test;
 
-/**
- * Distinct projection prefix token.
- */
-public final class DistinctProjectionPrefixToken extends SQLToken implements Attachable {
-    
-    public DistinctProjectionPrefixToken(final int startIndex) {
-        super(startIndex);
-    }
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class DistinctProjectionPrefixTokenTest {
     
-    @Override
-    public String toString() {
-        return "DISTINCT ";
+    @Test
+    void assertGetStopIndex() {
+        assertThat(new DistinctProjectionPrefixToken(10).getStopIndex(), is(10));
     }
     
-    @Override
-    public int getStopIndex() {
-        return getStartIndex();
+    @Test
+    void assertToString() {
+        assertThat(new DistinctProjectionPrefixToken(0).toString(), is("DISTINCT "));
     }
 }