Search in sources :

Example 1 with FacilityInspectionsDTO

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;
}
Also used : Response(gov.ca.cwds.rest.api.Response) FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) Rr809Dn(gov.ca.cwds.cals.persistence.model.fas.Rr809Dn) ArrayList(java.util.ArrayList) FacilityInspectionsDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO)

Example 2 with FacilityInspectionsDTO

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);
        }
    });
}
Also used : Invocation(javax.ws.rs.client.Invocation) FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) WebTarget(javax.ws.rs.client.WebTarget) FacilityInspectionsDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Example 3 with FacilityInspectionsDTO

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));
}
Also used : Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) FacilityInspectionsDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Aggregations

FacilityInspectionsDTO (gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO)3 BaseCalsApiIntegrationTest (gov.ca.cwds.cals.BaseCalsApiIntegrationTest)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 Rr809Dn (gov.ca.cwds.cals.persistence.model.fas.Rr809Dn)1 Response (gov.ca.cwds.rest.api.Response)1 ArrayList (java.util.ArrayList)1