1
1
package com .researchspace .export .pdf ;
2
2
3
3
import static com .researchspace .testutils .RSpaceTestUtils .loadTextResourceFromPdfDir ;
4
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
5
import static org .junit .jupiter .api .Assertions .assertTrue ;
5
6
import static org .mockito .Mockito .any ;
6
7
import static org .mockito .Mockito .when ;
@@ -85,6 +86,12 @@ public void outputNonAsciiCharactersTest(String nonAscii) throws Exception {
85
86
86
87
@ Test
87
88
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 {
88
95
// create 2 pdf docs then concatenate and verify the output doc contains the 2 inputs
89
96
String doc1Html = loadTextResourceFromPdfDir ("doc1.html" );
90
97
ExportProcesserInput exportProcesserInput1 =
@@ -105,10 +112,25 @@ public void concatenatesFiles() throws Exception {
105
112
106
113
List <File > filesToConcatenate = List .of (pdfDoc1 , pdfDoc2 );
107
114
pdfProcessor .concatenateExportedFilesIntoOne (outputFile , filesToConcatenate , config );
108
- String output = readPdfContent (outputFile );
115
+ return readPdfContent (outputFile );
116
+ }
109
117
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 ());
112
134
}
113
135
114
136
private String readPdfContent (File outFile ) throws IOException {
0 commit comments