@Test public void shouldReturnErrorMsgIfSomeRequisitionsAreAlreadyConverted() { RequisitionList rnrList = new RequisitionList(); doThrow(new DataException("msg.rnr.already.converted.to.order")). when(orderService).convertToOrder(rnrList, 1L); ResponseEntity<OpenLmisResponse> response = orderController.convertToOrder(rnrList, request); assertThat(response.getStatusCode(), is(CONFLICT)); assertThat(response.getBody().getErrorMsg(), is("msg.rnr.already.converted.to.order")); verify(orderService).convertToOrder(rnrList, 1L); }
@RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") public ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList, HttpServletRequest request) { try { orderService.convertToOrder(rnrList, loggedInUserId(request)); } catch (DataException de) { return error("msg.rnr.already.converted.to.order", CONFLICT); } return new ResponseEntity<>(CREATED); }
OrderController extends BaseController { @RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") public ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList, HttpServletRequest request) { try { orderService.convertToOrder(rnrList, loggedInUserId(request)); } catch (DataException de) { return error("msg.rnr.already.converted.to.order", CONFLICT); } return new ResponseEntity<>(CREATED); } }
OrderController extends BaseController { @RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") public ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList, HttpServletRequest request) { try { orderService.convertToOrder(rnrList, loggedInUserId(request)); } catch (DataException de) { return error("msg.rnr.already.converted.to.order", CONFLICT); } return new ResponseEntity<>(CREATED); }  }
OrderController extends BaseController { @RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") public ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList, HttpServletRequest request) { try { orderService.convertToOrder(rnrList, loggedInUserId(request)); } catch (DataException de) { return error("msg.rnr.already.converted.to.order", CONFLICT); } return new ResponseEntity<>(CREATED); }  @RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList,
                                                         HttpServletRequest request); @RequestMapping(value = "/orders", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'VIEW_ORDER')") ResponseEntity<OpenLmisResponse> getOrdersForPage(@RequestParam(value = "page",
    required = true,
    defaultValue = "1") Integer page,
     @RequestParam(value="supplyDepot", defaultValue = "0") Long supplyDepot,
     @RequestParam(value="period", defaultValue = "0") Long period,
     @RequestParam(value="program", defaultValue = "0") Long program,
     HttpServletRequest request); @RequestMapping(value = "/orders/{id}/download.csv", method = GET, headers = ACCEPT_CSV) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'VIEW_ORDER')") ModelAndView downloadOrderCsv(@PathVariable Long id); @RequestMapping(value = "/order-file-template", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> getOrderFileTemplateDTO(); @RequestMapping(value = "/order-file-template", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> saveOrderFileTemplateDTO(@RequestBody OrderFileTemplateDTO orderFileTemplateDTO,
                                                                   HttpServletRequest request); @RequestMapping(value = "/order-number-configuration", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> getOrderNumberConfiguration(); @RequestMapping(value = "/order-number-configuration", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> updateOrderNumberConfiguration(@RequestBody OrderNumberConfiguration orderNumberConfiguration); @RequestMapping(value = "/date-formats", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> getAllDateFormats(); @RequestMapping(value = "/manage-pod-orders", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> getOrdersForPOD(@RequestParam("program") Long program, @RequestParam(value = "facility", defaultValue = "0") Long facility, HttpServletRequest request); }
OrderController extends BaseController { @RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") public ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList, HttpServletRequest request) { try { orderService.convertToOrder(rnrList, loggedInUserId(request)); } catch (DataException de) { return error("msg.rnr.already.converted.to.order", CONFLICT); } return new ResponseEntity<>(CREATED); }  @RequestMapping(value = "/orders", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'CONVERT_TO_ORDER')") ResponseEntity<OpenLmisResponse> convertToOrder(@RequestBody RequisitionList rnrList,
                                                         HttpServletRequest request); @RequestMapping(value = "/orders", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'VIEW_ORDER')") ResponseEntity<OpenLmisResponse> getOrdersForPage(@RequestParam(value = "page",
    required = true,
    defaultValue = "1") Integer page,
     @RequestParam(value="supplyDepot", defaultValue = "0") Long supplyDepot,
     @RequestParam(value="period", defaultValue = "0") Long period,
     @RequestParam(value="program", defaultValue = "0") Long program,
     HttpServletRequest request); @RequestMapping(value = "/orders/{id}/download.csv", method = GET, headers = ACCEPT_CSV) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'VIEW_ORDER')") ModelAndView downloadOrderCsv(@PathVariable Long id); @RequestMapping(value = "/order-file-template", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> getOrderFileTemplateDTO(); @RequestMapping(value = "/order-file-template", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> saveOrderFileTemplateDTO(@RequestBody OrderFileTemplateDTO orderFileTemplateDTO,
                                                                   HttpServletRequest request); @RequestMapping(value = "/order-number-configuration", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> getOrderNumberConfiguration(); @RequestMapping(value = "/order-number-configuration", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> updateOrderNumberConfiguration(@RequestBody OrderNumberConfiguration orderNumberConfiguration); @RequestMapping(value = "/date-formats", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'SYSTEM_SETTINGS')") ResponseEntity<OpenLmisResponse> getAllDateFormats(); @RequestMapping(value = "/manage-pod-orders", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> getOrdersForPOD(@RequestParam("program") Long program, @RequestParam(value = "facility", defaultValue = "0") Long facility, HttpServletRequest request); static final String ORDERS; static final String ORDER; static final String ORDER_FILE_TEMPLATE; static final String ORDER_NUMBER_CONFIGURATION; static final String DATE_FORMATS; static final String PAGE_SIZE; static final String NUMBER_OF_PAGES; static final String ORDERS_FOR_POD; }