### Question:
ProcessErrorReportExcelServlet extends SlingSafeMethodsServlet { @SuppressWarnings("squid:S3776") protected Workbook createSpreadsheet(ManagedProcess report) { Workbook wb = new XSSFWorkbook(); String name = report.getName(); for (char ch : new char[]{'\\', '/', '*', '[', ']', ':', '?'}) { name = StringUtils.remove(name, ch); } Sheet sheet = wb.createSheet(name); sheet.createFreezePane(0, 1, 0, 1); Row headerRow = sheet.createRow(0); CellStyle headerStyle = createHeaderStyle(wb); CellStyle dateStyle = wb.createCellStyle(); CreationHelper createHelper = wb.getCreationHelper(); dateStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyy/mm/dd h:mm:ss")); for (String columnName : Arrays.asList("Time", "Path", "Error", "Stack trace")) { Cell headerCell = headerRow.createCell(headerRow.getPhysicalNumberOfCells()); headerCell.setCellValue(columnName); headerCell.setCellStyle(headerStyle); } Collection<ArchivedProcessFailure> rows = report.getReportedErrorsList(); for (ArchivedProcessFailure error : rows) { Row row = sheet.createRow(sheet.getPhysicalNumberOfRows()); Cell c; c = row.createCell(0); c.setCellValue(error.time); c.setCellStyle(dateStyle); c = row.createCell(1); c.setCellValue(error.nodePath); c = row.createCell(2); c.setCellValue(error.error); c = row.createCell(3); c.setCellValue(error.stackTrace); } autosize(sheet, 4); sheet.setAutoFilter(new CellRangeAddress(0, 1 + rows.size(), 0, 3)); return wb; }    }### Answer:
@Test public void createSpreadsheet() throws Exception { final int overB2Width = servlet.getColumnBlockSize() * servlet.getMinColumnBlockCount(); final int overC3Width = servlet.getColumnBlockSize() * (servlet.getMaxColumnBlockCount() + 1); addFailure("path1", "error1", "stacktrace1"); addFailure("path2", repeatUntilMinLengthReached("error2", overB2Width), "stacktrace2"); addFailure("path3", "error3", repeatUntilMinLengthReached("stacktrace3", overC3Width)); addFailure("path4", "error4", "stacktrace4"); Workbook wb = servlet.createSpreadsheet(process); assertNotNull("Created workbook", wb); assertEquals("Created one sheet", 1, wb.getNumberOfSheets()); assertEquals("Created correct number of rows", 5, wb.getSheetAt(0).getPhysicalNumberOfRows()); final String b2String = wb.getSheetAt(0).getRow(2).getCell(2).getStringCellValue(); assertTrue("expect cell starts with repeated: " + b2String, b2String.startsWith("error2error2") && b2String.length() >= overB2Width); final String c3String = wb.getSheetAt(0).getRow(3).getCell(3).getStringCellValue(); assertTrue("expect cell starts with repeated: " + c3String, c3String.startsWith("stacktrace3stacktrace3") && c3String.length() >= overC3Width); final int cWidth = wb.getSheetAt(0).getColumnWidth(3); assertTrue("expect C column width is less than requested: " + cWidth + " < " + overC3Width, cWidth < overC3Width); }