-
Notifications
You must be signed in to change notification settings - Fork 464
test: Add unit tests for utility classes #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive unit tests for utility classes in the fesod-common module, enhancing test coverage across multiple utility classes including validation, string manipulation, collection utilities, I/O operations, and more.
- Adds unit tests for 9 utility classes (ValidateUtils, StringUtils, PositionUtils, MemberUtils, MapUtils, ListUtils, IoUtils, IntUtils, BooleanUtils)
- Includes comprehensive test cases covering edge cases, error conditions, and normal operations
- Changes StringUtilsTest class visibility from public to package-private for consistency
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ValidateUtilsTest.java | New test file covering validation utility methods including isTrue and notNull with various parameter types |
| StringUtilsTest.java | Enhanced test file with comprehensive tests for string operations (isEmpty, isBlank, equals, isNumeric, regionMatches) and visibility change |
| PositionUtilsTest.java | New test file for position/cell reference utilities with tests for row and column extraction |
| MemberUtilsTest.java | New test file for reflection utility methods testing access modifier checks and accessibility workarounds |
| MapUtilsTest.java | New test file for map creation utilities testing HashMap, TreeMap, LinkedHashMap factory methods and capacity calculations |
| ListUtilsTest.java | New test file for list utilities covering ArrayList creation from various sources and capacity management |
| IoUtilsTest.java | New test file for I/O operations testing byte array conversion and stream copying functionality |
| IntUtilsTest.java | New test file for integer utilities testing saturated casting from long to int |
| BooleanUtilsTest.java | New test file for boolean utilities testing various boolean checking methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| void test_getRowByRowTagt() { | ||
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt("1", null)); | ||
| Assertions.assertEquals(9, PositionUtils.getRowByRowTagt("10", 5)); | ||
| Assertions.assertEquals(6, PositionUtils.getRowByRowTagt(null, 5)); | ||
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt(null, null)); |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name contains a typo: "getRowByRowTagt" should be "getRowByRowTag" (without the extra 't' at the end).
| void test_getRowByRowTagt() { | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt("1", null)); | |
| Assertions.assertEquals(9, PositionUtils.getRowByRowTagt("10", 5)); | |
| Assertions.assertEquals(6, PositionUtils.getRowByRowTagt(null, 5)); | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt(null, null)); | |
| void test_getRowByRowTag() { | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTag("1", null)); | |
| Assertions.assertEquals(9, PositionUtils.getRowByRowTag("10", 5)); | |
| Assertions.assertEquals(6, PositionUtils.getRowByRowTag(null, 5)); | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTag(null, null)); |
| void test_getRowByRowTagt() { | ||
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt("1", null)); | ||
| Assertions.assertEquals(9, PositionUtils.getRowByRowTagt("10", 5)); | ||
| Assertions.assertEquals(6, PositionUtils.getRowByRowTagt(null, 5)); | ||
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt(null, null)); |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method calls contain a typo: "getRowByRowTagt" should be "getRowByRowTag" (without the extra 't' at the end). This appears multiple times and should match the actual utility method name being tested.
| void test_getRowByRowTagt() { | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt("1", null)); | |
| Assertions.assertEquals(9, PositionUtils.getRowByRowTagt("10", 5)); | |
| Assertions.assertEquals(6, PositionUtils.getRowByRowTagt(null, 5)); | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTagt(null, null)); | |
| void test_getRowByRowTag() { | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTag("1", null)); | |
| Assertions.assertEquals(9, PositionUtils.getRowByRowTag("10", 5)); | |
| Assertions.assertEquals(6, PositionUtils.getRowByRowTag(null, 5)); | |
| Assertions.assertEquals(0, PositionUtils.getRowByRowTag(null, null)); |
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Tests {@link MemberUtilsTest} |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JavaDoc comment incorrectly references "MemberUtilsTest" instead of "MemberUtils". The comment should reference the class being tested, not the test class itself.
| * Tests {@link MemberUtilsTest} | |
| * Tests {@link MemberUtils} |
| } | ||
| } | ||
|
|
||
| static class TestData { |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visibility modifier of the TestData class should be "private static" instead of just "static". The class is only used internally within this test class and should follow proper encapsulation principles.
| static class TestData { | |
| private static class TestData { |
|
|
||
| @Test | ||
| void test_isTrue() { | ||
| Assertions.assertDoesNotThrow(() -> ValidateUtils.isTrue(1 + 1 == 2)); |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test is always true.
|
Hi @bengbengbalabalabeng |
Thanks for the review. I've applied. 😊 |
|
|
||
| @Test | ||
| void test_getCol() { | ||
| Assertions.assertEquals(0, PositionUtils.getCol("A1", null)); // A -> 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not recommended to use end-of-line comments in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
delei
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Purpose of the pull request
Add unit tests for utility classes in
fesod-commonmodule.Checklist