@Test public void shouldGetSupervisoryNodesSearchCriteria() throws Exception { String searchCriteria = "nodeName"; int page = 10; Pagination pagination = new Pagination(0, 0); whenNew(Pagination.class).withArguments(page, pageSize).thenReturn(pagination); when(supervisoryNodeRepository.getSupervisoryNodesBy(pagination, searchCriteria)).thenReturn(Collections.EMPTY_LIST); List<SupervisoryNode> searchResult = supervisoryNodeService.getSupervisoryNodesBy(page, searchCriteria, true); verify(supervisoryNodeRepository).getSupervisoryNodesByParent(pagination, searchCriteria); assertThat(searchResult, is(Collections.EMPTY_LIST)); }
public List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent) { if (parent) { return supervisoryNodeRepository.getSupervisoryNodesByParent(getPagination(page), nameSearchCriteria); } return supervisoryNodeRepository.getSupervisoryNodesBy(getPagination(page), nameSearchCriteria); }
SupervisoryNodeService { public List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent) { if (parent) { return supervisoryNodeRepository.getSupervisoryNodesByParent(getPagination(page), nameSearchCriteria); } return supervisoryNodeRepository.getSupervisoryNodesBy(getPagination(page), nameSearchCriteria); } }
SupervisoryNodeService { public List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent) { if (parent) { return supervisoryNodeRepository.getSupervisoryNodesByParent(getPagination(page), nameSearchCriteria); } return supervisoryNodeRepository.getSupervisoryNodesBy(getPagination(page), nameSearchCriteria); }  }
SupervisoryNodeService { public List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent) { if (parent) { return supervisoryNodeRepository.getSupervisoryNodesByParent(getPagination(page), nameSearchCriteria); } return supervisoryNodeRepository.getSupervisoryNodesBy(getPagination(page), nameSearchCriteria); }  @Autowired void setPageSize(@Value("${search.page.size}") String pageSize); void save(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); SupervisoryNode getFor(Facility facility, Program program); User getApproverFor(Facility facility, Program program); SupervisoryNode getParent(Long id); User getApproverForGivenSupervisoryNodeAndProgram(SupervisoryNode supervisoryNode, Program program); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode supervisoryNode); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); Pagination getPagination(Integer page); Integer getTotalSearchResultCount(String param, Boolean parent); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId); }
SupervisoryNodeService { public List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent) { if (parent) { return supervisoryNodeRepository.getSupervisoryNodesByParent(getPagination(page), nameSearchCriteria); } return supervisoryNodeRepository.getSupervisoryNodesBy(getPagination(page), nameSearchCriteria); }  @Autowired void setPageSize(@Value("${search.page.size}") String pageSize); void save(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesBy(Integer page, String nameSearchCriteria, Boolean parent); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); SupervisoryNode getFor(Facility facility, Program program); User getApproverFor(Facility facility, Program program); SupervisoryNode getParent(Long id); User getApproverForGivenSupervisoryNodeAndProgram(SupervisoryNode supervisoryNode, Program program); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode supervisoryNode); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); Pagination getPagination(Integer page); Integer getTotalSearchResultCount(String param, Boolean parent); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId);  }