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

jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new 2c31bdd4e6 test: Refactored tests in LowerCaseLinkHashMapTest to use 
parameterized unit testing (#7160)
2c31bdd4e6 is described below

commit 2c31bdd4e666cd82ebf0dcf105ccc786b6c5ac40
Author: Monil <mon...@uci.edu>
AuthorDate: Sat Feb 15 02:02:24 2025 -0800

    test: Refactored tests in LowerCaseLinkHashMapTest to use parameterized 
unit testing (#7160)
---
 changes/en-us/2.x.md                                      |  2 ++
 changes/zh-cn/2.x.md                                      |  2 ++
 .../seata/common/util/LowerCaseLinkHashMapTest.java       | 15 ++++++++++-----
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 93faf87d4c..1ae5a80cfd 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -50,6 +50,7 @@ Add changes here for all PR submitted to the 2.x branch.
 
 - [[#7092](https://github.com/apache/incubator-seata/pull/7092)] fix the issue 
of NacosMockTest failing to run
 - [[#7098](https://github.com/apache/incubator-seata/pull/7098)] Add unit 
tests for the `seata-common` module
+- [[#7160](https://github.com/apache/incubator-seata/pull/7160)] Refactored 
tests in `LowerCaseLinkHashMapTest` to use parameterized unit testing
 
 ### refactor:
 
@@ -72,5 +73,6 @@ Thanks to these contributors for their code commits. Please 
report an unintended
 - [wxrqforever](https://github.com/wxrqforever)
 - [xingfudeshi](https://github.com/xingfudeshi)
 - [YongGoose](https://github.com/YongGoose)
+- [Monilnarang](https://github.com/Monilnarang)
 
 Also, we receive many valuable issues, questions and advices from our 
community. Thanks for you all.
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index b4c6eac7fa..24d392898a 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -50,6 +50,7 @@
 
 - [[#7092](https://github.com/apache/incubator-seata/pull/7092)] 
修复NacosMockTest测试方法并行导致测试结果被干扰失败的问题
 - [[#7098](https://github.com/apache/incubator-seata/pull/7098)] 增加 
`seata-common` 模块的测试用例
+- [[#7160](https://github.com/apache/incubator-seata/pull/7160)] 在 
LowerCaseLinkHashMapTest 中重构测试,以使用参数化单元测试
 
 ### refactor:
 
@@ -72,5 +73,6 @@
 - [wxrqforever](https://github.com/wxrqforever)
 - [xingfudeshi](https://github.com/xingfudeshi)
 - [YongGoose](https://github.com/YongGoose)
+- [Monilnarang](https://github.com/Monilnarang)
 
 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
diff --git 
a/common/src/test/java/org/apache/seata/common/util/LowerCaseLinkHashMapTest.java
 
b/common/src/test/java/org/apache/seata/common/util/LowerCaseLinkHashMapTest.java
index 2d5191b73b..0e7dcbc8b5 100644
--- 
a/common/src/test/java/org/apache/seata/common/util/LowerCaseLinkHashMapTest.java
+++ 
b/common/src/test/java/org/apache/seata/common/util/LowerCaseLinkHashMapTest.java
@@ -26,6 +26,8 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
 
 
 public class LowerCaseLinkHashMapTest {
@@ -122,11 +124,14 @@ public class LowerCaseLinkHashMapTest {
         Assertions.assertArrayEquals(values.toArray(), 
lowerCaseLinkHashMap.values().toArray());
     }
 
-    @Test
-    void getOrDefault() {
-        Assertions.assertEquals("Value", 
lowerCaseLinkHashMap.getOrDefault("Key", "abc"));
-        Assertions.assertEquals("Value", 
lowerCaseLinkHashMap.getOrDefault("key", "abc"));
-        Assertions.assertEquals("abc", 
lowerCaseLinkHashMap.getOrDefault("default", "abc"));
+    @ParameterizedTest
+    @CsvSource(value = {
+            "Value, Key, abc",
+            "Value, key, abc",
+            "abc, default, abc"
+    })
+    void getOrDefault1(String expected, String key, String defaultValue) {
+        Assertions.assertEquals(expected, 
lowerCaseLinkHashMap.getOrDefault(key, defaultValue));
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to