aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/test/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-pdfbox-2/src/test/java/at')
-rw-r--r--pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java51
-rw-r--r--pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java21
2 files changed, 66 insertions, 6 deletions
diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java
new file mode 100644
index 00000000..fbe3cdea
--- /dev/null
+++ b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/PDFBoxPlaceholderExtractorTest.java
@@ -0,0 +1,51 @@
+package at.gv.egiz.pdfas.lib.testpdfbox;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.junit.Test;
+
+import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor;
+import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
+import lombok.SneakyThrows;
+
+public class PDFBoxPlaceholderExtractorTest {
+
+ @Test
+ @SneakyThrows
+ public void nextPlaceholder() {
+ SignaturePlaceholderData result = getNextSignaturePlaceHolder("/data/platzhalter_en_de_test.pdf");
+ assertEquals("Im48", result.getPlaceholderName());
+
+ }
+
+ @Test
+ @SneakyThrows
+ public void allPlaceHolders() {
+ List<String> listOfPlaceHolders = getPlaceHolders("/data/platzhalter_en_de_test.pdf");
+ assertNotNull(listOfPlaceHolders);
+
+ }
+
+ private static List<String> getPlaceHolders(String filePath) throws IOException {
+ final PDDocument doc = PDDocument.load(PDFBoxPlaceholderExtractorTest.class.getResourceAsStream(
+ filePath));
+ final List<String> results = SignatureFieldsAndPlaceHolderExtractor.findEmptySignatureFields(doc);
+ return results;
+
+ }
+
+ private static SignaturePlaceholderData getNextSignaturePlaceHolder(String filePath) throws IOException {
+ final PDDocument doc = PDDocument.load(PDFBoxPlaceholderExtractorTest.class.getResourceAsStream(
+ filePath));
+ final SignaturePlaceholderData result =
+ SignatureFieldsAndPlaceHolderExtractor.getNextUnusedSignaturePlaceHolder(doc);
+ return result;
+
+ }
+
+}
diff --git a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java
index 0d85c82b..61a1199d 100644
--- a/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java
+++ b/pdf-as-pdfbox-2/src/test/java/at/gv/egiz/pdfas/lib/testpdfbox/SignatureFieldsAndPlaceHolderExtractorTest.java
@@ -1,16 +1,17 @@
package at.gv.egiz.pdfas.lib.testpdfbox;
-import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor;
-import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.junit.Assert;
-import org.junit.Test;
-
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.junit.Assert;
+import org.junit.Test;
+
+import at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder.SignatureFieldsAndPlaceHolderExtractor;
+import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
+
public class SignatureFieldsAndPlaceHolderExtractorTest {
public String getPath(String resourceName) {
@@ -48,6 +49,14 @@ public class SignatureFieldsAndPlaceHolderExtractorTest {
SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("manySignFields.pdf"));
Assert.assertEquals(null,result);
}
+
+ @Test
+ public void firstQrCodeOnUnsignedDoc() {
+ SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2-2.pdf"));
+ Assert.assertEquals("Image5",result.getPlaceholderName());
+
+ }
+
@Test
public void subsequentCalls(){
SignaturePlaceholderData result = getNextSignaturePlaceHolder(getPath("new_qr_2_signed_signed_signed.pdf"));