|
| 1 | +package org.springframework.batch.extensions.excel.support.rowset; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.BeforeEach; |
| 4 | +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; |
| 9 | + |
| 10 | +import java.util.ArrayList; |
| 11 | +import java.util.Arrays; |
| 12 | +import java.util.List; |
| 13 | +import java.util.Properties; |
| 14 | + |
| 15 | +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
| 16 | +import static org.junit.jupiter.api.Assertions.*; |
| 17 | +import static org.mockito.BDDMockito.given; |
| 18 | + |
| 19 | +class DefaultRowSetTest { |
| 20 | + |
| 21 | + private DefaultRowSet rowSet; |
| 22 | + |
| 23 | + @BeforeEach |
| 24 | + void setUp() { |
| 25 | + rowSet = new DefaultRowSet(new MockSheet( |
| 26 | + "Sheet1", |
| 27 | + Arrays.asList("col1a,col1b,col1c".split(","), "col2a,col2b,col2c".split(","), "col3a,col3b,col3c".split(",")) |
| 28 | + ), new RowSetMetaData() { |
| 29 | + @Override |
| 30 | + public String[] getColumnNames() { |
| 31 | + return new String[]{ "cola", "colb"}; |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public String getSheetName() { |
| 36 | + return "Sheet1"; |
| 37 | + } |
| 38 | + }); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + void shouldReturnPropsSizeEqualsToMetadataColumns() { |
| 43 | + rowSet.next(); |
| 44 | + var properties = rowSet.getProperties(); |
| 45 | + |
| 46 | + assertThat(properties.size()).isEqualTo(2); |
| 47 | + assertThat(properties.getProperty("cola")).isEqualTo("col1a"); |
| 48 | + assertThat(properties.getProperty("colb")).isEqualTo("col1b"); |
| 49 | + assertThat(properties.getProperty("colc")).isNull(); |
| 50 | + } |
| 51 | +} |
0 commit comments