@Test public void shouldSavePOD() throws Exception { OrderPOD orderPod = new OrderPOD(); when(principal.getName()).thenReturn("2"); doNothing().when(restPODService).updatePOD(orderPod, 2L); ResponseEntity<RestResponse> response = new ResponseEntity<>(new RestResponse(SUCCESS, "success"), OK); PowerMockito.when(success("message.success.pod.updated")).thenReturn(response); ResponseEntity<RestResponse> responseEntity = controller.savePOD(orderPod, "ON123", principal); assertThat(responseEntity.getBody().getSuccess(), is("success")); verify(restPODService).updatePOD(orderPod, 2L); }
@RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal) { try { orderPod.setOrderNumber(orderNumber); restPODService.updatePOD(orderPod, loggedInUserId(principal)); return RestResponse.success("message.success.pod.updated"); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } }
RestPODController extends BaseController { @RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal) { try { orderPod.setOrderNumber(orderNumber); restPODService.updatePOD(orderPod, loggedInUserId(principal)); return RestResponse.success("message.success.pod.updated"); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } } }
RestPODController extends BaseController { @RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal) { try { orderPod.setOrderNumber(orderNumber); restPODService.updatePOD(orderPod, loggedInUserId(principal)); return RestResponse.success("message.success.pod.updated"); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } }  }
RestPODController extends BaseController { @RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal) { try { orderPod.setOrderNumber(orderNumber); restPODService.updatePOD(orderPod, loggedInUserId(principal)); return RestResponse.success("message.success.pod.updated"); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } }  @RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal); }
RestPODController extends BaseController { @RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) public ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal) { try { orderPod.setOrderNumber(orderNumber); restPODService.updatePOD(orderPod, loggedInUserId(principal)); return RestResponse.success("message.success.pod.updated"); } catch (DataException e) { return RestResponse.error(e.getOpenLmisMessage(), BAD_REQUEST); } }  @RequestMapping(value = "/rest-api/orders/{orderNumber}/pod", method = POST, headers = ACCEPT_JSON) ResponseEntity<RestResponse> savePOD(@RequestBody OrderPOD orderPod, @PathVariable String orderNumber, Principal principal);  }