Copilot commented on code in PR #916:
URL: https://github.com/apache/fesod/pull/916#discussion_r3231803969


##########
fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.sheet.write.style;
+
+import org.apache.fesod.sheet.metadata.property.SheetFreezePaneProperty;
+import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder;
+import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+class SheetFreezePaneStrategyTest {
+
+    @Test
+    void constructor_throws_whenColSplitNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(-1, 0, 0, 0));
+    }
+
+    @Test
+    void constructor_throws_whenRowSplitNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(0, -1, 0, 0));
+    }
+
+    @Test
+    void constructor_throws_whenLeftmostColumnNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(0, 0, -1, 0));
+    }
+
+    @Test
+    void constructor_throws_whenTopRowNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(0, 0, 0, -1));
+    }
+
+    @Test
+    void constructor_acceptsAllZeros() {
+        Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(0, 0, 
0, 0));
+    }
+
+    @Test
+    void constructor_acceptsPositiveValues() {
+        Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(2, 3, 
4, 5));
+    }
+
+    @Test
+    void constructor_fromProperty_copiesAllFields() {
+        SheetFreezePaneProperty property = new SheetFreezePaneProperty();
+        property.setColSplit(1);
+        property.setRowSplit(2);
+        property.setLeftmostColumn(3);
+        property.setTopRow(4);
+
+        Assertions.assertDoesNotThrow(() -> new 
SheetFreezePaneStrategy(property));

Review Comment:
   Test name says it "copiesAllFields", but the assertion only checks that 
construction does not throw. Either add assertions that the constructed 
strategy uses the property values (e.g., by invoking `afterSheetCreate` and 
verifying `createFreezePane` params) or rename the test to reflect what it 
actually verifies.
   



##########
fesod-sheet/src/test/java/org/apache/fesod/sheet/write/style/SheetFreezePaneStrategyTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.sheet.write.style;
+
+import org.apache.fesod.sheet.metadata.property.SheetFreezePaneProperty;
+import org.apache.fesod.sheet.write.metadata.holder.WriteSheetHolder;
+import org.apache.fesod.sheet.write.metadata.holder.WriteWorkbookHolder;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+class SheetFreezePaneStrategyTest {
+
+    @Test
+    void constructor_throws_whenColSplitNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(-1, 0, 0, 0));
+    }
+
+    @Test
+    void constructor_throws_whenRowSplitNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(0, -1, 0, 0));
+    }
+
+    @Test
+    void constructor_throws_whenLeftmostColumnNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(0, 0, -1, 0));
+    }
+
+    @Test
+    void constructor_throws_whenTopRowNegative() {
+        Assertions.assertThrows(IllegalArgumentException.class, () -> new 
SheetFreezePaneStrategy(0, 0, 0, -1));
+    }
+
+    @Test
+    void constructor_acceptsAllZeros() {
+        Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(0, 0, 
0, 0));
+    }
+
+    @Test
+    void constructor_acceptsPositiveValues() {
+        Assertions.assertDoesNotThrow(() -> new SheetFreezePaneStrategy(2, 3, 
4, 5));
+    }
+
+    @Test
+    void constructor_fromProperty_copiesAllFields() {
+        SheetFreezePaneProperty property = new SheetFreezePaneProperty();
+        property.setColSplit(1);
+        property.setRowSplit(2);
+        property.setLeftmostColumn(3);
+        property.setTopRow(4);
+
+        Assertions.assertDoesNotThrow(() -> new 
SheetFreezePaneStrategy(property));
+    }
+
+    @Test
+    void afterSheetCreate_createsFreezePaneWithCorrectParams() {
+        SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(2, 3, 
4, 5);
+
+        WriteWorkbookHolder workbookHolder = 
Mockito.mock(WriteWorkbookHolder.class);
+        WriteSheetHolder sheetHolder = Mockito.mock(WriteSheetHolder.class);
+        Sheet sheet = Mockito.mock(Sheet.class);
+        Mockito.when(sheetHolder.getSheet()).thenReturn(sheet);
+
+        strategy.afterSheetCreate(workbookHolder, sheetHolder);
+
+        Mockito.verify(sheet).createFreezePane(2, 3, 4, 5);
+    }
+
+    @Test
+    void afterSheetCreate_withZeroValues() {
+        SheetFreezePaneStrategy strategy = new SheetFreezePaneStrategy(0, 0, 
0, 0);
+
+        WriteWorkbookHolder workbookHolder = 
Mockito.mock(WriteWorkbookHolder.class);
+        WriteSheetHolder sheetHolder = Mockito.mock(WriteSheetHolder.class);
+        Sheet sheet = Mockito.mock(Sheet.class);
+        org.mockito.Mockito.when(sheetHolder.getSheet()).thenReturn(sheet);
+

Review Comment:
   Minor inconsistency: this test uses both the imported `Mockito` and 
fully-qualified `org.mockito.Mockito` in the same file. Prefer using the 
imported `Mockito` consistently to keep the test concise.



##########
fesod-sheet/src/main/java/org/apache/fesod/sheet/annotation/write/style/FreezePane.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.sheet.annotation.write.style;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation used to define a freeze pane for an Excel sheet.
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+public @interface FreezePane {
+
+    /**
+     * Horizontal position of split.
+     */
+    int colSplit();
+
+    /**
+     * Vertical position of split.
+     */
+    int rowSplit();

Review Comment:
   `@FreezePane` makes `colSplit` and `rowSplit` mandatory (no defaults), 
whereas most existing annotations in 
`org.apache.fesod.sheet.annotation.write.style` provide defaults (e.g., 
`@ColumnWidth`, `@HeadRowHeight`, `@OnceAbsoluteMerge`). Consider adding 
defaults so `@FreezePane` can be used as a simple opt-in and callers only 
specify values when deviating from the default behavior.
   



-- 
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]

Reply via email to