Search in sources :

Example 6 with RFA1aFormDTO

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

the class RFA1aCornerCasesSubmitApplicationTest method changeStatusBackToDraftTest.

@Test
public void changeStatusBackToDraftTest() throws Exception {
    if (TestModeUtils.isIntegrationTestsMode()) {
        return;
    }
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    applicantHelper.postApplicant(form.getId(), applicantHelper.getValidApplicant());
    residenceHelper.putResidence(form.getId(), residenceHelper.getResidenceDTO());
    Response response = statusHelper.submitApplication(form.getId(), FIXTURE_PATH_TO_PRINCIPAL);
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    statusHelper.assertSubmitted(form.getId());
    response = statusHelper.changeApplicationStatusTo(RFAApplicationStatus.DRAFT, form.getId());
    assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
    statusHelper.assertSubmitted(form.getId());
}
Also used : Response(javax.ws.rs.core.Response) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) Test(org.junit.Test)

Example 7 with RFA1aFormDTO

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

the class RFA1aFormsResourceTest method updateApplicationFormTest.

@Test
public void updateApplicationFormTest() throws Exception {
    RFA1aFormDTO rfaFormCreate = formAHelper.createRFA1aForm();
    WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + rfaFormCreate.getId());
    rfaFormCreate.setOtherTypeDescription("newOtherTypeDescription");
    RFA1aFormDTO rfaFormGet = target.request(MediaType.APPLICATION_JSON).put(Entity.entity(rfaFormCreate, MediaType.APPLICATION_JSON_TYPE), RFA1aFormDTO.class);
    assertNotNull(rfaFormGet);
    assertEquals(rfaFormCreate, rfaFormGet);
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 8 with RFA1aFormDTO

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

the class RFA1aMinorChildrenResourceTest method restoreUnselectedValueBackTest.

@Test
public void restoreUnselectedValueBackTest() throws Exception {
    String inputFixture = "{\"relationship_to_applicants\": []}";
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + API.RFA_1A_MINOR_CHILDREN);
    MinorChildDTO minorChildDTO = clientTestRule.getMapper().readValue(inputFixture, MinorChildDTO.class);
    MinorChildDTO postMinorChildDTO = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(minorChildDTO, MediaType.APPLICATION_JSON_TYPE), MinorChildDTO.class);
    String removeArrayFixture = "{\n" + "  \"id\" : %s\n" + ", \"relationship_to_applicants\":null" + "}";
    minorChildDTO = clientTestRule.getMapper().readValue(String.format(removeArrayFixture, postMinorChildDTO.getId()), MinorChildDTO.class);
    target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + API.RFA_1A_MINOR_CHILDREN + "/" + postMinorChildDTO.getId());
    MinorChildDTO putMinorChildDTO = target.request(MediaType.APPLICATION_JSON).put(Entity.entity(minorChildDTO, MediaType.APPLICATION_JSON_TYPE), MinorChildDTO.class);
    String finalFixture = "{\n" + "  \"id\" : %s\n" + "}";
    JSONAssert.assertEquals(String.format(finalFixture, putMinorChildDTO.getId()), clientTestRule.getMapper().writeValueAsString(putMinorChildDTO), JSONCompareMode.STRICT);
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) MinorChildDTO(gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test)

Example 9 with RFA1aFormDTO

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

the class RFA1aMinorChildrenResourceTest method checkInputOutput.

private void checkInputOutput(String inputFixture, String expectedOutputFixture) throws Exception {
    RFA1aFormDTO form = formAHelper.createRFA1aForm();
    WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + API.RFA_1A_MINOR_CHILDREN);
    MinorChildDTO minorChildDTO = clientTestRule.getMapper().readValue(inputFixture, MinorChildDTO.class);
    MinorChildDTO postMinorChildDTO = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(minorChildDTO, MediaType.APPLICATION_JSON_TYPE), MinorChildDTO.class);
    target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + API.RFA_1A_MINOR_CHILDREN + "/" + postMinorChildDTO.getId());
    MinorChildDTO getMinorChildDTO = target.request(MediaType.APPLICATION_JSON).get(MinorChildDTO.class);
    JSONAssert.assertEquals(String.format(expectedOutputFixture, getMinorChildDTO.getId()), clientTestRule.getMapper().writeValueAsString(getMinorChildDTO), JSONCompareMode.STRICT);
}
Also used : RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) MinorChildDTO(gov.ca.cwds.cals.service.dto.rfa.MinorChildDTO) WebTarget(javax.ws.rs.client.WebTarget)

Example 10 with RFA1aFormDTO

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

the class RFA1aPrintPDFTest method getPDFTest.

@Ignore
@Test
public void getPDFTest() throws Exception {
    // For integration test only
    if (!TestModeUtils.isIntegrationTestsMode()) {
        return;
    }
    RFA1aFormDTO form = createRfa1aFormDTO();
    WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "?" + QueryParams.EXPANDED + "=true");
    RFA1aFormDTO getExpandedFormResponse = target.request(MediaType.APPLICATION_JSON).get(RFA1aFormDTO.class);
    assertNotNull(getExpandedFormResponse);
    Response response = target.request("application/pdf").get();
    assertNotNull(response);
    System.out.println(response.getLength());
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) WebTarget(javax.ws.rs.client.WebTarget) Ignore(org.junit.Ignore) 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