You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/04/20 05:47:13 UTC

[shardingsphere] branch master updated: Add generic type for EncryptAlgorithm usage (#16944)

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

panjuan 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 26c63a954b1 Add generic type for EncryptAlgorithm usage (#16944)
26c63a954b1 is described below

commit 26c63a954b17e16b3a523e493745e6058e4be384
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Apr 20 13:46:56 2022 +0800

    Add generic type for EncryptAlgorithm usage (#16944)
    
    * Add generic type for EncryptAlgorithm usage
    
    * Add generic type for EncryptAlgorithm usage
---
 .../config/AlgorithmProvidedEncryptRuleConfiguration.java   |  2 +-
 .../rewriter/EncryptInsertValueParameterRewriter.java       |  2 +-
 .../token/generator/EncryptInsertValuesTokenGenerator.java  |  8 +++++---
 .../encrypt/algorithm/AESEncryptAlgorithmTest.java          |  2 +-
 .../encrypt/algorithm/MD5EncryptAlgorithmTest.java          |  4 ++--
 .../encrypt/algorithm/RC4EncryptAlgorithmTest.java          |  2 +-
 .../encrypt/algorithm/SM3EncryptAlgorithmTest.java          |  2 +-
 .../encrypt/algorithm/SM4EncryptAlgorithmTest.java          |  2 +-
 ...lgorithmProvidedEncryptRuleConfigurationCheckerTest.java |  2 +-
 .../encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java     |  8 ++------
 .../encrypt/merge/dql/EncryptMergedResultTest.java          |  6 ++++--
 .../rewrite/token/EncryptAssignmentTokenGeneratorTest.java  | 13 +++++++------
 ...ptRuleAlgorithmProviderConfigurationYamlSwapperTest.java |  3 +--
 .../spring/boot/EncryptRuleSpringBootConfiguration.java     |  2 +-
 .../encrypt/spring/boot/EncryptSpringBootStarterTest.java   |  2 +-
 .../spring/namespace/EncryptSpringNamespaceTest.java        |  6 +++---
 16 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
index 4db7c15e9d0..fc3571b8b73 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/config/AlgorithmProvidedEncryptRuleConfiguration.java
@@ -42,7 +42,7 @@ public final class AlgorithmProvidedEncryptRuleConfiguration implements SchemaRu
     
     private Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
     
-    private Map<String, EncryptAlgorithm> encryptors = new LinkedHashMap<>();
+    private Map<String, EncryptAlgorithm<?, ?>> encryptors = new LinkedHashMap<>();
     
     private boolean queryWithCipherColumn = true;
 }
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
index 77b543933a6..51caf70d503 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
@@ -73,7 +73,7 @@ public final class EncryptInsertValueParameterRewriter implements ParameterRewri
     }
     
     private void encryptInsertValues(final GroupedParameterBuilder parameterBuilder, final InsertStatementContext insertStatementContext, 
-                                     final EncryptAlgorithm encryptAlgorithm, final EncryptContext encryptContext) {
+                                     final EncryptAlgorithm<?, ?> encryptAlgorithm, final EncryptContext encryptContext) {
         int columnIndex = getColumnIndex(parameterBuilder, insertStatementContext, encryptContext.getColumnName());
         int count = 0;
         for (List<Object> each : insertStatementContext.getGroupedParameters()) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java
index 4e1734b9a48..16d30b094a2 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptInsertValuesTokenGenerator.java
@@ -149,11 +149,12 @@ public final class EncryptInsertValuesTokenGenerator implements OptionalSQLToken
         }
     }
     
-    private void addAssistedQueryColumn(final InsertValue insertValueToken, final EncryptAlgorithm encryptAlgorithm, final int columnIndex,
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private void addAssistedQueryColumn(final InsertValue insertValueToken, final EncryptAlgorithm<?, ?> encryptAlgorithm, final int columnIndex,
                                         final EncryptContext encryptContext, final InsertValueContext insertValueContext, final Object originalValue) {
         if (encryptRule.findAssistedQueryColumn(encryptContext.getTableName(), encryptContext.getColumnName()).isPresent()) {
             DerivedSimpleExpressionSegment derivedExpressionSegment = isAddLiteralExpressionSegment(insertValueContext, columnIndex)
-                    ? new DerivedLiteralExpressionSegment(((QueryAssistedEncryptAlgorithm) encryptAlgorithm).queryAssistedEncrypt(null == originalValue ? null : originalValue, encryptContext))
+                    ? new DerivedLiteralExpressionSegment(((QueryAssistedEncryptAlgorithm) encryptAlgorithm).queryAssistedEncrypt(originalValue, encryptContext))
                     : new DerivedParameterMarkerExpressionSegment(getParameterIndexCount(insertValueToken));
             insertValueToken.getValues().add(columnIndex + 1, derivedExpressionSegment);
         }
@@ -174,7 +175,8 @@ public final class EncryptInsertValuesTokenGenerator implements OptionalSQLToken
         return result;
     }
     
-    private void setCipherColumn(final InsertValue insertValueToken, final EncryptAlgorithm encryptAlgorithm, final int columnIndex, 
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private void setCipherColumn(final InsertValue insertValueToken, final EncryptAlgorithm encryptAlgorithm, final int columnIndex,
                                  final EncryptContext encryptContext, final ExpressionSegment valueExpression, final Object originalValue) {
         if (valueExpression instanceof LiteralExpressionSegment) {
             insertValueToken.getValues().set(columnIndex, new LiteralExpressionSegment(
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithmTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithmTest.java
index 8feec438a6b..e43ff8ac109 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithmTest.java
@@ -38,7 +38,7 @@ public final class AESEncryptAlgorithmTest {
         ShardingSphereServiceLoader.register(EncryptAlgorithm.class);
     }
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<Object, String> encryptAlgorithm;
     
     @Before
     public void setUp() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithmTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithmTest.java
index 74a01316af8..1b54b8afa6b 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/MD5EncryptAlgorithmTest.java
@@ -38,11 +38,11 @@ public final class MD5EncryptAlgorithmTest {
         ShardingSphereServiceLoader.register(EncryptAlgorithm.class);
     }
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<Object, String> encryptAlgorithm;
     
     @Before
     public void setUp() {
-        encryptAlgorithm = ShardingSphereAlgorithmFactory.createAlgorithm(new ShardingSphereAlgorithmConfiguration("Md5", new Properties()), EncryptAlgorithm.class);
+        encryptAlgorithm = ShardingSphereAlgorithmFactory.createAlgorithm(new ShardingSphereAlgorithmConfiguration("MD5", new Properties()), EncryptAlgorithm.class);
     }
     
     @Test
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
index c3214075b1f..7abf81540da 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithmTest.java
@@ -39,7 +39,7 @@ public final class RC4EncryptAlgorithmTest {
         ShardingSphereServiceLoader.register(EncryptAlgorithm.class);
     }
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<Object, String> encryptAlgorithm;
     
     @Before
     public void setUp() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM3EncryptAlgorithmTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM3EncryptAlgorithmTest.java
index 4c1ac761be2..25d4fedbfed 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM3EncryptAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM3EncryptAlgorithmTest.java
@@ -38,7 +38,7 @@ public final class SM3EncryptAlgorithmTest {
         ShardingSphereServiceLoader.register(EncryptAlgorithm.class);
     }
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<Object, String> encryptAlgorithm;
     
     @Before
     public void setUp() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM4EncryptAlgorithmTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM4EncryptAlgorithmTest.java
index c25741c7459..d5c6e5d9585 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM4EncryptAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/algorithm/SM4EncryptAlgorithmTest.java
@@ -38,7 +38,7 @@ public final class SM4EncryptAlgorithmTest {
         ShardingSphereServiceLoader.register(EncryptAlgorithm.class);
     }
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<Object, String> encryptAlgorithm;
     
     @Before
     public void setUp() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java
index 7235f1a5109..ece6855a68d 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java
@@ -48,7 +48,7 @@ public final class AlgorithmProvidedEncryptRuleConfigurationCheckerTest {
     
     private AlgorithmProvidedEncryptRuleConfiguration createValidConfiguration() {
         AlgorithmProvidedEncryptRuleConfiguration result = mock(AlgorithmProvidedEncryptRuleConfiguration.class);
-        EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
+        EncryptAlgorithm<?, ?> encryptAlgorithm = mock(EncryptAlgorithm.class);
         when(result.getEncryptors()).thenReturn(Collections.singletonMap("type1", encryptAlgorithm));
         return result;
     }
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
index d5b1d4f0988..97254511ee1 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptAlgorithmMetaDataTest.java
@@ -72,7 +72,7 @@ public final class EncryptAlgorithmMetaDataTest {
     @Mock
     private ProjectionsContext projectionsContext;
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<?, ?> encryptAlgorithm;
     
     @Before
     public void setUp() {
@@ -82,7 +82,7 @@ public final class EncryptAlgorithmMetaDataTest {
         when(columnProjection.getName()).thenReturn("id");
         when(columnProjection.getExpression()).thenReturn("id");
         when(selectStatementContext.getTablesContext()).thenReturn(tablesContext);
-        encryptAlgorithm = ShardingSphereAlgorithmFactory.createAlgorithm(new ShardingSphereAlgorithmConfiguration("Md5", new Properties()), EncryptAlgorithm.class);
+        encryptAlgorithm = ShardingSphereAlgorithmFactory.createAlgorithm(new ShardingSphereAlgorithmConfiguration("MD5", new Properties()), EncryptAlgorithm.class);
     }
     
     @Test
@@ -121,8 +121,6 @@ public final class EncryptAlgorithmMetaDataTest {
     
     @Test
     public void assertFindEncryptor() {
-        Map<String, String> columnTableNames = new HashMap<>();
-        columnTableNames.put(columnProjection.getExpression(), "t_order");
         when(encryptRule.findEncryptor("t_order", "id")).thenReturn(Optional.of(encryptAlgorithm));
         EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData(DefaultSchema.LOGIC_NAME, schema, encryptRule, selectStatementContext);
         Optional<EncryptAlgorithm> actualEncryptor = encryptAlgorithmMetaData.findEncryptor("t_order", "id");
@@ -132,8 +130,6 @@ public final class EncryptAlgorithmMetaDataTest {
     
     @Test
     public void assertIsQueryWithCipherColumn() {
-        Map<String, String> columnTableNames = new HashMap<>();
-        columnTableNames.put(columnProjection.getExpression(), "t_order");
         when(encryptRule.isQueryWithCipherColumn("t_order")).thenReturn(true);
         EncryptAlgorithmMetaData encryptAlgorithmMetaData = new EncryptAlgorithmMetaData(DefaultSchema.LOGIC_NAME, schema, encryptRule, selectStatementContext);
         assertTrue(encryptAlgorithmMetaData.isQueryWithCipherColumn("t_order"));
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
index 08e077b176b..1ac2c9d9650 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/EncryptMergedResultTest.java
@@ -80,10 +80,11 @@ public final class EncryptMergedResultTest {
         assertThat(new EncryptMergedResult(metaData, mergedResult).getValue(1, String.class), is("VALUE"));
     }
     
+    @SuppressWarnings("unchecked")
     @Test
     public void assertGetValueWithQueryWithCipherColumnAndMatchedEncryptorWithNotNullCiphertext() throws SQLException {
         when(mergedResult.getValue(1, Object.class)).thenReturn("VALUE");
-        EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
+        EncryptAlgorithm<String, String> encryptAlgorithm = mock(EncryptAlgorithm.class);
         EncryptContext encryptContext = EncryptContextBuilder.build(DefaultSchema.LOGIC_NAME, "t_encrypt", "order_id", mock(EncryptRule.class));
         when(encryptAlgorithm.decrypt("VALUE", encryptContext)).thenReturn("ORIGINAL_VALUE");
         when(metaData.findEncryptContext(1)).thenReturn(Optional.of(encryptContext));
@@ -92,9 +93,10 @@ public final class EncryptMergedResultTest {
         assertThat(new EncryptMergedResult(metaData, mergedResult).getValue(1, String.class), is("ORIGINAL_VALUE"));
     }
     
+    @SuppressWarnings("unchecked")
     @Test
     public void assertGetValueWithQueryWithCipherColumnAndMatchedEncryptorWithNullCiphertext() throws SQLException {
-        EncryptAlgorithm encryptAlgorithm = mock(EncryptAlgorithm.class);
+        EncryptAlgorithm<String, String> encryptAlgorithm = mock(EncryptAlgorithm.class);
         EncryptContext encryptContext = EncryptContextBuilder.build(DefaultSchema.LOGIC_NAME, "t_encrypt", "order_id", mock(EncryptRule.class));
         when(metaData.findEncryptContext(1)).thenReturn(Optional.of(encryptContext));
         when(metaData.isQueryWithCipherColumn("t_encrypt")).thenReturn(true);
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptAssignmentTokenGeneratorTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptAssignmentTokenGeneratorTest.java
index b5d4c0ef31d..2cd2563ce60 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptAssignmentTokenGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/EncryptAssignmentTokenGeneratorTest.java
@@ -33,19 +33,20 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.MockedStatic;
 import org.mockito.junit.MockitoJUnitRunner;
-import java.util.Arrays;
+
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Optional;
 
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.hamcrest.CoreMatchers.is;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mockStatic;
 import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 
 @RunWith(MockitoJUnitRunner.class)
 public final class EncryptAssignmentTokenGeneratorTest {
@@ -66,7 +67,7 @@ public final class EncryptAssignmentTokenGeneratorTest {
     
     private ParameterMarkerExpressionSegment parameterMarkerExpression;
     
-    private EncryptAlgorithm encryptAlgorithm;
+    private EncryptAlgorithm<?, ?> encryptAlgorithm;
     
     @Before
     public void setup() {
@@ -81,11 +82,11 @@ public final class EncryptAssignmentTokenGeneratorTest {
         tokenGenerator = new EncryptAssignmentTokenGenerator();
         tokenGenerator.setEncryptRule(encryptRule);
         when(updateStatement.getAllTables().iterator().next().getTableName().getIdentifier().getValue()).thenReturn("table");
-        when(updateStatement.getSqlStatement().getSetAssignment().getAssignments()).thenReturn(Arrays.asList(assignmentSegment));
+        when(updateStatement.getSqlStatement().getSetAssignment().getAssignments()).thenReturn(Collections.singletonList(assignmentSegment));
         when(assignmentSegment.getColumns().get(0).getIdentifier().getValue()).thenReturn("columns");
         when(encryptRule.findEncryptor(eq("table"), eq("columns"))).thenReturn(Optional.of(encryptAlgorithm));
         when(insertStatement.getAllTables().iterator().next().getTableName().getIdentifier().getValue()).thenReturn("table");
-        when(setAssignmentSegment.getAssignments()).thenReturn(Arrays.asList(assignmentSegment));
+        when(setAssignmentSegment.getAssignments()).thenReturn(Collections.singletonList(assignmentSegment));
     }
     
     @Test
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleAlgorithmProviderConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index 2833f2c9e96..bb4e22d2da2 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -51,10 +51,9 @@ public final class EncryptRuleAlgorithmProviderConfigurationYamlSwapperTest {
         assertTrue(actual.getEncryptors().isEmpty());
     }
     
-    @SuppressWarnings("rawtypes")
     private AlgorithmProvidedEncryptRuleConfiguration createAlgorithmProvidedEncryptRuleConfiguration() {
         Collection<EncryptTableRuleConfiguration> tables = Collections.singletonList(new EncryptTableRuleConfiguration("tbl", Collections.emptyList(), null));
-        Map<String, EncryptAlgorithm> encryptors = new LinkedHashMap<>();
+        Map<String, EncryptAlgorithm<?, ?>> encryptors = new LinkedHashMap<>();
         return new AlgorithmProvidedEncryptRuleConfiguration(tables, encryptors, true);
     }
     
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/main/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptRuleSpringBootConfiguration.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/main/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptRuleSpringBootConfiguration.java
index 630958bb93c..8a09c557841 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/main/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptRuleSpringBootConfiguration.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/main/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptRuleSpringBootConfiguration.java
@@ -59,7 +59,7 @@ public class EncryptRuleSpringBootConfiguration {
      * @return encrypt rule configuration
      */
     @Bean
-    public RuleConfiguration encryptRuleConfiguration(final ObjectProvider<Map<String, EncryptAlgorithm>> encryptors) {
+    public RuleConfiguration encryptRuleConfiguration(final ObjectProvider<Map<String, EncryptAlgorithm<?, ?>>> encryptors) {
         AlgorithmProvidedEncryptRuleConfiguration result = swapper.swapToObject(yamlConfig.getEncrypt());
         result.setEncryptors(Optional.ofNullable(encryptors.getIfAvailable()).orElse(Collections.emptyMap()));
         result.setQueryWithCipherColumn(yamlConfig.getEncrypt().isQueryWithCipherColumn());
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java
index 616646b0443..b4299b6c688 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-boot-starter/src/test/java/org/apache/shardingsphere/encrypt/spring/boot/EncryptSpringBootStarterTest.java
@@ -63,7 +63,7 @@ public class EncryptSpringBootStarterTest {
         assertEncryptTable(encryptRuleConfiguration.getTables().iterator().next());
     }
     
-    private void assertEncryptors(final Map<String, EncryptAlgorithm> encryptors) {
+    private void assertEncryptors(final Map<String, EncryptAlgorithm<?, ?>> encryptors) {
         assertThat(encryptors.size(), is(2));
         assertThat(encryptors.get("aesEncryptor"), instanceOf(AESEncryptAlgorithm.class));
         assertThat(encryptors.get("aesEncryptor").getProps().getProperty("aes-key-value"), is("123456"));
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java
index 0045a768fac..c3cac8aa7c3 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/test/java/org/apache/shardingsphere/encrypt/spring/namespace/EncryptSpringNamespaceTest.java
@@ -39,10 +39,10 @@ import static org.junit.Assert.assertThat;
 public final class EncryptSpringNamespaceTest extends AbstractJUnit4SpringContextTests {
     
     @Resource
-    private EncryptAlgorithm aesEncryptor;
+    private EncryptAlgorithm<Object, String> aesEncryptor;
     
     @Resource
-    private EncryptAlgorithm md5Encryptor;
+    private EncryptAlgorithm<Object, String> md5Encryptor;
     
     @Resource
     private AlgorithmProvidedEncryptRuleConfiguration encryptRule;
@@ -65,7 +65,7 @@ public final class EncryptSpringNamespaceTest extends AbstractJUnit4SpringContex
         assertEncryptTable(encryptRule.getTables().iterator().next());
     }
     
-    private void assertEncryptors(final Map<String, EncryptAlgorithm> encryptors) {
+    private void assertEncryptors(final Map<String, EncryptAlgorithm<?, ?>> encryptors) {
         assertThat(encryptors.size(), is(2));
         assertThat(encryptors.get("aesEncryptor"), instanceOf(AESEncryptAlgorithm.class));
         assertThat(encryptors.get("aesEncryptor").getProps().getProperty("aes-key-value"), is("123456"));