You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/01/21 08:30:39 UTC

[shardingsphere] branch master updated: Add more unit test for EncryptSQLRewriteContextDecorator (#14979)

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

menghaoran 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 25baca1  Add more unit test for EncryptSQLRewriteContextDecorator (#14979)
25baca1 is described below

commit 25baca1ff168a4ec9eee49e89641339f4b004a86
Author: liguoping <xd...@163.com>
AuthorDate: Fri Jan 21 16:29:36 2022 +0800

    Add more unit test for EncryptSQLRewriteContextDecorator (#14979)
    
    * Add more unit test for EncryptSQLRewriteContextDecorator
    
    * private final
---
 .../EncryptSQLRewriteContextDecoratorTest.java     | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java
new file mode 100644
index 0000000..2290fd3
--- /dev/null
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/impl/EncryptSQLRewriteContextDecoratorTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.rewrite.impl;
+
+import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
+import org.apache.shardingsphere.encrypt.rewrite.context.EncryptSQLRewriteContextDecorator;
+import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContext;
+import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.junit.Test;
+
+import java.util.Objects;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class EncryptSQLRewriteContextDecoratorTest {
+    
+    private final EncryptSQLRewriteContextDecorator encryptSQLRewriteContextDecorator = new EncryptSQLRewriteContextDecorator();
+    
+    @Test
+    public void assertDecorate() {
+        EncryptRule encryptRule = mock(EncryptRule.class);
+        ConfigurationProperties configurationProperties = mock(ConfigurationProperties.class);
+        SQLRewriteContext sqlRewriteContext = mock(SQLRewriteContext.class);
+        RouteContext routeContext = mock(RouteContext.class);
+        encryptSQLRewriteContextDecorator.decorate(encryptRule, configurationProperties, sqlRewriteContext, routeContext);
+        assertTrue(Objects.nonNull(sqlRewriteContext.getSqlTokens()));
+    }
+    
+    @Test
+    public void assertOrder() {
+        assertThat(encryptSQLRewriteContextDecorator.getOrder(), is(EncryptOrder.ORDER));
+    }
+    
+    @Test
+    public void assertTypeClass() {
+        assertThat(encryptSQLRewriteContextDecorator.getTypeClass(), equalTo(EncryptRule.class));
+    }
+}