Search in sources :

Example 6 with ApplicantDTO

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

the class PacketBuilder method applicants.

public PacketBuilder applicants(RFA1aFormDTO rfa1aFormDTO) {
    List<PersonSummaryDTO> applicants = new ArrayList<>();
    if (checkIfSectionIsNotEmpty(rfa1aFormDTO.getApplicants())) {
        for (ApplicantDTO applicant : rfa1aFormDTO.getApplicants()) {
            applicants.add(new PersonSummaryDTO(applicant.getId(), applicant.getFirstName(), applicant.getLastName(), checkIdIfExists(applicant.getRfa1bForm())));
        }
    }
    this.applicants = applicants;
    return this;
}
Also used : ArrayList(java.util.ArrayList) RelationshipToApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.RelationshipToApplicantDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) PersonSummaryDTO(gov.ca.cwds.cals.service.dto.packet.PersonSummaryDTO)

Example 7 with ApplicantDTO

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

the class RFA1aRequiredFieldsValidationTest method checkDriverLicenseNumberFormTest.

@Test
public void checkDriverLicenseNumberFormTest() throws Exception {
    RFA1aFormDTO form = prepareValidForm();
    ApplicantDTO applicant = applicantHelper.getValidApplicant();
    applicant.setFirstName("Some");
    applicant.setDriverLicenseNumber("");
    StateType driverLicenseState = new StateType();
    driverLicenseState.setId("CA");
    driverLicenseState.setValue("California");
    applicant.setDriverLicenseState(driverLicenseState);
    applicantHelper.postApplicant(form.getId(), applicant);
    List<IssueDetails> cvIssues = getIssueDetails(form);
    // "CV000008");
    Assert.assertTrue(cvIssues.stream().anyMatch(id -> id.getCode().equals(REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER)));
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Arrays(java.util.Arrays) REQUIRED_OTHER_PEOPLE_IN_RESIDENCE(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_OTHER_PEOPLE_IN_RESIDENCE) BeforeClass(org.junit.BeforeClass) REQUIRED_APPLICANT_DRIVER_LICENSE_STATE(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DRIVER_LICENSE_STATE) PhoneNumberType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.PhoneNumberType) REQUIRED_APPLICANT_OTHER_NAMES_FIRST_NAME(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_OTHER_NAMES_FIRST_NAME) StateType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.StateType) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) REQUIRED_APPLICANT_PHONE_NUMBER(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_PHONE_NUMBER) REQUIRED_PHYSICAL_MAILING_THE_SAME(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_PHYSICAL_MAILING_THE_SAME) RFAAddressDTO(gov.ca.cwds.cals.service.dto.rfa.RFAAddressDTO) REQUIRED_MINOR_CHILD_DATE_OF_BIRTH(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_MINOR_CHILD_DATE_OF_BIRTH) REQUIRED_MINOR_CHILD_GENDER(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_MINOR_CHILD_GENDER) PhoneDTO(gov.ca.cwds.cals.service.dto.rfa.PhoneDTO) REQUIRED_HOME_LANGUAGES(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_HOME_LANGUAGES) REQUIRED_WEAPON_IN_HOME_FIELD(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_WEAPON_IN_HOME_FIELD) REQUIRED_RESIDENCE_ADDRESS_CITY(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_RESIDENCE_ADDRESS_CITY) REQUIRED_RESIDENCE_STREET_ADDRESS(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_RESIDENCE_STREET_ADDRESS) REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DRIVER_LICENSE_NUMBER) REQUIRED_APPLICANT_DATE_OF_BIRTH(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_DATE_OF_BIRTH) REQUIRED_BODY_OF_WATER_EXIST_FIELD(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_BODY_OF_WATER_EXIST_FIELD) REQUIRED_MINOR_CHILD_ADOPTED(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_MINOR_CHILD_ADOPTED) IOException(java.io.IOException) Test(org.junit.Test) REQUIRED_MINOR_CHILD_FINANCIALLY_SUPPORTED(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_MINOR_CHILD_FINANCIALLY_SUPPORTED) Collectors(java.util.stream.Collectors) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) REQUIRED_RESIDENCE_ADDRESS_ZIP(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_RESIDENCE_ADDRESS_ZIP) TypedPersonNameDTO(gov.ca.cwds.cals.service.dto.rfa.TypedPersonNameDTO) List(java.util.List) REQUIRED_MINOR_CHILD_RELATIONSHIP_APPLICANT_ID(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_MINOR_CHILD_RELATIONSHIP_APPLICANT_ID) Response(javax.ws.rs.core.Response) MinorChildDTO(gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO) REQUIRED_RESIDENCE_OWNERSHIP(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_RESIDENCE_OWNERSHIP) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) ResidenceDTO(gov.ca.cwds.cals.service.dto.rfa.ResidenceDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) REQUIRED_APPLICANT_OTHER_NAMES_LAST_NAME(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_OTHER_NAMES_LAST_NAME) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) REQUIRED_RESIDENCE_ADDRESS_STATE(gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_RESIDENCE_ADDRESS_STATE) AddressType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.AddressType) StateType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.StateType) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) Test(org.junit.Test)

Example 8 with ApplicantDTO

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

the class LIC198bResourceTest method getLIC198bFormApplicantTest.

@Test
public void getLIC198bFormApplicantTest() throws Exception {
    RFA1aFormDTO form1a = formAHelper.createRFA1aForm();
    LIC198bFormDTO created = getExternalEntityApiHelper().createEntity(form1a);
    ApplicantDTO applicantDTO = applicantHelper.getFirstExistedOrPostNewApplicant(form1a.getId(), applicantHelper.getValidApplicant());
    WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form1a.getId() + "/" + getExternalEntityApiHelper().getConfiguration().getApiPath() + "/" + API.RFA_1A_APPLICANTS + "/" + applicantDTO.getId());
    LIC198bFormDTO found = target.request().get(getExternalEntityApiHelper().getConfiguration().getEntityClass());
    assertThat(found).isEqualTo(created);
}
Also used : LIC198bFormDTO(gov.ca.cwds.cals.service.dto.rfa.lic198b.LIC198bFormDTO) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 9 with ApplicantDTO

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

the class LIC198bResourceTest method getExternalEntityApiHelper.

@Override
protected BaseExternalEntityApiHelper<LIC198bFormDTO> getExternalEntityApiHelper() {
    TestExternalEntityConfiguration<LIC198bFormDTO> configuration = new TestExternalEntityConfiguration<LIC198bFormDTO>(clientTestRule, LIC198bFormDTO.class, API.LIC_198B_FORMS) {

        @Override
        protected String getFixture() {
            return LIC198B_FORM_FIXTURE;
        }

        @Override
        public GenericType<CollectionDTO<LIC198bFormDTO>> getCollectionDTOGenericType() {
            return new GenericType<CollectionDTO<LIC198bFormDTO>>() {
            };
        }

        @Override
        public void modifyEntity(LIC198bFormDTO lic198bFormDTO) {
            lic198bFormDTO.getIdentifyingData().getPersonName().setFirstName("Petya");
        }
    };
    return new BaseExternalEntityApiHelper<LIC198bFormDTO>(clientTestRule, configuration, formAHelper) {

        @Override
        public LIC198bFormDTO createEntity(RFA1aFormDTO form) throws IOException {
            ApplicantDTO applicantDTO = applicantHelper.getFirstExistedOrPostNewApplicant(form.getId(), applicantHelper.getValidApplicant());
            WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + configuration.getApiPath() + "/" + API.RFA_1A_APPLICANTS + "/" + applicantDTO.getId());
            LIC198bFormDTO entity = configuration.createEntity();
            return target.request(MediaType.APPLICATION_JSON).post(Entity.entity(entity, MediaType.APPLICATION_JSON_TYPE), configuration.getEntityClass());
        }
    };
}
Also used : GenericType(javax.ws.rs.core.GenericType) LIC198bFormDTO(gov.ca.cwds.cals.service.dto.rfa.lic198b.LIC198bFormDTO) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) CollectionDTO(gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) WebTarget(javax.ws.rs.client.WebTarget) TestExternalEntityConfiguration(gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration)

Example 10 with ApplicantDTO

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

the class RFA1aApplicantResourceTest method testEmptyLastNameValidation.

@Test
public void testEmptyLastNameValidation() throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    ApplicantDTO applicant = getApplicantDTO();
    applicant.setFirstName("setFirstName");
    applicant.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-last-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)

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