You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/04/27 10:42:49 UTC
[shardingsphere] branch master updated: Refactor EncryptRuleConfigurationYamlSwapperTest (#17149)
This is an automated email from the ASF dual-hosted git repository.
yx9o 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 dab914a6eda Refactor EncryptRuleConfigurationYamlSwapperTest (#17149)
dab914a6eda is described below
commit dab914a6edac43f82a60be00280aa6597d5bda74
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Apr 27 18:42:42 2022 +0800
Refactor EncryptRuleConfigurationYamlSwapperTest (#17149)
---
.../EncryptRuleConfigurationYamlSwapperTest.java | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationYamlSwapperTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationYamlSwapperTest.java
index 1e9c8786f3f..0698100f4ab 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationYamlSwapperTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/EncryptRuleConfigurationYamlSwapperTest.java
@@ -24,14 +24,9 @@ import org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguratio
import org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapperFactory;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import java.io.File;
import java.io.IOException;
@@ -44,19 +39,10 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
-@RunWith(MockitoJUnitRunner.class)
public final class EncryptRuleConfigurationYamlSwapperTest {
- static {
- ShardingSphereServiceLoader.register(YamlRuleConfigurationSwapper.class);
- }
-
- @Mock
- private EncryptRuleConfiguration ruleConfig;
-
- private final EncryptRuleConfigurationYamlSwapper encryptRuleConfigurationYamlSwapper = new EncryptRuleConfigurationYamlSwapper();
-
@Test
public void assertSwapToYamlConfiguration() {
YamlEncryptRuleConfiguration actual = getSwapper().swapToYamlConfiguration(createEncryptRuleConfiguration());
@@ -89,6 +75,7 @@ public final class EncryptRuleConfigurationYamlSwapperTest {
}
private EncryptRuleConfigurationYamlSwapper getSwapper() {
+ EncryptRuleConfiguration ruleConfig = mock(EncryptRuleConfiguration.class);
return (EncryptRuleConfigurationYamlSwapper) YamlRuleConfigurationSwapperFactory.newInstanceMapByRuleConfigurations(Collections.singletonList(ruleConfig)).get(ruleConfig);
}
@@ -97,8 +84,9 @@ public final class EncryptRuleConfigurationYamlSwapperTest {
URL url = getClass().getClassLoader().getResource("yaml/encrypt-dataConverters.yaml");
assertNotNull(url);
YamlEncryptRuleConfiguration yamlConfig = YamlEngine.unmarshal(new File(url.getFile()), YamlEncryptRuleConfiguration.class);
- EncryptRuleConfiguration actualConfig = encryptRuleConfigurationYamlSwapper.swapToObject(yamlConfig);
- YamlEncryptRuleConfiguration actualYamlConfig = encryptRuleConfigurationYamlSwapper.swapToYamlConfiguration(actualConfig);
+ EncryptRuleConfigurationYamlSwapper swapper = new EncryptRuleConfigurationYamlSwapper();
+ EncryptRuleConfiguration actualConfig = swapper.swapToObject(yamlConfig);
+ YamlEncryptRuleConfiguration actualYamlConfig = swapper.swapToYamlConfiguration(actualConfig);
assertThat(YamlEngine.marshal(actualYamlConfig), is(YamlEngine.marshal(yamlConfig)));
}
}