-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove Louisiana PDF
- Loading branch information
Showing
4 changed files
with
57 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.mdbenefits.app.pdf; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.lowagie.text.pdf.PdfReader; | ||
import com.lowagie.text.pdf.parser.PdfTextExtractor; | ||
import formflow.library.data.Submission; | ||
import formflow.library.pdf.PdfService; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
import org.mdbenefits.app.data.SubmissionTestBuilder; | ||
import org.mdbenefits.app.utils.TestUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@ActiveProfiles("test") | ||
@SpringBootTest | ||
class PDFServiceTest { | ||
|
||
@Autowired | ||
PdfService pdfService; | ||
|
||
@Test | ||
void generate() throws IOException { | ||
Submission submission = new SubmissionTestBuilder() | ||
.withPersonalInfo("John", "Doe", "10", "12", "1999", | ||
"", "", "", "", "") | ||
.withHouseholdMember("Jane", "Doe", "1", "5", "2000", | ||
"wife", "F", "", "", "123", null, null) | ||
.with("homeAddressStreetAddress1", "972 Mission St, 5th Floor") | ||
.with("homeAddressCity", "San Francisco") | ||
.with("homeAddressState", "CA") | ||
.with("homeAddressZipCode", "94103") | ||
.build(); | ||
submission.setFlow("mdBenefitsFlow"); | ||
|
||
File pdfFile = pdfService.generate(submission); | ||
String text = getText(pdfFile); | ||
assertThat(text).contains("Doe, John"); | ||
} | ||
|
||
private static String getText(File file) throws IOException { | ||
try (PdfReader reader = new PdfReader(file.getPath())) { | ||
PdfTextExtractor pdfTextExtractor = new PdfTextExtractor(reader); | ||
return pdfTextExtractor.getTextFromPage(1); | ||
} | ||
} | ||
} |