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));
}
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));
}
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;
}
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;
}
Aggregations