Search in sources :

Example 11 with ApplicantDTO

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

the class RFA1aApplicantResourceTest method testDuplicatePhoneNumbersWithExtension.

@Test
public void testDuplicatePhoneNumbersWithExtension() throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    ApplicantDTO applicant = getApplicantDTO();
    applicant.getPhones().clear();
    applicant.getPhones().add(createPhone());
    applicant.getPhones().add(createPhone());
    try {
        applicantHelper.postApplicant(form.getId(), applicant);
        fail();
    } catch (ClientErrorException e) {
        assertEquals(422, e.getResponse().getStatus());
        String entity = e.getResponse().readEntity(String.class);
        Map<String, Object> parameters = new HashMap<>();
        BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
        Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
        IssueDetails detail = issueDetails.iterator().next();
        parameters.put("incident_id", detail.getIncidentId());
        assertResponseByFixtureTemplate(entity, "fixtures/rfa/validation/applicant-duplicate-phone-numbers-with-extensions-response.json", parameters);
    }
}
Also used : BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Set(java.util.Set) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) ClientErrorException(javax.ws.rs.ClientErrorException) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 12 with ApplicantDTO

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

the class RFA1aApplicantResourceTest method checkMaxFirstNameSizeTest.

@Test
public void checkMaxFirstNameSizeTest() throws Exception {
    try {
        ApplicantDTO applicantDTO = getApplicantDTO();
        applicantDTO.setFirstName("12345678901234567890x");
        RFA1aFormDTO form = formAHelper.createRFA1aForm();
        applicantHelper.postApplicant(form.getId(), applicantDTO);
        fail();
    } catch (ClientErrorException e) {
        Map<String, Object> parameters = new HashMap<>();
        BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
        Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
        IssueDetails detail = issueDetails.iterator().next();
        parameters.put("incident_id", detail.getIncidentId());
        parameters.put("property", "firstName");
        parameters.put("invalid_value", "12345678901234567890x");
        parameters.put("user_message", "12345678901234567890x exceeds maximum length of 20");
        checkValidationResponse(e, parameters);
    }
}
Also used : BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Set(java.util.Set) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) ClientErrorException(javax.ws.rs.ClientErrorException) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 13 with ApplicantDTO

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

the class RFA1aApplicantResourceTest method checkMaxLastNameSizeTest.

@Test
public void checkMaxLastNameSizeTest() throws Exception {
    try {
        ApplicantDTO applicantDTO = getApplicantDTO();
        applicantDTO.setLastName("1234567890123456789012345X");
        RFA1aFormDTO form = formAHelper.createRFA1aForm();
        applicantHelper.postApplicant(form.getId(), applicantDTO);
        fail();
    } catch (ClientErrorException e) {
        Map<String, Object> parameters = new HashMap<>();
        BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
        Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
        IssueDetails detail = issueDetails.iterator().next();
        parameters.put("incident_id", detail.getIncidentId());
        parameters.put("property", "lastName");
        parameters.put("invalid_value", "1234567890123456789012345X");
        parameters.put("user_message", "1234567890123456789012345X exceeds maximum length of 25");
        checkValidationResponse(e, parameters);
    }
}
Also used : BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Set(java.util.Set) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) ClientErrorException(javax.ws.rs.ClientErrorException) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 14 with ApplicantDTO

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

the class RFA1aApplicantResourceTest method postDuplicateApplicantFirstNameValidationTest.

@Test
public void postDuplicateApplicantFirstNameValidationTest() throws Exception {
    try {
        RFA1aFormDTO form = formAHelper.createRFA1aForm();
        ApplicantDTO firstApplicant = applicantHelper.postApplicant(form.getId(), getApplicantDTO());
        ApplicantDTO secondApplicant = getApplicantDTO();
        secondApplicant.setFirstName("differentName");
        secondApplicant = applicantHelper.postApplicant(form.getId(), secondApplicant);
        secondApplicant.setFirstName(firstApplicant.getFirstName());
        putApplicant(form, secondApplicant);
        fail();
    } catch (ClientErrorException e) {
        assertEquals(422, e.getResponse().getStatus());
        String entity = e.getResponse().readEntity(String.class);
        Map<String, Object> parameters = new HashMap<>();
        BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
        Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
        IssueDetails detail = issueDetails.iterator().next();
        parameters.put("incident_id", detail.getIncidentId());
        assertResponseByFixtureTemplate(entity, "fixtures/rfa/validation/applicant-duplicate-name-violation-response.json", parameters);
    }
}
Also used : BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Set(java.util.Set) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) ClientErrorException(javax.ws.rs.ClientErrorException) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 15 with ApplicantDTO

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

the class RFA1aCoreSubmitApplicationTest method submitApplication.

private RFA1aFormDTO submitApplication() throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    ApplicantDTO applicantDTO = applicantHelper.postApplicant(form.getId(), applicantHelper.getValidApplicant());
    ApplicantDTO secondApplicant = applicantHelper.getValidApplicant();
    secondApplicant.setFirstName("John");
    StateType driverLicenseState = new StateType();
    driverLicenseState.setId("MD");
    driverLicenseState.setValue("Maryland");
    secondApplicant.setDriverLicenseState(driverLicenseState);
    secondApplicant.getEthnicity().setId(2L);
    secondApplicant.getEthnicity().setValue("American Indian");
    secondApplicant = applicantHelper.postApplicant(form.getId(), secondApplicant);
    residenceHelper.putResidence(form.getId(), residenceHelper.getResidenceDTO());
    RFA1bFormDTO rfa1bForm = formBHelper.getRfa1bForm();
    formBHelper.postRfa1bForm(form.getId(), applicantDTO.getId(), rfa1bForm);
    otherAdultHelper.createOtherAdults(form.getId(), secondApplicant);
    minorChildHelper.createMinorChildren(form.getId(), applicantDTO);
    Response response = statusHelper.submitApplication(form.getId(), FIXTURE_PATH_TO_PRINCIPAL);
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    form = formAHelper.getRFA1aForm(form.getId());
    return form;
}
Also used : Response(javax.ws.rs.core.Response) RFA1bFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO) StateType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.StateType) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)

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