This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new e724b5a91f4 Fix test case error (#20415)
e724b5a91f4 is described below
commit e724b5a91f4ec968515523b0b138296d7befe2d8
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 22 20:04:32 2022 +0800
Fix test case error (#20415)
* Add EncryptLogicColumnNotFoundException
* Fix test case error
---
.../user-manual/error-code/sql-error-code.cn.md | 1 +
.../user-manual/error-code/sql-error-code.en.md | 1 +
.../EncryptLogicColumnNotFoundException.java | 33 ++++++++++++++++++++++
.../shardingsphere/encrypt/rule/EncryptTable.java | 6 ++--
.../encrypt/rule/EncryptTableTest.java | 6 ++--
5 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index b49a776f249..c77cd9b1017 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -27,5 +27,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HY004 | 24001 | The SQL clause \`%s\` is unsupported in encrypt
rule |
| 44000 | 24002 | Altered column \`%s\` must use same encrypt
algorithm with previous column \`%s\` in table \`%s\` |
| 42000 | 24003 | Insert value of index \`%s\` can not support for
encrypt |
+| 44000 | 24004 | Can not find logic encrypt column by \`%s\` |
| HY004 | 25000 | Shadow column \`%s\` of table \`%s\` does not
support \`%s\` type |
| 42000 | 30000 | Unknown exception: %s |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 716a4d4fe1c..e66a02fe5e4 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -27,5 +27,6 @@ SQL error codes provide by standard `SQL State`, `Vendor
Code` and `Reason`, whi
| HY004 | 24001 | The SQL clause \`%s\` is unsupported in encrypt
rule |
| 44000 | 24002 | Altered column \`%s\` must use same encrypt
algorithm with previous column \`%s\` in table \`%s\` |
| 42000 | 24003 | Insert value of index \`%s\` can not support for
encrypt |
+| 44000 | 24004 | Can not find logic encrypt column by \`%s\` |
| HY004 | 25000 | Shadow column \`%s\` of table \`%s\` does not
support \`%s\` type |
| 42000 | 30000 | Unknown exception: %s |
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/exception/EncryptLogicColumnNotFoundException.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/exception/EncryptLogicColumnNotFoundException.java
new file mode 100644
index 00000000000..a5aa8e97978
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/exception/EncryptLogicColumnNotFoundException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.encrypt.exception;
+
+import
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
+import
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
+
+/**
+ * Encrypt logic column not found exception.
+ */
+public final class EncryptLogicColumnNotFoundException extends
ShardingSphereSQLException {
+
+ private static final long serialVersionUID = 3934531389314348880L;
+
+ public EncryptLogicColumnNotFoundException(final String actualColumn) {
+ super(XOpenSQLState.CHECK_OPTION_VIOLATION, 24004, "Can not find logic
encrypt column by `%s`", actualColumn);
+ }
+}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
index db22488607d..95ac33ccda5 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptTable.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.encrypt.rule;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+import
org.apache.shardingsphere.encrypt.exception.EncryptLogicColumnNotFoundException;
import java.util.Collection;
import java.util.HashMap;
@@ -88,7 +88,7 @@ public final class EncryptTable {
return entry.getKey();
}
}
- throw new ShardingSphereException("Can not find logic column by %s.",
cipherColumn);
+ throw new EncryptLogicColumnNotFoundException(cipherColumn);
}
/**
@@ -103,7 +103,7 @@ public final class EncryptTable {
return entry.getKey();
}
}
- throw new ShardingSphereException("Can not find logic column by %s.",
plainColumn);
+ throw new EncryptLogicColumnNotFoundException(plainColumn);
}
/**
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
index 14119ea7caf..8706c0f8c98 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rule/EncryptTableTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.encrypt.rule;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+import
org.apache.shardingsphere.encrypt.exception.EncryptLogicColumnNotFoundException;
import org.junit.Before;
import org.junit.Test;
@@ -62,7 +62,7 @@ public final class EncryptTableTest {
assertNotNull(encryptTable.getLogicColumnByCipherColumn("cipherColumn"));
}
- @Test(expected = ShardingSphereException.class)
+ @Test(expected = EncryptLogicColumnNotFoundException.class)
public void assertGetLogicColumnByCipherColumnWhenNotFind() {
encryptTable.getLogicColumnByCipherColumn("invalidColumn");
}
@@ -72,7 +72,7 @@ public final class EncryptTableTest {
assertNotNull(encryptTable.getLogicColumnByPlainColumn("plainColumn"));
}
- @Test(expected = ShardingSphereException.class)
+ @Test(expected = EncryptLogicColumnNotFoundException.class)
public void assertGetLogicColumnByPlainColumnWhenNotFind() {
encryptTable.getLogicColumnByPlainColumn("invalidColumn");
}