Search in sources :

Example 21 with IssueDetails

use of gov.ca.cwds.rest.exception.IssueDetails in project cals-api by ca-cwds.

the class RFA1aRequiredFieldsValidationTest method getIssueDetails.

private List<IssueDetails> getIssueDetails(RFA1aFormDTO form) {
    Response response = statusHelper.submitApplication(form.getId());
    assertEquals(422, response.getStatus());
    IssueDetailesList issueDetailesList = response.readEntity(IssueDetailesList.class);
    return issueDetailesList.getIssueDetails().stream().filter(issueDetails -> issueDetails.getCode().startsWith("CV")).collect(Collectors.toList());
}
Also used : Response(javax.ws.rs.core.Response) 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)

Example 22 with IssueDetails

use of gov.ca.cwds.rest.exception.IssueDetails in project cals-api by ca-cwds.

the class ExceptionHandlingResponseTest method corruptedJSONValidationTest.

@Test
public void corruptedJSONValidationTest() throws Exception {
    String fixture = "{\"wrong\": -1}";
    Response response = clientTestRule.target(API.RFA_1A_FORMS).request(MediaType.APPLICATION_JSON).post(Entity.entity(clientTestRule.getMapper().readValue(fixture, Wrong.class), MediaType.APPLICATION_JSON_TYPE));
    assertEquals(400, response.getStatus());
    String entity = response.readEntity(String.class);
    BaseExceptionResponse baseExceptionResponse = clientTestRule.getMapper().readValue(entity, BaseExceptionResponse.class);
    VelocityHelper velocityHelper = new VelocityHelper();
    IssueDetails details = baseExceptionResponse.getIssueDetails().iterator().next();
    velocityHelper.setParameter("incident_id", details.getIncidentId());
    velocityHelper.setParameter("user_message", BASE_MESSAGE);
    assertResponseByFixture(entity, velocityHelper.process("fixtures/exception/json-error-response.json"));
}
Also used : BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Response(javax.ws.rs.core.Response) BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) VelocityHelper(gov.ca.cwds.cals.web.rest.utils.VelocityHelper) BaseRFAIntegrationTest(gov.ca.cwds.cals.web.rest.rfa.BaseRFAIntegrationTest) Test(org.junit.Test)

Example 23 with IssueDetails

use of gov.ca.cwds.rest.exception.IssueDetails in project cals-api by ca-cwds.

the class ExceptionHandlingResponseTest method expectedExceptionTest.

@Test
public void expectedExceptionTest() throws Exception {
    WebTarget target = clientTestRule.target(FACILITIES + "/" + FACILITY_ID + "/" + Constants.API.COMPLAINTS + "/" + WRONG_FACILITY_ID);
    Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
    Response response = invocation.get();
    assertEquals(404, response.getStatus());
    String entity = response.readEntity(String.class);
    BaseExceptionResponse baseExceptionResponse = clientTestRule.getMapper().readValue(entity, BaseExceptionResponse.class);
    VelocityHelper velocityHelper = new VelocityHelper();
    IssueDetails details = baseExceptionResponse.getIssueDetails().iterator().next();
    velocityHelper.setParameter("incident_id", details.getIncidentId());
    velocityHelper.setParameter("user_message", BASE_MESSAGE);
    velocityHelper.setParameter("technical_message", Constants.ExpectedExceptionMessages.COMPLAINT_NOT_FOUND_BY_ID);
    assertResponseByFixture(entity, velocityHelper.process("fixtures/exception/expected-exception.json"));
}
Also used : BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Response(javax.ws.rs.core.Response) BaseExceptionResponse(gov.ca.cwds.rest.exception.BaseExceptionResponse) Invocation(javax.ws.rs.client.Invocation) IssueDetails(gov.ca.cwds.rest.exception.IssueDetails) WebTarget(javax.ws.rs.client.WebTarget) VelocityHelper(gov.ca.cwds.cals.web.rest.utils.VelocityHelper) BaseRFAIntegrationTest(gov.ca.cwds.cals.web.rest.rfa.BaseRFAIntegrationTest) Test(org.junit.Test)

Example 24 with IssueDetails

use of gov.ca.cwds.rest.exception.IssueDetails in project cals-api by ca-cwds.

the class RFA1aApplicantResourceTest method testDuplicatePhoneNumbers.

@Test
public void testDuplicatePhoneNumbers() throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    ApplicantDTO applicant = getApplicantDTO();
    applicant.getPhones().clear();
    applicant.getPhones().add(createPhoneNoExtension());
    applicant.getPhones().add(createPhoneNoExtension());
    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-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 25 with IssueDetails

use of gov.ca.cwds.rest.exception.IssueDetails 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)

Aggregations

IssueDetails (gov.ca.cwds.rest.exception.IssueDetails)30 BaseExceptionResponse (gov.ca.cwds.rest.exception.BaseExceptionResponse)22 Test (org.junit.Test)19 RFA1aFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO)15 ApplicantDTO (gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)14 HashMap (java.util.HashMap)12 Set (java.util.Set)11 Map (java.util.Map)10 ClientErrorException (javax.ws.rs.ClientErrorException)10 Response (javax.ws.rs.core.Response)10 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 REQUIRED_APPLICANT_PHONE_NUMBER (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_APPLICANT_PHONE_NUMBER)4 REQUIRED_BODY_OF_WATER_EXIST_FIELD (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_BODY_OF_WATER_EXIST_FIELD)4 REQUIRED_HOME_LANGUAGES (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_HOME_LANGUAGES)4 REQUIRED_MINOR_CHILD_ADOPTED (gov.ca.cwds.cals.Constants.Validation.Business.Code.REQUIRED_MINOR_CHILD_ADOPTED)4