Skip to content

Commit

Permalink
Add cover pages to PDF (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
spokenbird authored Mar 12, 2024
1 parent b4d20b5 commit e907d82
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ inputFields:
#Page1
applicantFullName: applicant_full_name
phoneNumber: applicant_home_phone_number
emailAddress: applicant_email
homeAddressStreetAddress1: applicant_home_address_line1
homeAddressStreetAddress2: applicant_home_address_line2
homeAddressCity: applicant_home_address_city
Expand Down Expand Up @@ -42,6 +43,7 @@ inputFields:
applicantIsEnrolledInSchool: applicant_is_in_school
applicantRace: applicant_race
applicantEthnicity: applicant_ethnicity
confirmationNumber: confirmation_number

#Section M
someoneHasDrugKingpinFelony: household_drugpin_felony_bool
Expand Down
Binary file modified src/main/resources/pdfs/9701.pdf
Binary file not shown.
21 changes: 17 additions & 4 deletions src/test/java/org/mdbenefits/app/pdf/PdfServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import formflow.library.pdf.PdfService;
import java.io.File;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mdbenefits.app.data.SubmissionTestBuilder;
Expand Down Expand Up @@ -54,20 +55,32 @@ void generate() throws IOException {
.with("someoneConvictedForTradingBenefits", "true")
.with("someoneIsReceivingBenefitsWithFakeID", "false")
.with("applicantRace[]", List.of(RaceType.ASIAN.name(), RaceType.WHITE.name()))
.with("confirmationNumber", "M123456789")
.build();

submission.setFlow("mdBenefitsFlow");
submission.setSubmittedAt(OffsetDateTime.parse("2024-01-01T00:00:00Z"));

File pdfFile = pdfService.generate(submission);

// Cover page 1
String page1 = getPageText(pdfFile, 1);
// Confirmation number
assertThat(page1).contains("M123456789");
// Applicant full name
assertThat(page1).contains("Doe, John");
// Submission Date
assertThat(page1).contains("01/01/2024");
// Applicant Phone
assertThat(page1).contains("(510) 555-1212");
// 9701 Page 1
String page4 = getPageText(pdfFile, 4);
assertThat(page4).contains("Doe, John");

String page2 = getPageText(pdfFile, 2);
String page5 = getPageText(pdfFile, 5);
// applicant DOB
assertThat(page2).contains("12/10/1999");
assertThat(page5).contains("12/10/1999");
// applicant Race
assertThat(page2).contains("2,5");
assertThat(page5).contains("2,5");
}

private static String getPageText(File file, int page) throws IOException {
Expand Down

0 comments on commit e907d82

Please sign in to comment.