@Test public void shouldGetSupervisoryNodesWithRightsForUser() throws Exception { List<SupervisoryNode> expected = new ArrayList<>(); when(supervisoryNodeMapper.getAllSupervisoryNodesInHierarchyByUserAndRights(1L, "{CREATE_REQUISITION, AUTHORIZE_REQUISITION}")).thenReturn(expected); List<SupervisoryNode> actual = repository.getAllSupervisoryNodesInHierarchyBy(1L, CREATE_REQUISITION, AUTHORIZE_REQUISITION); assertThat(actual, is(expected)); verify(supervisoryNodeMapper).getAllSupervisoryNodesInHierarchyByUserAndRights(1L, "{CREATE_REQUISITION, AUTHORIZE_REQUISITION}"); }
public List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames) { return supervisoryNodeMapper.getAllSupervisoryNodesInHierarchyBy(userId, programId, commaSeparateRightNames(rightNames)); }
SupervisoryNodeRepository { public List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames) { return supervisoryNodeMapper.getAllSupervisoryNodesInHierarchyBy(userId, programId, commaSeparateRightNames(rightNames)); } }
SupervisoryNodeRepository { public List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames) { return supervisoryNodeMapper.getAllSupervisoryNodesInHierarchyBy(userId, programId, commaSeparateRightNames(rightNames)); } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); }
SupervisoryNodeRepository { public List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames) { return supervisoryNodeMapper.getAllSupervisoryNodesInHierarchyBy(userId, programId, commaSeparateRightNames(rightNames)); } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); void insert(SupervisoryNode supervisoryNode); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); Long getIdForCode(String code); Long getSupervisoryNodeParentId(Long supervisoryNodeId); SupervisoryNode getFor(Facility facility, Program program); SupervisoryNode getParent(Long id); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode node); List<SupervisoryNode> getAllChildSupervisoryNodesInHierarchy(SupervisoryNode node); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); void update(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesByParent(Pagination pagination, String nameSearchCriteria); List<SupervisoryNode> getSupervisoryNodesBy(Pagination pagination, String nameSearchCriteria); Integer getTotalSearchResultCount(String param); Integer getTotalParentSearchResultCount(String param); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId); }
SupervisoryNodeRepository { public List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames) { return supervisoryNodeMapper.getAllSupervisoryNodesInHierarchyBy(userId, programId, commaSeparateRightNames(rightNames)); } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); void insert(SupervisoryNode supervisoryNode); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, Long programId, String... rightNames); Long getIdForCode(String code); Long getSupervisoryNodeParentId(Long supervisoryNodeId); SupervisoryNode getFor(Facility facility, Program program); SupervisoryNode getParent(Long id); List<SupervisoryNode> getAll(); List<SupervisoryNode> getAllSupervisoryNodesInHierarchyBy(Long userId, String... rightNames); List<SupervisoryNode> getAllParentSupervisoryNodesInHierarchy(SupervisoryNode node); List<SupervisoryNode> getAllChildSupervisoryNodesInHierarchy(SupervisoryNode node); SupervisoryNode getByCode(SupervisoryNode supervisoryNode); void update(SupervisoryNode supervisoryNode); List<SupervisoryNode> getSupervisoryNodesByParent(Pagination pagination, String nameSearchCriteria); List<SupervisoryNode> getSupervisoryNodesBy(Pagination pagination, String nameSearchCriteria); Integer getTotalSearchResultCount(String param); Integer getTotalParentSearchResultCount(String param); SupervisoryNode getSupervisoryNode(Long id); List<SupervisoryNode> getFilteredSupervisoryNodesByName(String param); List<SupervisoryNode> searchTopLevelSupervisoryNodesByName(String param); Long getTotalUnassignedSupervisoryNodeOfUserBy(Long userId, Long programId);  }