@Test public void shouldReturnUserSupervisedFacilitiesForAProgram() { Long userId = 1L; Long programId = 1L; List<Facility> facilities = new ArrayList<>(); List<SupervisoryNode> supervisoryNodes = new ArrayList<>(); List<RequisitionGroup> requisitionGroups = new ArrayList<>(); when(facilityRepository.getFacilitiesBy(programId, requisitionGroups)).thenReturn(facilities); when(supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, CREATE_REQUISITION)).thenReturn(supervisoryNodes); when(requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes)).thenReturn(requisitionGroups); List<Facility> result = facilityService.getUserSupervisedFacilities(userId, programId, CREATE_REQUISITION); verify(facilityRepository).getFacilitiesBy(programId, requisitionGroups); verify(supervisoryNodeService).getAllSupervisoryNodesInHierarchyBy(userId, programId, CREATE_REQUISITION); verify(requisitionGroupService).getRequisitionGroupsBy(supervisoryNodes); assertThat(result, is(facilities)); }
public List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames) { List<SupervisoryNode> supervisoryNodes = supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, rightNames); List<RequisitionGroup> requisitionGroups = requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes); return facilityRepository.getFacilitiesBy(programId, requisitionGroups); }
FacilityService { public List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames) { List<SupervisoryNode> supervisoryNodes = supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, rightNames); List<RequisitionGroup> requisitionGroups = requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes); return facilityRepository.getFacilitiesBy(programId, requisitionGroups); } }
FacilityService { public List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames) { List<SupervisoryNode> supervisoryNodes = supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, rightNames); List<RequisitionGroup> requisitionGroups = requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes); return facilityRepository.getFacilitiesBy(programId, requisitionGroups); }  }
FacilityService { public List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames) { List<SupervisoryNode> supervisoryNodes = supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, rightNames); List<RequisitionGroup> requisitionGroups = requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes); return facilityRepository.getFacilitiesBy(programId, requisitionGroups); }  @Transactional void update(Facility facility); List<FacilityType> getAllTypes(); List<GeographicZone> getAllZones(); Facility getHomeFacility(Long userId); Facility getById(Long id); @Transactional void updateEnabledAndActiveFor(Facility facility); List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames); void save(Facility newFacility); void updateAndNotifyForVirtualFacilities(Facility parentFacility); List<Facility> getForUserAndRights(Long userId, String... rightNames); FacilityType getFacilityTypeByCode(FacilityType facilityType); Facility getByCode(Facility facility); List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId); List<Facility> getAllByProgramSupportedModifiedDate(Date dateModified); Facility getFacilityWithReferenceDataForCode(String facilityCode); List<Facility> searchBy(String searchParam, String columnName, Pagination pagination); List<Facility> getEnabledWarehouses(); Facility getFacilityByCode(String facilityCode); List<Facility> getChildFacilities(Facility facility); List<Facility> getAllByRequisitionGroupMemberModifiedDate(Date modifiedDate); List<Facility> getAllParentsByModifiedDate(Date modifiedDate); Facility getOperativeFacilityByCode(String facilityCode); List<Facility> getCompleteListInRequisitionGroups(List<RequisitionGroup> requisitionGroups); List<FacilityContact> getContactList(Long facilityId, String notificationMedium); List<FacilitySupervisor> getFacilitySupervisors(Long facilityId); List<Facility> getUserSupervisedFacilities(Long userId); List<Facility> getAllForGeographicZone(Long geographizZoneId); Integer getFacilitiesCountBy(String searchParam, Long facilityTypeId, Long geoZoneId, Boolean virtualFacility, Boolean enabled); List<Facility> searchFacilitiesBy(String searchParam, Long facilityTypeId, Long geoZoneId, Boolean virtualFacility, Boolean enabled); Integer getTotalSearchResultCountByColumnName(String searchParam, String columnName); List<Facility> getFacilityByTypeAndRequisitionGroupId(Long facilityTypeId, Long rgroupId); List<FacilityGeoTreeDto> getGeoRegionFacilityTree(Long userId); List<FacilityGeoTreeDto> getGeoDistrictFacility(Long userId); List<FacilityGeoTreeDto> getGeoFlatFacilityTree(Long userId); Facility getFacilityById(Long id); }
FacilityService { public List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames) { List<SupervisoryNode> supervisoryNodes = supervisoryNodeService.getAllSupervisoryNodesInHierarchyBy(userId, programId, rightNames); List<RequisitionGroup> requisitionGroups = requisitionGroupService.getRequisitionGroupsBy(supervisoryNodes); return facilityRepository.getFacilitiesBy(programId, requisitionGroups); }  @Transactional void update(Facility facility); List<FacilityType> getAllTypes(); List<GeographicZone> getAllZones(); Facility getHomeFacility(Long userId); Facility getById(Long id); @Transactional void updateEnabledAndActiveFor(Facility facility); List<Facility> getUserSupervisedFacilities(Long userId, Long programId, String... rightNames); void save(Facility newFacility); void updateAndNotifyForVirtualFacilities(Facility parentFacility); List<Facility> getForUserAndRights(Long userId, String... rightNames); FacilityType getFacilityTypeByCode(FacilityType facilityType); Facility getByCode(Facility facility); List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId); List<Facility> getAllByProgramSupportedModifiedDate(Date dateModified); Facility getFacilityWithReferenceDataForCode(String facilityCode); List<Facility> searchBy(String searchParam, String columnName, Pagination pagination); List<Facility> getEnabledWarehouses(); Facility getFacilityByCode(String facilityCode); List<Facility> getChildFacilities(Facility facility); List<Facility> getAllByRequisitionGroupMemberModifiedDate(Date modifiedDate); List<Facility> getAllParentsByModifiedDate(Date modifiedDate); Facility getOperativeFacilityByCode(String facilityCode); List<Facility> getCompleteListInRequisitionGroups(List<RequisitionGroup> requisitionGroups); List<FacilityContact> getContactList(Long facilityId, String notificationMedium); List<FacilitySupervisor> getFacilitySupervisors(Long facilityId); List<Facility> getUserSupervisedFacilities(Long userId); List<Facility> getAllForGeographicZone(Long geographizZoneId); Integer getFacilitiesCountBy(String searchParam, Long facilityTypeId, Long geoZoneId, Boolean virtualFacility, Boolean enabled); List<Facility> searchFacilitiesBy(String searchParam, Long facilityTypeId, Long geoZoneId, Boolean virtualFacility, Boolean enabled); Integer getTotalSearchResultCountByColumnName(String searchParam, String columnName); List<Facility> getFacilityByTypeAndRequisitionGroupId(Long facilityTypeId, Long rgroupId); List<FacilityGeoTreeDto> getGeoRegionFacilityTree(Long userId); List<FacilityGeoTreeDto> getGeoDistrictFacility(Long userId); List<FacilityGeoTreeDto> getGeoFlatFacilityTree(Long userId); Facility getFacilityById(Long id); static final String FACILITY_CATEGORY; static final String FACILITY_TITLE; static final String ERROR_FACILITY_CODE_INVALID; static final String SMS; static final String EMAIL; }