Copilot commented on code in PR #756: URL: https://github.com/apache/fesod/pull/756#discussion_r2661396666
########## fesod-common/src/test/java/org/apache/fesod/common/util/PositionUtilsTest.java: ########## @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fesod.common.util; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests {@link PositionUtils} + */ +class PositionUtilsTest { + + @Test + 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)); Review Comment: The method name contains a typo: "getRowByRowTagt" should be "getRowByRowTag" (without the extra 't' at the end). ```suggestion 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)); ``` ########## fesod-common/src/test/java/org/apache/fesod/common/util/PositionUtilsTest.java: ########## @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fesod.common.util; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests {@link PositionUtils} + */ +class PositionUtilsTest { + + @Test + 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)); Review Comment: 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. ```suggestion 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)); ``` ########## fesod-common/src/test/java/org/apache/fesod/common/util/MemberUtilsTest.java: ########## @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fesod.common.util; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests {@link MemberUtilsTest} Review Comment: The JavaDoc comment incorrectly references "MemberUtilsTest" instead of "MemberUtils". The comment should reference the class being tested, not the test class itself. ```suggestion * Tests {@link MemberUtils} ``` ########## fesod-common/src/test/java/org/apache/fesod/common/util/ValidateUtilsTest.java: ########## @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fesod.common.util; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Tests {@link ValidateUtils} + */ +class ValidateUtilsTest { + + @Test + void test_isTrue_long() { + Assertions.assertDoesNotThrow(() -> ValidateUtils.isTrue(true, "Error count: %d", 100L)); + + IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> { + ValidateUtils.isTrue(false, "Error count: %d", 50L); + }); + Assertions.assertEquals("Error count: 50", exception.getMessage()); + } + + @Test + void test_isTrue_double() { + Assertions.assertDoesNotThrow(() -> ValidateUtils.isTrue(true, "Value: %.1f", 1.5)); + + IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> { + ValidateUtils.isTrue(false, "Value: %.2f", 3.1415); + }); + Assertions.assertEquals("Value: 3.14", exception.getMessage()); + } + + @Test + void test_isTrue_objects() { + Assertions.assertDoesNotThrow(() -> ValidateUtils.isTrue(true, "Failed for %s and %s", "A", "B")); + + IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> { + ValidateUtils.isTrue(false, "User %s has id %d", "Admin", 123); + }); + Assertions.assertEquals("User Admin has id 123", exception.getMessage()); + } + + @Test + void test_isTrue() { + Assertions.assertDoesNotThrow(() -> ValidateUtils.isTrue(1 + 1 == 2)); Review Comment: Test is always true. ########## fesod-common/src/test/java/org/apache/fesod/common/util/StringUtilsTest.java: ########## @@ -22,7 +22,194 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class StringUtilsTest { +/** + * Tests {@link StringUtils} + */ +class StringUtilsTest { + + private abstract static class RunTest { + + abstract boolean invoke(); + + void run(final TestData data, final String id) { + if (data.throwable != null) { + Assertions.assertThrows(data.throwable, this::invoke, id + " Expected " + data.throwable); + } else { + final boolean stringCheck = invoke(); + Assertions.assertEquals(data.expected, stringCheck, id + " Failed test " + data); + } + } + } + + static class TestData { Review Comment: 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. ```suggestion private static class TestData { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
