Rohitpandey357 commented on code in PR #19493: URL: https://github.com/apache/shardingsphere/pull/19493#discussion_r928468161
########## shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingRemoveTokenGeneratorTest.java: ########## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sharding.rewrite.token; + +import org.apache.shardingsphere.infra.binder.statement.dml.InsertStatementContext; +import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext; +import org.apache.shardingsphere.sharding.rewrite.token.generator.impl.ShardingRemoveTokenGenerator; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public final class ShardingRemoveTokenGeneratorTest { + + @Test + public void assertIsGenerateSQLToken() { + ShardingRemoveTokenGenerator shardingRemoveTokenGenerator = new ShardingRemoveTokenGenerator(); + assertFalse(shardingRemoveTokenGenerator.isGenerateSQLToken(mock(InsertStatementContext.class))); + SelectStatementContext selectStatementContext = mock(SelectStatementContext.class, RETURNS_DEEP_STUBS); + when(selectStatementContext.getProjectionsContext().getAggregationDistinctProjections().isEmpty()).thenReturn(Boolean.TRUE); + assertFalse(shardingRemoveTokenGenerator.isGenerateSQLToken(selectStatementContext)); + when(selectStatementContext.getProjectionsContext().getAggregationDistinctProjections().isEmpty()).thenReturn(Boolean.FALSE); + assertTrue(shardingRemoveTokenGenerator.isGenerateSQLToken(selectStatementContext)); Review Comment: Hi @terrymanu , I could do that but i just followed the project structure. In all the other test classes, there are 2 calls for isGenerateSQLToken(). If i split this in 2 methods, then we should also split in the other test classes. For example, refer to this -> https://github.com/apache/shardingsphere/blob/master/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/ShardingInsertValuesTokenGeneratorTest.java -- 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]
