@Test public void shouldSubmitRequisitionForACommTrackUser() throws Exception { Report report = new Report(); Rnr requisition = new Rnr(); requisition.setId(1L); when(service.submitReport(report, 1L)).thenReturn(requisition); ResponseEntity<RestResponse> expectResponse = new ResponseEntity<>(new RestResponse(RNR, requisition.getId()), OK); when(RestResponse.response(RNR, requisition.getId(), HttpStatus.CREATED)).thenReturn(expectResponse); ResponseEntity<RestResponse> response = controller.submitRequisition(report, principal); assertThat((Long) response.getBody().getData().get(RNR), is(1L)); }
@RequestMapping(value = "/rest-api/requisitions", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal) { Rnr requisition; try { requisition = restRequisitionService.submitReport(report, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return response(RNR, requisition.getId(), CREATED); }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal) { Rnr requisition; try { requisition = restRequisitionService.submitReport(report, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return response(RNR, requisition.getId(), CREATED); } }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal) { Rnr requisition; try { requisition = restRequisitionService.submitReport(report, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return response(RNR, requisition.getId(), CREATED); }  }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal) { Rnr requisition; try { requisition = restRequisitionService.submitReport(report, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return response(RNR, requisition.getId(), CREATED); }  @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", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> submitRequisition(@RequestBody Report report, Principal principal) { Rnr requisition; try { requisition = restRequisitionService.submitReport(report, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return response(RNR, requisition.getId(), CREATED); }  @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; }