You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2022/10/06 16:25:13 UTC

[shardingsphere] branch master updated: Revise YamlTransactionRuleConfigurationSwapperTest (#21362)

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

sunnianjun 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 00e4079f667 Revise YamlTransactionRuleConfigurationSwapperTest (#21362)
00e4079f667 is described below

commit 00e4079f66777af43251a3e704652cbb2d6c5933
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri Oct 7 00:25:04 2022 +0800

    Revise YamlTransactionRuleConfigurationSwapperTest (#21362)
---
 ...amlTransactionRuleConfigurationSwapperTest.java | 33 ++++++++++++++--------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
similarity index 50%
rename from shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
rename to kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
index e66b5b3b9d9..570243d483d 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
+++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
@@ -17,25 +17,34 @@
 
 package org.apache.shardingsphere.transaction.yaml.swapper;
 
-import static org.junit.Assert.assertEquals;
-
-import java.util.Properties;
 import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
 import org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
 import org.junit.Test;
 
-public class YamlTransactionRuleConfigurationSwapperTest {
-    
-    private final YamlTransactionRuleConfigurationSwapper swapper = new YamlTransactionRuleConfigurationSwapper();
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public final class YamlTransactionRuleConfigurationSwapperTest {
     
     @Test
     public void assertSwapToYamlConfiguration() {
-        Properties props = new Properties();
-        TransactionRuleConfiguration yamlTransactionRuleConfig = new TransactionRuleConfiguration("default", "provider", props);
-        YamlTransactionRuleConfiguration actual = swapper.swapToYamlConfiguration(yamlTransactionRuleConfig);
-        assertEquals(props, actual.getProps());
-        assertEquals("provider", actual.getProviderType());
-        assertEquals("default", actual.getDefaultType());
+        YamlTransactionRuleConfiguration actual = new YamlTransactionRuleConfigurationSwapper().swapToYamlConfiguration(new TransactionRuleConfiguration("default", "provider", new Properties()));
+        assertThat(actual.getDefaultType(), is("default"));
+        assertThat(actual.getProviderType(), is("provider"));
+        assertThat(actual.getProps(), is(new Properties()));
     }
     
+    @Test
+    public void assertSwapToObject() {
+        YamlTransactionRuleConfiguration yamlConfig = new YamlTransactionRuleConfiguration();
+        yamlConfig.setDefaultType("default");
+        yamlConfig.setProviderType("provider");
+        yamlConfig.setProps(new Properties());
+        TransactionRuleConfiguration actual = new YamlTransactionRuleConfigurationSwapper().swapToObject(yamlConfig);
+        assertThat(actual.getDefaultType(), is("default"));
+        assertThat(actual.getProviderType(), is("provider"));
+        assertThat(actual.getProps(), is(new Properties()));
+    }
 }