Skip to content

Commit

Permalink
Generate 9701 PDF
Browse files Browse the repository at this point in the history
- Remove Louisiana PDF
  • Loading branch information
vrajmohan committed Jan 23, 2024
1 parent 827a6a4 commit 680c8ef
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flow: mdBenefitsFlow
pdf: /pdfs/la_application_for_assistance.pdf
pdf: /pdfs/9701.pdf
inputFields:
# submission field name --> PDF field name

Expand All @@ -12,10 +12,9 @@ inputFields:
# Green lines = in YAML but not PDF

# Overview Page
firstName: firstName
lastName: lastName
applicantFullName: applicantFullName
applicantSsn: applicantSsn
homeAddressStreetAddress1: homeAddressStreetAddress1
homeAddressStreetAddress1: homeAddressNumberAndStreet
homeAddressStreetAddress2: homeAddressStreetAddress2
homeAddressZipCode: homeAddressZipCode
homeAddressState: homeAddressState
Expand Down Expand Up @@ -43,17 +42,6 @@ inputFields:
applicantNonCitizenInd: applicantNonCitizenInd
applicantHomelessInd: applicantHomelessInd

authorizedRepresentative: authorizedRepresentative
authorizedRepFirstName: authorizedRepFirstName
authorizedRepLastName: authorizedRepLastName
authorizedRepStreetAddress1: authorizedRepStreetAddress1
authorizedRepStreetAddress2: authorizedRepStreetAddress2
authorizedRepZipCode: authorizedRepZipCode
authorizedRepState: authorizedRepState
authorizedRepCity: authorizedRepCity
authorizedRepPhoneNumber: authorizedRepPhoneNumber
needsMedicaid: needsMedicaid

hasDependentCareExpenses: hasDependentCareExpenses
expensesDependentCare: expensesDependentCare
hasChildSupportExpenses: hasChildSupportExpenses
Expand Down Expand Up @@ -160,13 +148,12 @@ subflowInfo:
household:
totalIterations: 7
inputFields:
householdMemberFirstName: householdMemberFirstName
householdMemberLastName: householdMemberLastName
householdMemberFullName: householdMemberFullName
householdMemberSex: householdSex
householdRelationshipFormatted: householdRelationship
householdMaritalStatusFormatted: householdMaritalStatus
householdHighestEducationFormatted: householdHighestEducation
householdBirthdayFormatted: householdBirthday
householdMemberDOB: householdMemberDOB
householdUSCitizenDerived: householdUSCitizen
householdRaceEthnicityCode: householdRaceEthnicCode
ssns: ssns
Expand Down
Binary file added src/main/resources/pdfs/9701.pdf
Binary file not shown.
Binary file not shown.
52 changes: 52 additions & 0 deletions src/test/java/org/mdbenefits/app/pdf/PdfServiceTest.java
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);
}
}
}

0 comments on commit 680c8ef

Please sign in to comment.