You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "tobehardest (via GitHub)" <gi...@apache.org> on 2023/05/07 16:31:36 UTC

[GitHub] [shardingsphere] tobehardest opened a new pull request, #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

tobehardest opened a new pull request, #25507:
URL: https://github.com/apache/shardingsphere/pull/25507

   Fixes #25353 
   
   Changes proposed in this pull request:
     -
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] I have self-reviewed the commit code.
   - [x] I have (or in comment I request) added corresponding labels for the pull request.
   - [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tobehardest commented on pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "tobehardest (via GitHub)" <gi...@apache.org>.
tobehardest commented on PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#issuecomment-1592468143

   please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#issuecomment-1596596820

   @tobehardest Thanks for your contribution


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on a diff in pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on code in PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#discussion_r1231765808


##########
features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java:
##########
@@ -35,45 +34,61 @@
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class YamlReadwriteSplittingRuleConfigurationSwapperTest {
-    
+
     @Test
     void assertSwapToYamlConfiguration() {
         YamlReadwriteSplittingRuleConfiguration actual = getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
         assertThat(actual.getDataSources().size(), is(1));
         assertThat(actual.getLoadBalancers().size(), is(1));
+        assertReadwriteSplittingRule(actual);
+    }
+
+    void assertReadwriteSplittingRule(final YamlReadwriteSplittingRuleConfiguration actual) {
+        assertNotNull(actual.getDataSources().get("readwrite"));
+        YamlReadwriteSplittingDataSourceRuleConfiguration config = actual.getDataSources().get("readwrite");
+        assertThat(config.getWriteDataSourceName(), CoreMatchers.is("write_ds"));
+        assertThat(actual.getDataSources().get("readwrite").getLoadBalancerName(), CoreMatchers.is("random"));

Review Comment:
   `CoreMatchers.is` could be `is`



##########
features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java:
##########
@@ -35,45 +34,61 @@
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.mockito.Mockito.mock;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class YamlReadwriteSplittingRuleConfigurationSwapperTest {
-    
+
     @Test
     void assertSwapToYamlConfiguration() {
         YamlReadwriteSplittingRuleConfiguration actual = getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
         assertThat(actual.getDataSources().size(), is(1));
         assertThat(actual.getLoadBalancers().size(), is(1));
+        assertReadwriteSplittingRule(actual);
+    }
+
+    void assertReadwriteSplittingRule(final YamlReadwriteSplittingRuleConfiguration actual) {
+        assertNotNull(actual.getDataSources().get("readwrite"));
+        YamlReadwriteSplittingDataSourceRuleConfiguration config = actual.getDataSources().get("readwrite");
+        assertThat(config.getWriteDataSourceName(), CoreMatchers.is("write_ds"));
+        assertThat(actual.getDataSources().get("readwrite").getLoadBalancerName(), CoreMatchers.is("random"));
     }
-    
+
+    void assertReadwriteSplittingRule(final ReadwriteSplittingRuleConfiguration actual) {
+        ReadwriteSplittingDataSourceRuleConfiguration config = actual.getDataSources().iterator().next();
+        assertThat(config.getName(), CoreMatchers.is("t_readwrite"));
+        assertThat(config.getWriteDataSourceName(), CoreMatchers.is("write_ds"));
+        assertThat(config.getLoadBalancerName(), CoreMatchers.is("random"));
+    }
+
     private ReadwriteSplittingRuleConfiguration creatReadwriteSplittingRuleConfiguration() {
         Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = Collections.singletonList(
                 new ReadwriteSplittingDataSourceRuleConfiguration("readwrite", "write_ds", Arrays.asList("read_ds_0", "read_ds_1"), "random"));
         Map<String, AlgorithmConfiguration> loadBalancers = Collections.singletonMap("myLoadBalancer", new AlgorithmConfiguration("RANDOM", new Properties()));
         return new ReadwriteSplittingRuleConfiguration(dataSources, loadBalancers);
     }
-    
+
     @Test
     void assertSwapToObject() {
-        ReadwriteSplittingRuleConfiguration actual = getSwapper().swapToObject(creatYamlReadwriteSplittingRuleConfiguration());
+        ReadwriteSplittingRuleConfiguration actual = getSwapper().swapToObject(createYamlReadwriteSplittingRuleConfiguration());
         assertThat(actual.getDataSources().size(), is(1));
         assertThat(actual.getLoadBalancers().size(), is(1));
+        assertReadwriteSplittingRule(actual);
     }
-    
-    private YamlReadwriteSplittingRuleConfiguration creatYamlReadwriteSplittingRuleConfiguration() {
-        YamlReadwriteSplittingRuleConfiguration result = new YamlReadwriteSplittingRuleConfiguration();
+
+    private YamlReadwriteSplittingRuleConfiguration createYamlReadwriteSplittingRuleConfiguration() {
         YamlReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig = new YamlReadwriteSplittingDataSourceRuleConfiguration();
         dataSourceRuleConfig.setReadDataSourceNames(Arrays.asList("read_ds_0", "read_ds_1"));
         dataSourceRuleConfig.setWriteDataSourceName("write_ds");
+        dataSourceRuleConfig.setLoadBalancerName("random");
+        YamlReadwriteSplittingRuleConfiguration result = new YamlReadwriteSplittingRuleConfiguration();
         result.getDataSources().put("t_readwrite", dataSourceRuleConfig);
         YamlAlgorithmConfiguration algorithmConfig = new YamlAlgorithmConfiguration();
         algorithmConfig.setType("RANDOM");
         result.getLoadBalancers().put("random_loadbalancer", algorithmConfig);
         return result;
     }
-    
+

Review Comment:
   Indentation in empty line between methods could be kept



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tobehardest commented on pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "tobehardest (via GitHub)" <gi...@apache.org>.
tobehardest commented on PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#issuecomment-1565253313

   Updated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz merged pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz merged PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] tobehardest commented on pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "tobehardest (via GitHub)" <gi...@apache.org>.
tobehardest commented on PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#issuecomment-1594171231

   OK.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on a diff in pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on code in PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#discussion_r1209072909


##########
features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.readwritesplitting.yaml.swapper;
+
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.util.spi.type.ordered.OrderedSPILoader;
+import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+public class YamlReadwriteSplittingRuleConfigurationSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        YamlReadwriteSplittingRuleConfiguration actual = getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));
+    }
+    
+    private ReadwriteSplittingRuleConfiguration creatReadwriteSplittingRuleConfiguration() {
+        Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = Collections.singletonList(
+                new ReadwriteSplittingDataSourceRuleConfiguration("readwrite", "write_ds", Arrays.asList("read_ds_0", "read_ds_1"), "random"));
+        Map<String, AlgorithmConfiguration> loadBalancers = Collections.singletonMap("myLoadBalancer", new AlgorithmConfiguration("RANDOM", new Properties()));
+        return new ReadwriteSplittingRuleConfiguration(dataSources, loadBalancers);
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        ReadwriteSplittingRuleConfiguration actual = getSwapper().swapToObject(creatYamlReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));
+    }
+    
+    private YamlReadwriteSplittingRuleConfiguration creatYamlReadwriteSplittingRuleConfiguration() {

Review Comment:
   `creat` could be `create`



##########
features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.readwritesplitting.yaml.swapper;
+
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.util.spi.type.ordered.OrderedSPILoader;
+import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+public class YamlReadwriteSplittingRuleConfigurationSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        YamlReadwriteSplittingRuleConfiguration actual = getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));
+    }
+    
+    private ReadwriteSplittingRuleConfiguration creatReadwriteSplittingRuleConfiguration() {
+        Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = Collections.singletonList(
+                new ReadwriteSplittingDataSourceRuleConfiguration("readwrite", "write_ds", Arrays.asList("read_ds_0", "read_ds_1"), "random"));
+        Map<String, AlgorithmConfiguration> loadBalancers = Collections.singletonMap("myLoadBalancer", new AlgorithmConfiguration("RANDOM", new Properties()));
+        return new ReadwriteSplittingRuleConfiguration(dataSources, loadBalancers);
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        ReadwriteSplittingRuleConfiguration actual = getSwapper().swapToObject(creatYamlReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));
+    }
+    
+    private YamlReadwriteSplittingRuleConfiguration creatYamlReadwriteSplittingRuleConfiguration() {
+        YamlReadwriteSplittingRuleConfiguration result = new YamlReadwriteSplittingRuleConfiguration();
+        YamlReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig = new YamlReadwriteSplittingDataSourceRuleConfiguration();
+        dataSourceRuleConfig.setReadDataSourceNames(Arrays.asList("read_ds_0", "read_ds_1"));
+        dataSourceRuleConfig.setWriteDataSourceName("write_ds");
+        result.getDataSources().put("t_readwrite", dataSourceRuleConfig);
+        YamlAlgorithmConfiguration algorithmConfig = new YamlAlgorithmConfiguration();
+        algorithmConfig.setType("RANDOM");
+        result.getLoadBalancers().put("random_loadbalancer", algorithmConfig);
+        return result;
+    }
+    
+    private YamlReadwriteSplittingRuleConfigurationSwapper getSwapper() {
+        ReadwriteSplittingRuleConfiguration ruleConfig = mock(ReadwriteSplittingRuleConfiguration.class);
+        return (YamlReadwriteSplittingRuleConfigurationSwapper) OrderedSPILoader.getServices(YamlRuleConfigurationSwapper.class, Collections.singleton(ruleConfig)).get(ruleConfig);

Review Comment:
   Could we just `new YamlReadwriteSplittingRuleConfigurationSwapper()` to simplify code?



##########
features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.readwritesplitting.yaml.swapper;
+
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.util.spi.type.ordered.OrderedSPILoader;
+import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+public class YamlReadwriteSplittingRuleConfigurationSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        YamlReadwriteSplittingRuleConfiguration actual = getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));
+    }
+    
+    private ReadwriteSplittingRuleConfiguration creatReadwriteSplittingRuleConfiguration() {
+        Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = Collections.singletonList(
+                new ReadwriteSplittingDataSourceRuleConfiguration("readwrite", "write_ds", Arrays.asList("read_ds_0", "read_ds_1"), "random"));
+        Map<String, AlgorithmConfiguration> loadBalancers = Collections.singletonMap("myLoadBalancer", new AlgorithmConfiguration("RANDOM", new Properties()));
+        return new ReadwriteSplittingRuleConfiguration(dataSources, loadBalancers);
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        ReadwriteSplittingRuleConfiguration actual = getSwapper().swapToObject(creatYamlReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));

Review Comment:
   Could we assert part of the important content?



##########
features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.readwritesplitting.yaml.swapper;
+
+import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.util.spi.type.ordered.OrderedSPILoader;
+import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceRuleConfiguration;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+public class YamlReadwriteSplittingRuleConfigurationSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        YamlReadwriteSplittingRuleConfiguration actual = getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
+        assertThat(actual.getDataSources().size(), is(1));
+        assertThat(actual.getLoadBalancers().size(), is(1));

Review Comment:
   Could we assert part of the important content?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] sandynz commented on pull request #25507: Add test cases for YamlReadwriteSplittingRuleConfigurationSwapper

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on PR #25507:
URL: https://github.com/apache/shardingsphere/pull/25507#issuecomment-1556460132

   Hi @tobehardest , there's check style error, could you update the code?
   
   ```
   Error:  /home/runner/work/shardingsphere/shardingsphere/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/
   YamlReadwriteSplittingRuleConfigurationSwapperTest.java:32:17: Using the '.*' form of import should be avoided - java.util.*. [AvoidStarImport]
   
   Error:  /home/runner/work/shardingsphere/shardingsphere/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/
   YamlReadwriteSplittingRuleConfigurationSwapperTest.java:48: Line is longer than 200 characters (found 233). [LineLength]
   ```
   
   And you could import `src/resources/code-style-idea.xml` into your IDEA Code Style.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org