delei commented on code in PR #942:
URL: https://github.com/apache/fesod/pull/942#discussion_r3551558548
##########
fesod-sheet/src/test/java/org/apache/fesod/sheet/FesodSheetTest.java:
##########
@@ -247,4 +252,40 @@ void testReadSheet_withAllParams_shouldReturnBuilder() {
ExcelReaderSheetBuilder builder = FesodSheet.readSheet(0, "DataSheet",
100);
Assertions.assertNotNull(builder);
}
+
+ @Test
+ void testReadSheet_withColumnIndexes_shouldConfigureAll() {
+
+ java.util.List<java.util.List<String>> head = new
java.util.ArrayList<>();
+ head.add(new ArrayList<>(Arrays.asList("ID")));
+ head.add(new ArrayList<>(Arrays.asList("Name")));
+ head.add(new ArrayList<>(Arrays.asList("Age")));
+ head.add(new ArrayList<>(Arrays.asList("Gender")));
+
+ List<List<Object>> dataList = new ArrayList<>();
+ dataList.add(Arrays.asList("1", "Alice", "30", "Female"));
+
+
FesodSheet.write(tempFile).head(head).sheet("Sheet1").doWrite(dataList);
+
+ List<Integer> targetColumns = Arrays.asList(0, 2);
+
+ ExcelReaderSheetBuilder builder = FesodSheet.readSheetWithColumns(0,
"Sheet1", 100, targetColumns);
+ ReadSheet configuredSheet = builder.build();
+ List<Map<Integer, String>> readResults =
+ FesodSheet.read(tempFile).sheet(configuredSheet).doReadSync();
+
+ // builder tests
+ Assertions.assertNotNull(builder, "Builder should not be null");
+ Assertions.assertNotNull(configuredSheet, "The internal ReadSheet
should be created");
+ Assertions.assertEquals(1, configuredSheet.getSheetNo());
+ Assertions.assertEquals("Sheet1", configuredSheet.getSheetName());
+ Assertions.assertEquals(100, configuredSheet.getNumRows());
+ Assertions.assertEquals(targetColumns,
configuredSheet.getIncludeColumnIndexes());
+ // data related tests
+ Assertions.assertNotNull(readResults);
+ Map<Integer, String> parsedRow = readResults.get(0);
+ Assertions.assertEquals("1", parsedRow.get(0));
+ Assertions.assertEquals("Alice", parsedRow.get(1));
Review Comment:
```java
List<Integer> targetColumns = Arrays.asList(0, 2);
```
The `targetColumns` variable has been set to only include columns 0 and 2,
why are there three columns of data in the result?
Is there any misunderstanding or unfinished code logic?
--
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]