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

jianglongtao 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 0d973d6  Add SQL parser test case for ResetScalingStatement (#15733) 
(#15754)
0d973d6 is described below

commit 0d973d6dd62f6a072560eadc11fafe4664d5702c
Author: Panagiotis Parthenis <[email protected]>
AuthorDate: Wed Mar 2 13:54:26 2022 +0000

    Add SQL parser test case for ResetScalingStatement (#15733) (#15754)
---
 .../UpdatableScalingRALStatementAssert.java        |  5 ++
 .../update/ResetScalingStatementAssert.java        | 61 ++++++++++++++++++++++
 .../jaxb/cases/domain/SQLParserTestCases.java      |  7 ++-
 .../ral/scaling/ResetScalingStatementTestCase.java | 37 +++++++++++++
 .../src/main/resources/case/ral/update.xml         |  4 ++
 .../main/resources/sql/supported/ral/update.xml    |  1 +
 6 files changed, 114 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/UpdatableScalingRALStatementAssert.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/UpdatableScalingRALStatementAssert.java
index ef8e801..f14fff1 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/UpdatableScalingRALStatementAssert.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/UpdatableScalingRALStatementAssert.java
@@ -21,14 +21,17 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.scaling.UpdatableScalingRALStatement;
 import 
org.apache.shardingsphere.scaling.distsql.statement.ApplyScalingStatement;
+import 
org.apache.shardingsphere.scaling.distsql.statement.ResetScalingStatement;
 import 
org.apache.shardingsphere.scaling.distsql.statement.RestoreScalingSourceWritingStatement;
 import 
org.apache.shardingsphere.scaling.distsql.statement.StopScalingSourceWritingStatement;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.scaling.update.ApplyScalingStatementAssert;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.scaling.update.ResetScalingStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.scaling.update.RestoreScalingSourceWritingStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.scaling.update.StopScalingSourceWritingStatementAssert;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.ApplyScalingStatementTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.ResetScalingStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.RestoreScalingSourceWritingStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.StopScalingSourceWritingStatementTestCase;
 
@@ -53,6 +56,8 @@ public final class UpdatableScalingRALStatementAssert {
             RestoreScalingSourceWritingStatementAssert.assertIs(assertContext, 
(RestoreScalingSourceWritingStatement) actual, 
(RestoreScalingSourceWritingStatementTestCase) expected);
         } else if (actual instanceof ApplyScalingStatement) {
             ApplyScalingStatementAssert.assertIs(assertContext, 
(ApplyScalingStatement) actual, (ApplyScalingStatementTestCase) expected);
+        } else if (actual instanceof ResetScalingStatement) {
+            ResetScalingStatementAssert.assertIs(assertContext, 
(ResetScalingStatement) actual, (ResetScalingStatementTestCase) expected);
         }
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/update/ResetScalingStatementAssert.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/update/ResetScalingStatementAssert.java
new file mode 100644
index 0000000..2d1557a
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/asserts/statement/distsql/ral/impl/scaling/update/ResetScalingStatementAssert.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.test.sql.parser.parameterized.asserts.statement.distsql.ral.impl.scaling.update;
+
+import org.apache.commons.collections4.CollectionUtils;
+import 
org.apache.shardingsphere.scaling.distsql.statement.ResetScalingStatement;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.asserts.SQLCaseAssertContext;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.ResetScalingStatementTestCase;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Reset scaling statement assert.
+ */
+public final class ResetScalingStatementAssert {
+    
+    /**
+     * Assert reset scaling statement is correct with expected parser result.
+     *
+     * @param assertContext assert context
+     * @param actual actual reset scaling statement
+     * @param expected expected reset scaling statement test case
+     */
+    public static void assertIs(final SQLCaseAssertContext assertContext, 
final ResetScalingStatement actual, final ResetScalingStatementTestCase 
expected) {
+        if (null == expected) {
+            assertNull(assertContext.getText("Actual statement should not 
exist."), actual);
+        } else {
+            assertNotNull(assertContext.getText("Actual statement should 
exist."), actual);
+            assertJobIds(assertContext, actual.getJobId(), 
expected.getJobIds());
+        }
+    }
+    
+    private static void assertJobIds(final SQLCaseAssertContext assertContext, 
final String actual, final List<String> expected) {
+        if (CollectionUtils.isEmpty(expected)) {
+            assertNull(assertContext.getText("Actual job id should not 
exist."), actual);
+        } else {
+            assertNotNull(assertContext.getText("Actual job id should 
exist."), actual);
+            assertThat(assertContext.getText("Job id assertion error"), 
actual, is(expected.iterator().next()));
+        }
+    }
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 1d67746..ac762e4 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -202,6 +202,7 @@ import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.RestoreScalingSourceWritingStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.ShowScalingCheckAlgorithmsStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.StopScalingSourceWritingStatementTestCase;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling.ResetScalingStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.alter.AlterDatabaseDiscoveryConstructionRuleStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.alter.AlterDatabaseDiscoveryDefinitionRuleStatementTestCase;
 import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.rdl.alter.AlterDatabaseDiscoveryHeartbeatStatementTestCase;
@@ -766,7 +767,10 @@ public final class SQLParserTestCases {
     
     @XmlElement(name = "apply-scaling")
     private final List<ApplyScalingStatementTestCase> 
applyScalingStatementTestCases = new LinkedList<>();
-    
+
+    @XmlElement(name = "reset-scaling")
+    private final List<ResetScalingStatementTestCase> 
resetScalingStatementTestCases = new LinkedList<>();
+
     @XmlElement(name = "create-sharding-scaling-rule")
     private final List<CreateShardingScalingRuleStatementTestCase> 
createShardingScalingRuleStatementTestCases = new LinkedList<>();
     
@@ -1280,6 +1284,7 @@ public final class SQLParserTestCases {
         putAll(stopScalingSourceWritingStatementTestCase, result);
         putAll(restoreScalingSourceWritingStatementTestCase, result);
         putAll(applyScalingStatementTestCases, result);
+        putAll(resetScalingStatementTestCases, result);
         putAll(createShardingScalingRuleStatementTestCases, result);
         putAll(dropShardingScalingRuleStatementTestCases, result);
         putAll(enableShardingScalingRuleStatementTestCases, result);
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/scaling/ResetScalingStatementTestCase.java
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/scaling/ResetScalingStatementTestCase.java
new file mode 100644
index 0000000..2e294cb
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/distsql/ral/scaling/ResetScalingStatementTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * 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.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.scaling;
+
+import lombok.Getter;
+import lombok.Setter;
+import 
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+import javax.xml.bind.annotation.XmlElement;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Reset scaling statement test case.
+ */
+@Getter
+@Setter
+public final class ResetScalingStatementTestCase extends SQLParserTestCase {
+    
+    @XmlElement(name = "job-id")
+    private final List<String> jobIds = new LinkedList<>();
+}
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/update.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/update.xml
index aa6f2f7..e5029c2 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/update.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ral/update.xml
@@ -28,4 +28,8 @@
     <apply-scaling sql-case-id="apply-scaling">
         <job-id>123</job-id>
     </apply-scaling>
+
+    <reset-scaling sql-case-id="reset-scaling">
+        <job-id>123</job-id>
+    </reset-scaling>
 </sql-parser-test-cases>
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/update.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/update.xml
index 5623183..eb56974 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/update.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ral/update.xml
@@ -20,4 +20,5 @@
     <distsql-case id="stop-scaling-source-writing" value="STOP SCALING SOURCE 
WRITING 123;" />
     <distsql-case id="restore-scaling-source-writing" value="RESTORE SCALING 
SOURCE WRITING 123;" />
     <distsql-case id="apply-scaling" value="APPLY SCALING 123;" />
+    <distsql-case id="reset-scaling" value="RESET SCALING 123;" />
 </sql-cases>

Reply via email to