use of gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO in project cals-api by ca-cwds.
the class FacilityInspectionCollectionService method find.
@Override
public Response find(Serializable facilityId) {
Response res = null;
final FacilityInspectionsDTO dto = new FacilityInspectionsDTO();
List<Rr809Dn> deficiencies = inspectionDao.findDeficienciesByFacilityNumber(String.valueOf(facilityId));
final List<FacilityInspectionDTO> inspections = new ArrayList<>();
deficiencies.forEach(def -> inspections.add(facilityInspectionMapper.toFacilityInspectionDto(def)));
if (!inspections.isEmpty()) {
dto.setInspections(inspections);
res = dto;
}
return res;
}
use of gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO in project cals-api by ca-cwds.
the class FacilityInspectionsTest method getAllFacilityInspectionsTest.
@Test
public void getAllFacilityInspectionsTest() throws JsonProcessingException {
WebTarget target = clientTestRule.target(FACILITIES + "/" + FACILITY_NUMBER + "/" + Constants.API.INSPECTIONS);
Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
FacilityInspectionsDTO inspectionsDTO = invocation.get(FacilityInspectionsDTO.class);
assertTrue(inspectionsDTO != null);
assertTrue(inspectionsDTO.getInspections() != null);
assertTrue(inspectionsDTO.getInspections().size() == 1);
FacilityInspectionDTO inspectionDTO0 = inspectionsDTO.getInspections().get(0);
String inspectionId = inspectionDTO0.getId();
target = clientTestRule.target(FACILITIES + "/" + FACILITY_NUMBER + "/" + Constants.API.INSPECTIONS + "/" + INSPECTION_ID);
invocation = target.request(MediaType.APPLICATION_JSON);
final FacilityInspectionDTO inspectionDTO = invocation.get(FacilityInspectionDTO.class);
// Expected only 1 deficiency object
assertTrue(inspectionDTO.getDeficiencies().size() == 2);
inspectionsDTO.getInspections().forEach(inspection -> {
if (INSPECTION_ID.equals(inspection.getId())) {
assertEquals(inspection, inspectionDTO);
}
});
}
use of gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO in project cals-api by ca-cwds.
the class FacilityInspectionsTest method getFacilityInspectionsResponseTest.
@Test
public void getFacilityInspectionsResponseTest() throws Exception {
WebTarget target = clientTestRule.target(FACILITIES + "/" + FACILITY_NUMBER + "/" + Constants.API.INSPECTIONS);
Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
FacilityInspectionsDTO inspectionsDTO = invocation.get(FacilityInspectionsDTO.class);
String fixture = fixture(INSPECTIONS_RESPONSE_JSON);
assertEqualsResponse(fixture, transformDTOtoJSON(inspectionsDTO));
}
Aggregations