RED-9925 - Remove extra breakline from report
This commit is contained in:
parent
1ecd05f91c
commit
41ac300907
@ -586,6 +586,8 @@ public class WordReportGenerationService {
|
||||
|
||||
private int setText(XWPFTableCell cell, String value) {
|
||||
|
||||
// Apache POI automatically adds an initial empty paragraph to a cell resulting in a break line.
|
||||
cell.removeParagraph(0);
|
||||
cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
|
||||
XWPFParagraph addParagraph = cell.addParagraph();
|
||||
XWPFRun run = addParagraph.createRun();
|
||||
|
||||
@ -32,6 +32,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mockito;
|
||||
@ -186,6 +190,19 @@ public class RedactionReportIntegrationTest {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(getTemporaryDirectory() + "/Justification Appendix A1_justification.docx")) {
|
||||
fileOutputStream.write(wordReport);
|
||||
}
|
||||
|
||||
for (XWPFTable table : doc.getTables()) {
|
||||
for (XWPFTableRow row : table.getRows()) {
|
||||
for (XWPFTableCell cell : row.getTableCells()) {
|
||||
for (XWPFParagraph paragraph : cell.getParagraphs()) {
|
||||
String paragraphText = paragraph.getText();
|
||||
if (!paragraphText.equals("\n")) {
|
||||
Assertions.assertFalse(paragraphText.startsWith("\n"), "Paragraph starts with an empty line.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user