strongduanmu commented on code in PR #28843:
URL: https://github.com/apache/shardingsphere/pull/28843#discussion_r1582847464
##########
infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java:
##########
@@ -409,6 +412,29 @@ private void assertSetWhere(final SelectStatement
selectStatement) {
assertThat(actual.getWhereSegments(),
is(Collections.singletonList(whereSegment)));
}
+ @Test
+ void assertFindColumnProjectionWithoutExpandProjections() {
+ SelectStatementContext selectStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+
+
when(selectStatementContext.getProjectionsContext().getExpandProjections()).thenReturn(Collections.emptyList());
+
+ Optional<ColumnProjection> result =
selectStatementContext.findColumnProjection(1);
+
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ void assertFindColumnProjectionInvalidProjectionType() {
+ ExpressionProjection projection = mock(ExpressionProjection.class);
+ SelectStatementContext selectStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+
+
when(selectStatementContext.getProjectionsContext().getExpandProjections()).thenReturn(Collections.singletonList(projection));
+
+ Optional<ColumnProjection> result =
selectStatementContext.findColumnProjection(1);
+
+ assertFalse(result.isPresent());
+ }
+
Review Comment:
Is it possible to add an unit test under normal scenarios?
##########
infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/dml/SelectStatementContextTest.java:
##########
@@ -409,6 +412,29 @@ private void assertSetWhere(final SelectStatement
selectStatement) {
assertThat(actual.getWhereSegments(),
is(Collections.singletonList(whereSegment)));
}
+ @Test
+ void assertFindColumnProjectionWithoutExpandProjections() {
+ SelectStatementContext selectStatementContext =
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
+
Review Comment:
Please remove useless blank line.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]