Skip to content

Conversation

@bengbengbalabalabeng
Copy link
Contributor

@bengbengbalabalabeng bengbengbalabalabeng commented Dec 25, 2025

Purpose of the pull request

Add unit tests for utility classes in fesod-common module.

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Copy link
Contributor

Copilot AI left a 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.

Comment on lines 31 to 35
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));
Copy link

Copilot AI Jan 5, 2026

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).

Suggested change
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));

Copilot uses AI. Check for mistakes.
Comment on lines 31 to 35
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));
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
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));

Copilot uses AI. Check for mistakes.
import org.junit.jupiter.api.Test;

/**
* Tests {@link MemberUtilsTest}
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
* Tests {@link MemberUtilsTest}
* Tests {@link MemberUtils}

Copilot uses AI. Check for mistakes.
}
}

static class TestData {
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
static class TestData {
private static class TestData {

Copilot uses AI. Check for mistakes.

@Test
void test_isTrue() {
Assertions.assertDoesNotThrow(() -> ValidateUtils.isTrue(1 + 1 == 2));
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is always true.

Copilot uses AI. Check for mistakes.
@delei
Copy link
Member

delei commented Jan 5, 2026

Hi @bengbengbalabalabeng
This is not necessary, but I still recommend that you refer to the suggestions provided by it to improve the code :)

@bengbengbalabalabeng
Copy link
Contributor Author

This is not necessary, but I still recommend that you refer to the suggestions provided by it to improve the code :)

Thanks for the review. I've applied. 😊


@Test
void test_getCol() {
Assertions.assertEquals(0, PositionUtils.getCol("A1", null)); // A -> 0
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@delei delei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@delei delei merged commit d713131 into apache:main Jan 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants