@Test public void shouldReturnStatusOKIfNoException() throws Exception { setupStockData(); mockStatic(RestResponse.class); String successMsg = "msg.stockmanagement.adjuststocksuccess"; ResponseEntity<RestResponse> expectedResponse = new ResponseEntity<>(new RestResponse(SUCCESS, successMsg), HttpStatus.OK); when(RestResponse.success(successMsg)).thenReturn(expectedResponse); ResponseEntity<RestResponse> response = restStockCardController.adjustStock(facilityId, stockEventList, principal); verify(restStockCardService).adjustStock(facilityId, stockEventList, userId); assertThat(response.getStatusCode(), is(HttpStatus.OK)); assertThat(response.getBody().getSuccess(), is(successMsg)); }
@RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) public ResponseEntity adjustStock(@PathVariable long facilityId, @RequestBody(required = true) List<StockEvent> events, Principal principal) { try { restStockCardService.adjustStock(facilityId, events, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.success("msg.stockmanagement.adjuststocksuccess"); }
RestStockCardController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) public ResponseEntity adjustStock(@PathVariable long facilityId, @RequestBody(required = true) List<StockEvent> events, Principal principal) { try { restStockCardService.adjustStock(facilityId, events, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.success("msg.stockmanagement.adjuststocksuccess"); } }
RestStockCardController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) public ResponseEntity adjustStock(@PathVariable long facilityId, @RequestBody(required = true) List<StockEvent> events, Principal principal) { try { restStockCardService.adjustStock(facilityId, events, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.success("msg.stockmanagement.adjuststocksuccess"); }  }
RestStockCardController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) public ResponseEntity adjustStock(@PathVariable long facilityId, @RequestBody(required = true) List<StockEvent> events, Principal principal) { try { restStockCardService.adjustStock(facilityId, events, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.success("msg.stockmanagement.adjuststocksuccess"); }  @RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) ResponseEntity adjustStock(@PathVariable long facilityId,
                                      @RequestBody(required = true) List<StockEvent> events,
                                      Principal principal); }
RestStockCardController extends BaseController { @RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) public ResponseEntity adjustStock(@PathVariable long facilityId, @RequestBody(required = true) List<StockEvent> events, Principal principal) { try { restStockCardService.adjustStock(facilityId, events, loggedInUserId(principal)); } catch (DataException e) { return error(e.getOpenLmisMessage(), BAD_REQUEST); } return RestResponse.success("msg.stockmanagement.adjuststocksuccess"); }  @RequestMapping(value = "/rest-api/facilities/{facilityId}/stockCards", method = POST, headers = ACCEPT_JSON) ResponseEntity adjustStock(@PathVariable long facilityId,
                                      @RequestBody(required = true) List<StockEvent> events,
                                      Principal principal);  }