@Test public void styleBorder() throws Exception { DataSection section = mock(DataSection.class); StyleOption styleLeft = StyleOption.SECTION_BORDER_LEFT; StyleOption styleRight = StyleOption.SECTION_BORDER_RIGHT; DataCell cellLeft = mock(DataCell.class); DataCell cellRight = mock(DataCell.class); DataCell[][] matrix = new DataCell[2][2]; matrix[0][0] = cellLeft; matrix[1][0] = cellRight; doReturn(matrix).when(section).getMatrix(); doReturn(1).when(section).getMaxX(); doReturn(1).when(section).getMaxY(); Styler.styleSectionBorder(section, styleLeft, styleRight); verify(section, times(2)).addCell(any(DataCell.class)); verify(cellLeft, times(1)).addStyle(styleLeft); verify(cellRight, times(1)).addStyle(styleRight); }
public static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { DataCell cellLeft = cellMatrix[0][y]; DataCell cellRight = cellMatrix[section.getMaxX()][y]; if (cellLeft == null) { cellLeft = new DataCell("", 0, y); section.addCell(cellLeft); } if (cellRight == null) { cellRight = new DataCell("", section.getMaxX(), y); section.addCell(cellRight); } cellLeft.addStyle(styleLeft); cellRight.addStyle(styleRight); } }
Styler { public static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { DataCell cellLeft = cellMatrix[0][y]; DataCell cellRight = cellMatrix[section.getMaxX()][y]; if (cellLeft == null) { cellLeft = new DataCell("", 0, y); section.addCell(cellLeft); } if (cellRight == null) { cellRight = new DataCell("", section.getMaxX(), y); section.addCell(cellRight); } cellLeft.addStyle(styleLeft); cellRight.addStyle(styleRight); } } }
Styler { public static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { DataCell cellLeft = cellMatrix[0][y]; DataCell cellRight = cellMatrix[section.getMaxX()][y]; if (cellLeft == null) { cellLeft = new DataCell("", 0, y); section.addCell(cellLeft); } if (cellRight == null) { cellRight = new DataCell("", section.getMaxX(), y); section.addCell(cellRight); } cellLeft.addStyle(styleLeft); cellRight.addStyle(styleRight); } }  }
Styler { public static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { DataCell cellLeft = cellMatrix[0][y]; DataCell cellRight = cellMatrix[section.getMaxX()][y]; if (cellLeft == null) { cellLeft = new DataCell("", 0, y); section.addCell(cellLeft); } if (cellRight == null) { cellRight = new DataCell("", section.getMaxX(), y); section.addCell(cellRight); } cellLeft.addStyle(styleLeft); cellRight.addStyle(styleRight); } }  static void disallowBodyStyles(DataSection section); static void styleSectionBottom(DataSection section, StyleOption style); static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleHorizontally(DataSection section, StyleOption... styles); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleVertically(DataSection section, StyleOption... styles); void style(DataCell dataCell, Cell cell, Workbook wBook); }
Styler { public static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight) throws Exception { DataCell[][] cellMatrix = section.getMatrix(); if (cellMatrix == null) { throw new Exception(NO_MATRIX_ERR_MSG); } for (int y = 0; y <= section.getMaxY(); y++) { DataCell cellLeft = cellMatrix[0][y]; DataCell cellRight = cellMatrix[section.getMaxX()][y]; if (cellLeft == null) { cellLeft = new DataCell("", 0, y); section.addCell(cellLeft); } if (cellRight == null) { cellRight = new DataCell("", section.getMaxX(), y); section.addCell(cellRight); } cellLeft.addStyle(styleLeft); cellRight.addStyle(styleRight); } }  static void disallowBodyStyles(DataSection section); static void styleSectionBottom(DataSection section, StyleOption style); static void styleSectionBorder(DataSection section, StyleOption styleLeft, StyleOption styleRight); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleHorizontally(DataSection section, StyleOption... styles); @SuppressWarnings({ "checkstyle:NPathComplexity", "checkstyle:CyclomaticComplexity" }) static void extendStyleVertically(DataSection section, StyleOption... styles); void style(DataCell dataCell, Cell cell, Workbook wBook);  }