Search in sources :

Example 36 with ApplicantDTO

use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.

the class RFA1aApplicantService method create.

@Override
public ApplicantDTO create(RFAExternalEntityUpdateParameterObject<ApplicantDTO> request) {
    ApplicantDTO applicant = super.create(request);
    RFA1aForm form = formsDao.find(request.getFormId());
    if (form.getStatus() != RFAApplicationStatus.IN_PROGRESS) {
        form.setStatus(RFAApplicationStatus.IN_PROGRESS);
    }
    return applicant;
}
Also used : RFA1aForm(gov.ca.cwds.cals.persistence.model.calsns.rfa.RFA1aForm) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)

Example 37 with ApplicantDTO

use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.

the class RFA1aFormMapper method toApplicantDTO.

default ApplicantDTO toApplicantDTO(RFA1aApplicant entity) {
    ApplicantDTO applicantDTO = entity.getApplicant();
    Optional.ofNullable(entity.getRfa1bForm()).ifPresent(rfa1bForm -> applicantDTO.setRfa1bForm(rfa1bForm.getEntityDTO()));
    Optional.ofNullable(entity.getLic198bForm()).ifPresent(lic198bForm -> applicantDTO.setLic198bForm(lic198bForm.getEntityDTO()));
    return applicantDTO;
}
Also used : ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)

Example 38 with ApplicantDTO

use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.

the class Rfa1aFormGenerationTest method testPdfGeneration.

@Test
public void testPdfGeneration() throws Exception {
    String templatePath = "dms/rfa1a-case/RFA-01A Resource Family Application.pdf";
    String scriptPath = "dms/rfa1a-form/RFA-1A-form.groovy";
    RFA1aFormDTO rfa1aForm = mapper.readValue(RFA_1A_FIXTURE, RFA1aFormDTO.class);
    rfa1aForm.setId(100L);
    Long applicant1Id = 1L;
    Long applicant2Id = 2L;
    ApplicantDTO applicant1 = getApplicant(applicant1Id, 1);
    ApplicantDTO applicant2 = getApplicant(applicant2Id, 2);
    applicant2.getEmployment().setIncome(new BigDecimal("4500.00"));
    IncomeType incomeType = new IncomeType();
    incomeType.setId(2L);
    incomeType.setValue("monthly");
    applicant2.getEmployment().setIncomeType(incomeType);
    List<ApplicantDTO> applicants = new ArrayList<>();
    applicants.add(applicant1);
    applicants.add(applicant2);
    rfa1aForm.setApplicants(applicants);
    ResidenceDTO residenceDTO = mapper.readValue(RESIDENCE_FIXTURE, ResidenceDTO.class);
    rfa1aForm.setResidence(residenceDTO);
    ApplicantsRelationshipDTO applicantsRelationshipDTO = mapper.readValue(APPLICANTS_RELATIONSHIP_FIXTURE, ApplicantsRelationshipDTO.class);
    rfa1aForm.setApplicantsRelationship(applicantsRelationshipDTO);
    MinorChildDTO minorChild1 = getMinorChild(applicant1Id, 1);
    MinorChildDTO minorChild2 = getMinorChild(applicant1Id, 2);
    MinorChildDTO minorChild3 = getMinorChild(applicant2Id, 3);
    MinorChildDTO minorChild4 = getMinorChild(applicant2Id, 4);
    List<MinorChildDTO> minorChildren = new ArrayList<>();
    minorChildren.add(minorChild1);
    minorChildren.add(minorChild2);
    minorChildren.add(minorChild3);
    minorChildren.add(minorChild4);
    rfa1aForm.setMinorChildren(minorChildren);
    OtherAdultDTO otherAdult11 = getOtherAdult(applicant1Id, 1);
    OtherAdultDTO otherAdult12 = getOtherAdult(applicant1Id, 2);
    OtherAdultDTO otherAdult21 = getOtherAdult(applicant2Id, 3);
    OtherAdultDTO otherAdult22 = getOtherAdult(applicant2Id, 4);
    List<OtherAdultDTO> otherAdults = new ArrayList<>();
    otherAdults.add(otherAdult11);
    otherAdults.add(otherAdult12);
    otherAdults.add(otherAdult21);
    otherAdults.add(otherAdult22);
    rfa1aForm.setOtherAdults(otherAdults);
    ApplicantsHistoryDTO applicantsHistoryDTO = mapper.readValue(APPLICANTS_HISTORY_FIXTURE, ApplicantsHistoryDTO.class);
    List<FormerSpouseDTO> formerSpouses = applicantsHistoryDTO.getFormerSpouses();
    FormerSpouseDTO formerSpouseDTO = formerSpouses.remove(0);
    String formerSpouseJson = mapper.writeValueAsString(formerSpouseDTO);
    FormerSpouseDTO formerSpouse11 = getFormerSpouse(formerSpouseJson, applicant1Id);
    FormerSpouseDTO formerSpouse12 = getFormerSpouse(formerSpouseJson, applicant1Id);
    FormerSpouseDTO formerSpouse21 = getFormerSpouse(formerSpouseJson, applicant2Id);
    FormerSpouseDTO formerSpouse22 = getFormerSpouse(formerSpouseJson, applicant2Id);
    formerSpouses.add(formerSpouse11);
    formerSpouses.add(formerSpouse12);
    formerSpouses.add(formerSpouse21);
    formerSpouses.add(formerSpouse22);
    applicantsHistoryDTO.setFormerSpouses(formerSpouses);
    List<AdultChildDTO> adultChildren = applicantsHistoryDTO.getAdultChildren();
    AdultChildDTO adultChildDTO = adultChildren.remove(0);
    String adultChildJson = mapper.writeValueAsString(adultChildDTO);
    AdultChildDTO adultChild11 = getAdultChild(adultChildJson, applicant1Id);
    AdultChildDTO adultChild12 = getAdultChild(adultChildJson, applicant1Id);
    AdultChildDTO adultChild21 = getAdultChild(adultChildJson, applicant2Id);
    AdultChildDTO adultChild22 = getAdultChild(adultChildJson, applicant2Id);
    // Rename
    adultChild11.setFirstName(adultChild11.getFirstName() + "_1");
    adultChild12.setFirstName(adultChild12.getFirstName() + "_2");
    adultChild21.setFirstName(adultChild21.getFirstName() + "_3");
    adultChild22.setFirstName(adultChild22.getFirstName() + "_4");
    adultChildren.add(adultChild11);
    adultChildren.add(adultChild12);
    adultChildren.add(adultChild21);
    adultChildren.add(adultChild22);
    applicantsHistoryDTO.setAdultChildren(adultChildren);
    rfa1aForm.setApplicantsHistory(applicantsHistoryDTO);
    ChildDesiredDTO childDesiredDTO = mapper.readValue(CHILD_DESIRED_FIXTURE, ChildDesiredDTO.class);
    rfa1aForm.setChildDesired(childDesiredDTO);
    AdoptionHistoryDTO adoptionHistoryDTO = mapper.readValue(ADOPTION_HISTORY_FIXTURE, AdoptionHistoryDTO.class);
    rfa1aForm.setAdoptionHistory(adoptionHistoryDTO);
    ReferencesDTO referencesDTO = mapper.readValue(REFERENCES_FIXTURE, ReferencesDTO.class);
    rfa1aForm.setReferences(referencesDTO);
    ApplicantsDeclarationDTO applicantsDeclarationDTO = mapper.readValue(APPLICANTS_DECLARATION_FIXTURE, ApplicantsDeclarationDTO.class);
    List<ApplicantsDeclarationDTO.ApplicantSignature> applicantSignatures = applicantsDeclarationDTO.getApplicantSignatures();
    ApplicantsDeclarationDTO.ApplicantSignature applicantSignature = applicantSignatures.remove(0);
    String applicantSignatureJson = mapper.writeValueAsString(applicantSignature);
    ApplicantsDeclarationDTO.ApplicantSignature applicantSignature1 = getApplicantSignature(applicantSignatureJson, applicant1Id);
    ApplicantsDeclarationDTO.ApplicantSignature applicantSignature2 = getApplicantSignature(applicantSignatureJson, applicant2Id);
    applicantSignatures.add(applicantSignature1);
    applicantSignatures.add(applicantSignature2);
    rfa1aForm.setApplicantsDeclaration(applicantsDeclarationDTO);
    String request = mapper.writeValueAsString(rfa1aForm);
    // Check generation for empty form
    generateAndAssertPdf(templatePath, fixture(scriptPath), "{}", new HashMap<>());
    Map<String, String> expectedValuesMap = new HashMap<>();
    expectedValuesMap.put("APPLICANT ONE:  ANNUAL INCOME_pg 1", "98000.00");
    expectedValuesMap.put("APPLICANT TWO:  ANNUAL INCOME_pg 1", "54000.00");
    generateAndAssertPdf(templatePath, fixture(scriptPath), request, expectedValuesMap);
}
Also used : AdoptionHistoryDTO(gov.ca.cwds.cals.service.dto.rfa.AdoptionHistoryDTO) HashMap(java.util.HashMap) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) ArrayList(java.util.ArrayList) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) ResidenceDTO(gov.ca.cwds.cals.service.dto.rfa.ResidenceDTO) ReferencesDTO(gov.ca.cwds.cals.service.dto.rfa.ReferencesDTO) IncomeType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.IncomeType) OtherAdultDTO(gov.ca.cwds.cals.service.dto.rfa.OtherAdultDTO) ApplicantsHistoryDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantsHistoryDTO) ChildDesiredDTO(gov.ca.cwds.cals.service.dto.rfa.ChildDesiredDTO) AdultChildDTO(gov.ca.cwds.cals.service.dto.rfa.AdultChildDTO) BigDecimal(java.math.BigDecimal) MinorChildDTO(gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO) ApplicantsRelationshipDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantsRelationshipDTO) ApplicantsDeclarationDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantsDeclarationDTO) FormerSpouseDTO(gov.ca.cwds.cals.service.dto.rfa.FormerSpouseDTO) Test(org.junit.Test)

Example 39 with ApplicantDTO

use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.

the class ApplicantUtilsTest method testIncomeTypeMonthly.

@Test
public void testIncomeTypeMonthly() {
    ApplicantDTO applicantDTO = new ApplicantDTO();
    EmploymentDTO employmentDTO = new EmploymentDTO();
    employmentDTO.setIncome(new BigDecimal(100));
    IncomeType annualIncomeType = new IncomeType();
    annualIncomeType.setValue("monthly");
    employmentDTO.setIncomeType(annualIncomeType);
    applicantDTO.setEmployment(employmentDTO);
    assertEquals(new BigDecimal(1200), Utils.Applicant.getAnnualIncome(applicantDTO));
}
Also used : ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) IncomeType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.IncomeType) BigDecimal(java.math.BigDecimal) EmploymentDTO(gov.ca.cwds.cals.service.dto.rfa.EmploymentDTO) Test(org.junit.Test)

Example 40 with ApplicantDTO

use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.

the class ApplicantUtilsTest method testIncomeTypeYearly.

@Test
public void testIncomeTypeYearly() {
    ApplicantDTO applicantDTO = new ApplicantDTO();
    EmploymentDTO employmentDTO = new EmploymentDTO();
    employmentDTO.setIncome(new BigDecimal(100));
    IncomeType annualIncomeType = new IncomeType();
    annualIncomeType.setValue("yearly");
    employmentDTO.setIncomeType(annualIncomeType);
    applicantDTO.setEmployment(employmentDTO);
    assertEquals(new BigDecimal(100), Utils.Applicant.getAnnualIncome(applicantDTO));
}
Also used : ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) IncomeType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.IncomeType) BigDecimal(java.math.BigDecimal) EmploymentDTO(gov.ca.cwds.cals.service.dto.rfa.EmploymentDTO) Test(org.junit.Test)

Aggregations

ApplicantDTO (gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)41 RFA1aFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO)28 Test (org.junit.Test)27 IssueDetails (gov.ca.cwds.rest.exception.IssueDetails)12 HashMap (java.util.HashMap)11 BaseExceptionResponse (gov.ca.cwds.rest.exception.BaseExceptionResponse)10 Map (java.util.Map)10 Set (java.util.Set)10 ClientErrorException (javax.ws.rs.ClientErrorException)10 Response (javax.ws.rs.core.Response)8 MinorChildDTO (gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO)6 RFA1bFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO)6 BigDecimal (java.math.BigDecimal)6 WebTarget (javax.ws.rs.client.WebTarget)6 StateType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.StateType)5 ResidenceDTO (gov.ca.cwds.cals.service.dto.rfa.ResidenceDTO)5 EmploymentDTO (gov.ca.cwds.cals.service.dto.rfa.EmploymentDTO)4 AddressType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.AddressType)3 IncomeType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.IncomeType)3 PhoneNumberType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.PhoneNumberType)3