You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/10/02 06:55:07 UTC

[shardingsphere] branch master updated: [Issue #20353]-Add unit test for SQLStats (#21306)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 668291b2b4d [Issue #20353]-Add unit test for SQLStats (#21306)
668291b2b4d is described below

commit 668291b2b4de5cddac2bec167c8b3519257b0b54
Author: Abhinav Koppula <ab...@gmail.com>
AuthorDate: Sun Oct 2 12:24:59 2022 +0530

    [Issue #20353]-Add unit test for SQLStats (#21306)
---
 .../sql/parser/sql/common/SQLStatsTest.java        | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStatsTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStatsTest.java
new file mode 100644
index 00000000000..7473fc488d5
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/common/SQLStatsTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertNull;
+
+import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
+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.junit.Test;
+
+public final class SQLStatsTest {
+    
+    @Test
+    public void assertAddTable() {
+        SQLStats sqlStats = new SQLStats();
+        assertNull(sqlStats.getTables().get("foo"));
+        SimpleTableSegment tableSegment = new SimpleTableSegment(new TableNameSegment(0, 5, new IdentifierValue("foo")));
+        sqlStats.addTable(tableSegment);
+        assertThat(sqlStats.getTables().get("foo"), is(tableSegment));
+        sqlStats.addTable(tableSegment);
+        assertThat(sqlStats.getTables().get("foo"), is(tableSegment));
+    }
+    
+    @Test
+    public void assertAddColumn() {
+        SQLStats sqlStats = new SQLStats();
+        ColumnSegment columnSegment = new ColumnSegment(0, 5, new IdentifierValue("foo"));
+        assertNull(sqlStats.getColumns().get(columnSegment.hashCode()));
+        sqlStats.addColumn(columnSegment);
+        assertThat(sqlStats.getColumns().get(columnSegment.hashCode()), is(columnSegment));
+        sqlStats.addColumn(columnSegment);
+        assertThat(sqlStats.getColumns().get(columnSegment.hashCode()), is(columnSegment));
+    }
+}