-
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.
- Loading branch information
Showing
3 changed files
with
114 additions
and
0 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
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; | ||
} | ||
} |
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
67 changes: 67 additions & 0 deletions
67
src/test/java/org/ilgcc/app/pdf/ProviderSSNPreparerTest.java
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,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)); | ||
} | ||
} |