From e17795bfa39180f81880e2f3ab620b4cf1f73036 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 16 Nov 2024 11:13:55 +0800 Subject: [PATCH 1/3] Add test cases on ProjectionsToken --- .../rewrite/token/pojo/ProjectionsToken.java | 10 ++--- .../token/pojo/ProjectionsTokenTest.java | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsToken.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsToken.java index 0088eb5c92480..e3b505a65b830 100644 --- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsToken.java +++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsToken.java @@ -37,6 +37,11 @@ public ProjectionsToken(final int startIndex, final Map> projections = new HashMap<>(1, 1); + RouteUnit routeUnit = new RouteUnit(new RouteMapper("foo_ds", "foo_ds_0"), Collections.singleton(new RouteMapper("foo_tbl", "foo_tbl_1"))); + assertThat(new ProjectionsToken(0, Collections.singletonMap(routeUnit, Collections.singleton("foo_col"))).toString(routeUnit), is(", foo_col")); + } +} From f65b6160b08c924a8570cff95818c6e9000dc8b4 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 16 Nov 2024 11:17:17 +0800 Subject: [PATCH 2/3] Add test cases on ProjectionsToken --- .../token/pojo/ProjectionsTokenTest.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java index b7d5b9d2226cc..9a918ebee5519 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java @@ -31,15 +31,15 @@ class ProjectionsTokenTest { - @Test - void assertGetStopIndex() { - assertThat(new ProjectionsToken(10, Collections.emptyMap()).getStopIndex(), is(10)); - } + @Test + void assertGetStopIndex() { + assertThat(new ProjectionsToken(10, Collections.emptyMap()).getStopIndex(), is(10)); + } - @Test - void assertToStringWithoutRouteUnit() { - Map> projections = new HashMap<>(1, 1); - RouteUnit routeUnit = new RouteUnit(new RouteMapper("foo_ds", "foo_ds_0"), Collections.singleton(new RouteMapper("foo_tbl", "foo_tbl_1"))); - assertThat(new ProjectionsToken(0, Collections.singletonMap(routeUnit, Collections.singleton("foo_col"))).toString(routeUnit), is(", foo_col")); - } + @Test + void assertToStringWithoutRouteUnit() { + Map> projections = new HashMap<>(1, 1); + RouteUnit routeUnit = new RouteUnit(new RouteMapper("foo_ds", "foo_ds_0"), Collections.singleton(new RouteMapper("foo_tbl", "foo_tbl_1"))); + assertThat(new ProjectionsToken(0, Collections.singletonMap(routeUnit, Collections.singleton("foo_col"))).toString(routeUnit), is(", foo_col")); + } } From 037ab4e2a628b8a8f936d202d53345d1d92f6229 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 16 Nov 2024 11:20:29 +0800 Subject: [PATCH 3/3] Add test cases on ProjectionsToken --- .../sharding/rewrite/token/pojo/ProjectionsTokenTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java index 9a918ebee5519..b3048affed11f 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/ProjectionsTokenTest.java @@ -21,10 +21,7 @@ import org.apache.shardingsphere.infra.route.context.RouteUnit; import org.junit.jupiter.api.Test; -import java.util.Collection; import java.util.Collections; -import java.util.HashMap; -import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -38,7 +35,6 @@ void assertGetStopIndex() { @Test void assertToStringWithoutRouteUnit() { - Map> projections = new HashMap<>(1, 1); RouteUnit routeUnit = new RouteUnit(new RouteMapper("foo_ds", "foo_ds_0"), Collections.singleton(new RouteMapper("foo_tbl", "foo_tbl_1"))); assertThat(new ProjectionsToken(0, Collections.singletonMap(routeUnit, Collections.singleton("foo_col"))).toString(routeUnit), is(", foo_col")); }