Search in sources :

Example 1 with FacilityChildDTO

use of gov.ca.cwds.cals.service.dto.FacilityChildDTO 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 2 with FacilityChildDTO

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

the class FacilityChildResourceTest method testGetFacilityChild.

@Test
public void testGetFacilityChild() throws Exception {
    String pathInfo = FACILITIES + "/{" + FACILITY_ID + "}/" + CHILDREN;
    pathInfo = pathInfo.replace("{" + FACILITY_ID + "}", "577000449") + "/AyRhLiI07n";
    WebTarget target = clientTestRule.target(pathInfo);
    Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
    FacilityChildDTO facilityChildDTO = invocation.get(FacilityChildDTO.class);
    // age of child is calculated by current date, so there is workaround for test
    // 17 is age in fixture
    facilityChildDTO.getPerson().setAge(16);
    String fixture = fixture("fixtures/facility/facility-child-response.json");
    assertEqualsResponse(fixture, transformDTOtoJSON(facilityChildDTO));
}
Also used : 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 FacilityChildDTO

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

the class FacilityService method loadFacilityFromCwsCms.

private FacilityDTO loadFacilityFromCwsCms(FacilityParameterObject parameterObject) {
    FacilityDTO facilityDto = cwsFacilityService.loadFacilityFromCwsCms(parameterObject);
    if (parameterObject.isExpanded()) {
        List<FacilityChildDTO> facilityChildren = cwsFacilityService.findFacilityChildrenByFacilityId(parameterObject.getFacilityId());
        List<FacilityInspectionDTO> inspections = fasFacilityService.findInspectionsByFacilityId(facilityDto.getLicenseNumber());
        List<ComplaintDTO> complaints = fasFacilityService.findComplaintsByFacilityId(facilityDto.getLicenseNumber());
        facilityDto = facilityMapper.toExpandedFacilityDTO(facilityDto, facilityChildren, inspections, complaints);
    }
    return facilityDto;
}
Also used : FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) FacilityDTO(gov.ca.cwds.cals.service.dto.FacilityDTO) FacilityChildDTO(gov.ca.cwds.cals.service.dto.FacilityChildDTO) ComplaintDTO(gov.ca.cwds.cals.service.dto.ComplaintDTO)

Example 4 with FacilityChildDTO

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

the class FacilityService method loadFacilityFromLis.

private FacilityDTO loadFacilityFromLis(FacilityParameterObject parameterObject) {
    FacilityDTO facilityDto = lisFacilityService.loadFacilityFromLis(parameterObject);
    FacilityInformation facilityInformation = fasFacilityService.findFacilityInfoByLicenseNumber(parameterObject);
    if (facilityInformation != null) {
        lisFacilityService.attachVisitsData(facilityInformation);
    }
    fasFacilityMapper.toFacilityDTO(facilityDto, facilityInformation);
    if (parameterObject.isExpanded()) {
        List<FacilityChildDTO> facilityChildren = cwsFacilityService.findFacilityChildrenByLicenseNumber(Integer.valueOf(parameterObject.getFacilityId()));
        List<FacilityInspectionDTO> inspections = fasFacilityService.findInspectionsByFacilityId(parameterObject.getFacilityId());
        List<ComplaintDTO> complaints = fasFacilityService.findComplaintsByFacilityId(parameterObject.getFacilityId());
        facilityDto = facilityMapper.toExpandedFacilityDTO(facilityDto, facilityChildren, inspections, complaints);
    }
    return facilityDto;
}
Also used : FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) FacilityInformation(gov.ca.cwds.cals.persistence.model.fas.FacilityInformation) FacilityDTO(gov.ca.cwds.cals.service.dto.FacilityDTO) FacilityChildDTO(gov.ca.cwds.cals.service.dto.FacilityChildDTO) ComplaintDTO(gov.ca.cwds.cals.service.dto.ComplaintDTO)

Aggregations

FacilityChildDTO (gov.ca.cwds.cals.service.dto.FacilityChildDTO)4 BaseCalsApiIntegrationTest (gov.ca.cwds.cals.BaseCalsApiIntegrationTest)2 ComplaintDTO (gov.ca.cwds.cals.service.dto.ComplaintDTO)2 FacilityDTO (gov.ca.cwds.cals.service.dto.FacilityDTO)2 FacilityInspectionDTO (gov.ca.cwds.cals.service.dto.FacilityInspectionDTO)2 Invocation (javax.ws.rs.client.Invocation)2 WebTarget (javax.ws.rs.client.WebTarget)2 Test (org.junit.Test)2 FacilityInformation (gov.ca.cwds.cals.persistence.model.fas.FacilityInformation)1 FacilityChildrenDto (gov.ca.cwds.cals.service.dto.FacilityChildrenDto)1