@Test public void shouldGetRequisitionById() throws Exception { mockStatic(ReplenishmentDTO.class); Long rnrId = 3L; Rnr rnr = new Rnr(rnrId); ReplenishmentDTO replenishmentDTO = new ReplenishmentDTO(); Order order = mock(Order.class); when(ReplenishmentDTO.prepareForREST(rnr, order)).thenReturn(replenishmentDTO); when(service.getReplenishmentDetails(rnrId)).thenReturn(replenishmentDTO); ResponseEntity<RestResponse> expectedResponse = new ResponseEntity<>(new RestResponse("requisition", replenishmentDTO), OK); when(RestResponse.response("requisition", replenishmentDTO)).thenReturn(expectedResponse); ResponseEntity<RestResponse> response = controller.getReplenishment(rnrId); assertThat(response, is(expectedResponse)); verify(service).getReplenishmentDetails(rnrId); }
@RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id) { try { return response("requisition", restRequisitionService.getReplenishmentDetails(id)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id) { try { return response("requisition", restRequisitionService.getReplenishmentDetails(id)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } } }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id) { try { return response("requisition", restRequisitionService.getReplenishmentDetails(id)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } }  }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id) { try { return response("requisition", restRequisitionService.getReplenishmentDetails(id)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } }  @RequestMapping(value = "/rest-api/requisitions", method = POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal); @RequestMapping(value = "/rest-api/sdp-requisitions", method = POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> submitSDPRequisition(@RequestBody Report report, Principal principal); @RequestMapping(value = "/rest-api/requisitions/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal); @RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id); @RequestMapping(value="/rest-api/requisitions", method = GET, headers = ACCEPT_JSON) ResponseEntity<RestResponse> getRequisitionsByFacility(@RequestParam(value="facilityCode") String facilityCode); }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id) { try { return response("requisition", restRequisitionService.getReplenishmentDetails(id)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } }  @RequestMapping(value = "/rest-api/requisitions", method = POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal); @RequestMapping(value = "/rest-api/sdp-requisitions", method = POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> submitSDPRequisition(@RequestBody Report report, Principal principal); @RequestMapping(value = "/rest-api/requisitions/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal); @RequestMapping(value = "/rest-api/requisitions/{id}", method = GET, headers = ACCEPT_JSON) ResponseEntity<RestResponse> getReplenishment(@PathVariable Long id); @RequestMapping(value="/rest-api/requisitions", method = GET, headers = ACCEPT_JSON) ResponseEntity<RestResponse> getRequisitionsByFacility(@RequestParam(value="facilityCode") String facilityCode); static final String RNR; }