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 40ca6220df2 Add more test cases on ProjectionsContext (#33190)
40ca6220df2 is described below
commit 40ca6220df2f654b50375c902f137643860986b8
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Oct 9 19:31:41 2024 +0800
Add more test cases on ProjectionsContext (#33190)
---
.../select/projection/ProjectionsContextTest.java | 26 ++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/ProjectionsContextTest.java
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/ProjectionsContextTest.java
index 52825d14c28..26210e709fd 100644
---
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/ProjectionsContextTest.java
+++
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/segment/select/projection/ProjectionsContextTest.java
@@ -45,25 +45,25 @@ import static org.mockito.Mockito.mock;
class ProjectionsContextTest {
@Test
- void assertUnqualifiedShorthandProjectionWithEmptyItems() {
+ void assertIsUnqualifiedShorthandProjectionWithEmptyItems() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.emptySet());
assertFalse(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
- void assertUnqualifiedShorthandProjectionWithWrongProjection() {
+ void assertIsUnqualifiedShorthandProjectionWithWrongProjection() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.singleton(getColumnProjection()));
assertFalse(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
- void assertUnqualifiedShorthandProjectionWithWrongShortProjection() {
+ void assertIsUnqualifiedShorthandProjectionWithWrongShortProjection() {
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.singleton(getShorthandProjection()));
assertFalse(projectionsContext.isUnqualifiedShorthandProjection());
}
@Test
- void assertUnqualifiedShorthandProjection() {
+ void assertIsUnqualifiedShorthandProjection() {
Projection projection = new ShorthandProjection(null,
Collections.emptyList());
ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.singleton(projection));
assertTrue(projectionsContext.isUnqualifiedShorthandProjection());
@@ -159,4 +159,22 @@ class ProjectionsContextTest {
Collections.singletonList(new ExpressionProjection(new
ExpressionProjectionSegment(0, 0, "MAX(id)"), new IdentifierValue("max"), new
MySQLDatabaseType())));
assertFalse(maxProjection.isContainsLastInsertIdProjection());
}
+
+ @Test
+ void assertNotFindColumnProjectionWithOutOfIndex() {
+ ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.emptySet());
+ assertFalse(projectionsContext.findColumnProjection(1).isPresent());
+ }
+
+ @Test
+ void assertNotFindColumnProjectionWithNotColumnProjection() {
+ ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.singleton(mock(Projection.class)));
+ assertFalse(projectionsContext.findColumnProjection(1).isPresent());
+ }
+
+ @Test
+ void assertFindColumnProjection() {
+ ProjectionsContext projectionsContext = new ProjectionsContext(0, 0,
true, Collections.singleton(mock(ColumnProjection.class)));
+ assertTrue(projectionsContext.findColumnProjection(1).isPresent());
+ }
}