@Test public void shouldGetRequisitionGroupWithMemberById() throws Exception { RequisitionGroup requisitionGroup = new RequisitionGroup(); Long requisitionGroupId = 1L; List<RequisitionGroupMember> requisitionGroupMembers = asList(new RequisitionGroupMember()); List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules = asList( new RequisitionGroupProgramSchedule()); when(requisitionGroupService.getBy(requisitionGroupId)).thenReturn(requisitionGroup); when(requisitionGroupService.getMembersBy(requisitionGroupId)).thenReturn(requisitionGroupMembers); when(requisitionGroupProgramScheduleService.getByRequisitionGroupId(requisitionGroupId)).thenReturn( requisitionGroupProgramSchedules); ResponseEntity<OpenLmisResponse> response = requisitionGroupController.getById(requisitionGroupId); verify(requisitionGroupService).getBy(requisitionGroupId); verify(requisitionGroupService).getMembersBy(requisitionGroupId); verify(requisitionGroupProgramScheduleService).getByRequisitionGroupId(requisitionGroupId); assertThat( ((RequisitionGroupFormDTO) response.getBody().getData().get("requisitionGroupData")).getRequisitionGroup(), is(requisitionGroup)); assertThat( ((RequisitionGroupFormDTO) response.getBody().getData().get("requisitionGroupData")).getRequisitionGroupMembers(), is(requisitionGroupMembers)); }
@RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id) { RequisitionGroup requisitionGroup = requisitionGroupService.getBy(id); List<RequisitionGroupMember> requisitionGroupMembers = requisitionGroupService.getMembersBy(id); List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules = requisitionGroupProgramScheduleService.getByRequisitionGroupId( id); RequisitionGroupFormDTO requisitionGroupFormDTO = new RequisitionGroupFormDTO(requisitionGroup, requisitionGroupMembers, requisitionGroupProgramSchedules); return OpenLmisResponse.response("requisitionGroupData", requisitionGroupFormDTO); }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id) { RequisitionGroup requisitionGroup = requisitionGroupService.getBy(id); List<RequisitionGroupMember> requisitionGroupMembers = requisitionGroupService.getMembersBy(id); List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules = requisitionGroupProgramScheduleService.getByRequisitionGroupId( id); RequisitionGroupFormDTO requisitionGroupFormDTO = new RequisitionGroupFormDTO(requisitionGroup, requisitionGroupMembers, requisitionGroupProgramSchedules); return OpenLmisResponse.response("requisitionGroupData", requisitionGroupFormDTO); } }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id) { RequisitionGroup requisitionGroup = requisitionGroupService.getBy(id); List<RequisitionGroupMember> requisitionGroupMembers = requisitionGroupService.getMembersBy(id); List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules = requisitionGroupProgramScheduleService.getByRequisitionGroupId( id); RequisitionGroupFormDTO requisitionGroupFormDTO = new RequisitionGroupFormDTO(requisitionGroup, requisitionGroupMembers, requisitionGroupProgramSchedules); return OpenLmisResponse.response("requisitionGroupData", requisitionGroupFormDTO); }  }
RequisitionGroupController extends BaseController { @RequestMapping(value = "/requisitionGroups/{id}", method = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id) { RequisitionGroup requisitionGroup = requisitionGroupService.getBy(id); List<RequisitionGroupMember> requisitionGroupMembers = requisitionGroupService.getMembersBy(id); List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules = requisitionGroupProgramScheduleService.getByRequisitionGroupId( id); RequisitionGroupFormDTO requisitionGroupFormDTO = new RequisitionGroupFormDTO(requisitionGroup, requisitionGroupMembers, requisitionGroupProgramSchedules); return OpenLmisResponse.response("requisitionGroupData", requisitionGroupFormDTO); }  @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 = GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_REQUISITION_GROUP')") public ResponseEntity<OpenLmisResponse> getById(@PathVariable(value = "id") Long id) { RequisitionGroup requisitionGroup = requisitionGroupService.getBy(id); List<RequisitionGroupMember> requisitionGroupMembers = requisitionGroupService.getMembersBy(id); List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules = requisitionGroupProgramScheduleService.getByRequisitionGroupId( id); RequisitionGroupFormDTO requisitionGroupFormDTO = new RequisitionGroupFormDTO(requisitionGroup, requisitionGroupMembers, requisitionGroupProgramSchedules); return OpenLmisResponse.response("requisitionGroupData", requisitionGroupFormDTO); }  @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; }