Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Properties getProperties() {
}

Properties props = new Properties();
for (int i = 0; i < this.currentRow.length; i++) {
for (int i = 0; i < names.length; i++) {
String value = this.currentRow[i];
if (value != null) {
props.setProperty(names[i], value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class StreamingXlsxMappingTests {

@Test
void readAndMapRowsUsingRowMapper() throws Exception {
var columns = new String[] {"id", "position", "lastName", "firstName", "birthYear", "debutYear", "comment"};
var columns = new String[] {"id", "position", "lastName", "firstName", "birthYear", "debutYear"};
var rowSetFactory = new DefaultRowSetFactory();
rowSetFactory.setColumnNameExtractor(new StaticColumnNameExtractor(columns));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2025-2025 the original author or authors.
*
* Licensed 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
*
* https://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.springframework.batch.extensions.excel.support.rowset;

import java.util.Arrays;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.springframework.batch.extensions.excel.MockSheet;

import static org.assertj.core.api.Assertions.assertThat;

class DefaultRowSetTests {

private DefaultRowSet rowSet;

@BeforeEach
void setUp() {
this.rowSet = new DefaultRowSet(new MockSheet(
"Sheet1",
Arrays.asList("col1a,col1b,col1c".split(","), "col2a,col2b,col2c".split(","), "col3a,col3b,col3c".split(","))
), new RowSetMetaData() {
@Override
public String[] getColumnNames() {
return new String[]{ "cola", "colb"};
}

@Override
public String getSheetName() {
return "Sheet1";
}
});
}

@Test
void shouldReturnPropsSizeEqualsToMetadataColumns() {
this.rowSet.next();
var properties = this.rowSet.getProperties();

assertThat(properties.size()).isEqualTo(2);
assertThat(properties.getProperty("cola")).isEqualTo("col1a");
assertThat(properties.getProperty("colb")).isEqualTo("col1b");
assertThat(properties.getProperty("colc")).isNull();
}
}