sluk3r commented on a change in pull request #3281: #3138 improved coverage for sharding core preprocessor URL: https://github.com/apache/incubator-shardingsphere/pull/3281#discussion_r335497199
########## File path: sharding-core/sharding-core-preprocessor/src/test/java/org/apache/shardingsphere/core/preprocessor/segment/select/projection/engine/ProjectionsContextEngineTest.java ########## @@ -59,4 +62,40 @@ public void assertProjectionsContextCreatedProperlyWhenSelectItemPresent() { ProjectionsContext projectionsContext = new ProjectionsContextEngine(null).createProjectionsContext(null, selectStatement, mock(GroupByContext.class), mock(OrderByContext.class)); assertNotNull(projectionsContext); } + + @Test + public void createProjectionsContextWhenOrderByContextOrderItemsPresent() { + SelectStatement selectStatement = mock(SelectStatement.class); + SelectItemsSegment selectItemsSegment = mock(SelectItemsSegment.class); + when(selectStatement.getSelectItems()).thenReturn(selectItemsSegment); + ShorthandSelectItemSegment shorthandSelectItemSegment = new ShorthandSelectItemSegment(0, 10, "text"); + TableSegment owner = new TableSegment(0, 10, "name"); + owner.setOwner(new SchemaSegment(0, 10, "name")); + shorthandSelectItemSegment.setOwner(owner); + when(selectItemsSegment.getSelectItems()).thenReturn(Collections.<SelectItemSegment>singleton(shorthandSelectItemSegment)); + OrderByContext orderByContext = mock(OrderByContext.class); + OrderByItem orderByItem = mock(OrderByItem.class); + when(orderByItem.getSegment()).thenReturn(mock(IndexOrderByItemSegment.class)); + when(orderByContext.getItems()).thenReturn(Collections.singletonList(orderByItem)); + ProjectionsContext actual = new ProjectionsContextEngine(null).createProjectionsContext(null, selectStatement, mock(GroupByContext.class), orderByContext); + assertNotNull(actual); + } + + @Test + public void assertProjectionsContextCreatedProperlyWhenOrderByItemSegmentNotInstanceOfIndexOrderByItemSegment() { Review comment: the method name of assertProjectionsContextCreatedProperlyWhenOrderByItemSegmentNotInstanceOfIndexOrderByItemSegment express the meaning: assert that ProjectionsContext instance is created when OrderByItemSegment is not instance of InstanceOfIndexOrderByItemSegment, corresponding to the following switch in the format of negation: ![image](https://user-images.githubusercontent.com/6405801/66926479-b2467780-f060-11e9-9697-3be07bf8722d.png) So, I think the method name of assertProjectionsContextCreatedProperlyWhenOrderByItemSegmentNotInstanceOfIndexOrderByItemSegment could not be changed. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services