You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/06/07 09:41:38 UTC
[causeway] branch master updated: CAUSEWAY-2297: minor technical dept.
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/master by this push:
new 947055003b CAUSEWAY-2297: minor technical dept.
947055003b is described below
commit 947055003b7f9db6bd43e8bb4ee7f44f75568533
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Jun 7 11:41:31 2023 +0200
CAUSEWAY-2297: minor technical dept.
---
.../extensions/excel/applib/WorksheetSpec.java | 19 +-
.../extensions/excel/applib/util/PivotUtils.java | 19 +-
.../excel/applib/util/PivotUtilsTest.java | 367 ++++++++++-----------
.../excel/applib/util/SheetPivoterTest.java | 43 +--
4 files changed, 223 insertions(+), 225 deletions(-)
diff --git a/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/WorksheetSpec.java b/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/WorksheetSpec.java
index 27890b9836..9f3bee8a2c 100644
--- a/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/WorksheetSpec.java
+++ b/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/WorksheetSpec.java
@@ -24,8 +24,10 @@ import javax.inject.Inject;
import org.apache.causeway.applib.annotation.Programmatic;
import org.apache.causeway.applib.services.inject.ServiceInjector;
+import org.apache.causeway.commons.internal.base._Casts;
import lombok.Setter;
+import lombok.SneakyThrows;
/**
* @since 2.0 {@index}
@@ -57,15 +59,10 @@ public class WorksheetSpec {
this.viewModelClass = viewModelClass;
}
- @Override
+ @Override @SneakyThrows
public T create() {
- try {
- final T t = viewModelClass.newInstance();
- servicesInjector.injectServicesInto(t);
- return t;
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
+ final T t = viewModelClass.getConstructor().newInstance();
+ return servicesInjector.injectServicesInto(t);
}
@Override
@@ -86,11 +83,11 @@ public class WorksheetSpec {
* @param sheetName - must be 31 chars or less
* @param <T>
*/
- public <T> WorksheetSpec(final Class<T> viewModelClass, String sheetName) {
+ public <T> WorksheetSpec(final Class<T> viewModelClass, final String sheetName) {
this(viewModelClass, sheetName, Mode.STRICT);
}
- public <T> WorksheetSpec(final Class<T> viewModelClass, String sheetName, final Mode mode) {
+ public <T> WorksheetSpec(final Class<T> viewModelClass, final String sheetName, final Mode mode) {
this(new RowFactory.Default<>(viewModelClass), sheetName, mode);
}
@@ -115,7 +112,7 @@ public class WorksheetSpec {
}
@Programmatic
- public <T> RowFactory<T> getFactory() { return (RowFactory<T>) factory; }
+ public <T> RowFactory<T> getFactory() { return _Casts.uncheckedCast(factory); }
@Programmatic
public String getSheetName() {
diff --git a/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/util/PivotUtils.java b/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/util/PivotUtils.java
index a2a26baa28..9217a6337a 100644
--- a/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/util/PivotUtils.java
+++ b/extensions/core/excel/applib/src/main/java/org/apache/causeway/extensions/excel/applib/util/PivotUtils.java
@@ -63,9 +63,11 @@ public class PivotUtils {
}
- static boolean cellValueEquals(Cell cell, Cell other) {
+ static boolean cellValueEquals(final Cell cell, final Cell other) {
- if (cell != null && other != null && cell.getCellType() == other.getCellType()) {
+ if (cell != null
+ && other != null
+ && cell.getCellType() == other.getCellType()) {
switch (cell.getCellType()) {
case BLANK:
@@ -83,8 +85,6 @@ public class PivotUtils {
return true;
}
break;
- case FORMULA:
- break;
case NUMERIC:
if (cell.getNumericCellValue() == other.getNumericCellValue()){
return true;
@@ -94,13 +94,16 @@ public class PivotUtils {
if (cell.getStringCellValue().equals(other.getStringCellValue())){
return true;
}
+ case FORMULA:
+ case _NONE:
+ break;
}
}
- return false;
+ return false;
}
- static Cell addCellValueTo(Cell source, Cell target){
+ static Cell addCellValueTo(final Cell source, final Cell target){
if (source == null) {
return target;
@@ -115,7 +118,7 @@ public class PivotUtils {
return target;
}
- static void copyCell(Cell source, Cell target) {
+ static void copyCell(final Cell source, final Cell target) {
// If the source cell is null, return
if (source == null) {
@@ -137,6 +140,8 @@ public class PivotUtils {
// Set the cell data value
switch (source.getCellType()) {
+ case _NONE:
+ break;
case BLANK:
target.setBlank();
break;
diff --git a/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/PivotUtilsTest.java b/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/PivotUtilsTest.java
index 4571f4042b..a8ce610048 100644
--- a/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/PivotUtilsTest.java
+++ b/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/PivotUtilsTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.causeway.extensions.excel.applib.util;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@@ -33,273 +34,267 @@ import org.junit.jupiter.api.Test;
class PivotUtilsTest {
@Test
- void createAnnotationRowTest() {
+ void createAnnotationRowTest() throws IOException {
// given
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet();
- Row r = sheet.createRow(0);
+ try(XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet();
+ Row r = sheet.createRow(0);
- List<String> l = Arrays.asList("a", "b", "c");
+ List<String> l = Arrays.asList("a", "b", "c");
- // when
- PivotUtils.createAnnotationRow(r,l);
+ // when
+ PivotUtils.createAnnotationRow(r,l);
- // then
- Assertions.assertThat(r.getCell(0).getStringCellValue()).isEqualTo("a");
- Assertions.assertThat(r.getCell(1).getStringCellValue()).isEqualTo("b");
- Assertions.assertThat(r.getCell(2).getStringCellValue()).isEqualTo("c");
+ // then
+ Assertions.assertThat(r.getCell(0).getStringCellValue()).isEqualTo("a");
+ Assertions.assertThat(r.getCell(1).getStringCellValue()).isEqualTo("b");
+ Assertions.assertThat(r.getCell(2).getStringCellValue()).isEqualTo("c");
+ }
}
@Test
- void createOrderRowTest() {
+ void createOrderRowTest() throws IOException {
// given
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet();
- Row r = sheet.createRow(1);
+ try(XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet();
+ Row r = sheet.createRow(1);
- List<Integer> l = Arrays.asList(1, 0, 2);
+ List<Integer> l = Arrays.asList(1, 0, 2);
- // when
- PivotUtils.createOrderRow(r,l);
-
- // then
- Assertions.assertThat(r.getCell(0).getNumericCellValue()).isEqualTo(1);
- Assertions.assertThat(r.getCell(1).getNumericCellValue()).isEqualTo(0);
- Assertions.assertThat(r.getCell(2).getNumericCellValue()).isEqualTo(2);
+ // when
+ PivotUtils.createOrderRow(r,l);
+ // then
+ Assertions.assertThat(r.getCell(0).getNumericCellValue()).isEqualTo(1);
+ Assertions.assertThat(r.getCell(1).getNumericCellValue()).isEqualTo(0);
+ Assertions.assertThat(r.getCell(2).getNumericCellValue()).isEqualTo(2);
+ }
}
@Test
- void cellValueEqualsTest() {
+ void cellValueEqualsTest() throws IOException {
// given
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet();
- Row r = sheet.createRow(0);
- Cell c1 = r.createCell(0);
- Cell c2 = r.createCell(1);
-
- // when numeric (double)
- c1.setCellValue(1.000000000000001);
- c2.setCellValue(1);
-
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ try(XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet();
+ Row r = sheet.createRow(0);
+ Cell c1 = r.createCell(0);
+ Cell c2 = r.createCell(1);
- // when (limits of double comparison)
- c1.setCellValue(1.0000000000000001);
- c2.setCellValue(1);
+ // when numeric (double)
+ c1.setCellValue(1.000000000000001);
+ c2.setCellValue(1);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when
- c1.setCellValue(1);
- c2.setCellValue(0.9999999999999999);
+ // when (limits of double comparison)
+ c1.setCellValue(1.0000000000000001);
+ c2.setCellValue(1);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
- // when (limits of double comparison)
- c1.setCellValue(1);
- c2.setCellValue(0.99999999999999999);
+ // when
+ c1.setCellValue(1);
+ c2.setCellValue(0.9999999999999999);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when (empty cells or cells with values not set, can't compare)
- c1 = r.createCell(0);
- c2 = r.createCell(1);
+ // when (limits of double comparison)
+ c1.setCellValue(1);
+ c2.setCellValue(0.99999999999999999);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
- // when (type not equal)
- c1 = r.createCell(0);
- c1.setCellType(CellType.BLANK);
- c2 = r.createCell(1);
- c2.setCellType(CellType.BOOLEAN);
+ // when (empty cells or cells with values not set, can't compare)
+ c1 = r.createCell(0);
+ c2 = r.createCell(1);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
- // when string
- c1 = r.createCell(0);
- c2 = r.createCell(1);
- c1.setCellValue("a");
- c2.setCellValue("a");
+ // when (type not equal)
+ c1 = r.createCell(0);
+ c1.setBlank();
+ c2 = r.createCell(1);
+ c2.setCellValue(false);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when case sensitive
- c1.setCellValue("a");
- c2.setCellValue("A");
+ // when string
+ c1 = r.createCell(0);
+ c2 = r.createCell(1);
+ c1.setCellValue("a");
+ c2.setCellValue("a");
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
- // when empty string
- c1.setCellValue("");
- c2.setCellValue("");
+ // when case sensitive
+ c1.setCellValue("a");
+ c2.setCellValue("A");
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when empty string and empty cell
- c1 = r.createCell(0);
- c2 = r.createCell(1);
- c1.setCellValue("");
+ // when empty string
+ c1.setCellValue("");
+ c2.setCellValue("");
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
- // when string and numeric
- c1 = r.createCell(0);
- c2 = r.createCell(1);
- c1.setCellValue("a");
- c2.setCellType(CellType.NUMERIC);
+ // when empty string and empty cell
+ c1 = r.createCell(0);
+ c2 = r.createCell(1);
+ c1.setCellValue("");
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when string and numeric
- c1 = r.createCell(0);
- c2 = r.createCell(1);
- c1.setCellValue("a");
- c2.setCellValue(0);
+ // when string and numeric
+ c1 = r.createCell(0);
+ c2 = r.createCell(1);
+ c1.setCellValue("a");
+ c2.setCellValue(1.2);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when boolean
- c1.setCellValue(true);
- c2.setCellValue(true);
+ // when string and numeric
+ c1 = r.createCell(0);
+ c2 = r.createCell(1);
+ c1.setCellValue("a");
+ c2.setCellValue(0);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
- // when
- c1.setCellValue(false);
- c2.setCellValue(true);
+ // when boolean
+ c1.setCellValue(true);
+ c2.setCellValue(true);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
- // when 0 (false) 1 (true) value in boolean cell supported
- c1.setCellValue(true);
- c2.setCellValue(1);
- c2.setCellType(CellType.BOOLEAN);
+ // when
+ c1.setCellValue(false);
+ c2.setCellValue(true);
- // then
- Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(true);
+ // then
+ Assertions.assertThat(PivotUtils.cellValueEquals(c1,c2)).isEqualTo(false);
+ }
}
@Test
- void addCellValueToTest(){
+ void addCellValueToTest() throws IOException{
// given
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet();
- Row r = sheet.createRow(0);
+ try(XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet();
+ Row r = sheet.createRow(0);
- // when source null
- Cell cSource = null;
- Cell cTarget = r.createCell(1);
- cTarget.setCellValue(1);
+ // when source null
+ Cell cSource = null;
+ Cell cTarget = r.createCell(1);
+ cTarget.setCellValue(1);
- PivotUtils.addCellValueTo(cSource, cTarget);
+ PivotUtils.addCellValueTo(cSource, cTarget);
- // then
- Assertions.assertThat(cTarget.getNumericCellValue()).isEqualTo(1);
+ // then
+ Assertions.assertThat(cTarget.getNumericCellValue()).isEqualTo(1);
- // when numeric
- cSource = r.createCell(0);
- cTarget = r.createCell(1);
- cSource.setCellValue(1);
- cTarget.setCellValue(2);
+ // when numeric
+ cSource = r.createCell(0);
+ cTarget = r.createCell(1);
+ cSource.setCellValue(1);
+ cTarget.setCellValue(2);
- PivotUtils.addCellValueTo(cSource, cTarget);
+ PivotUtils.addCellValueTo(cSource, cTarget);
- // then
- Assertions.assertThat(cTarget.getNumericCellValue()).isEqualTo(3);
+ // then
+ Assertions.assertThat(cTarget.getNumericCellValue()).isEqualTo(3);
- // when mixed: adding ignored
- cSource.setCellValue(1);
- cTarget.setCellValue("b");
+ // when mixed: adding ignored
+ cSource.setCellValue(1);
+ cTarget.setCellValue("b");
- PivotUtils.addCellValueTo(cSource, cTarget);
+ PivotUtils.addCellValueTo(cSource, cTarget);
- // then
- Assertions.assertThat(cTarget.getStringCellValue()).isEqualTo("b");
+ // then
+ Assertions.assertThat(cTarget.getStringCellValue()).isEqualTo("b");
- // when boolean: adding ignored
- cSource.setCellValue(true);
- cTarget.setCellValue(false);
+ // when boolean: adding ignored
+ cSource.setCellValue(true);
+ cTarget.setCellValue(false);
- PivotUtils.addCellValueTo(cSource, cTarget);
-
- // then
- Assertions.assertThat(cTarget.getBooleanCellValue()).isEqualTo(false);
+ PivotUtils.addCellValueTo(cSource, cTarget);
+ // then
+ Assertions.assertThat(cTarget.getBooleanCellValue()).isEqualTo(false);
+ }
}
- public void copyCellTest() {
+ public void copyCellTest() throws IOException {
// given
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet();
- Row r = sheet.createRow(0);
- Cell cTarget = r.createCell(0);
- cTarget.setCellValue(1);
-
- // given source null, do nothing
- Cell cSource = null;
+ try(XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet();
+ Row r = sheet.createRow(0);
+ Cell cTarget = r.createCell(0);
+ cTarget.setCellValue(1);
- // when
- PivotUtils.copyCell(cSource, cTarget);
+ // given source null, do nothing
+ Cell cSource = null;
- // then
- Assertions.assertThat(cTarget.getNumericCellValue()).isEqualTo(1);
+ // when
+ PivotUtils.copyCell(cSource, cTarget);
- // given source has no value
- cSource = r.createCell(1);
+ // then
+ Assertions.assertThat(cTarget.getNumericCellValue()).isEqualTo(1);
- // when
- PivotUtils.copyCell(cSource, cTarget);
+ // given source has no value
+ cSource = r.createCell(1);
- // then
- Assertions.assertThat(cTarget).isEqualTo(cSource);
- Assertions.assertThat(cTarget.getCellType()).isEqualTo(CellType.BLANK);
+ // when
+ PivotUtils.copyCell(cSource, cTarget);
- // given source has a value
- cSource = r.createCell(1);
- cSource.setCellValue("a");
+ // then
+ Assertions.assertThat(cTarget).isEqualTo(cSource);
+ Assertions.assertThat(cTarget.getCellType()).isEqualTo(CellType.BLANK);
- // when
- PivotUtils.copyCell(cSource, cTarget);
+ // given source has a value
+ cSource = r.createCell(1);
+ cSource.setCellValue("a");
- // then
- Assertions.assertThat(cTarget).isEqualTo(cSource);
- Assertions.assertThat(cTarget.getStringCellValue()).isEqualTo("a");
+ // when
+ PivotUtils.copyCell(cSource, cTarget);
- // given styles
- CellStyle styleSource = workbook.createCellStyle();
- cSource.setCellStyle(styleSource);
- CellStyle styleTarget = workbook.createCellStyle();
- cTarget.setCellStyle(styleTarget);
+ // then
+ Assertions.assertThat(cTarget).isEqualTo(cSource);
+ Assertions.assertThat(cTarget.getStringCellValue()).isEqualTo("a");
- // when
- PivotUtils.copyCell(cSource, cTarget);
+ // given styles
+ CellStyle styleSource = workbook.createCellStyle();
+ cSource.setCellStyle(styleSource);
+ CellStyle styleTarget = workbook.createCellStyle();
+ cTarget.setCellStyle(styleTarget);
- // then style is written over
- Assertions.assertThat(cTarget.getCellStyle()).isEqualTo(cSource.getCellStyle());
- Assertions.assertThat(cTarget.getCellStyle()).isEqualTo(styleSource);
+ // when
+ PivotUtils.copyCell(cSource, cTarget);
+ // then style is written over
+ Assertions.assertThat(cTarget.getCellStyle()).isEqualTo(cSource.getCellStyle());
+ Assertions.assertThat(cTarget.getCellStyle()).isEqualTo(styleSource);
+ }
}
}
diff --git a/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/SheetPivoterTest.java b/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/SheetPivoterTest.java
index 3924fe15ff..a8ff55d251 100644
--- a/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/SheetPivoterTest.java
+++ b/extensions/core/excel/applib/src/test/java/org/apache/causeway/extensions/excel/applib/util/SheetPivoterTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.causeway.extensions.excel.applib.util;
+import java.io.IOException;
import java.util.Arrays;
import java.util.List;
@@ -408,34 +409,34 @@ class SheetPivoterTest {
}
@Test
- void getDistinctValuesInSourceSheetColumnTest() {
+ void getDistinctValuesInSourceSheetColumnTest() throws IOException {
// given (only headers in source)
- XSSFWorkbook workbook = new XSSFWorkbook();
- XSSFSheet sheet = workbook.createSheet();
- sheet.createRow(0).createCell(0).setCellValue("row");
- sheet.createRow(1).createCell(0).setCellValue(1);
- sheet.createRow(2).createCell(0).setCellValue("fieldname");
+ try(XSSFWorkbook workbook = new XSSFWorkbook()) {
+ XSSFSheet sheet = workbook.createSheet();
+ sheet.createRow(0).createCell(0).setCellValue("row");
+ sheet.createRow(1).createCell(0).setCellValue(1);
+ sheet.createRow(2).createCell(0).setCellValue("fieldname");
- // when
- List<Cell> l = p.getDistinctValuesInSourceSheetColumn(sheet, 0);
-
- // then
- assertThat(l.size()).isEqualTo(0);
+ // when
+ List<Cell> l = SheetPivoter.getDistinctValuesInSourceSheetColumn(sheet, 0);
- // and when (values are added)
- sheet.createRow(3).createCell(0).setCellValue("a");
- sheet.createRow(4).createCell(0).setCellValue("a");
- sheet.createRow(5).createCell(0).setCellValue("b");
- sheet.createRow(6).createCell(0).setCellValue(1);
- sheet.createRow(7).createCell(0).setCellValue(""); // empty string differs from empty cell
- sheet.createRow(8).createCell(0); // empty string differs from empty cell
+ // then
+ assertThat(l.size()).isEqualTo(0);
- l = p.getDistinctValuesInSourceSheetColumn(sheet, 0);
+ // and when (values are added)
+ sheet.createRow(3).createCell(0).setCellValue("a");
+ sheet.createRow(4).createCell(0).setCellValue("a");
+ sheet.createRow(5).createCell(0).setCellValue("b");
+ sheet.createRow(6).createCell(0).setCellValue(1);
+ sheet.createRow(7).createCell(0).setCellValue(""); // empty string differs from empty cell
+ sheet.createRow(8).createCell(0); // empty string differs from empty cell
- // then
- assertThat(l.size()).isEqualTo(5);
+ l = SheetPivoter.getDistinctValuesInSourceSheetColumn(sheet, 0);
+ // then
+ assertThat(l.size()).isEqualTo(5);
+ }
}
void testRow(final int rowNumber, final Object... vals){