Search in sources :

Example 46 with RFA1aFormDTO

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

the class RFA1aApplicantResourceTest method testEmptyFirstNameValidation.

@Test
public void testEmptyFirstNameValidation() throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    ApplicantDTO applicant = getApplicantDTO();
    applicant.setFirstName(" ");
    applicant.setLastName("setLastName");
    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-empty-first-name-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 47 with RFA1aFormDTO

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

the class RFA1aApplicantResourceTest method postDuplicateApplicantMiddleNameValidationTest.

@Test
public void postDuplicateApplicantMiddleNameValidationTest() throws Exception {
    try {
        RFA1aFormDTO form = formAHelper.createRFA1aForm();
        ApplicantDTO firstApplicant = applicantHelper.postApplicant(form.getId(), getApplicantDTO());
        ApplicantDTO secondApplicant = getApplicantDTO();
        secondApplicant.setMiddleName("differentName");
        secondApplicant = applicantHelper.postApplicant(form.getId(), secondApplicant);
        secondApplicant.setMiddleName(firstApplicant.getMiddleName());
        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 48 with RFA1aFormDTO

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

the class RFA1aApplicantResourceTest method testBlankPhonesAreNotDuplicated.

@Test
public void testBlankPhonesAreNotDuplicated() throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    ApplicantDTO applicant = getApplicantDTO();
    applicant.getPhones().clear();
    applicant.getPhones().add(createPhone(" ", "   ", false, createPhoneNumberType()));
    applicant.getPhones().add(createPhone(null, "     ", false, createPhoneNumberType()));
    assertNoSuchError(() -> applicantHelper.postApplicant(form.getId(), applicant), APPLICANT_PHONE_NUMBERS_DUPLICATION);
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) Test(org.junit.Test)

Example 49 with RFA1aFormDTO

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

the class RFA1aApplicantResourceTest method postDuplicateApplicantsValidationTest.

@Test
public void postDuplicateApplicantsValidationTest() throws Exception {
    try {
        RFA1aFormDTO form = formAHelper.createRFA1aForm();
        applicantHelper.postApplicant(form.getId(), getApplicantDTO());
        applicantHelper.postApplicant(form.getId(), getApplicantDTO());
        fail();
    } catch (ClientErrorException e) {
        assertEquals(422, e.getResponse().getStatus());
    }
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) ClientErrorException(javax.ws.rs.ClientErrorException) Test(org.junit.Test)

Example 50 with RFA1aFormDTO

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

the class RFA1aApplicantResourceTest method postDuplicateApplicantLastNameValidationTest.

@Test
public void postDuplicateApplicantLastNameValidationTest() throws Exception {
    try {
        RFA1aFormDTO form = formAHelper.createRFA1aForm();
        ApplicantDTO firstApplicant = applicantHelper.postApplicant(form.getId(), getApplicantDTO());
        ApplicantDTO secondApplicant = getApplicantDTO();
        secondApplicant.setLastName("differentName");
        secondApplicant = applicantHelper.postApplicant(form.getId(), secondApplicant);
        secondApplicant.setLastName(firstApplicant.getLastName());
        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)

Aggregations

RFA1aFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO)59 Test (org.junit.Test)37 ApplicantDTO (gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)30 WebTarget (javax.ws.rs.client.WebTarget)19 IssueDetails (gov.ca.cwds.rest.exception.IssueDetails)15 Response (javax.ws.rs.core.Response)15 BaseExceptionResponse (gov.ca.cwds.rest.exception.BaseExceptionResponse)12 HashMap (java.util.HashMap)12 MinorChildDTO (gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO)11 ClientErrorException (javax.ws.rs.ClientErrorException)11 Map (java.util.Map)10 Set (java.util.Set)10 StateType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.StateType)7 ResidenceDTO (gov.ca.cwds.cals.service.dto.rfa.ResidenceDTO)7 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)4 REQUIRED_APPLICANT_DATE_OF_BIRTH (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DATE_OF_BIRTH)4 REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER)4 REQUIRED_APPLICANT_DRIVER_LICENSE_STATE (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DRIVER_LICENSE_STATE)4 REQUIRED_APPLICANT_OTHER_NAMES_FIRST_NAME (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_OTHER_NAMES_FIRST_NAME)4 REQUIRED_APPLICANT_OTHER_NAMES_LAST_NAME (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_OTHER_NAMES_LAST_NAME)4