Search in sources :

Example 1 with FacilityChildrenDto

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

the class FacilityChildAuthorizationTest method getFacilityChildren.

private void getFacilityChildren(String principal, String childrenFixture) throws Exception {
    FacilityChildrenDto facilityChildDTO = getFacilityChildrenDTO(principal);
    String fixture = fixture(childrenFixture);
    assertEqualsResponse(fixture, transformDTOtoJSON(facilityChildDTO));
}
Also used : FacilityChildrenDto(gov.ca.cwds.cals.service.dto.FacilityChildrenDto)

Example 2 with FacilityChildrenDto

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

the class FacilityChildResourceTest method testGetChildrenFromLISFacility.

@Test
public void testGetChildrenFromLISFacility() throws Exception {
    String pathInfo = FACILITIES + "/{" + FACILITY_ID + "}/" + CHILDREN;
    pathInfo = pathInfo.replace("{" + FACILITY_ID + "}", "577000449");
    WebTarget target = clientTestRule.target(pathInfo);
    Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
    FacilityChildrenDto facilityChildDTO = invocation.get(FacilityChildrenDto.class);
    // age of child is calculated by current date, so there is workaround for test
    for (FacilityChildDTO childDTO : facilityChildDTO.getChildren()) {
        if (childDTO.getId().equals("AyRhLiI07n")) {
            // 17 is age in fixture
            childDTO.getPerson().setAge(16);
        }
        if (childDTO.getId().equals("AKgQavu07n")) {
            // 16 is age in fixture
            childDTO.getPerson().setAge(15);
        }
    }
    String fixture = fixture("fixtures/facility/facility-children-response.json");
    assertEqualsResponse(fixture, transformDTOtoJSON(facilityChildDTO));
}
Also used : FacilityChildrenDto(gov.ca.cwds.cals.service.dto.FacilityChildrenDto) Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) FacilityChildDTO(gov.ca.cwds.cals.service.dto.FacilityChildDTO) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Example 3 with FacilityChildrenDto

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

the class FacilityChildResourceTest method testGetFacilityChildrenWithAssignedWorkerPresent.

@Test
public void testGetFacilityChildrenWithAssignedWorkerPresent() throws Exception {
    String pathInfo = FACILITIES + "/{" + FACILITY_ID + "}/" + CHILDREN + "?" + TestSecurityFilter.PATH_TO_PRINCIPAL_FIXTURE + '=' + SECURITY_CLIENT_PRINCIPAL_SAME_COUNTY_SEALED_JSON;
    pathInfo = pathInfo.replace("{" + FACILITY_ID + "}", "412252222");
    JsonIdentityAuthParams params = new JsonIdentityAuthParams(fixture(SECURITY_CLIENT_PRINCIPAL_SAME_COUNTY_SEALED_JSON));
    WebTarget target = clientTestRule.target(pathInfo, params);
    Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
    FacilityChildrenDto facilityChildDTO = invocation.get(FacilityChildrenDto.class);
    String fixture = fixture("fixtures/facility/facility-children-response-assigned-worker-present.json");
    assertEqualsResponse(fixture, transformDTOtoJSON(facilityChildDTO));
}
Also used : FacilityChildrenDto(gov.ca.cwds.cals.service.dto.FacilityChildrenDto) Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) JsonIdentityAuthParams(gov.ca.cwds.test.support.JsonIdentityAuthParams) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Example 4 with FacilityChildrenDto

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

the class FacilityChildCollectionService method find.

@Override
public Response find(Serializable params) {
    FacilityChildParameterObject parameterObject = (FacilityChildParameterObject) params;
    FacilityChildrenDto facilityChildrenDto = new FacilityChildrenDto();
    if (parameterObject.getUnitOfWork().equals(UnitOfWork.CMS)) {
        facilityChildrenDto.getChildren().addAll(getChildrenFromCwsFacility(parameterObject.getFacilityId()));
    } else {
        facilityChildrenDto.getChildren().addAll(getChildrenFromLisFacility(parameterObject.getFacilityId()));
    }
    return facilityChildrenDto.getChildren().isEmpty() ? null : facilityChildrenDto;
}
Also used : FacilityChildrenDto(gov.ca.cwds.cals.service.dto.FacilityChildrenDto) FacilityChildParameterObject(gov.ca.cwds.cals.web.rest.parameter.FacilityChildParameterObject)

Aggregations

FacilityChildrenDto (gov.ca.cwds.cals.service.dto.FacilityChildrenDto)4 BaseCalsApiIntegrationTest (gov.ca.cwds.cals.BaseCalsApiIntegrationTest)2 Invocation (javax.ws.rs.client.Invocation)2 WebTarget (javax.ws.rs.client.WebTarget)2 Test (org.junit.Test)2 FacilityChildDTO (gov.ca.cwds.cals.service.dto.FacilityChildDTO)1 FacilityChildParameterObject (gov.ca.cwds.cals.web.rest.parameter.FacilityChildParameterObject)1 JsonIdentityAuthParams (gov.ca.cwds.test.support.JsonIdentityAuthParams)1