You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/10/18 06:28:06 UTC

(shardingsphere) branch master updated: Add test cases on PipelinePrepareSQLBuilder (#33293)

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 4a3d46bb677 Add test cases on PipelinePrepareSQLBuilder (#33293)
4a3d46bb677 is described below

commit 4a3d46bb677da022702000b8f5bdf6d95e0ccbc0
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Oct 18 14:27:59 2024 +0800

    Add test cases on PipelinePrepareSQLBuilder (#33293)
    
    * Refactor CoordinatorRegistryCenterInitializer
    
    * Add more test cases on PipelineImportSQLBuilder
    
    * Add test cases on PipelinePrepareSQLBuilder
---
 .../sql/PipelinePrepareSQLBuilderTest.java         | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelinePrepareSQLBuilderTest.java b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelinePrepareSQLBuilderTest.java
new file mode 100644
index 00000000000..f01921a89d7
--- /dev/null
+++ b/kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/sql/PipelinePrepareSQLBuilderTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.data.pipeline.core.sqlbuilder.sql;
+
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+class PipelinePrepareSQLBuilderTest {
+    
+    private final PipelinePrepareSQLBuilder sqlBuilder = new PipelinePrepareSQLBuilder(TypedSPILoader.getService(DatabaseType.class, "FIXTURE"));
+    
+    @Test
+    void assertBuildCreateSchemaSQL() {
+        assertFalse(sqlBuilder.buildCreateSchemaSQL("foo_schema").isPresent());
+    }
+    
+    @Test
+    void assertBuildDropSQL() {
+        assertThat(sqlBuilder.buildDropSQL("foo_schema", "foo_tbl"), is("DROP TABLE IF EXISTS foo_tbl"));
+    }
+    
+    @Test
+    void assertBuildCountSQL() {
+        assertThat(sqlBuilder.buildCountSQL("foo_schema", "foo_tbl"), is("SELECT COUNT(*) FROM foo_tbl"));
+    }
+    
+    @Test
+    void assertBuildEstimatedCountSQL() {
+        assertFalse(sqlBuilder.buildEstimatedCountSQL("foo_catalog", "foo_schema", "foo_tbl").isPresent());
+    }
+    
+    @Test
+    void assertBuildUniqueKeyMinMaxValuesSQL() {
+        assertThat(sqlBuilder.buildUniqueKeyMinMaxValuesSQL("foo_schema", "foo_tbl", "foo_key"), is("SELECT MIN(foo_key), MAX(foo_key) FROM foo_tbl"));
+    }
+    
+    @Test
+    void assertBuildCheckEmptyTableSQL() {
+        assertThat(sqlBuilder.buildCheckEmptyTableSQL("foo_schema", "foo_tbl"), is("SELECT * FROM foo_tbl LIMIT 1"));
+    }
+}