Skip to content

Commit

Permalink
test: Refactored tests in LowerCaseLinkHashMapTest to use parameteriz…
Browse files Browse the repository at this point in the history
…ed unit testing (#7160)
  • Loading branch information
Monilnarang authored Feb 15, 2025
1 parent 56a2f14 commit 2c31bdd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
2 changes: 2 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2c31bdd

Please sign in to comment.