@Test public void shouldGetAllFacilitiesInDeliveryZoneForSupportedProgram() throws Exception { List<Facility> memberFacilities = new ArrayList<>(); Facility facility = new Facility(1L); Facility facility2 = new Facility(2L); memberFacilities.add(facility); memberFacilities.add(facility2); Long deliveryZoneId = 1l; Long programId = 1l; when(facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId)).thenReturn(memberFacilities); ProgramSupported programSupported = new ProgramSupported(); when(programSupportedService.getFilledByFacilityIdAndProgramId(facility.getId(), programId)).thenReturn(programSupported); when(programSupportedService.getFilledByFacilityIdAndProgramId(facility2.getId(), programId)).thenReturn(programSupported); List<Facility> facilities = facilityService.getAllForDeliveryZoneAndProgram(deliveryZoneId, programId); assertThat(facilities, is(memberFacilities)); assertThat(facilities.get(0).getSupportedPrograms(), is(asList(programSupported))); assertThat(facilities.get(1).getSupportedPrograms(), is(asList(programSupported))); verify(facilityRepository).getAllInDeliveryZoneFor(deliveryZoneId, programId); }
public List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId) { List<Facility> facilities = facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId); for (Facility facility : facilities) { facility.getSupportedPrograms().add(programSupportedService.getFilledByFacilityIdAndProgramId(facility.getId(), programId)); } return facilities; }
FacilityService { public List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId) { List<Facility> facilities = facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId); for (Facility facility : facilities) { facility.getSupportedPrograms().add(programSupportedService.getFilledByFacilityIdAndProgramId(facility.getId(), programId)); } return facilities; } }
FacilityService { public List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId) { List<Facility> facilities = facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId); for (Facility facility : facilities) { facility.getSupportedPrograms().add(programSupportedService.getFilledByFacilityIdAndProgramId(facility.getId(), programId)); } return facilities; }  }
FacilityService { public List<Facility> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId) { List<Facility> facilities = facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId); for (Facility facility : facilities) { facility.getSupportedPrograms().add(programSupportedService.getFilledByFacilityIdAndProgramId(facility.getId(), programId)); } return facilities; }  @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> getAllForDeliveryZoneAndProgram(Long deliveryZoneId, Long programId) { List<Facility> facilities = facilityRepository.getAllInDeliveryZoneFor(deliveryZoneId, programId); for (Facility facility : facilities) { facility.getSupportedPrograms().add(programSupportedService.getFilledByFacilityIdAndProgramId(facility.getId(), programId)); } return facilities; }  @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; }