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/08/24 00:55:54 UTC

[shardingsphere] branch master updated: Added test class for ClusterStatementHandler (#20453)

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 66242c5ea76 Added test class for ClusterStatementHandler (#20453)
66242c5ea76 is described below

commit 66242c5ea765067d254b6bee0a58b0e2e54fa5f2
Author: Moukthika Vuyyuru <32...@users.noreply.github.com>
AuthorDate: Wed Aug 24 06:25:47 2022 +0530

    Added test class for ClusterStatementHandler (#20453)
    
    * Added test class for CommentStatementHandler
    
    * Added test class for CommentStatementHandler
    
    * Added test class for CommentStatementHandler
    
    * Added test class for ClusterStatementHandler
    
    * Added test class for ClusterStatementHandler
---
 .../handler/ddl/ClusterStatementHandlerTest.java   | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/ClusterStatementHandlerTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/ClusterStatementHandlerTest.java
new file mode 100644
index 00000000000..27ddfc56220
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/ClusterStatementHandlerTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.dialect.handler.ddl;
+
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexNameSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
+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.statement.ddl.ClusterStatement;
+import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLClusterStatement;
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class ClusterStatementHandlerTest {
+    
+    @Test
+    public void assertGetSimpleTableSegmentWithTableSegment() {
+        PostgreSQLClusterStatement statement = new PostgreSQLClusterStatement();
+        statement.setTable(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue(""))));
+        Optional<SimpleTableSegment> actual = ClusterStatementHandler.getSimpleTableSegment(statement);
+        assertTrue(actual.isPresent());
+    }
+    
+    @Test
+    public void assertGetSimpleTableSegmentWithoutTableSegment() {
+        ClusterStatement statement = mock(ClusterStatement.class);
+        Optional<SimpleTableSegment> actual = ClusterStatementHandler.getSimpleTableSegment(statement);
+        assertFalse(actual.isPresent());
+    }
+    
+    @Test
+    public void assertGetIndexSegmentWithIndexSegment() {
+        PostgreSQLClusterStatement statement = new PostgreSQLClusterStatement();
+        statement.setIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue(""))));
+        Optional<IndexSegment> actual = ClusterStatementHandler.getIndexSegment(statement);
+        assertTrue(actual.isPresent());
+    }
+    
+    @Test
+    public void assertGetIndexSegmentWithoutIndexSegment() {
+        ClusterStatement statement = mock(ClusterStatement.class);
+        Optional<IndexSegment> actual = ClusterStatementHandler.getIndexSegment(statement);
+        assertFalse(actual.isPresent());
+    }
+}