Skip to content

Commit

Permalink
Update test code with new API for loading documents into pdfbox
Browse files Browse the repository at this point in the history
  • Loading branch information
froque committed Sep 4, 2023
1 parent fde2666 commit 98ea2fa
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.UUID;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -103,7 +105,7 @@ void testPdfCreation()
ADCreditNoteData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -155,7 +157,7 @@ void testPdfCreationFromBundle()
ADCreditNoteData entityData = this.extractor.extract(uidEntity);
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.nio.file.Paths;
import java.util.UUID;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -106,7 +107,7 @@ void testPdfCreation()
ADCreditReceiptData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -143,7 +144,7 @@ void testPdfCreationFromBundle()
ADCreditReceiptData entityData = this.extractor.extract(uidEntity);
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -89,7 +91,7 @@ void testPdfCreation() throws ExportServiceException, IOException {
ADInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -113,7 +115,7 @@ void testDifferentRegion() throws ExportServiceException, IOException {
ADInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -131,7 +133,7 @@ void testManyEntries() throws ExportServiceException, IOException {
ADInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -149,7 +151,7 @@ void testManyEntriesWithDifrentRegions() throws ExportServiceException, IOExcept
ADInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(2, doc.getNumberOfPages());
}
}
Expand All @@ -170,7 +172,7 @@ void testPdfCreationFromBundle() throws ExportServiceException, IOException {
ADInvoiceData entityData = this.extractor.extract(entity.getUID());
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -89,7 +91,7 @@ void testPdfCreation() throws ExportServiceException, IOException {
ADReceiptData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -116,7 +118,7 @@ void testPdfCreationFromBundle() throws ExportServiceException, IOException {
ADReceiptData entityData = this.extractor.extract(entity.getUID());
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -87,7 +89,7 @@ void testPdfCreation()
ADSimpleInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -115,7 +117,7 @@ void testPdfCreationFromBundle() throws ExportServiceException, IOException {
ADSimpleInvoiceData entityData = this.extractor.extract(entity.getUID());
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.nio.file.Paths;
import java.util.UUID;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -105,7 +106,7 @@ public class TestFRCreditNotePDFTransformer extends FRPersistencyAbstractTest {
FRCreditNoteData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -156,7 +157,7 @@ public class TestFRCreditNotePDFTransformer extends FRPersistencyAbstractTest {
FRCreditNoteData entityData = this.extractor.extract(uidEntity);
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.nio.file.Paths;
import java.util.UUID;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -105,7 +106,7 @@ public class TestFRCreditReceiptPDFTransformer extends FRPersistencyAbstractTest
FRCreditReceiptData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -142,7 +143,7 @@ public class TestFRCreditReceiptPDFTransformer extends FRPersistencyAbstractTest
FRCreditReceiptData entityData = this.extractor.extract(uidEntity);
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -91,7 +92,7 @@ public void testPdfCreation()
FRInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -116,7 +117,7 @@ public void testDifferentRegion()
FRInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -135,7 +136,7 @@ public void testManyEntries()
FRInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -154,7 +155,7 @@ public void testManyEntriesWithDifferentRegions()
FRInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -174,7 +175,7 @@ public void testPdfCreationFromBundle() throws ExportServiceException, IOExcepti
FRInvoiceData entityData = this.extractor.extract(entity.getUID());
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void testPdfCreation() throws ExportServiceException, IOException {
FRReceiptData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -119,7 +120,7 @@ public void testPdfCreationFromBundle() throws ExportServiceException, IOExcepti
FRReceiptData entityData = this.extractor.extract(entity.getUID());
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void testPdfCreation()
FRSimpleInvoiceData entityData = this.extractor.extract(entity.getUID());
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -120,7 +121,7 @@ public void testPdfCreationFromBundle() throws ExportServiceException, IOExcepti
FRSimpleInvoiceData entityData = this.extractor.extract(entity.getUID());
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.UUID;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -108,7 +110,7 @@ void testPdfCreation()
PTCreditNoteData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down Expand Up @@ -146,7 +148,7 @@ void testPdfCreationFromBundle()
PTCreditNoteData entityData = this.extractor.extract(uidEntity);
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.apache.pdfbox.Loader;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -92,7 +94,7 @@ void testPdfCreation() throws ExportServiceException, IOException {
PTInvoiceData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -118,7 +120,7 @@ void testDifferentRegion() throws ExportServiceException, IOException {
PTInvoiceData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -137,7 +139,7 @@ void testManyEntries() throws ExportServiceException, IOException {
PTInvoiceData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand All @@ -156,7 +158,7 @@ void testManyEntriesWithDifrentRegions() throws ExportServiceException, IOExcept
PTInvoiceData entityData = this.extractor.extract(uidEntity);
this.transformer.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(2, doc.getNumberOfPages());
}
}
Expand All @@ -179,7 +181,7 @@ void testPdfCreationFromBundle() throws ExportServiceException, IOException {
PTInvoiceData entityData = this.extractor.extract(uidEntity);
transformerBundle.transform(entityData, os);

try (PDDocument doc = PDDocument.load(result)) {
try (PDDocument doc = Loader.loadPDF(result)) {
assertEquals(1, doc.getNumberOfPages());
}
}
Expand Down
Loading

0 comments on commit 98ea2fa

Please sign in to comment.