FacilityFacadeEjb implements FacilityFacade { @Override public List<FacilityDto> getAllByRegionAfter(String regionUuid, Date date) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<FacilityDto> cq = cb.createQuery(FacilityDto.class); Root<Facility> facility = cq.from(Facility.class); selectDtoFields(cq, facility); Predicate filter = facilityService.createChangeDateFilter(cb, facility, date); if (regionUuid != null) { Predicate regionFilter = cb.equal(facility.get(Facility.REGION), regionService.getByUuid(regionUuid)); filter = AbstractAdoService.and(cb, filter, regionFilter); } if (filter != null) { cq.where(filter); } return em.createQuery(cq).getResultList(); }  @Override List<FacilityReferenceDto> getActiveFacilitiesByCommunityAndType(
		CommunityReferenceDto communityRef,
		FacilityType type,
		boolean includeOtherFacility,
		boolean includeNoneFacility); @Override List<FacilityReferenceDto> getActiveFacilitiesByDistrictAndType(
		DistrictReferenceDto districtRef,
		FacilityType type,
		boolean includeOtherFacility,
		boolean includeNoneFacility); @Override List<FacilityReferenceDto> getActiveHospitalsByCommunity(CommunityReferenceDto communityRef, boolean includeOtherFacility); @Override List<FacilityReferenceDto> getActiveHospitalsByDistrict(DistrictReferenceDto districtRef, boolean includeOtherFacility); @Override List<FacilityReferenceDto> getAllActiveLaboratories(boolean includeOtherFacility); @Override List<String> getAllUuids(); @Override List<FacilityDto> getAllByRegionAfter(String regionUuid, Date date); @Override List<FacilityDto> getAllWithoutRegionAfter(Date date); @Override FacilityDto getByUuid(String uuid); @Override List<FacilityDto> getByUuids(List<String> uuids); @Override FacilityReferenceDto getFacilityReferenceByUuid(String uuid); @Override FacilityReferenceDto getFacilityReferenceById(long id); @Override Map<String, String> getDistrictUuidsForFacilities(List<FacilityReferenceDto> facilities); @Override Map<String, String> getCommunityUuidsForFacilities(List<FacilityReferenceDto> facilities); @Override List<FacilityReferenceDto> getByNameAndType(
		String name,
		DistrictReferenceDto districtRef,
		CommunityReferenceDto communityRef,
		FacilityType type,
		boolean includeArchivedEntities); @Override List<FacilityReferenceDto> getLaboratoriesByName(String name, boolean includeArchivedEntities); @Override void archive(String facilityUuid); @Override void dearchive(String facilityUuid); @Override boolean hasArchivedParentInfrastructure(Collection<String> facilityUuids); static FacilityReferenceDto toReferenceDto(Facility entity); @Override List<FacilityDto> getIndexList(FacilityCriteria facilityCriteria, Integer first, Integer max, List<SortProperty> sortProperties); @Override long count(FacilityCriteria criteria); @Override void saveFacility(FacilityDto dto);  }
@Test public void testGetAllByRegionAfter() throws InterruptedException { RDCF rdcf = creator.createRDCF(); getFacilityService().doFlush(); Date date = new Date(); List<FacilityDto> results = getFacilityFacade().getAllByRegionAfter(rdcf.region.getUuid(), date); assertEquals(0, results.size()); Thread.sleep(1); String facilityName = "facility2"; creator.createFacility(facilityName, rdcf.region, rdcf.district, rdcf.community); results = getFacilityFacade().getAllByRegionAfter(rdcf.region.getUuid(), date); assertEquals(1, results.size()); assertEquals(facilityName, results.get(0).getName()); assertEquals(rdcf.community.getUuid(), results.get(0).getCommunity().getUuid()); assertEquals(rdcf.region.getUuid(), results.get(0).getRegion().getUuid()); }