Skip to content

Commit

Permalink
Adds ProviderSSNPreparer and test.
Browse files Browse the repository at this point in the history
  • Loading branch information
enyia21 committed Jan 8, 2025
1 parent 0c76897 commit 56a2dff
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/org/ilgcc/app/pdf/ProviderSSNPreparer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.ilgcc.app.pdf;

import formflow.library.data.Submission;
import formflow.library.data.SubmissionRepositoryService;
import formflow.library.pdf.PdfMap;
import formflow.library.pdf.SingleField;
import formflow.library.pdf.SubmissionField;
import formflow.library.pdf.SubmissionFieldPreparer;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.ilgcc.app.utils.ProviderSubmissionUtilities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ProviderSSNPreparer implements SubmissionFieldPreparer {

@Autowired
SubmissionRepositoryService submissionRepositoryService;
@Autowired
private ProviderSubmissionUtilities providerSubmissionUtilities;

@Override
public Map<String, SubmissionField> prepareSubmissionFields(Submission familySubmission, PdfMap pdfMap) {
var results = new HashMap<String, SubmissionField>();
Optional<Submission> providerSubmission = providerSubmissionUtilities.getProviderSubmissionFromId(
submissionRepositoryService, familySubmission);
if (providerSubmission.isEmpty()) {
return results;
}
var providerInputData = providerSubmission.get().getInputData();
if (providerInputData.containsKey("providerIdentityCheckSSN")) {
results.put("providerSSN",
new SingleField("providerSSN", (String) providerInputData.getOrDefault("providerIdentityCheckSSN", ""),
null));
}else if(providerInputData.containsKey("providerTaxIdSSN")){
results.put("providerSSN",
new SingleField("providerSSN", (String) providerInputData.getOrDefault("providerTaxIdSSN", ""),
null));
}else{
return results;
}
return results;
}
}
1 change: 1 addition & 0 deletions src/main/resources/pdf-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ inputFields:
providerConviction: PROVIDER_CONVICTION
providerConvictionExplanation: PROVIDER_CONVICTION_EXPLANATION
providerIdentityCheckDateOfBirthDate: PROVIDER_DOB
providerSSN: PROVIDER_SSN
providerSignature: PROVIDER_SIGNATURE
providerSignatureDate: PROVIDER_SIGNATURE_DATE
clientResponseConfirmationCode: APPLICATION_CONFIRMATION_CODE
Expand Down
67 changes: 67 additions & 0 deletions src/test/java/org/ilgcc/app/pdf/ProviderSSNPreparerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.ilgcc.app.pdf;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import formflow.library.data.Submission;
import formflow.library.data.SubmissionRepositoryService;
import formflow.library.pdf.SingleField;
import formflow.library.pdf.SubmissionField;
import java.util.Map;
import org.ilgcc.app.IlGCCApplication;
import org.ilgcc.app.utils.SubmissionTestBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

@SpringBootTest(
classes = IlGCCApplication.class,
properties = "il-gcc.dts.expand-existing-provider-flow=true"
)
@ActiveProfiles("test")
public class ProviderSSNPreparerTest {


@Autowired
private ProviderSSNPreparer preparer;

@Autowired
private SubmissionRepositoryService submissionRepositoryService;

private Submission familySubmission;
private Submission providerSubmission;

@Test
public void shouldPrintProviderIdentityCheckSSNToPDFIfPresent() {
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerIdentityCheckSSN", "445-32-6666")
.with("providerTaxIdSSN", "555-55-5555")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerSSN")).isEqualTo(new SingleField("providerSSN", "445-32-6666", null));
}
@Test
public void shouldPrintProviderTaxIdSSNIfPresent() {
providerSubmission = new SubmissionTestBuilder()
.withFlow("providerresponse")
.withProviderSubmissionData()
.with("providerTaxIdSSN", "444-44-4444")
.build();
submissionRepositoryService.save(providerSubmission);

familySubmission = new SubmissionTestBuilder()
.withFlow("gcc")
.with("providerResponseSubmissionId", providerSubmission.getId())
.build();
Map<String, SubmissionField> result = preparer.prepareSubmissionFields(familySubmission, null);
assertThat(result.get("providerSSN")).isEqualTo(new SingleField("providerSSN", "444-44-4444", null));
}
}

0 comments on commit 56a2dff

Please sign in to comment.