@Test public void shouldSearchRequisitionGroupByNodeName() throws Exception { String searchParam = "searchParam"; Pagination pagination = new Pagination(0, 0); List<RequisitionGroup> requisitionGroups = asList(new RequisitionGroup()); when(requisitionGroupRepository.searchByNodeName(searchParam, pagination)).thenReturn(requisitionGroups); List<RequisitionGroup> requisitionGroupList = requisitionGroupService.search(searchParam, "supervisoryNode", pagination); verify(requisitionGroupRepository).searchByNodeName(searchParam, pagination); assertThat(requisitionGroupList, is(requisitionGroups)); }
public List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination) { if (columnName.equals(REQUISITION_GROUP)) { return requisitionGroupRepository.searchByGroupName(searchParam, pagination); } return requisitionGroupRepository.searchByNodeName(searchParam, pagination); }
RequisitionGroupService { public List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination) { if (columnName.equals(REQUISITION_GROUP)) { return requisitionGroupRepository.searchByGroupName(searchParam, pagination); } return requisitionGroupRepository.searchByNodeName(searchParam, pagination); } }
RequisitionGroupService { public List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination) { if (columnName.equals(REQUISITION_GROUP)) { return requisitionGroupRepository.searchByGroupName(searchParam, pagination); } return requisitionGroupRepository.searchByNodeName(searchParam, pagination); }  }
RequisitionGroupService { public List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination) { if (columnName.equals(REQUISITION_GROUP)) { return requisitionGroupRepository.searchByGroupName(searchParam, pagination); } return requisitionGroupRepository.searchByNodeName(searchParam, pagination); }  @Transactional void saveWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                          List<RequisitionGroupMember> requisitionGroupMembers,
                                          List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                          Long userId); void save(RequisitionGroup requisitionGroup); void saveRequisitionGroupMembers(List<RequisitionGroupMember> requisitionGroupMembers,
                                          RequisitionGroup requisitionGroup,
                                          Long userId); List<RequisitionGroup> getRequisitionGroupsBy(List<SupervisoryNode> supervisoryNodes); RequisitionGroup getByCode(RequisitionGroup requisitionGroup); List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination); Integer getTotalRecords(String searchParam, String columnName); RequisitionGroup getBy(Long id); List<RequisitionGroupMember> getMembersBy(Long requisitionGroupId); void updateWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                            List<RequisitionGroupMember> requisitionGroupMembers,
                                            List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                            Long userId); void saveRequisitionGroupProgramSchedules(List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                                   RequisitionGroup requisitionGroup,
                                                   Long userId); }
RequisitionGroupService { public List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination) { if (columnName.equals(REQUISITION_GROUP)) { return requisitionGroupRepository.searchByGroupName(searchParam, pagination); } return requisitionGroupRepository.searchByNodeName(searchParam, pagination); }  @Transactional void saveWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                          List<RequisitionGroupMember> requisitionGroupMembers,
                                          List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                          Long userId); void save(RequisitionGroup requisitionGroup); void saveRequisitionGroupMembers(List<RequisitionGroupMember> requisitionGroupMembers,
                                          RequisitionGroup requisitionGroup,
                                          Long userId); List<RequisitionGroup> getRequisitionGroupsBy(List<SupervisoryNode> supervisoryNodes); RequisitionGroup getByCode(RequisitionGroup requisitionGroup); List<RequisitionGroup> search(String searchParam, String columnName, Pagination pagination); Integer getTotalRecords(String searchParam, String columnName); RequisitionGroup getBy(Long id); List<RequisitionGroupMember> getMembersBy(Long requisitionGroupId); void updateWithMembersAndSchedules(RequisitionGroup requisitionGroup,
                                            List<RequisitionGroupMember> requisitionGroupMembers,
                                            List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                            Long userId); void saveRequisitionGroupProgramSchedules(List<RequisitionGroupProgramSchedule> requisitionGroupProgramSchedules,
                                                   RequisitionGroup requisitionGroup,
                                                   Long userId); static final String REQUISITION_GROUP; }