@Test public void shouldApproveReport() throws Exception { Long requisitionId = 1L; Long userId = 1L; Rnr expectedRnr = new Rnr(); expectedRnr.setId(1L); Report report = mock(Report.class); doNothing().when(report).validateForApproval(); doNothing().when(service).approve(report, requisitionId, userId); ResponseEntity<RestResponse> expectResponse = new ResponseEntity<>(new RestResponse(SUCCESS, "success"), OK); when(RestResponse.success("msg.rnr.approved.success")).thenReturn(expectResponse); ResponseEntity<RestResponse> response = controller.approve(requisitionId, report, principal); assertThat(response.getBody().getSuccess(), is("success")); verify(service).approve(report, requisitionId, userId); }
@RequestMapping(value = "/rest-api/requisitions/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal) { try { report.validateForApproval(); restRequisitionService.approve(report, requisitionId, loggedInUserId(principal)); return success("msg.rnr.approved.success"); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal) { try { report.validateForApproval(); restRequisitionService.approve(report, requisitionId, loggedInUserId(principal)); return success("msg.rnr.approved.success"); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } } }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal) { try { report.validateForApproval(); restRequisitionService.approve(report, requisitionId, loggedInUserId(principal)); return success("msg.rnr.approved.success"); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } }  }
RestRequisitionController extends BaseController { @RequestMapping(value = "/rest-api/requisitions/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal) { try { report.validateForApproval(); restRequisitionService.approve(report, requisitionId, loggedInUserId(principal)); return success("msg.rnr.approved.success"); } 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/{requisitionId}/approve", method = PUT, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> approve(@PathVariable Long requisitionId, @RequestBody Report report, Principal principal) { try { report.validateForApproval(); restRequisitionService.approve(report, requisitionId, loggedInUserId(principal)); return success("msg.rnr.approved.success"); } 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; }