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 3b6530f7de3 YamlKeyGenerateStrategyConfigurationSwapperTest adding UTs 
(#30933)
3b6530f7de3 is described below

commit 3b6530f7de3cff56c210d33d5fee7443f5523080
Author: shubham-j-sde <[email protected]>
AuthorDate: Sat Apr 20 18:11:19 2024 +0530

    YamlKeyGenerateStrategyConfigurationSwapperTest adding UTs (#30933)
    
    Co-authored-by: Shubham Jaiswal <[email protected]>
---
 ...eyGenerateStrategyConfigurationSwapperTest.java | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlKeyGenerateStrategyConfigurationSwapperTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlKeyGenerateStrategyConfigurationSwapperTest.java
new file mode 100644
index 00000000000..6295712bc2f
--- /dev/null
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlKeyGenerateStrategyConfigurationSwapperTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.sharding.yaml.swapper.strategy;
+
+import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class YamlKeyGenerateStrategyConfigurationSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        KeyGenerateStrategyConfiguration data = new 
KeyGenerateStrategyConfiguration("id", "default");
+        YamlKeyGenerateStrategyConfigurationSwapper swapper = new 
YamlKeyGenerateStrategyConfigurationSwapper();
+        YamlKeyGenerateStrategyConfiguration actual = 
swapper.swapToYamlConfiguration(data);
+        assertThat(actual.getColumn(), is("id"));
+        assertThat(actual.getKeyGeneratorName(), is("default"));
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        YamlKeyGenerateStrategyConfiguration yamlConfig = new 
YamlKeyGenerateStrategyConfiguration();
+        yamlConfig.setColumn("id");
+        yamlConfig.setKeyGeneratorName("default");
+        YamlKeyGenerateStrategyConfigurationSwapper swapper = new 
YamlKeyGenerateStrategyConfigurationSwapper();
+        KeyGenerateStrategyConfiguration actual = 
swapper.swapToObject(yamlConfig);
+        assertThat(actual.getColumn(), is("id"));
+        assertThat(actual.getKeyGeneratorName(), is("default"));
+    }
+}

Reply via email to