lwtdev commented on a change in pull request #8160:
URL: https://github.com/apache/shardingsphere/pull/8160#discussion_r524959211



##########
File path: 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/extractor/TableExtractorTest.java
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.sql.parser.sql.common.extractor;
+
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.LockSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Optional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+
+public class TableExtractorTest {
+
+    private TableExtractor tableExtractor;
+
+    @Before
+    public void init() {
+        tableExtractor = new TableExtractor();
+    }
+
+    @Test
+    public void assertExtractTablesFromSelectLockWithEmptyValue() {
+        MySQLSelectStatement selectStatement = new MySQLSelectStatement();
+        tableExtractor.extractTablesFromSelect(selectStatement);
+        assertTrue(tableExtractor.getRewriteTables().isEmpty());
+    }
+
+    @Test
+    public void assertExtractTablesFromSelectLockWithValue() {
+        MySQLSelectStatement selectStatement = new MySQLSelectStatement();
+        LockSegment lockSegment = new LockSegment(108, 154);
+        selectStatement.setLock(lockSegment);
+        List<SimpleTableSegment> tables = new LinkedList<>();
+        lockSegment.setForTables(tables);
+        tables.add(new SimpleTableSegment(122, 128, new 
IdentifierValue("t_order")));
+        tables.add(new SimpleTableSegment(143, 154, new 
IdentifierValue("t_order_item")));
+
+        tableExtractor.extractTablesFromSelect(selectStatement);
+
+        assertNotNull(tableExtractor.getRewriteTables());

Review comment:
       But I found that it doesn’t seem to be the case in the project, so I 
will keep with the project and delete these blank lines




----------------------------------------------------------------
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:
[email protected]


Reply via email to