Zhenye-Na commented on code in PR #28843:
URL: https://github.com/apache/shardingsphere/pull/28843#discussion_r1583455034
##########
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:
I tried with mocking, and was getting NPE after it, so I was considering at
least getting the unit test for failed scenarios. If you prefer, I can try to
get the successful cases in unit tests as well. Though I dont have a specific
timeline for this.
--
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]