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