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

zhangliang 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 1095d83ed84 add unit tests (#28832)
1095d83ed84 is described below

commit 1095d83ed8404c2fd32a02232c7007a8980e8dcb
Author: Sakshi Jain <[email protected]>
AuthorDate: Wed Mar 27 21:17:36 2024 +0530

    add unit tests (#28832)
---
 .../impl/SubqueryExpressionSegmentBinderTest.java  | 60 ++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git 
a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubqueryExpressionSegmentBinderTest.java
 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubqueryExpressionSegmentBinderTest.java
new file mode 100644
index 00000000000..5ae275f016e
--- /dev/null
+++ 
b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/segment/expression/impl/SubqueryExpressionSegmentBinderTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.infra.binder.segment.expression.impl;
+
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.subquery.SubqueryExpressionSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.subquery.SubquerySegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.dml.SQLServerSelectStatement;
+import 
org.apache.shardingsphere.infra.binder.segment.from.TableSegmentBinderContext;
+import 
org.apache.shardingsphere.infra.binder.statement.SQLStatementBinderContext;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.isA;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class SubqueryExpressionSegmentBinderTest {
+    
+    @Test
+    public void testBind() {
+        SelectStatement selectStatement = new SQLServerSelectStatement();
+        selectStatement.setProjections(new ProjectionsSegment(0, 0));
+        SubquerySegment subquery = new SubquerySegment(0, 10, selectStatement, 
"subquery");
+        SubqueryExpressionSegment segment = new 
SubqueryExpressionSegment(subquery);
+        SQLStatementBinderContext statementBinderContext = new 
SQLStatementBinderContext(null, null, null, null);
+        Map<String, TableSegmentBinderContext> tableBinderContexts = new 
HashMap<>();
+        SubqueryExpressionSegment expected = new 
SubqueryExpressionSegment(SubquerySegmentBinder.bind(segment.getSubquery(), 
statementBinderContext, tableBinderContexts));
+        SubqueryExpressionSegment actual = 
SubqueryExpressionSegmentBinder.bind(segment, statementBinderContext, 
tableBinderContexts);
+        assertThat(actual, isA(SubqueryExpressionSegment.class));
+        assertThat(actual.getStartIndex(), is(expected.getStartIndex()));
+        assertThat(actual.getStopIndex(), is(expected.getStopIndex()));
+        assertThat(actual.getText(), is(expected.getText()));
+        assertThat(actual.getSubquery().getStartIndex(), 
is(expected.getSubquery().getStartIndex()));
+        assertThat(actual.getSubquery().getStopIndex(), 
is(expected.getSubquery().getStopIndex()));
+        assertThat(actual.getSubquery().getSubqueryType(), 
is(expected.getSubquery().getSubqueryType()));
+        assertThat(actual.getSubquery().getText(), 
is(expected.getSubquery().getText()));
+        assertThat(actual.getSubquery().getSelect().getDatabaseType(), 
is(expected.getSubquery().getSelect().getDatabaseType()));
+        
assertThat(actual.getSubquery().getSelect().getProjections().getProjections(), 
is(expected.getSubquery().getSelect().getProjections().getProjections()));
+    }
+}

Reply via email to