@Test public void styleNoStyles() { Styler styler = new Styler(); DataCell dataCell = mock(DataCell.class); Cell cell = mock(Cell.class); Workbook workbook = mock(Workbook.class); CellStyle style = mock(CellStyle.class); Font font = mock(Font.class); doReturn(null).when(dataCell).getStyles(); doReturn(style).when(workbook).createCellStyle(); doReturn(font).when(workbook).createFont(); styler.style(dataCell, cell, workbook); verify(dataCell).getStyles(); verify(style, times(1)).setWrapText(true); verify(style, times(1)).setFont(any(Font.class)); verify(style, times(1)).setVerticalAlignment(CellStyle.VERTICAL_TOP); verify(cell, times(1)).setCellStyle(style); verifyNoMoreInteractions(style); verifyNoMoreInteractions(cell); verifyNoMoreInteractions(dataCell); }
public void style(DataCell dataCell, Cell cell, Workbook wBook) { Set<StyleOption> styles = dataCell.getStyles(); CellStyle cellStyle = wBook.createCellStyle(); cellStyle.setWrapText(true); if (this.defaultFont == null) { this.defaultFont = createDefaultFont(wBook); } cellStyle.setFont(this.defaultFont); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); if (this.setDefaultStyle(styles, cell, cellStyle)) { return; } if (this.styleCache.containsKey(styles)) { cell.setCellStyle(this.styleCache.get(styles)); return; } this.setFontStyles(styles, cell, cellStyle, wBook); this.setBorderStyles(styles, cell, cellStyle, wBook); this.styleCache.put(styles, cellStyle); }
Styler { public void style(DataCell dataCell, Cell cell, Workbook wBook) { Set<StyleOption> styles = dataCell.getStyles(); CellStyle cellStyle = wBook.createCellStyle(); cellStyle.setWrapText(true); if (this.defaultFont == null) { this.defaultFont = createDefaultFont(wBook); } cellStyle.setFont(this.defaultFont); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); if (this.setDefaultStyle(styles, cell, cellStyle)) { return; } if (this.styleCache.containsKey(styles)) { cell.setCellStyle(this.styleCache.get(styles)); return; } this.setFontStyles(styles, cell, cellStyle, wBook); this.setBorderStyles(styles, cell, cellStyle, wBook); this.styleCache.put(styles, cellStyle); } }
Styler { public void style(DataCell dataCell, Cell cell, Workbook wBook) { Set<StyleOption> styles = dataCell.getStyles(); CellStyle cellStyle = wBook.createCellStyle(); cellStyle.setWrapText(true); if (this.defaultFont == null) { this.defaultFont = createDefaultFont(wBook); } cellStyle.setFont(this.defaultFont); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); if (this.setDefaultStyle(styles, cell, cellStyle)) { return; } if (this.styleCache.containsKey(styles)) { cell.setCellStyle(this.styleCache.get(styles)); return; } this.setFontStyles(styles, cell, cellStyle, wBook); this.setBorderStyles(styles, cell, cellStyle, wBook); this.styleCache.put(styles, cellStyle); }  }
Styler { public void style(DataCell dataCell, Cell cell, Workbook wBook) { Set<StyleOption> styles = dataCell.getStyles(); CellStyle cellStyle = wBook.createCellStyle(); cellStyle.setWrapText(true); if (this.defaultFont == null) { this.defaultFont = createDefaultFont(wBook); } cellStyle.setFont(this.defaultFont); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); if (this.setDefaultStyle(styles, cell, cellStyle)) { return; } if (this.styleCache.containsKey(styles)) { cell.setCellStyle(this.styleCache.get(styles)); return; } this.setFontStyles(styles, cell, cellStyle, wBook); this.setBorderStyles(styles, cell, cellStyle, wBook); this.styleCache.put(styles, cellStyle); }  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 void style(DataCell dataCell, Cell cell, Workbook wBook) { Set<StyleOption> styles = dataCell.getStyles(); CellStyle cellStyle = wBook.createCellStyle(); cellStyle.setWrapText(true); if (this.defaultFont == null) { this.defaultFont = createDefaultFont(wBook); } cellStyle.setFont(this.defaultFont); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP); if (this.setDefaultStyle(styles, cell, cellStyle)) { return; } if (this.styleCache.containsKey(styles)) { cell.setCellStyle(this.styleCache.get(styles)); return; } this.setFontStyles(styles, cell, cellStyle, wBook); this.setBorderStyles(styles, cell, cellStyle, wBook); this.styleCache.put(styles, cellStyle); }  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);  }