@Test public void shouldUpdateRequisitionGroup() { RequisitionGroupFormDTO requisitionGroupFormDTO = new RequisitionGroupFormDTO(new RequisitionGroup(), asList(new RequisitionGroupMember()), asList(new RequisitionGroupProgramSchedule())); when(messageService.message("message.requisition.group.updated.success", (Object) null)).thenReturn( "updated success"); ResponseEntity<OpenLmisResponse> response = requisitionGroupController.update(1L, requisitionGroupFormDTO, request); verify(requisitionGroupService).updateWithMembersAndSchedules(requisitionGroupFormDTO.getRequisitionGroup(), requisitionGroupFormDTO.getRequisitionGroupMembers(), requisitionGroupFormDTO.getRequisitionGroupProgramSchedules(), userId); assertThat(response.getBody().getSuccessMsg(), is("updated success")); assertThat((Long) response.getBody().getData().get("requisitionGroupId"), is(1L)); }
@RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id, @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO, HttpServletRequest request) { try { Long userId = loggedInUserId(request); requisitionGroupFormDTO.getRequisitionGroup().setId(id); requisitionGroupService.updateWithMembersAndSchedules(requisitionGroupFormDTO.getRequisitionGroup(), requisitionGroupFormDTO.getRequisitionGroupMembers(), requisitionGroupFormDTO.getRequisitionGroupProgramSchedules(), userId); } catch (DataException e) { return error(e, BAD_REQUEST); } ResponseEntity<OpenLmisResponse> responseEntity = success( messageService.message("message.requisition.group.updated.success", requisitionGroupFormDTO.getRequisitionGroup().getName())); responseEntity.getBody().addData("requisitionGroupId", requisitionGroupFormDTO.getRequisitionGroup().getId()); return responseEntity; }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id, @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO, HttpServletRequest request) { try { Long userId = loggedInUserId(request); requisitionGroupFormDTO.getRequisitionGroup().setId(id); requisitionGroupService.updateWithMembersAndSchedules(requisitionGroupFormDTO.getRequisitionGroup(), requisitionGroupFormDTO.getRequisitionGroupMembers(), requisitionGroupFormDTO.getRequisitionGroupProgramSchedules(), userId); } catch (DataException e) { return error(e, BAD_REQUEST); } ResponseEntity<OpenLmisResponse> responseEntity = success( messageService.message("message.requisition.group.updated.success", requisitionGroupFormDTO.getRequisitionGroup().getName())); responseEntity.getBody().addData("requisitionGroupId", requisitionGroupFormDTO.getRequisitionGroup().getId()); return responseEntity; } }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id, @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO, HttpServletRequest request) { try { Long userId = loggedInUserId(request); requisitionGroupFormDTO.getRequisitionGroup().setId(id); requisitionGroupService.updateWithMembersAndSchedules(requisitionGroupFormDTO.getRequisitionGroup(), requisitionGroupFormDTO.getRequisitionGroupMembers(), requisitionGroupFormDTO.getRequisitionGroupProgramSchedules(), userId); } catch (DataException e) { return error(e, BAD_REQUEST); } ResponseEntity<OpenLmisResponse> responseEntity = success( messageService.message("message.requisition.group.updated.success", requisitionGroupFormDTO.getRequisitionGroup().getName())); responseEntity.getBody().addData("requisitionGroupId", requisitionGroupFormDTO.getRequisitionGroup().getId()); return responseEntity; }  }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id, @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO, HttpServletRequest request) { try { Long userId = loggedInUserId(request); requisitionGroupFormDTO.getRequisitionGroup().setId(id); requisitionGroupService.updateWithMembersAndSchedules(requisitionGroupFormDTO.getRequisitionGroup(), requisitionGroupFormDTO.getRequisitionGroupMembers(), requisitionGroupFormDTO.getRequisitionGroupProgramSchedules(), userId); } catch (DataException e) { return error(e, BAD_REQUEST); } ResponseEntity<OpenLmisResponse> responseEntity = success( messageService.message("message.requisition.group.updated.success", requisitionGroupFormDTO.getRequisitionGroup().getName())); responseEntity.getBody().addData("requisitionGroupId", requisitionGroupFormDTO.getRequisitionGroup().getId()); return responseEntity; }  @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam,
                                                 @RequestParam(value = "columnName") String columnName,
                                                 @RequestParam(value = "page", defaultValue = "1") Integer page); @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id); @RequestMapping(value = "/requisitionGroups", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> insert(@RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id,
                                                 @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id, @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO, HttpServletRequest request) { try { Long userId = loggedInUserId(request); requisitionGroupFormDTO.getRequisitionGroup().setId(id); requisitionGroupService.updateWithMembersAndSchedules(requisitionGroupFormDTO.getRequisitionGroup(), requisitionGroupFormDTO.getRequisitionGroupMembers(), requisitionGroupFormDTO.getRequisitionGroupProgramSchedules(), userId); } catch (DataException e) { return error(e, BAD_REQUEST); } ResponseEntity<OpenLmisResponse> responseEntity = success( messageService.message("message.requisition.group.updated.success", requisitionGroupFormDTO.getRequisitionGroup().getName())); responseEntity.getBody().addData("requisitionGroupId", requisitionGroupFormDTO.getRequisitionGroup().getId()); return responseEntity; }  @RequestMapping(value = "/requisitionGroups", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> search(@RequestParam(value = "searchParam") String searchParam,
                                                 @RequestParam(value = "columnName") String columnName,
                                                 @RequestParam(value = "page", defaultValue = "1") Integer page); @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id); @RequestMapping(value = "/requisitionGroups", method = POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> insert(@RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); @RequestMapping(value = "/requisitionGroups/{id}", method = PUT, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") ResponseEntity<OpenLmisResponse> update(@PathVariable(value = "id") Long id,
                                                 @RequestBody RequisitionGroupFormDTO requisitionGroupFormDTO,
                                                 HttpServletRequest request); static final String SEARCH_PAGE_SIZE; }