@Test public void shouldReturnIdForTheGivenCode() { when(supervisoryNodeMapper.getIdForCode("ABC")).thenReturn(10L); assertThat(repository.getIdForCode("ABC"), is(10L)); }
public Long getIdForCode(String code) { Long supervisoryNodeId = supervisoryNodeMapper.getIdForCode(code); if (supervisoryNodeId == null) throw new DataException("error.supervisory.node.invalid"); return supervisoryNodeId; }
SupervisoryNodeRepository { public Long getIdForCode(String code) { Long supervisoryNodeId = supervisoryNodeMapper.getIdForCode(code); if (supervisoryNodeId == null) throw new DataException("error.supervisory.node.invalid"); return supervisoryNodeId; } }
SupervisoryNodeRepository { public Long getIdForCode(String code) { Long supervisoryNodeId = supervisoryNodeMapper.getIdForCode(code); if (supervisoryNodeId == null) throw new DataException("error.supervisory.node.invalid"); return supervisoryNodeId; } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); }
SupervisoryNodeRepository { public Long getIdForCode(String code) { Long supervisoryNodeId = supervisoryNodeMapper.getIdForCode(code); if (supervisoryNodeId == null) throw new DataException("error.supervisory.node.invalid"); return supervisoryNodeId; } @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 Long getIdForCode(String code) { Long supervisoryNodeId = supervisoryNodeMapper.getIdForCode(code); if (supervisoryNodeId == null) throw new DataException("error.supervisory.node.invalid"); return supervisoryNodeId; } @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);  }