You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/03/22 16:39:01 UTC
[shardingsphere] branch master updated: Reuse ExistingAssert (#24768)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 7304be07c03 Reuse ExistingAssert (#24768)
7304be07c03 is described below
commit 7304be07c0371deb58412cadf0e47adcb300de90
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Mar 23 00:38:51 2023 +0800
Reuse ExistingAssert (#24768)
---
...uleStatementAssert.java => ExistingAssert.java} | 22 +++++-----
.../ral/impl/QueryableRALStatementAssert.java | 50 ++++++----------------
.../ral/impl/UpdatableRALStatementAssert.java | 6 +--
.../impl/cdc/ShowStreamingListStatementAssert.java | 46 --------------------
.../cdc/ShowStreamingStatusStatementAssert.java | 9 +---
.../statement/ral/impl/migration/JobIdAssert.java | 4 +-
.../QueryableScalingRALStatementAssert.java | 17 +++-----
...howMigrationCheckAlgorithmsStatementAssert.java | 46 --------------------
.../ShowMigrationCheckStatusStatementAssert.java | 9 +---
.../query/ShowMigrationListStatementAssert.java | 46 --------------------
...MigrationSourceStorageUnitsStatementAssert.java | 46 --------------------
.../query/ShowMigrationStatusStatementAssert.java | 9 +---
.../update/CheckMigrationStatementAssert.java | 6 +--
.../update/CommitMigrationStatementAssert.java | 9 +---
.../update/DropMigrationCheckStatementAssert.java | 48 ---------------------
...rMigrationSourceStorageUnitStatementAssert.java | 6 +--
.../update/RollbackMigrationStatementAssert.java | 9 +---
.../update/StartMigrationCheckStatementAssert.java | 9 +---
.../update/StartMigrationStatementAssert.java | 9 +---
.../update/StopMigrationCheckStatementAssert.java | 9 +---
.../update/StopMigrationStatementAssert.java | 9 +---
.../ConvertYamlConfigurationStatementAssert.java | 6 +--
...ExportDatabaseConfigurationStatementAssert.java | 47 --------------------
.../queryable/ExportMetaDataStatementAssert.java | 47 --------------------
.../ExportStorageNodesStatementAssert.java | 47 --------------------
.../ShowAuthorityRuleStatementAssert.java | 46 --------------------
.../ShowComputeNodeInfoStatementAssert.java | 46 --------------------
.../ShowComputeNodeModeStatementAssert.java | 46 --------------------
.../queryable/ShowComputeNodesStatementAssert.java | 46 --------------------
.../queryable/ShowDistVariableStatementAssert.java | 8 +---
.../ShowDistVariablesStatementAssert.java | 43 -------------------
.../ShowSQLParserRuleStatementAssert.java | 46 --------------------
.../ShowSQLTranslatorRuleStatementAssert.java | 46 --------------------
...FromReadwriteSplittingRulesStatementAssert.java | 47 --------------------
.../ShowTableMetaDataStatementAssert.java | 11 ++---
.../queryable/ShowTrafficRulesStatementAssert.java | 8 +---
.../ShowTransactionRuleStatementAssert.java | 49 ---------------------
.../updatable/AlterComputeNodeStatementAssert.java | 8 +---
...eSplittingStorageUnitStatusStatementAssert.java | 8 +---
.../AlterSQLParserRuleStatementAssert.java | 10 ++---
.../updatable/AlterTrafficRuleStatementAssert.java | 12 ++----
...ImportDatabaseConfigurationStatementAssert.java | 9 ++--
.../updatable/ImportMetaDataStatementAssert.java | 9 ++--
.../updatable/LabelComputeNodeStatementAssert.java | 8 +---
.../impl/updatable/LockClusterStatementAssert.java | 9 ++--
.../RefreshTableMetaDataStatementAssert.java | 8 +---
.../UnlabelComputeNodeStatementAssert.java | 8 +---
.../AlterDatabaseDiscoveryRuleStatementAssert.java | 8 +---
...AlterDefaultShadowAlgorithmStatementAssert.java | 7 +--
...lterDefaultShardingStrategyStatementAssert.java | 8 +---
.../impl/AlterEncryptRuleStatementAssert.java | 6 +--
.../alter/impl/AlterMaskRuleStatementAssert.java | 6 +--
...AlterReadwriteSplittingRuleStatementAssert.java | 6 +--
.../alter/impl/AlterShadowRuleStatementAssert.java | 6 +--
...ShardingTableReferenceRulesStatementAssert.java | 6 +--
.../AlterShardingTableRuleStatementAssert.java | 6 +--
.../CreateBroadcastTableRuleStatementAssert.java | 8 +---
...CreateDatabaseDiscoveryRuleStatementAssert.java | 8 +---
...reateDefaultShadowAlgorithmStatementAssert.java | 7 +--
...eateDefaultShardingStrategyStatementAssert.java | 8 +---
.../impl/CreateEncryptRuleStatementAssert.java | 6 +--
.../create/impl/CreateMaskRuleStatementAssert.java | 6 +--
...reateReadwriteSplittingRuleStatementAssert.java | 6 +--
.../impl/CreateShadowRuleStatementAssert.java | 6 +--
...eShardingTableReferenceRuleStatementAssert.java | 6 +--
.../CreateShardingTableRuleStatementAssert.java | 6 +--
...faultSingleTableStorageUnitStatementAssert.java | 8 +---
.../DropBroadcastTableRuleStatementAssert.java | 8 +---
...pDatabaseDiscoveryHeartbeatStatementAssert.java | 8 +---
.../DropDatabaseDiscoveryRuleStatementAssert.java | 8 +---
.../DropDatabaseDiscoveryTypeStatementAssert.java | 8 +---
...DropDefaultShardingStrategyStatementAssert.java | 8 +---
.../drop/impl/DropEncryptRuleStatementAssert.java | 8 +---
.../rdl/drop/impl/DropMaskRuleStatementAssert.java | 8 +---
.../DropReadwriteSplittingRuleStatementAssert.java | 8 +---
.../impl/DropShadowAlgorithmStatementAssert.java | 8 +---
.../drop/impl/DropShadowRuleStatementAssert.java | 8 +---
.../impl/DropShardingAlgorithmStatementAssert.java | 6 +--
.../impl/DropShardingAuditorStatementAssert.java | 6 +--
.../DropShardingKeyGeneratorStatementAssert.java | 6 +--
...ShardingTableReferenceRulesStatementAssert.java | 9 ++--
.../impl/DropShardingTableRuleStatementAssert.java | 8 +---
.../rul/impl/sql/FormatSQLStatementAssert.java | 8 +---
.../rul/impl/sql/ParseStatementAssert.java | 8 +---
.../rul/impl/sql/PreviewStatementAssert.java | 8 +---
.../tcl/impl/RollbackStatementAssert.java | 2 +-
86 files changed, 172 insertions(+), 1205 deletions(-)
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTransactionRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ExistingAssert.java
similarity index 65%
rename from test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTransactionRuleStatementAssert.java
rename to test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ExistingAssert.java
index 734f473de43..9520cf5ec2d 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTransactionRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ExistingAssert.java
@@ -15,32 +15,34 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable;
+package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
-import org.apache.shardingsphere.transaction.distsql.parser.statement.updatable.AlterTransactionRuleStatement;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
- * Alter transaction rule statement assert.
+ * Existing assert.
*/
-public final class AlterTransactionRuleStatementAssert {
+public final class ExistingAssert {
/**
- * Assert alter transaction rule statement is correct with expected parser result.
+ * Assert actual SQL statement is correct with expected parser result.
*
* @param assertContext assert context
- * @param actual actual alter transaction rule statement
- * @param expected expected alter transaction rule statement test case
+ * @param actual actual SQL statement
+ * @param expected expected parser result
+ * @return existed or not
*/
- public static void assertIs(final SQLCaseAssertContext assertContext, final AlterTransactionRuleStatement actual, final SQLParserTestCase expected) {
+ public static boolean assertIs(final SQLCaseAssertContext assertContext, final SQLStatement actual, final SQLParserTestCase expected) {
if (null == expected) {
assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ return false;
}
+ assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ return true;
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java
index 36aa8288f5a..7e1128fd80d 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/QueryableRALStatementAssert.java
@@ -35,39 +35,16 @@ import org.apache.shardingsphere.parser.distsql.parser.statement.queryable.ShowS
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowStatusFromReadwriteSplittingRulesStatement;
import org.apache.shardingsphere.sqltranslator.distsql.parser.statement.ShowSQLTranslatorRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ConvertYamlConfigurationStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ExportDatabaseConfigurationStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ExportMetaDataStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ExportStorageNodesStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowAuthorityRuleStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowComputeNodeInfoStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowComputeNodeModeStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowComputeNodesStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowDistVariableStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowDistVariablesStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowSQLParserRuleStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowSQLTranslatorRuleStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowStatusFromReadwriteSplittingRulesStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowTableMetaDataStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowTrafficRulesStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.queryable.ShowTransactionRuleStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ConvertYamlConfigurationStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ExportDatabaseConfigurationStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ExportMetaDataStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ExportStorageNodesStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowAuthorityRuleStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodeInfoStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodeModeStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodesStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariableStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariablesStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowSQLParserRuleStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowSQLTranslatorRuleStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowStatusFromReadwriteSplittingRulesStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTableMetaDataStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTrafficRulesStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTransactionRuleStatementTestCase;
import org.apache.shardingsphere.traffic.distsql.parser.statement.queryable.ShowTrafficRulesStatement;
import org.apache.shardingsphere.transaction.distsql.parser.statement.queryable.ShowTransactionRuleStatement;
@@ -88,34 +65,33 @@ public final class QueryableRALStatementAssert {
if (actual instanceof ShowDistVariableStatement) {
ShowDistVariableStatementAssert.assertIs(assertContext, (ShowDistVariableStatement) actual, (ShowDistVariableStatementTestCase) expected);
} else if (actual instanceof ShowDistVariablesStatement) {
- ShowDistVariablesStatementAssert.assertIs(assertContext, (ShowDistVariablesStatement) actual, (ShowDistVariablesStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowComputeNodesStatement) {
- ShowComputeNodesStatementAssert.assertIs(assertContext, (ShowComputeNodesStatement) actual, (ShowComputeNodesStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowStatusFromReadwriteSplittingRulesStatement) {
- ShowStatusFromReadwriteSplittingRulesStatementAssert.assertIs(assertContext, (ShowStatusFromReadwriteSplittingRulesStatement) actual,
- (ShowStatusFromReadwriteSplittingRulesStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowTableMetaDataStatement) {
ShowTableMetaDataStatementAssert.assertIs(assertContext, (ShowTableMetaDataStatement) actual, (ShowTableMetaDataStatementTestCase) expected);
} else if (actual instanceof ShowAuthorityRuleStatement) {
- ShowAuthorityRuleStatementAssert.assertIs(assertContext, (ShowAuthorityRuleStatement) actual, (ShowAuthorityRuleStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowTransactionRuleStatement) {
- ShowTransactionRuleStatementAssert.assertIs(assertContext, (ShowTransactionRuleStatement) actual, (ShowTransactionRuleStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowTrafficRulesStatement) {
ShowTrafficRulesStatementAssert.assertIs(assertContext, (ShowTrafficRulesStatement) actual, (ShowTrafficRulesStatementTestCase) expected);
} else if (actual instanceof ShowSQLParserRuleStatement) {
- ShowSQLParserRuleStatementAssert.assertIs(assertContext, (ShowSQLParserRuleStatement) actual, (ShowSQLParserRuleStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ExportDatabaseConfigurationStatement) {
- ExportDatabaseConfigurationStatementAssert.assertIs(assertContext, (ExportDatabaseConfigurationStatement) actual, (ExportDatabaseConfigurationStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ExportMetaDataStatement) {
- ExportMetaDataStatementAssert.assertIs(assertContext, (ExportMetaDataStatement) actual, (ExportMetaDataStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ExportStorageNodesStatement) {
- ExportStorageNodesStatementAssert.assertIs(assertContext, (ExportStorageNodesStatement) actual, (ExportStorageNodesStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowSQLTranslatorRuleStatement) {
- ShowSQLTranslatorRuleStatementAssert.assertIs(assertContext, (ShowSQLTranslatorRuleStatement) actual, (ShowSQLTranslatorRuleStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowComputeNodeInfoStatement) {
- ShowComputeNodeInfoStatementAssert.assertIs(assertContext, (ShowComputeNodeInfoStatement) actual, (ShowComputeNodeInfoStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowComputeNodeModeStatement) {
- ShowComputeNodeModeStatementAssert.assertIs(assertContext, (ShowComputeNodeModeStatement) actual, (ShowComputeNodeModeStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ConvertYamlConfigurationStatement) {
ConvertYamlConfigurationStatementAssert.assertIs(assertContext, (ConvertYamlConfigurationStatement) actual, (ConvertYamlConfigurationStatementTestCase) expected);
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/UpdatableRALStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/UpdatableRALStatementAssert.java
index 64a0ebd8fac..6e87186121f 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/UpdatableRALStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/UpdatableRALStatementAssert.java
@@ -20,22 +20,22 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
-import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LockClusterStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.AlterComputeNodeStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.ImportDatabaseConfigurationStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.ImportMetaDataStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LabelComputeNodeStatement;
+import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LockClusterStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.RefreshTableMetaDataStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.SetDistVariableStatement;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.UnlabelComputeNodeStatement;
import org.apache.shardingsphere.parser.distsql.parser.statement.updatable.AlterSQLParserRuleStatement;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.status.AlterReadwriteSplittingStorageUnitStatusStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.AlterComputeNodeStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.AlterReadwriteSplittingStorageUnitStatusStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.AlterSQLParserRuleStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.AlterTrafficRuleStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.AlterTransactionRuleStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.ImportDatabaseConfigurationStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.ImportMetaDataStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.updatable.LabelComputeNodeStatementAssert;
@@ -91,7 +91,7 @@ public final class UpdatableRALStatementAssert {
} else if (actual instanceof ImportMetaDataStatement) {
ImportMetaDataStatementAssert.assertIs(assertContext, (ImportMetaDataStatement) actual, (ImportMetaDataStatementTestCase) expected);
} else if (actual instanceof AlterTransactionRuleStatement) {
- AlterTransactionRuleStatementAssert.assertIs(assertContext, (AlterTransactionRuleStatement) actual, expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof AlterReadwriteSplittingStorageUnitStatusStatement) {
AlterReadwriteSplittingStorageUnitStatusStatementAssert.assertIs(assertContext,
(AlterReadwriteSplittingStorageUnitStatusStatement) actual, (AlterReadwriteSplittingStorageUnitStatusStatementTestCase) expected);
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingListStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingListStatementAssert.java
deleted file mode 100644
index c5cab53e625..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingListStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.cdc;
-
-import org.apache.shardingsphere.cdc.distsql.statement.ShowStreamingListStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.cdc.ShowStreamingListStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show streaming list statement assert.
- */
-public final class ShowStreamingListStatementAssert {
-
- /**
- * Assert show streaming list statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show streaming list statement
- * @param expected expected show streaming list statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowStreamingListStatement actual, final ShowStreamingListStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingStatusStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingStatusStatementAssert.java
index 291e50a3805..1c49f1e821d 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingStatusStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/cdc/ShowStreamingStatusStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.cdc.distsql.statement.ShowStreamingStatusStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.cdc.ShowStreamingStatusStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Show streaming status statement assert.
*/
@@ -38,10 +36,7 @@ public final class ShowStreamingStatusStatementAssert {
* @param expected expected show streaming status statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowStreamingStatusStatement actual, final ShowStreamingStatusStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/JobIdAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/JobIdAssert.java
index fc20c34979c..91210221fbc 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/JobIdAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/JobIdAssert.java
@@ -38,9 +38,9 @@ public final class JobIdAssert {
*/
public static void assertJobId(final SQLCaseAssertContext assertContext, final String actual, final String expected) {
if (null == expected) {
- assertNull(assertContext.getText("Actual job ID should not exist."), actual);
+ assertNull(actual, assertContext.getText("Actual job ID should not exist."));
} else {
- assertNotNull(assertContext.getText("Actual job ID should exist."), actual);
+ assertNotNull(actual, assertContext.getText("Actual job ID should exist."));
assertThat(assertContext.getText("Job ID assertion error."), actual, is(expected));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/QueryableScalingRALStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/QueryableScalingRALStatementAssert.java
index 924d98f4727..cc3ca370419 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/QueryableScalingRALStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/QueryableScalingRALStatementAssert.java
@@ -28,20 +28,13 @@ import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationListSt
import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationSourceStorageUnitsStatement;
import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationStatusStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.cdc.ShowStreamingListStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.cdc.ShowStreamingStatusStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.query.ShowMigrationCheckAlgorithmsStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.query.ShowMigrationCheckStatusStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.query.ShowMigrationListStatementAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.query.ShowMigrationSourceStorageUnitsStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.query.ShowMigrationStatusStatementAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowMigrationListStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.cdc.ShowStreamingListStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.cdc.ShowStreamingStatusStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationCheckAlgorithmsStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationCheckStatusStatementTestCase;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationSourceStorageUnitsStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationStatusStatementTestCase;
/**
@@ -60,17 +53,17 @@ public final class QueryableScalingRALStatementAssert {
public static void assertIs(final SQLCaseAssertContext assertContext, final QueryableScalingRALStatement actual, final SQLParserTestCase expected) {
// TODO add more test case
if (actual instanceof ShowMigrationListStatement) {
- ShowMigrationListStatementAssert.assertIs(assertContext, (ShowMigrationListStatement) actual, (ShowMigrationListStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowMigrationCheckAlgorithmsStatement) {
- ShowMigrationCheckAlgorithmsStatementAssert.assertIs(assertContext, (ShowMigrationCheckAlgorithmsStatement) actual, (ShowMigrationCheckAlgorithmsStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowMigrationCheckStatusStatement) {
ShowMigrationCheckStatusStatementAssert.assertIs(assertContext, (ShowMigrationCheckStatusStatement) actual, (ShowMigrationCheckStatusStatementTestCase) expected);
} else if (actual instanceof ShowMigrationStatusStatement) {
ShowMigrationStatusStatementAssert.assertIs(assertContext, (ShowMigrationStatusStatement) actual, (ShowMigrationStatusStatementTestCase) expected);
} else if (actual instanceof ShowMigrationSourceStorageUnitsStatement) {
- ShowMigrationSourceStorageUnitsStatementAssert.assertIs(assertContext, (ShowMigrationSourceStorageUnitsStatement) actual, (ShowMigrationSourceStorageUnitsStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowStreamingListStatement) {
- ShowStreamingListStatementAssert.assertIs(assertContext, (ShowStreamingListStatement) actual, (ShowStreamingListStatementTestCase) expected);
+ ExistingAssert.assertIs(assertContext, actual, expected);
} else if (actual instanceof ShowStreamingStatusStatement) {
ShowStreamingStatusStatementAssert.assertIs(assertContext, (ShowStreamingStatusStatement) actual, (ShowStreamingStatusStatementTestCase) expected);
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckAlgorithmsStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckAlgorithmsStatementAssert.java
deleted file mode 100644
index c3348207eeb..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckAlgorithmsStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.migration.query;
-
-import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationCheckAlgorithmsStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationCheckAlgorithmsStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show migration check algorithms statement assert.
- */
-public final class ShowMigrationCheckAlgorithmsStatementAssert {
-
- /**
- * Assert show migration check algorithms statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show migration check algorithms statement
- * @param expected expected show migration check algorithms statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowMigrationCheckAlgorithmsStatement actual, final ShowMigrationCheckAlgorithmsStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckStatusStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckStatusStatementAssert.java
index 30a108e00de..7bcd2473173 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckStatusStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationCheckStatusStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationCheckStatusStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationCheckStatusStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Show migration check status statement assert.
*/
@@ -38,10 +36,7 @@ public final class ShowMigrationCheckStatusStatementAssert {
* @param expected expected check migration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowMigrationCheckStatusStatement actual, final ShowMigrationCheckStatusStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationListStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationListStatementAssert.java
deleted file mode 100644
index 04faa8d4ecb..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationListStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.migration.query;
-
-import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationListStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowMigrationListStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show migration list statement assert.
- */
-public final class ShowMigrationListStatementAssert {
-
- /**
- * Assert show migration list statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show migration list statement
- * @param expected expected show migration list statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowMigrationListStatement actual, final ShowMigrationListStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationSourceStorageUnitsStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationSourceStorageUnitsStatementAssert.java
deleted file mode 100644
index 4f2346d67a7..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationSourceStorageUnitsStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.migration.query;
-
-import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationSourceStorageUnitsStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationSourceStorageUnitsStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show migration source storage units statement assert.
- */
-public final class ShowMigrationSourceStorageUnitsStatementAssert {
-
- /**
- * Assert show migration source storage units statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show migration source storage units statement
- * @param expected expected show migration source storage units statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowMigrationSourceStorageUnitsStatement actual, final ShowMigrationSourceStorageUnitsStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationStatusStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationStatusStatementAssert.java
index 6283324bf4d..1ccb53be2bc 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationStatusStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/query/ShowMigrationStatusStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.ShowMigrationStatusStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.ShowMigrationStatusStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Show migration status statement assert.
*/
@@ -38,10 +36,7 @@ public final class ShowMigrationStatusStatementAssert {
* @param expected expected show migration status statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowMigrationStatusStatement actual, final ShowMigrationStatusStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CheckMigrationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CheckMigrationStatementAssert.java
index 63ef3189827..443ffbc6108 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CheckMigrationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CheckMigrationStatementAssert.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.migration.distsql.statement.CheckMigrationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedAlgorithm;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.CheckMigrationStatementTestCase;
@@ -44,10 +45,7 @@ public final class CheckMigrationStatementAssert {
* @param expected expected check migration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CheckMigrationStatement actual, final CheckMigrationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
assertTypeStrategy(assertContext, actual.getTypeStrategy(), expected.getTableStrategies());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CommitMigrationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CommitMigrationStatementAssert.java
index 246232bc7e5..9e9a7806556 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CommitMigrationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/CommitMigrationStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.CommitMigrationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.CommitMigrationStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Commit migration statement assert.
*/
@@ -38,10 +36,7 @@ public final class CommitMigrationStatementAssert {
* @param expected expected statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CommitMigrationStatement actual, final CommitMigrationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/DropMigrationCheckStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/DropMigrationCheckStatementAssert.java
deleted file mode 100644
index b3f94273bb7..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/DropMigrationCheckStatementAssert.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.migration.update;
-
-import org.apache.shardingsphere.migration.distsql.statement.DropMigrationCheckStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.DropMigrationCheckStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Drop migration check statement assert.
- */
-public final class DropMigrationCheckStatementAssert {
-
- /**
- * Assert drop migration check statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual drop migration statement
- * @param expected expected drop migration statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final DropMigrationCheckStatement actual, final DropMigrationCheckStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RegisterMigrationSourceStorageUnitStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RegisterMigrationSourceStorageUnitStatementAssert.java
index 6d5f3366773..1853aceef22 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RegisterMigrationSourceStorageUnitStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RegisterMigrationSourceStorageUnitStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
import org.apache.shardingsphere.migration.distsql.statement.RegisterMigrationSourceStorageUnitStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.DataSourceAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedDataSource;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.RegisterMigrationSourceStorageUnitStatementTestCase;
@@ -49,10 +50,7 @@ public final class RegisterMigrationSourceStorageUnitStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final RegisterMigrationSourceStorageUnitStatement actual,
final RegisterMigrationSourceStorageUnitStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertDataSources(assertContext, actual.getDataSources(), expected.getDataSources());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RollbackMigrationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RollbackMigrationStatementAssert.java
index 9965dc87c08..61fac043cd6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RollbackMigrationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/RollbackMigrationStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.RollbackMigrationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.RollbackMigrationStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Rollback migration statement assert.
*/
@@ -38,10 +36,7 @@ public final class RollbackMigrationStatementAssert {
* @param expected expected statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final RollbackMigrationStatement actual, final RollbackMigrationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationCheckStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationCheckStatementAssert.java
index 68c801b392d..61e9fbdd7a9 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationCheckStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationCheckStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.StartMigrationCheckStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.StartMigrationCheckStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Start migration check statement assert.
*/
@@ -38,10 +36,7 @@ public final class StartMigrationCheckStatementAssert {
* @param expected expected start migration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final StartMigrationCheckStatement actual, final StartMigrationCheckStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationStatementAssert.java
index d049161a49b..95f36b30f3e 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StartMigrationStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.StartMigrationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.StartMigrationStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Start migration statement assert.
*/
@@ -38,10 +36,7 @@ public final class StartMigrationStatementAssert {
* @param expected expected start migration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final StartMigrationStatement actual, final StartMigrationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationCheckStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationCheckStatementAssert.java
index 274d72aa0ea..22554669934 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationCheckStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationCheckStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.StopMigrationCheckStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.StopMigrationCheckStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Stop migration check statement assert.
*/
@@ -38,10 +36,7 @@ public final class StopMigrationCheckStatementAssert {
* @param expected expected start migration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final StopMigrationCheckStatement actual, final StopMigrationCheckStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationStatementAssert.java
index 7bcf7ad334b..04dce7e5a9c 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/migration/update/StopMigrationStatementAssert.java
@@ -19,12 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.migration.distsql.statement.StopMigrationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ral.impl.migration.JobIdAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.migration.StopMigrationStatementTestCase;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
/**
* Stop migration statement assert.
*/
@@ -38,10 +36,7 @@ public final class StopMigrationStatementAssert {
* @param expected expected stop migration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final StopMigrationStatement actual, final StopMigrationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
JobIdAssert.assertJobId(assertContext, actual.getJobId(), expected.getJobId());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ConvertYamlConfigurationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ConvertYamlConfigurationStatementAssert.java
index 137b356033f..676a7438d08 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ConvertYamlConfigurationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ConvertYamlConfigurationStatementAssert.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ConvertYamlConfigurationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ConvertYamlConfigurationStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -38,9 +38,7 @@ public final class ConvertYamlConfigurationStatementAssert {
* @param expected expected convert yaml configuration statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ConvertYamlConfigurationStatement actual, final ConvertYamlConfigurationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should no exist."));
- } else {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getFilePath(), is(expected.getFilePath()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportDatabaseConfigurationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportDatabaseConfigurationStatementAssert.java
deleted file mode 100644
index fff3ee5b8d3..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportDatabaseConfigurationStatementAssert.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportDatabaseConfigurationStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ExportDatabaseConfigurationStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Export database configuration statement assert.
- */
-public final class ExportDatabaseConfigurationStatementAssert {
-
- /**
- * Assert export database configuration statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual export database configuration statement
- * @param expected expected export database configuration statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ExportDatabaseConfigurationStatement actual,
- final ExportDatabaseConfigurationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportMetaDataStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportMetaDataStatementAssert.java
deleted file mode 100644
index 8a07b539224..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportMetaDataStatementAssert.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportMetaDataStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ExportMetaDataStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Export meta data statement assert.
- */
-public final class ExportMetaDataStatementAssert {
-
- /**
- * Assert export meta data statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual export meta data statement
- * @param expected expected export meta data statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ExportMetaDataStatement actual,
- final ExportMetaDataStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportStorageNodesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportStorageNodesStatementAssert.java
deleted file mode 100644
index 369ed359d66..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ExportStorageNodesStatementAssert.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ExportStorageNodesStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ExportStorageNodesStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Export storage nodes statement assert.
- */
-public final class ExportStorageNodesStatementAssert {
-
- /**
- * Assert export storage nodes statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual export storage nodes statement
- * @param expected expected export storage nodes statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ExportStorageNodesStatement actual,
- final ExportStorageNodesStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowAuthorityRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowAuthorityRuleStatementAssert.java
deleted file mode 100644
index abb524976df..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowAuthorityRuleStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.authority.distsql.parser.statement.ShowAuthorityRuleStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowAuthorityRuleStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show authority rule statement assert.
- */
-public final class ShowAuthorityRuleStatementAssert {
-
- /**
- * Assert show authority rule statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show authority rule statement
- * @param expected expected show authority rule statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowAuthorityRuleStatement actual, final ShowAuthorityRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodeInfoStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodeInfoStatementAssert.java
deleted file mode 100644
index b2cc06f4272..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodeInfoStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowComputeNodeInfoStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodeInfoStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show compute node info statement assert.
- */
-public final class ShowComputeNodeInfoStatementAssert {
-
- /**
- * Assert show compute node info statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show compute node info statement
- * @param expected expected show compute node info statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowComputeNodeInfoStatement actual, final ShowComputeNodeInfoStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodeModeStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodeModeStatementAssert.java
deleted file mode 100644
index 163b97bcf6a..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodeModeStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowComputeNodeModeStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodeModeStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show compute node mode statement assert.
- */
-public final class ShowComputeNodeModeStatementAssert {
-
- /**
- * Assert show compute node mode statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show compute node mode statement
- * @param expected expected show compute node mode statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowComputeNodeModeStatement actual, final ShowComputeNodeModeStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodesStatementAssert.java
deleted file mode 100644
index 659d3ed70da..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowComputeNodesStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowComputeNodesStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowComputeNodesStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show compute nodes statement assert.
- */
-public final class ShowComputeNodesStatementAssert {
-
- /**
- * Assert show compute nodes statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show compute nodes statement
- * @param expected expected show compute nodes statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowComputeNodesStatement actual, final ShowComputeNodesStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariableStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariableStatementAssert.java
index 72553dd54c1..4a69e668d14 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariableStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariableStatementAssert.java
@@ -19,11 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowDistVariableStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariableStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -39,10 +38,7 @@ public final class ShowDistVariableStatementAssert {
* @param expected expected show dist variable statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowDistVariableStatement actual, final ShowDistVariableStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getName(), is(expected.getName()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariablesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariablesStatementAssert.java
deleted file mode 100644
index e1eaf18a946..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowDistVariablesStatementAssert.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowDistVariablesStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowDistVariablesStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show dist variables statement assert.
- */
-public final class ShowDistVariablesStatementAssert {
-
- /**
- * Assert show dist variables statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show dist variables statement
- * @param expected expected show dist variables statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowDistVariablesStatement actual, final ShowDistVariablesStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowSQLParserRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowSQLParserRuleStatementAssert.java
deleted file mode 100644
index 7605233fbc7..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowSQLParserRuleStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.parser.distsql.parser.statement.queryable.ShowSQLParserRuleStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowSQLParserRuleStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show SQL parser rule statement assert.
- */
-public final class ShowSQLParserRuleStatementAssert {
-
- /**
- * Assert show SQL parser rule statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show SQL parser rule statement
- * @param expected expected show SQL parser rule statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowSQLParserRuleStatement actual, final ShowSQLParserRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowSQLTranslatorRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowSQLTranslatorRuleStatementAssert.java
deleted file mode 100644
index de6dcccd2f5..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowSQLTranslatorRuleStatementAssert.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.sqltranslator.distsql.parser.statement.ShowSQLTranslatorRuleStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowSQLTranslatorRuleStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show SQL translator rule statement assert.
- */
-public final class ShowSQLTranslatorRuleStatementAssert {
-
- /**
- * Assert show SQL translator rule statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show SQL translator rule statement
- * @param expected expected show SQL translator rule statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowSQLTranslatorRuleStatement actual, final ShowSQLTranslatorRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowStatusFromReadwriteSplittingRulesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowStatusFromReadwriteSplittingRulesStatementAssert.java
deleted file mode 100644
index cf1b18f0c46..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowStatusFromReadwriteSplittingRulesStatementAssert.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowStatusFromReadwriteSplittingRulesStatement;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowStatusFromReadwriteSplittingRulesStatementTestCase;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show status from readwrite-splitting rules statement assert.
- */
-public final class ShowStatusFromReadwriteSplittingRulesStatementAssert {
-
- /**
- * Assert show readwrite-splitting read resources statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show status from readwrite-splitting rules statement
- * @param expected expected show status from readwrite-splitting rules statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowStatusFromReadwriteSplittingRulesStatement actual,
- final ShowStatusFromReadwriteSplittingRulesStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTableMetaDataStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTableMetaDataStatementAssert.java
index 6ed9ea79a63..1233314adc5 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTableMetaDataStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTableMetaDataStatementAssert.java
@@ -20,11 +20,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.ral.queryable.ShowTableMetaDataStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.database.DatabaseAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTableMetaDataStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -39,12 +38,8 @@ public final class ShowTableMetaDataStatementAssert {
* @param actual actual show table meta data statement
* @param expected expected show table meta data statement test case
*/
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowTableMetaDataStatement actual,
- final ShowTableMetaDataStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ public static void assertIs(final SQLCaseAssertContext assertContext, final ShowTableMetaDataStatement actual, final ShowTableMetaDataStatementTestCase expected) {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
DatabaseAssert.assertIs(assertContext, actual.getDatabase().get(), expected.getDatabase());
assertThat(assertContext.getText("Table assertion error:"), actual.getTableNames(), is(expected.getTableNames()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java
index 8065cd6765c..69ab9079dee 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTrafficRulesStatementAssert.java
@@ -20,12 +20,11 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTrafficRulesStatementTestCase;
import org.apache.shardingsphere.traffic.distsql.parser.statement.queryable.ShowTrafficRulesStatement;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class ShowTrafficRulesStatementAssert {
* @param expected expected show traffic rules statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ShowTrafficRulesStatement actual, final ShowTrafficRulesStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Rule name id assertion error"), actual.getRuleName(), is(expected.getRuleName()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTransactionRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTransactionRuleStatementAssert.java
deleted file mode 100644
index 3ed76e95057..00000000000
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/queryable/ShowTransactionRuleStatementAssert.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.it.sql.parser.internal.asserts.statement.ral.impl.queryable;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
-import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ShowTransactionRuleStatementTestCase;
-import org.apache.shardingsphere.transaction.distsql.parser.statement.queryable.ShowTransactionRuleStatement;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Show transaction rule statement assert.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShowTransactionRuleStatementAssert {
-
- /**
- * Assert show transaction rule statement is correct with expected parser result.
- *
- * @param assertContext assert context
- * @param actual actual show transaction rule statement
- * @param expected expected show transaction rule statement test case
- */
- public static void assertIs(final SQLCaseAssertContext assertContext, final ShowTransactionRuleStatement actual, final ShowTransactionRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- }
-}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterComputeNodeStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterComputeNodeStatementAssert.java
index 23d069fb12b..45cdf52209a 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterComputeNodeStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterComputeNodeStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.AlterComputeNodeStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.AlterComputeNodeStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class AlterComputeNodeStatementAssert {
* @param expected expected alter compute node statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterComputeNodeStatement actual, final AlterComputeNodeStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getInstanceId(), is(expected.getInstanceId()));
assertThat(actual.getKey(), is(expected.getKey()));
assertThat(actual.getValue(), is(actual.getValue()));
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterReadwriteSplittingStorageUnitStatusStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterReadwriteSplittingStorageUnitStatusStatementAssert.java
index 4af5f21ca18..f1b9278e4fc 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterReadwriteSplittingStorageUnitStatusStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterReadwriteSplittingStorageUnitStatusStatementAssert.java
@@ -22,14 +22,13 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.status.AlterReadwriteSplittingStorageUnitStatusStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.database.DatabaseAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.DatabaseContainedTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.AlterReadwriteSplittingStorageUnitStatusStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@@ -44,10 +43,7 @@ public final class AlterReadwriteSplittingStorageUnitStatusStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterReadwriteSplittingStorageUnitStatusStatement actual,
final AlterReadwriteSplittingStorageUnitStatusStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getGroupName(), is(expected.getGroupName()));
assertThat(actual.getStorageUnitName(), is(expected.getStorageUnitName()));
assertThat(actual.getStatus(), is(expected.getStatus()));
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterSQLParserRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterSQLParserRuleStatementAssert.java
index 748404b1e01..e0d349056e0 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterSQLParserRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterSQLParserRuleStatementAssert.java
@@ -20,13 +20,14 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.parser.distsql.parser.segment.CacheOptionSegment;
import org.apache.shardingsphere.parser.distsql.parser.statement.updatable.AlterSQLParserRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedCacheOption;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.AlterSQLParserRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.hamcrest.MatcherAssert.assertThat;
/**
* Alter SQL parser rule statement assert.
@@ -41,12 +42,7 @@ public final class AlterSQLParserRuleStatementAssert {
* @param expected expected alter SQL parser rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterSQLParserRuleStatement actual, final AlterSQLParserRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- }
- assertNotNull(actual);
+ ExistingAssert.assertIs(assertContext, actual, expected);
assertCacheOption(assertContext, actual.getParseTreeCache(), expected.getSqlParserRule().getParseTreeCache());
assertCacheOption(assertContext, actual.getSqlStatementCache(), expected.getSqlParserRule().getSqlStatementCache());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTrafficRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTrafficRuleStatementAssert.java
index b2585675d40..33146be93b5 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTrafficRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/AlterTrafficRuleStatementAssert.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AlgorithmAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ral.ExpectedTrafficRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.AlterTrafficRuleStatementTestCase;
import org.apache.shardingsphere.traffic.distsql.parser.segment.TrafficRuleSegment;
@@ -30,8 +31,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -47,22 +46,19 @@ public final class AlterTrafficRuleStatementAssert {
* @param expected expected alter traffic rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterTrafficRuleStatement actual, final AlterTrafficRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertTrafficRuleSegments(assertContext, actual.getSegments(), expected.getRules());
}
}
private static void assertTrafficRuleSegments(final SQLCaseAssertContext assertContext, final Collection<TrafficRuleSegment> actual, final List<ExpectedTrafficRule> expected) {
Map<String, TrafficRuleSegment> actualMap = actual.stream().collect(Collectors.toMap(TrafficRuleSegment::getName, each -> each));
- expected.forEach(each -> {
+ for (ExpectedTrafficRule each : expected) {
TrafficRuleSegment actualRule = actualMap.get(each.getName());
assertThat(actualRule.getName(), is(each.getName()));
assertThat(actualRule.getLabels(), is(each.getLabels()));
AlgorithmAssert.assertIs(assertContext, actualRule.getAlgorithm(), each.getTrafficAlgorithm());
AlgorithmAssert.assertIs(assertContext, actualRule.getLoadBalancer(), each.getLoadBalancer());
- });
+ }
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportDatabaseConfigurationStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportDatabaseConfigurationStatementAssert.java
index 346b06f004f..73aca5c6c48 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportDatabaseConfigurationStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportDatabaseConfigurationStatementAssert.java
@@ -21,10 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.ImportDatabaseConfigurationStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ImportDatabaseConfigurationStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -40,11 +40,8 @@ public final class ImportDatabaseConfigurationStatementAssert {
* @param actual actual import database configuration statement statement
* @param expected expected import configuration database statement statement test case
*/
- public static void assertIs(final SQLCaseAssertContext assertContext, final ImportDatabaseConfigurationStatement actual,
- final ImportDatabaseConfigurationStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
+ public static void assertIs(final SQLCaseAssertContext assertContext, final ImportDatabaseConfigurationStatement actual, final ImportDatabaseConfigurationStatementTestCase expected) {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getFilePath(), is(expected.getFilePath()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportMetaDataStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportMetaDataStatementAssert.java
index c55d764922a..cde22a8cb97 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportMetaDataStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/ImportMetaDataStatementAssert.java
@@ -21,11 +21,11 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.ImportMetaDataStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.ImportMetaDataStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Import meta data statement assert.
@@ -40,11 +40,8 @@ public final class ImportMetaDataStatementAssert {
* @param actual actual import meta data statement
* @param expected expected import meta data statement test case
*/
- public static void assertIs(final SQLCaseAssertContext assertContext, final ImportMetaDataStatement actual,
- final ImportMetaDataStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
+ public static void assertIs(final SQLCaseAssertContext assertContext, final ImportMetaDataStatement actual, final ImportMetaDataStatementTestCase expected) {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getFilePath().get(), is(expected.getFilePath()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LabelComputeNodeStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LabelComputeNodeStatementAssert.java
index dff5ea680f4..f2973fb60dd 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LabelComputeNodeStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LabelComputeNodeStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LabelComputeNodeStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.LabelComputeNodeStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class LabelComputeNodeStatementAssert {
* @param expected expected label compute node statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final LabelComputeNodeStatement actual, final LabelComputeNodeStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.isOverwrite(), is(expected.isOverwrite()));
assertThat(actual.getInstanceId(), is(expected.getInstanceId()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LockClusterStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LockClusterStatementAssert.java
index 3ea10492cea..fadb898e5aa 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LockClusterStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/LockClusterStatementAssert.java
@@ -21,11 +21,11 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LockClusterStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.LockClusterStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Lock cluster statement assert.
@@ -40,11 +40,8 @@ public final class LockClusterStatementAssert {
* @param actual actual lock cluster statement
* @param expected expected lock cluster statement test case
*/
- public static void assertIs(final SQLCaseAssertContext assertContext, final LockClusterStatement actual,
- final LockClusterStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
+ public static void assertIs(final SQLCaseAssertContext assertContext, final LockClusterStatement actual, final LockClusterStatementTestCase expected) {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getLockStrategy(), is(expected.getLockStrategy()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/RefreshTableMetaDataStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/RefreshTableMetaDataStatementAssert.java
index 16a4b4c7be0..6d2493bd764 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/RefreshTableMetaDataStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/RefreshTableMetaDataStatementAssert.java
@@ -19,11 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.RefreshTableMetaDataStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.RefreshTableMetaDataStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -39,10 +38,7 @@ public final class RefreshTableMetaDataStatementAssert {
* @param expected expected refresh table meta data statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final RefreshTableMetaDataStatement actual, final RefreshTableMetaDataStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
if (null != expected.getTableName()) {
assertThat(assertContext.getText("Table name assertion error"), actual.getTableName().get(), is(expected.getTableName()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/UnlabelComputeNodeStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/UnlabelComputeNodeStatementAssert.java
index ae79e626e1b..b6e30ee1008 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/UnlabelComputeNodeStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/ral/impl/updatable/UnlabelComputeNodeStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.UnlabelComputeNodeStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ral.UnlabelComputeNodeStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class UnlabelComputeNodeStatementAssert {
* @param expected expected unlabel compute node statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final UnlabelComputeNodeStatement actual, final UnlabelComputeNodeStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(actual.getInstanceId(), is(expected.getInstanceId()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDatabaseDiscoveryRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDatabaseDiscoveryRuleStatementAssert.java
index 112fa7074ce..f6b233de284 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDatabaseDiscoveryRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDatabaseDiscoveryRuleStatementAssert.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.AlterDatab
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AlgorithmAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.PropertiesAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedDatabaseDiscoveryRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.dbdiscovery.AlterDatabaseDiscoveryRuleStatementTestCase;
@@ -32,8 +33,6 @@ import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Alter database discovery rule statement assert.
@@ -49,10 +48,7 @@ public final class AlterDatabaseDiscoveryRuleStatementAssert {
* @param expected expected alter database discovery rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterDatabaseDiscoveryRuleStatement actual, final AlterDatabaseDiscoveryRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertDatabaseDiscoveryRules(assertContext, actual.getRules(), expected.getRules());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShadowAlgorithmStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShadowAlgorithmStatementAssert.java
index c9300eb8879..50bae4d8aec 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShadowAlgorithmStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShadowAlgorithmStatementAssert.java
@@ -23,11 +23,11 @@ import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowAlgorithmSe
import org.apache.shardingsphere.shadow.distsql.parser.statement.AlterDefaultShadowAlgorithmStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AlgorithmAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedShadowAlgorithm;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.shadow.AlterDefaultShadowAlgorithmStatementTestCase;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Alter default shadow algorithm statement assert.
@@ -43,10 +43,7 @@ public final class AlterDefaultShadowAlgorithmStatementAssert {
* @param expected expected alter default shadow algorithm statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterDefaultShadowAlgorithmStatement actual, final AlterDefaultShadowAlgorithmStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
expected.getAlgorithms().forEach(each -> assertIsAlgorithmsSegment(assertContext, actual.getShadowAlgorithmSegment(), each));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShardingStrategyStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShardingStrategyStatementAssert.java
index 0f09131fcaf..e1aba276255 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShardingStrategyStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterDefaultShardingStrategyStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.AlterDefaultShardingStrategyStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.AlterDefaultShardingStrategyStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class AlterDefaultShardingStrategyStatementAssert {
* @param expected expected alter default sharding strategy statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterDefaultShardingStrategyStatement actual, final AlterDefaultShardingStrategyStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText(String.format("`%s`'s default sharding strategy segment assertion error: ", actual.getClass().getSimpleName())),
actual.getDefaultType(), is(expected.getStrategy().getDefaultType()));
assertThat(assertContext.getText(String.format("`%s`'s default sharding strategy segment assertion error: ", actual.getClass().getSimpleName())),
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterEncryptRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterEncryptRuleStatementAssert.java
index aa820c80098..e7600160573 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterEncryptRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterEncryptRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegme
import org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.EncryptRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedEncryptRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.encrypt.AlterEncryptRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class AlterEncryptRuleStatementAssert {
* @param expected expected alter encrypt rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterEncryptRuleStatement actual, final AlterEncryptRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertEncryptRules(assertContext, actual.getRules(), expected.getRules());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterMaskRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterMaskRuleStatementAssert.java
index 570214bc1d2..58c8d5a6ab4 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterMaskRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterMaskRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.mask.distsql.parser.segment.MaskRuleSegment;
import org.apache.shardingsphere.mask.distsql.parser.statement.AlterMaskRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.MaskRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedMaskRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.mask.AlterMaskRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class AlterMaskRuleStatementAssert {
* @param expected expected alter mask rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterMaskRuleStatement actual, final AlterMaskRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertMaskRules(assertContext, actual.getRules(), expected.getRules());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterReadwriteSplittingRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterReadwriteSplittingRuleStatementAssert.java
index 5dc45538684..b905a016c4f 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterReadwriteSplittingRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterReadwriteSplittingRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.readwritesplitting.distsql.parser.segment.Readw
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.AlterReadwriteSplittingRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.ReadwriteSplittingRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExceptedReadwriteSplittingRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.readwritesplitting.AlterReadwriteSplittingRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class AlterReadwriteSplittingRuleStatementAssert {
* @param expected expected alter readwrite-splitting rule statement result
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterReadwriteSplittingRuleStatement actual, final AlterReadwriteSplittingRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertReadwriteSplittingRule(assertContext, actual.getRules(), expected.getRules());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShadowRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShadowRuleStatementAssert.java
index 8570992f515..b2e4a644ff6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShadowRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShadowRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowRuleSegment
import org.apache.shardingsphere.shadow.distsql.parser.statement.AlterShadowRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.ShadowRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedShadowRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.shadow.AlterShadowRuleStatementTestCase;
@@ -46,10 +47,7 @@ public final class AlterShadowRuleStatementAssert {
* @param expected expected alter shadow rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterShadowRuleStatement actual, final AlterShadowRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertShadowRule(assertContext, actual.getRules(), expected.getRules());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableReferenceRulesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableReferenceRulesStatementAssert.java
index 4b90d823cfe..bb39d64d5fb 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableReferenceRulesStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableReferenceRulesStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.sharding.distsql.parser.segment.table.TableRefe
import org.apache.shardingsphere.sharding.distsql.parser.statement.AlterShardingTableReferenceRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.ShardingTableReferenceRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedShardingTableReferenceRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.AlterShardingTableReferenceRulesStatementTestCase;
@@ -48,10 +49,7 @@ public final class AlterShardingTableReferenceRulesStatementAssert {
* @param expected expected alter sharding table reference rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterShardingTableReferenceRuleStatement actual, final AlterShardingTableReferenceRulesStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertShardingBindingTableRules(assertContext, actual.getRules(), expected.getRules());
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableRuleStatementAssert.java
index e86d77e5564..1b442c98c3d 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/alter/impl/AlterShardingTableRuleStatementAssert.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.sharding.distsql.parser.statement.AlterSharding
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AutoTableRuleAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.TableRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedAutoTableRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedTableRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
@@ -52,10 +53,7 @@ public final class AlterShardingTableRuleStatementAssert {
* @param expected expected alter sharding table rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final AlterShardingTableRuleStatement actual, final SQLParserTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
if (expected instanceof AlterShardingAutoTableRuleStatementTestCase) {
AlterShardingAutoTableRuleStatementTestCase autoTableRuleStatementTestCase = (AlterShardingAutoTableRuleStatementTestCase) expected;
Collection<AutoTableRuleSegment> actualAutoTableRules = actual.getRules().stream().map(each -> (AutoTableRuleSegment) each).collect(Collectors.toList());
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateBroadcastTableRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateBroadcastTableRuleStatementAssert.java
index 514fc40d69d..54b8b0dc610 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateBroadcastTableRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateBroadcastTableRuleStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateBroadcastTableRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.CreateBroadcastTableRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class CreateBroadcastTableRuleStatementAssert {
* @param expected expected create broadcast table rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateBroadcastTableRuleStatement actual, final CreateBroadcastTableRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertThat(assertContext.getText("create broadcast table rule assertion error: "), actual.getTables(), is(expected.getTables()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDatabaseDiscoveryRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDatabaseDiscoveryRuleStatementAssert.java
index 12a1b488a29..6910d0178ad 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDatabaseDiscoveryRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDatabaseDiscoveryRuleStatementAssert.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.CreateData
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AlgorithmAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.PropertiesAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedDatabaseDiscoveryRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.dbdiscovery.CreateDatabaseDiscoveryRuleStatementTestCase;
@@ -32,8 +33,6 @@ import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Create database discovery rule statement assert.
@@ -49,10 +48,7 @@ public final class CreateDatabaseDiscoveryRuleStatementAssert {
* @param expected expected create database discovery rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateDatabaseDiscoveryRuleStatement actual, final CreateDatabaseDiscoveryRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertDatabaseDiscoveryRules(assertContext, actual.getRules(), expected.getRules());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShadowAlgorithmStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShadowAlgorithmStatementAssert.java
index 5cc3ceadb90..9a805ce2e0f 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShadowAlgorithmStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShadowAlgorithmStatementAssert.java
@@ -23,13 +23,13 @@ import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowAlgorithmSe
import org.apache.shardingsphere.shadow.distsql.parser.statement.CreateDefaultShadowAlgorithmStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AlgorithmAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedShadowAlgorithm;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.shadow.CreateDefaultShadowAlgorithmStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Create default shadow algorithm statement assert.
@@ -45,10 +45,7 @@ public final class CreateDefaultShadowAlgorithmStatementAssert {
* @param expected expected create default shadow algorithm statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateDefaultShadowAlgorithmStatement actual, final CreateDefaultShadowAlgorithmStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
expected.getAlgorithms().forEach(each -> assertIsAlgorithmsSegment(assertContext, actual.getShadowAlgorithmSegment(), each));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShardingStrategyStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShardingStrategyStatementAssert.java
index d5350aa3a05..cfa5ad8675c 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShardingStrategyStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateDefaultShardingStrategyStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateDefaultShardingStrategyStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.CreateDefaultShardingStrategyStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class CreateDefaultShardingStrategyStatementAssert {
* @param expected expected create default sharding strategy statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateDefaultShardingStrategyStatement actual, final CreateDefaultShardingStrategyStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertThat(assertContext.getText(String.format("`%s`'s default sharding strategy segment assertion error: ", actual.getClass().getSimpleName())),
actual.getDefaultType(), is(expected.getStrategy().getDefaultType()));
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateEncryptRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateEncryptRuleStatementAssert.java
index 8eca6b54a37..7922f0fa68f 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateEncryptRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateEncryptRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegme
import org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.EncryptRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedEncryptRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.encrypt.CreateEncryptRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class CreateEncryptRuleStatementAssert {
* @param expected expected create encrypt rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateEncryptRuleStatement actual, final CreateEncryptRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertEncryptRules(assertContext, actual.getRules(), expected.getRules());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateMaskRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateMaskRuleStatementAssert.java
index e813a9738a8..f4e4de5fb9c 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateMaskRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateMaskRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.mask.distsql.parser.segment.MaskRuleSegment;
import org.apache.shardingsphere.mask.distsql.parser.statement.CreateMaskRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.MaskRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedMaskRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.mask.CreateMaskRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class CreateMaskRuleStatementAssert {
* @param expected expected create mask rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateMaskRuleStatement actual, final CreateMaskRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertMaskRules(assertContext, actual.getRules(), expected.getRules());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateReadwriteSplittingRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateReadwriteSplittingRuleStatementAssert.java
index d79cfc3f65e..d0d1440e5cb 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateReadwriteSplittingRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateReadwriteSplittingRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.readwritesplitting.distsql.parser.segment.Readw
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.CreateReadwriteSplittingRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.ReadwriteSplittingRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExceptedReadwriteSplittingRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.readwritesplitting.CreateReadwriteSplittingRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class CreateReadwriteSplittingRuleStatementAssert {
* @param expected expected create readwrite-splitting rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateReadwriteSplittingRuleStatement actual, final CreateReadwriteSplittingRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertReadwriteSplittingRule(assertContext, actual.getRules(), expected.getRules());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShadowRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShadowRuleStatementAssert.java
index 5d5894bb199..73f4fe4b7ce 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShadowRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShadowRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowRuleSegment
import org.apache.shardingsphere.shadow.distsql.parser.statement.CreateShadowRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.ShadowRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedShadowRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.shadow.CreateShadowRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class CreateShadowRuleStatementAssert {
* @param expected expected create shadow rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateShadowRuleStatement actual, final CreateShadowRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertShadowRule(assertContext, actual.getRules(), expected.getRules());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableReferenceRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableReferenceRuleStatementAssert.java
index 19187580c23..433c97800cb 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableReferenceRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableReferenceRuleStatementAssert.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.sharding.distsql.parser.segment.table.TableRefe
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingTableReferenceRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.rdl.ShardingTableReferenceRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.rdl.ExpectedShardingTableReferenceRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.CreateShardingTableReferenceRuleStatementTestCase;
@@ -48,10 +49,7 @@ public final class CreateShardingTableReferenceRuleStatementAssert {
* @param expected expected create sharding table reference rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateShardingTableReferenceRuleStatement actual, final CreateShardingTableReferenceRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(expected.isIfNotExists()));
assertShardingBindingTableRules(assertContext, actual.getRules(), expected.getRules());
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableRuleStatementAssert.java
index 238b56dfe03..6dd6879e0e6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/CreateShardingTableRuleStatementAssert.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardin
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.AutoTableRuleAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.segment.distsql.TableRuleAssert;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedAutoTableRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.segment.impl.distsql.ExpectedTableRule;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
@@ -54,10 +55,7 @@ public final class CreateShardingTableRuleStatementAssert {
* @param expected expected create sharding table rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final CreateShardingTableRuleStatement actual, final SQLParserTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
if (expected instanceof CreateShardingAutoTableRuleStatementTestCase) {
CreateShardingAutoTableRuleStatementTestCase autoTableRuleStatementTestCase = (CreateShardingAutoTableRuleStatementTestCase) expected;
assertThat(assertContext.getText("if not exists segment assertion error: "), actual.isIfNotExists(), is(autoTableRuleStatementTestCase.isIfNotExists()));
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/SetDefaultSingleTableStorageUnitStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/SetDefaultSingleTableStorageUnitStatementAssert.java
index beae8dbc471..349bf131611 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/SetDefaultSingleTableStorageUnitStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/create/impl/SetDefaultSingleTableStorageUnitStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.rdl.create.SetDefaultSingleTableStorageUnitStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.single.SetDefaultSingleTableStorageUnitStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -43,10 +42,7 @@ public final class SetDefaultSingleTableStorageUnitStatementAssert {
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final SetDefaultSingleTableStorageUnitStatement actual,
final SetDefaultSingleTableStorageUnitStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText(String.format("`%s`'s default data source assertion error: ", actual.getClass().getSimpleName())),
actual.getDefaultStorageUnit(), is(expected.getDefaultStorageUnit()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropBroadcastTableRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropBroadcastTableRuleStatementAssert.java
index 6527cab05e4..3190fc97473 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropBroadcastTableRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropBroadcastTableRuleStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropBroadcastTableRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropBroadcastTableRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropBroadcastTableRuleStatementAssert {
* @param expected expected drop broadcast table rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropBroadcastTableRuleStatement actual, final DropBroadcastTableRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("broadcast table rule assertion error: "), actual.getTables(), is(expected.getTables()));
assertThat(assertContext.getText("broadcast table rule assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryHeartbeatStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryHeartbeatStatementAssert.java
index 8659dd8db84..9e1ffab5b9d 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryHeartbeatStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryHeartbeatStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryHeartbeatStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.dbdiscovery.DropDatabaseDiscoveryHeartbeatStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropDatabaseDiscoveryHeartbeatStatementAssert {
* @param expected expected drop database discovery heartbeat statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropDatabaseDiscoveryHeartbeatStatement actual, final DropDatabaseDiscoveryHeartbeatStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("database discovery heartbeat assertion error: "), actual.getNames(), is(expected.getHeartbeats()));
assertThat(assertContext.getText("database discovery heartbeat assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryRuleStatementAssert.java
index 6741f1587af..9fe3050896a 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryRuleStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.dbdiscovery.DropDatabaseDiscoveryRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropDatabaseDiscoveryRuleStatementAssert {
* @param expected expected drop database discovery rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropDatabaseDiscoveryRuleStatement actual, final DropDatabaseDiscoveryRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("database discovery rule assertion error: "), actual.getNames(), is(expected.getNames()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryTypeStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryTypeStatementAssert.java
index aae5345b45c..74fe93ca2f6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryTypeStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDatabaseDiscoveryTypeStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.dbdiscovery.distsql.parser.statement.DropDatabaseDiscoveryTypeStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.dbdiscovery.DropDatabaseDiscoveryTypeStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropDatabaseDiscoveryTypeStatementAssert {
* @param expected expected drop database discovery type statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropDatabaseDiscoveryTypeStatement actual, final DropDatabaseDiscoveryTypeStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("database discovery type assertion error: "), actual.getTypes(), is(expected.getTypes()));
assertThat(assertContext.getText("database discovery type assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDefaultShardingStrategyStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDefaultShardingStrategyStatementAssert.java
index 001bdeff8e8..c7620eb7008 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDefaultShardingStrategyStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropDefaultShardingStrategyStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropDefaultShardingStrategyStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropDefaultShardingStrategyStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropDefaultShardingStrategyStatementAssert {
* @param expected expected drop default sharding strategy statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropDefaultShardingStrategyStatement actual, final DropDefaultShardingStrategyStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("default sharding strategy assertion error: "), actual.getDefaultType(), is(expected.getDefaultType()));
assertThat(assertContext.getText("default sharding strategy assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropEncryptRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropEncryptRuleStatementAssert.java
index 38bbe1bb49f..f618c88ce85 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropEncryptRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropEncryptRuleStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.encrypt.distsql.parser.statement.DropEncryptRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.encrypt.DropEncryptRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropEncryptRuleStatementAssert {
* @param expected expected drop encrypt rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropEncryptRuleStatement actual, final DropEncryptRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("encrypt rule assertion error: "), actual.getTables(), is(expected.getRuleNames()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropMaskRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropMaskRuleStatementAssert.java
index 24024d20208..4e12f8f7835 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropMaskRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropMaskRuleStatementAssert.java
@@ -21,12 +21,11 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.mask.distsql.parser.statement.DropMaskRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.mask.DropMaskRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Drop mask rule statement assert.
@@ -42,10 +41,7 @@ public final class DropMaskRuleStatementAssert {
* @param expected expected drop mask rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropMaskRuleStatement actual, final DropMaskRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Mask rule assertion error: "), actual.getTables(), is(expected.getRuleNames()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropReadwriteSplittingRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropReadwriteSplittingRuleStatementAssert.java
index 419dd0a5048..63b9bbe1e76 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropReadwriteSplittingRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropReadwriteSplittingRuleStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.DropReadwriteSplittingRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.readwritesplitting.DropReadwriteSplittingRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropReadwriteSplittingRuleStatementAssert {
* @param expected expected drop readwrite-splitting rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropReadwriteSplittingRuleStatement actual, final DropReadwriteSplittingRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("readwrite splitting assertion error: "), actual.getNames(), is(expected.getNames()));
assertThat(assertContext.getText("readwrite splitting assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowAlgorithmStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowAlgorithmStatementAssert.java
index 2ad761de5c9..dac0627569e 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowAlgorithmStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowAlgorithmStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.shadow.distsql.parser.statement.DropShadowAlgorithmStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.shadow.DropShadowAlgorithmStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropShadowAlgorithmStatementAssert {
* @param expected expected drop shadow algorithm statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShadowAlgorithmStatement actual, final DropShadowAlgorithmStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Shadow rule assertion error: "), actual.getNames(), is(expected.getNames()));
assertThat(assertContext.getText("Shadow rule assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowRuleStatementAssert.java
index b8124d1e2e9..be8644c7ec1 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShadowRuleStatementAssert.java
@@ -21,11 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.shadow.distsql.parser.statement.DropShadowRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.shadow.DropShadowRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -42,10 +41,7 @@ public final class DropShadowRuleStatementAssert {
* @param expected expected drop shadow rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShadowRuleStatement actual, final DropShadowRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Shadow rule assertion error: "), actual.getNames(), is(expected.getRuleNames()));
assertThat(assertContext.getText("Shadow rule assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAlgorithmStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAlgorithmStatementAssert.java
index 62f7f1fef2c..f5934c5ffd6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAlgorithmStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAlgorithmStatementAssert.java
@@ -21,10 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAlgorithmStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropShardingAlgorithmStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -41,9 +41,7 @@ public final class DropShardingAlgorithmStatementAssert {
* @param expected expected drop sharding algorithm statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShardingAlgorithmStatement actual, final DropShardingAlgorithmStatementTestCase expected) {
- if (null == expected.getNames()) {
- assertNull(actual, assertContext.getText("Actual algorithm should not exist."));
- } else {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Algorithm names assertion error: "), actual.getNames(), is(expected.getNames()));
assertThat(assertContext.getText("Contains exist clause assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAuditorStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAuditorStatementAssert.java
index 7834b79a61b..a3e8a840689 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAuditorStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingAuditorStatementAssert.java
@@ -21,10 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingAuditorStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropShardingAuditorStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -41,9 +41,7 @@ public final class DropShardingAuditorStatementAssert {
* @param expected expected drop sharding auditor statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShardingAuditorStatement actual, final DropShardingAuditorStatementTestCase expected) {
- if (null == expected.getNames()) {
- assertNull(actual, assertContext.getText("Actual auditor name should not exist."));
- } else {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Auditor names assertion error: "), actual.getNames(), is(expected.getNames()));
assertThat(assertContext.getText("Contains exist clause assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingKeyGeneratorStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingKeyGeneratorStatementAssert.java
index 1e53510f536..b0882367ae9 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingKeyGeneratorStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingKeyGeneratorStatementAssert.java
@@ -21,10 +21,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingKeyGeneratorStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropShardingKeyGeneratorStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -41,9 +41,7 @@ public final class DropShardingKeyGeneratorStatementAssert {
* @param expected expected drop sharding key generator statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShardingKeyGeneratorStatement actual, final DropShardingKeyGeneratorStatementTestCase expected) {
- if (null == expected.getNames()) {
- assertNull(actual, assertContext.getText("Actual key generator name should not exist."));
- } else {
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Key generator names assertion error: "), actual.getNames(), is(expected.getNames()));
assertThat(assertContext.getText("Contains exist clause assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableReferenceRulesStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableReferenceRulesStatementAssert.java
index 12e2f078404..a3f53b6078e 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableReferenceRulesStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableReferenceRulesStatementAssert.java
@@ -21,11 +21,11 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingTableReferenceRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropShardingTableReferenceRuleStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Drop sharding table reference rule statement assert.
@@ -41,8 +41,9 @@ public final class DropShardingTableReferenceRulesStatementAssert {
* @param expected expected drop sharding table reference rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShardingTableReferenceRuleStatement actual, final DropShardingTableReferenceRuleStatementTestCase expected) {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
- assertThat(assertContext.getText("Sharding table reference rule assertion error: "), actual.getNames(), is(expected.getRuleNames()));
- assertThat(assertContext.getText("Sharding table reference rule assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
+ assertThat(assertContext.getText("Sharding table reference rule assertion error: "), actual.getNames(), is(expected.getRuleNames()));
+ assertThat(assertContext.getText("Sharding table reference rule assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
+ }
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableRuleStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableRuleStatementAssert.java
index 190c2e592f9..19a53f98706 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableRuleStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rdl/drop/impl/DropShardingTableRuleStatementAssert.java
@@ -21,13 +21,12 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sharding.distsql.parser.statement.DropShardingTableRuleStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rdl.rule.sharding.DropShardingTableRuleStatementTestCase;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -44,10 +43,7 @@ public final class DropShardingTableRuleStatementAssert {
* @param expected expected drop sharding table rule statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DropShardingTableRuleStatement actual, final DropShardingTableRuleStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("Sharding table rule assertion error: "), actual.getTableNames().stream().map(each -> each.getIdentifier().getValue()).collect(Collectors.toList()),
is(expected.getRuleNames()));
assertThat(assertContext.getText("Sharding table rule assertion error: "), actual.isIfExists(), is(expected.isIfExists()));
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/FormatSQLStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/FormatSQLStatementAssert.java
index ba43b3112ab..48429fd3ccd 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/FormatSQLStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/FormatSQLStatementAssert.java
@@ -19,11 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.rul.sql.FormatStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rul.FormatSQLStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -39,10 +38,7 @@ public final class FormatSQLStatementAssert {
* @param expected expected format SQL statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final FormatStatement actual, final FormatSQLStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("SQL assertion error"), actual.getSql(), is(expected.getSql()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/ParseStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/ParseStatementAssert.java
index bfa06e9f55a..aae1f4690bb 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/ParseStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/ParseStatementAssert.java
@@ -19,11 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.rul.sql.ParseStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rul.ParseStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -39,10 +38,7 @@ public final class ParseStatementAssert {
* @param expected expected parse statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final ParseStatement actual, final ParseStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("SQL assertion error"), actual.getSql(), is(expected.getSql()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/PreviewStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/PreviewStatementAssert.java
index 58355fa4b81..e63d2b5ed78 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/PreviewStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/rul/impl/sql/PreviewStatementAssert.java
@@ -19,11 +19,10 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import org.apache.shardingsphere.distsql.parser.statement.rul.sql.PreviewStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
+import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ExistingAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.rul.PreviewStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
/**
@@ -39,10 +38,7 @@ public final class PreviewStatementAssert {
* @param expected expected preview statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final PreviewStatement actual, final PreviewStatementTestCase expected) {
- if (null == expected) {
- assertNull(actual, assertContext.getText("Actual statement should not exist."));
- } else {
- assertNotNull(actual, assertContext.getText("Actual statement should exist."));
+ if (ExistingAssert.assertIs(assertContext, actual, expected)) {
assertThat(assertContext.getText("SQL assertion error"), actual.getSql(), is(expected.getSql()));
}
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/tcl/impl/RollbackStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/tcl/impl/RollbackStatementAssert.java
index 4b19795618e..349bf7b7963 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/tcl/impl/RollbackStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/tcl/impl/RollbackStatementAssert.java
@@ -24,8 +24,8 @@ import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAsse
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.tcl.RollbackStatementTestCase;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**