@Test public void commitRowTest() { SpreadsheetExporter exporter = new SpreadsheetExporter(); SpreadsheetExporter spy = spy(exporter); Sheet sheet = mock(Sheet.class); Row row = mock(Row.class); Cell cell = mock(Cell.class); DataSection section = mock(DataSection.class); Styler styler = mock(Styler.class); DataCell dataCell = mock(DataCell.class); DataCell[][] matrix = new DataCell[1][1]; matrix[0][0] = dataCell; doReturn(matrix).when(section).getMatrix(); doReturn(row).when(sheet).createRow(anyInt()); doReturn(0).when(section).getMaxX(); doReturn(0).when(section).getMaxY(); doReturn(cell).when(row).createCell(anyInt()); doNothing().when(cell).setCellValue(anyString()); doNothing().when(styler).style(any(DataCell.class), any(Cell.class), any(Workbook.class)); doReturn(0).when(dataCell).getNumberOfLines(); spy.commitRows(section, sheet, styler); verify(sheet, times(1)).createRow(anyInt()); verify(row, times(1)).createCell(anyInt()); verify(cell, times(1)).setCellValue(anyString()); verify(styler, times(1)).style(any(DataCell.class), any(Cell.class), any(Workbook.class)); verify(row, atMost(0)).setHeight(anyShort()); }
protected void commitRows(DataSection section, Sheet sheet, Styler styler) { DataCell[][] cells = section.getMatrix(); Row row; for (Integer y = 0; y <= section.getMaxY(); y++) { row = sheet.createRow(y); Integer maxLines = 0; for (Integer x = 0; x <= section.getMaxX(); x++) { DataCell dataCell = cells[x][y]; if (dataCell == null) { continue; } Cell cell = row.createCell(x); cell.setCellValue(dataCell.getValue()); styler.style(dataCell, cell, this.wBook); if (dataCell.getNumberOfLines() != null) { maxLines = maxLines < dataCell.getNumberOfLines() ? dataCell.getNumberOfLines() : maxLines; } } if (maxLines > 1) { Integer height = maxLines * 400; row.setHeight(height.shortValue()); } } }
SpreadsheetExporter { protected void commitRows(DataSection section, Sheet sheet, Styler styler) { DataCell[][] cells = section.getMatrix(); Row row; for (Integer y = 0; y <= section.getMaxY(); y++) { row = sheet.createRow(y); Integer maxLines = 0; for (Integer x = 0; x <= section.getMaxX(); x++) { DataCell dataCell = cells[x][y]; if (dataCell == null) { continue; } Cell cell = row.createCell(x); cell.setCellValue(dataCell.getValue()); styler.style(dataCell, cell, this.wBook); if (dataCell.getNumberOfLines() != null) { maxLines = maxLines < dataCell.getNumberOfLines() ? dataCell.getNumberOfLines() : maxLines; } } if (maxLines > 1) { Integer height = maxLines * 400; row.setHeight(height.shortValue()); } } } }
SpreadsheetExporter { protected void commitRows(DataSection section, Sheet sheet, Styler styler) { DataCell[][] cells = section.getMatrix(); Row row; for (Integer y = 0; y <= section.getMaxY(); y++) { row = sheet.createRow(y); Integer maxLines = 0; for (Integer x = 0; x <= section.getMaxX(); x++) { DataCell dataCell = cells[x][y]; if (dataCell == null) { continue; } Cell cell = row.createCell(x); cell.setCellValue(dataCell.getValue()); styler.style(dataCell, cell, this.wBook); if (dataCell.getNumberOfLines() != null) { maxLines = maxLines < dataCell.getNumberOfLines() ? dataCell.getNumberOfLines() : maxLines; } } if (maxLines > 1) { Integer height = maxLines * 400; row.setHeight(height.shortValue()); } } }  }
SpreadsheetExporter { protected void commitRows(DataSection section, Sheet sheet, Styler styler) { DataCell[][] cells = section.getMatrix(); Row row; for (Integer y = 0; y <= section.getMaxY(); y++) { row = sheet.createRow(y); Integer maxLines = 0; for (Integer x = 0; x <= section.getMaxX(); x++) { DataCell dataCell = cells[x][y]; if (dataCell == null) { continue; } Cell cell = row.createCell(x); cell.setCellValue(dataCell.getValue()); styler.style(dataCell, cell, this.wBook); if (dataCell.getNumberOfLines() != null) { maxLines = maxLines < dataCell.getNumberOfLines() ? dataCell.getNumberOfLines() : maxLines; } } if (maxLines > 1) { Integer height = maxLines * 400; row.setHeight(height.shortValue()); } } }  void export(String[] enabledFieldsArray, List<Patient> patients, OutputStream outputStream); }
SpreadsheetExporter { protected void commitRows(DataSection section, Sheet sheet, Styler styler) { DataCell[][] cells = section.getMatrix(); Row row; for (Integer y = 0; y <= section.getMaxY(); y++) { row = sheet.createRow(y); Integer maxLines = 0; for (Integer x = 0; x <= section.getMaxX(); x++) { DataCell dataCell = cells[x][y]; if (dataCell == null) { continue; } Cell cell = row.createCell(x); cell.setCellValue(dataCell.getValue()); styler.style(dataCell, cell, this.wBook); if (dataCell.getNumberOfLines() != null) { maxLines = maxLines < dataCell.getNumberOfLines() ? dataCell.getNumberOfLines() : maxLines; } } if (maxLines > 1) { Integer height = maxLines * 400; row.setHeight(height.shortValue()); } } }  void export(String[] enabledFieldsArray, List<Patient> patients, OutputStream outputStream);  }