Skip to content

Commit 288c398

Browse files
author
Marten Deinum
committed
Polish contribution
- Adhere to rules from Checkstyle - Simplify implementation - Fix bug in other test-case (apparent after simplifying the implementation) Signed-off-by: Marten Deinum <[email protected]>
1 parent c69196e commit 288c398

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

spring-batch-excel/src/main/java/org/springframework/batch/extensions/excel/support/rowset/DefaultRowSet.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,9 @@ public Properties getProperties() {
7777
}
7878

7979
Properties props = new Properties();
80-
for (int i = 0; i < this.currentRow.length; i++) {
80+
for (int i = 0; i < names.length; i++) {
8181
String value = this.currentRow[i];
8282
if (value != null) {
83-
if (i > names.length - 1) {
84-
break;
85-
}
8683
props.setProperty(names[i], value);
8784
}
8885
}

spring-batch-excel/src/test/java/org/springframework/batch/extensions/excel/streaming/StreamingXlsxMappingTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class StreamingXlsxMappingTests {
3434

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
1+
/*
2+
* Copyright 2025-2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.springframework.batch.extensions.excel.support.rowset;
218

19+
import java.util.Arrays;
20+
321
import org.junit.jupiter.api.BeforeEach;
422
import org.junit.jupiter.api.Test;
5-
import org.junit.jupiter.api.extension.ExtendWith;
6-
import org.mockito.Mockito;
7-
import org.springframework.batch.extensions.excel.MockSheet;
8-
import org.springframework.batch.extensions.excel.Sheet;
923

10-
import java.util.ArrayList;
11-
import java.util.Arrays;
12-
import java.util.List;
13-
import java.util.Properties;
24+
import org.springframework.batch.extensions.excel.MockSheet;
1425

15-
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
16-
import static org.junit.jupiter.api.Assertions.*;
17-
import static org.mockito.BDDMockito.given;
26+
import static org.assertj.core.api.Assertions.assertThat;
1827

19-
class DefaultRowSetTest {
28+
class DefaultRowSetTests {
2029

2130
private DefaultRowSet rowSet;
2231

2332
@BeforeEach
2433
void setUp() {
25-
rowSet = new DefaultRowSet(new MockSheet(
34+
this.rowSet = new DefaultRowSet(new MockSheet(
2635
"Sheet1",
2736
Arrays.asList("col1a,col1b,col1c".split(","), "col2a,col2b,col2c".split(","), "col3a,col3b,col3c".split(","))
2837
), new RowSetMetaData() {
@@ -40,8 +49,8 @@ public String getSheetName() {
4049

4150
@Test
4251
void shouldReturnPropsSizeEqualsToMetadataColumns() {
43-
rowSet.next();
44-
var properties = rowSet.getProperties();
52+
this.rowSet.next();
53+
var properties = this.rowSet.getProperties();
4554

4655
assertThat(properties.size()).isEqualTo(2);
4756
assertThat(properties.getProperty("cola")).isEqualTo("col1a");

0 commit comments

Comments
 (0)