@Test public void shouldGetFacilityByCode() throws Exception { String facilityCode = "F11"; FacilityFeedDTO facilityFeedDTO = new FacilityFeedDTO(); Mockito.when(restFacilityService.getFacilityByCode(facilityCode)).thenReturn(facilityFeedDTO); ResponseEntity<RestResponse> response = restFacilityController.getFacilityByCode(facilityCode); assertThat((FacilityFeedDTO) response.getBody().getData().get("facility"), is(facilityFeedDTO)); verify(restFacilityService).getFacilityByCode(facilityCode); }
@RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode) { FacilityFeedDTO facilityFeedDTO; try { facilityFeedDTO = restFacilityService.getFacilityByCode(facilityCode); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.response(FACILITY, facilityFeedDTO); }
RestFacilityController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode) { FacilityFeedDTO facilityFeedDTO; try { facilityFeedDTO = restFacilityService.getFacilityByCode(facilityCode); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.response(FACILITY, facilityFeedDTO); } }
RestFacilityController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode) { FacilityFeedDTO facilityFeedDTO; try { facilityFeedDTO = restFacilityService.getFacilityByCode(facilityCode); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.response(FACILITY, facilityFeedDTO); }  }
RestFacilityController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode) { FacilityFeedDTO facilityFeedDTO; try { facilityFeedDTO = restFacilityService.getFacilityByCode(facilityCode); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.response(FACILITY, facilityFeedDTO); }  @RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode); }
RestFacilityController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode) { FacilityFeedDTO facilityFeedDTO; try { facilityFeedDTO = restFacilityService.getFacilityByCode(facilityCode); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.response(FACILITY, facilityFeedDTO); }  @RequestMapping(value = "/rest-api/facilities/{facilityCode}", method = GET, headers = ACCEPT_JSON) ResponseEntity<RestResponse> getFacilityByCode(@PathVariable String facilityCode); static final String FACILITY; }