@Test public void shouldGetSupervisoryNodeForFacilityProgram() throws Exception { Facility facility = new Facility(1L); Program program = new Program(1L); SupervisoryNode expectedSupervisoryNode = new SupervisoryNode(); RequisitionGroup requisitionGroup = make(a(defaultRequisitionGroup, with(code, "test code"))); when(requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(program, facility)).thenReturn(requisitionGroup); when(supervisoryNodeMapper.getFor(requisitionGroup.getCode())).thenReturn(expectedSupervisoryNode); SupervisoryNode actualSupervisoryNode = repository.getFor(facility, program); assertThat(actualSupervisoryNode, is(expectedSupervisoryNode)); }
public SupervisoryNode getFor(Facility facility, Program program) { RequisitionGroup requisitionGroup = requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(program, facility); return (requisitionGroup == null) ? null : supervisoryNodeMapper.getFor(requisitionGroup.getCode()); }
SupervisoryNodeRepository { public SupervisoryNode getFor(Facility facility, Program program) { RequisitionGroup requisitionGroup = requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(program, facility); return (requisitionGroup == null) ? null : supervisoryNodeMapper.getFor(requisitionGroup.getCode()); } }
SupervisoryNodeRepository { public SupervisoryNode getFor(Facility facility, Program program) { RequisitionGroup requisitionGroup = requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(program, facility); return (requisitionGroup == null) ? null : supervisoryNodeMapper.getFor(requisitionGroup.getCode()); } @Autowired  SupervisoryNodeRepository(SupervisoryNodeMapper supervisoryNodeMapper,
                                   FacilityRepository facilityRepository,
                                   RequisitionGroupRepository requisitionGroupRepository); }
SupervisoryNodeRepository { public SupervisoryNode getFor(Facility facility, Program program) { RequisitionGroup requisitionGroup = requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(program, facility); return (requisitionGroup == null) ? null : supervisoryNodeMapper.getFor(requisitionGroup.getCode()); } @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 SupervisoryNode getFor(Facility facility, Program program) { RequisitionGroup requisitionGroup = requisitionGroupRepository.getRequisitionGroupForProgramAndFacility(program, facility); return (requisitionGroup == null) ? null : supervisoryNodeMapper.getFor(requisitionGroup.getCode()); } @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);  }