Skip to content

Commit e35bb83

Browse files
committed
add tests to check the start page for the next doc in a multi-doc export is set correctly based on the config option selected for page numbering.
1 parent a115fc4 commit e35bb83

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/test/java/com/researchspace/export/pdf/PdfProcessorTest.java

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.researchspace.export.pdf;
22

33
import static com.researchspace.testutils.RSpaceTestUtils.loadTextResourceFromPdfDir;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
45
import static org.junit.jupiter.api.Assertions.assertTrue;
56
import static org.mockito.Mockito.any;
67
import static org.mockito.Mockito.when;
@@ -85,6 +86,12 @@ public void outputNonAsciiCharactersTest(String nonAscii) throws Exception {
8586

8687
@Test
8788
public void concatenatesFiles() throws Exception {
89+
String output = concatTwoDocuments();
90+
assertTrue(output.contains("This is document 1."));
91+
assertTrue(output.contains("This is document 2."));
92+
}
93+
94+
private String concatTwoDocuments() throws Exception{
8895
// create 2 pdf docs then concatenate and verify the output doc contains the 2 inputs
8996
String doc1Html = loadTextResourceFromPdfDir("doc1.html");
9097
ExportProcesserInput exportProcesserInput1 =
@@ -105,10 +112,25 @@ public void concatenatesFiles() throws Exception {
105112

106113
List<File> filesToConcatenate = List.of(pdfDoc1, pdfDoc2);
107114
pdfProcessor.concatenateExportedFilesIntoOne(outputFile, filesToConcatenate, config);
108-
String output = readPdfContent(outputFile);
115+
return readPdfContent(outputFile);
116+
}
109117

110-
assertTrue(output.contains("This is document 1."));
111-
assertTrue(output.contains("This is document 2."));
118+
@Test
119+
public void testPageNumbersRestartedEachDoc() throws Exception {
120+
concatTwoDocuments();
121+
122+
// config has start page reset to 0 i.e. next doc would begin at page 1, which is the default
123+
assertEquals(0, config.getStartPage());
124+
}
125+
126+
@Test
127+
public void testPageNumbersContiguous() throws Exception {
128+
config.setRestartPageNumberPerDoc(false);
129+
concatTwoDocuments();
130+
131+
// config has start page as page 3 i.e. next doc would begin at page 4, since the config
132+
// property to restart the page number on each doc is set to false
133+
assertEquals(3, config.getStartPage());
112134
}
113135

114136
private String readPdfContent(File outFile) throws IOException {

0 commit comments

Comments
 (0)