ExtendedCalendarServiceImpl implements ExtendedCalendarService { @SuppressWarnings("unchecked") @Override public Collection<Date> getServiceDatesWithinRange( ServiceIdActivation serviceIds, ServiceInterval interval, Date from, Date to) { if (_serviceDateRangeCache == null) return getServiceDatesWithinRangeExact(serviceIds, interval, from, to); ServiceDateRangeKey key = getCacheKey(serviceIds, interval, from, to); Element element = _serviceDateRangeCache.get(key); if (element == null) { serviceIds = key.getServiceIds(); interval = key.getInterval(); from = key.getFromTime(); to = key.getToTime(); Collection<Date> values = getServiceDatesWithinRangeExact(serviceIds, interval, from, to); element = new Element(key, values); _serviceDateRangeCache.put(element); } return (Collection<Date>) element.getValue(); }  void setServiceDateLowerBoundsInWeeks(int serviceDateLowerBoundsInWeeks); void setServiceDateUpperBoundsInWeeks(int serviceDateUpperBoundsInWeeks); @Autowired void setCalendarService(CalendarService calendarService); @Autowired void setTransitGraphDao(TransitGraphDao transitGraphDao); void setServiceDateRangeCacheInterval(int hours); void setServiceDateRangeCache(Cache serviceDateRangeCache); @PostConstruct @Refreshable(dependsOn = RefreshableResources.CALENDAR_DATA) void start(); @Cacheable @Override Set<ServiceDate> getServiceDatesForServiceIds(
      ServiceIdActivation serviceIds); @Cacheable @Override Set<Date> getDatesForServiceIds(ServiceIdActivation serviceIds); @Cacheable List<Date> getDatesForServiceIdsAsOrderedList(
      ServiceIdActivation serviceIds); @SuppressWarnings("unchecked") @Override Collection<Date> getServiceDatesWithinRange(
      ServiceIdActivation serviceIds, ServiceInterval interval, Date from,
      Date to); @Override @Cacheable boolean areServiceIdsActiveOnServiceDate(
      ServiceIdActivation serviceIds, Date serviceDate); @Override List<Date> getServiceDatesForInterval(ServiceIdActivation serviceIds,
      ServiceInterval serviceInterval, long time, boolean findDepartures); @Override List<Date> getNextServiceDatesForDepartureInterval(
      ServiceIdActivation serviceIds, ServiceInterval serviceInterval, long time); @Override List<Date> getPreviousServiceDatesForArrivalInterval(
      ServiceIdActivation serviceIds, ServiceInterval serviceInterval, long time);  }
@Test public void testGetServiceDatesWithinRange01() { ServiceIdActivation serviceIds = serviceIds(lsids("sA"), lsids("sB")); Date from = UnitTestingSupport.date("2010-09-10 09:30"); Date to = UnitTestingSupport.date("2010-09-10 10:30"); Collection<Date> dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(1, dates.size()); assertTrue(dates.contains(new ServiceDate(2010, 9, 10).getAsDate(timeZone()))); from = UnitTestingSupport.date("2010-09-11 09:30"); to = UnitTestingSupport.date("2010-09-11 10:30"); dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(0, dates.size()); }
@Test public void testGetServiceDatesWithinRange02() { ServiceIdActivation serviceIds = serviceIds(lsids("sA", "sB"), lsids()); Date from = UnitTestingSupport.date("2010-09-11 09:30"); Date to = UnitTestingSupport.date("2010-09-11 10:30"); Collection<Date> dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(1, dates.size()); assertTrue(dates.contains(new ServiceDate(2010, 9, 11).getAsDate(timeZone()))); from = UnitTestingSupport.date("2010-09-10 09:30"); to = UnitTestingSupport.date("2010-09-10 10:30"); dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(0, dates.size()); }
@Test public void testGetServiceDatesWithinRange03() { ServiceIdActivation serviceIds = serviceIds(lsids("sC", "sD"), lsids()); Date from = UnitTestingSupport.date("2010-09-13 09:30"); Date to = UnitTestingSupport.date("2010-09-13 10:30"); Collection<Date> dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(1, dates.size()); assertTrue(dates.contains(new ServiceDate(2010, 9, 13).getAsDate(timeZone()))); from = UnitTestingSupport.date("2010-09-12 09:30"); to = UnitTestingSupport.date("2010-09-12 10:30"); dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(0, dates.size()); }
@Test public void testGetServiceDatesWithinRange04() { ServiceIdActivation serviceIds = serviceIds(lsids("sA", "sC"), lsids()); Date from = UnitTestingSupport.date("2010-09-10 09:30"); Date to = UnitTestingSupport.date("2010-09-10 10:30"); Collection<Date> dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(0, dates.size()); from = UnitTestingSupport.date("2010-09-12 09:30"); to = UnitTestingSupport.date("2010-09-12 10:30"); dates = _service.getServiceDatesWithinRange(serviceIds, interval, from, to); assertEquals(0, dates.size()); }