diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 93faf87d4ca..1ae5a80cfda 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 b4c6eac7faf..24d392898ad 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 2d5191b73b7..0e7dcbc8b55 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.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 @@ void values() { 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