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

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new adaaebf27c6 Add Unit tests for InsertCipherNameTokenGenerator (#19507)
adaaebf27c6 is described below

commit adaaebf27c6be96be4d6655c3a95ce7c27536a5a
Author: Sushant Srivastava <[email protected]>
AuthorDate: Mon Jul 25 16:53:20 2022 +0530

    Add Unit tests for InsertCipherNameTokenGenerator (#19507)
    
    * Add Test for InsertCipherNameTokenGenerator
    
    * Added Unit Tests
    
    * Fix Checkstyle Errors
---
 .../InsertCipherNameTokenGeneratorTest.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/token/generator/InsertCipherNameTokenGeneratorTest.java
 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/InsertCipherNameTokenGeneratorTest.java
new file mode 100644
index 00000000000..b3b38248f53
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/InsertCipherNameTokenGeneratorTest.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.token.generator;
+
+import org.apache.shardingsphere.encrypt.rule.EncryptRule;
+import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class InsertCipherNameTokenGeneratorTest extends 
EncryptGeneratorBaseTest {
+    
+    private InsertCipherNameTokenGenerator generator;
+    
+    @Before
+    public void setup() {
+        generator = new InsertCipherNameTokenGenerator();
+        generator.setEncryptRule(new 
EncryptRule(createEncryptRuleConfiguration()));
+    }
+    
+    @Test
+    public void assertIsNotGenerateSQLTokenWithNotInsertStatement() {
+        
assertFalse(generator.isGenerateSQLToken(mock(SelectStatementContext.class)));
+    }
+    
+    @Test
+    public void assertIsGenerateSQLTokenWithInsertStatementContext() {
+        
assertTrue(generator.isGenerateSQLToken(createInsertStatementContext(Collections.emptyList())));
+    }
+    
+    @Test
+    public void assertGenerateSQLTokensWithInsertStatementContext() {
+        Collection<?> tokens = 
generator.generateSQLTokens(createInsertStatementContext(Collections.emptyList()));
+        assertThat(tokens.size(), is(1));
+    }
+}

Reply via email to