@Test public void shouldGetOrderPODByPodId() throws Exception { Long podId = 1L; Long orderId = 2L; OrderPOD orderPOD = new OrderPOD(); orderPOD.setOrderId(orderId); OrderPOD spyOrderPOD = spy(orderPOD); mockStatic(OrderPODDTO.class); when(service.getPodById(podId)).thenReturn(spyOrderPOD); when(spyOrderPOD.getStringReceivedDate()).thenReturn("2014-02-10"); Order order = new Order(); when(orderService.getOrder(orderId)).thenReturn(order); OrderPODDTO orderPODDTO = mock(OrderPODDTO.class); when(OrderPODDTO.getOrderDetailsForPOD(order)).thenReturn(orderPODDTO); ResponseEntity<OpenLmisResponse> response = controller.getPOD(podId); verify(service).getPodById(podId); assertThat((OrderPOD) response.getBody().getData().get(ORDER_POD), is(spyOrderPOD)); assertThat((OrderPODDTO) response.getBody().getData().get(ORDER), is(orderPODDTO)); assertThat((String) response.getBody().getData().get(RECEIVED_DATE), is("2014-02-10")); assertThat(response.getStatusCode(), is(HttpStatus.OK)); }
@RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") public ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId) throws ParseException { OrderPOD orderPOD = service.getPodById(podId); OrderPODDTO orderPODDTO = OrderPODDTO.getOrderDetailsForPOD(orderService.getOrder(orderPOD.getOrderId())); ResponseEntity<OpenLmisResponse> response = response(ORDER_POD, orderPOD); response.getBody().addData(ORDER, orderPODDTO); response.getBody().addData(RECEIVED_DATE, orderPOD.getStringReceivedDate()); return response; }
PODController extends BaseController { @RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") public ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId) throws ParseException { OrderPOD orderPOD = service.getPodById(podId); OrderPODDTO orderPODDTO = OrderPODDTO.getOrderDetailsForPOD(orderService.getOrder(orderPOD.getOrderId())); ResponseEntity<OpenLmisResponse> response = response(ORDER_POD, orderPOD); response.getBody().addData(ORDER, orderPODDTO); response.getBody().addData(RECEIVED_DATE, orderPOD.getStringReceivedDate()); return response; } }
PODController extends BaseController { @RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") public ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId) throws ParseException { OrderPOD orderPOD = service.getPodById(podId); OrderPODDTO orderPODDTO = OrderPODDTO.getOrderDetailsForPOD(orderService.getOrder(orderPOD.getOrderId())); ResponseEntity<OpenLmisResponse> response = response(ORDER_POD, orderPOD); response.getBody().addData(ORDER, orderPODDTO); response.getBody().addData(RECEIVED_DATE, orderPOD.getStringReceivedDate()); return response; }  }
PODController extends BaseController { @RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") public ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId) throws ParseException { OrderPOD orderPOD = service.getPodById(podId); OrderPODDTO orderPODDTO = OrderPODDTO.getOrderDetailsForPOD(orderService.getOrder(orderPOD.getOrderId())); ResponseEntity<OpenLmisResponse> response = response(ORDER_POD, orderPOD); response.getBody().addData(ORDER, orderPODDTO); response.getBody().addData(RECEIVED_DATE, orderPOD.getStringReceivedDate()); return response; }  @RequestMapping(value = "/pods", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> createPOD(@RequestParam Long orderId,
                                                    HttpServletRequest request); @RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId); @RequestMapping(value = "/pods/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> save(@RequestBody OrderPOD orderPOD, @PathVariable Long id, HttpServletRequest request); @RequestMapping(value = "/pods/submit/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> submit(@PathVariable Long id, HttpServletRequest request); @RequestMapping(value = "/pods/{id}/print", method = GET, headers = ACCEPT_JSON) ModelAndView print(@PathVariable Long id); }
PODController extends BaseController { @RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") public ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId) throws ParseException { OrderPOD orderPOD = service.getPodById(podId); OrderPODDTO orderPODDTO = OrderPODDTO.getOrderDetailsForPOD(orderService.getOrder(orderPOD.getOrderId())); ResponseEntity<OpenLmisResponse> response = response(ORDER_POD, orderPOD); response.getBody().addData(ORDER, orderPODDTO); response.getBody().addData(RECEIVED_DATE, orderPOD.getStringReceivedDate()); return response; }  @RequestMapping(value = "/pods", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> createPOD(@RequestParam Long orderId,
                                                    HttpServletRequest request); @RequestMapping(value = "/pods/{id}", method = GET, headers = ACCEPT_JSON) @PostAuthorize("@fulfillmentPermissionService.hasPermission(principal, returnObject.body.data.get(\"order\").getId(), 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> getPOD(@PathVariable("id") Long podId); @RequestMapping(value = "/pods/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> save(@RequestBody OrderPOD orderPOD, @PathVariable Long id, HttpServletRequest request); @RequestMapping(value = "/pods/submit/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal, 'MANAGE_POD')") ResponseEntity<OpenLmisResponse> submit(@PathVariable Long id, HttpServletRequest request); @RequestMapping(value = "/pods/{id}/print", method = GET, headers = ACCEPT_JSON) ModelAndView print(@PathVariable Long id); static final String ORDER_POD; static final String ORDER; static final String RECEIVED_DATE; static final String PRINT_POD; }