use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class CalendarServiceImplTest method test.
@Test
public void test() throws IOException {
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsTestData.readGtfs(dao, GtfsTestData.getIslandGtfs(), "26");
CalendarServiceDataFactoryImpl factory = new CalendarServiceDataFactoryImpl();
factory.setGtfsDao(dao);
CalendarServiceData data = factory.createData();
CalendarServiceImpl service = new CalendarServiceImpl();
service.setData(data);
ServiceDate from = new ServiceDate(2008, 10, 27);
ServiceDate to = new ServiceDate(2009, 9, 27);
Set<ServiceDate> toExclude = new HashSet<ServiceDate>();
toExclude.add(new ServiceDate(2009, 1, 1));
// 23,1,1,1,1,1,0,0,20081027,20090927
Set<ServiceDate> dates = service.getServiceDatesForServiceId(new AgencyAndId("26", "23"));
assertEquals(239, dates.size());
Date fromDate = from.getAsDate();
Date toDate = to.getAsDate();
Calendar c = Calendar.getInstance();
c.setTime(fromDate);
while (c.getTime().compareTo(toDate) <= 0) {
ServiceDate day = new ServiceDate(c);
int dow = c.get(Calendar.DAY_OF_WEEK);
if (!(dow == Calendar.SATURDAY || dow == Calendar.SUNDAY || toExclude.contains(day))) {
assertTrue(dates.contains(day));
}
c.add(Calendar.DAY_OF_YEAR, 1);
}
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class LocalizedServiceIdTest method testCompareTo.
@Test
public void testCompareTo() {
TimeZone tzLA = TimeZone.getTimeZone("America/Los_Angeles");
TimeZone tzNY = TimeZone.getTimeZone("America/New_York");
LocalizedServiceId lsidA = new LocalizedServiceId(new AgencyAndId("1", "sA"), tzLA);
LocalizedServiceId lsidB = new LocalizedServiceId(new AgencyAndId("1", "sA"), tzNY);
LocalizedServiceId lsidC = new LocalizedServiceId(new AgencyAndId("1", "sB"), tzLA);
LocalizedServiceId lsidD = new LocalizedServiceId(new AgencyAndId("1", "sB"), tzNY);
LocalizedServiceId lsidE = new LocalizedServiceId(new AgencyAndId("2", "sB"), tzLA);
assertEquals(0, lsidA.compareTo(lsidA));
assertTrue(lsidA.compareTo(lsidB) < 0);
assertTrue(lsidA.compareTo(lsidC) < 0);
assertTrue(lsidA.compareTo(lsidD) < 0);
assertTrue(lsidA.compareTo(lsidE) < 0);
assertTrue(lsidB.compareTo(lsidA) > 0);
assertEquals(0, lsidB.compareTo(lsidB));
assertTrue(lsidB.compareTo(lsidC) < 0);
assertTrue(lsidB.compareTo(lsidD) < 0);
assertTrue(lsidB.compareTo(lsidE) < 0);
assertTrue(lsidC.compareTo(lsidA) > 0);
assertTrue(lsidC.compareTo(lsidB) > 0);
assertEquals(0, lsidC.compareTo(lsidC));
assertTrue(lsidC.compareTo(lsidD) < 0);
assertTrue(lsidC.compareTo(lsidE) < 0);
assertTrue(lsidD.compareTo(lsidA) > 0);
assertTrue(lsidD.compareTo(lsidB) > 0);
assertTrue(lsidD.compareTo(lsidC) > 0);
assertEquals(0, lsidD.compareTo(lsidD));
assertTrue(lsidD.compareTo(lsidE) < 0);
assertTrue(lsidE.compareTo(lsidA) > 0);
assertTrue(lsidE.compareTo(lsidB) > 0);
assertTrue(lsidE.compareTo(lsidC) > 0);
assertTrue(lsidE.compareTo(lsidD) > 0);
assertEquals(0, lsidE.compareTo(lsidE));
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class DeferredValueSupportTest method testResolveAgencyAndId_DefaultAgencyId.
@Test
public void testResolveAgencyAndId_DefaultAgencyId() {
Stop stop = new Stop();
BeanWrapper bean = BeanWrapperFactory.wrap(stop);
AgencyAndId id = _support.resolveAgencyAndId(bean, "id", "1");
assertEquals(new AgencyAndId("a0", "1"), id);
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testTripStopTimesVirtualMethod.
@Test
public void testTripStopTimesVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "t0"));
_dao.saveEntity(trip);
StopTime stopTime = new StopTime();
stopTime.setTrip(trip);
stopTime.setStop(new Stop());
_dao.saveEntity(stopTime);
PropertyMethod method = _resolver.getPropertyMethod(Trip.class, "stop_times");
assertEquals(Arrays.asList(stopTime), method.invoke(trip));
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsTransformerTest method testRemoveCalendarCollection.
@Test
public void testRemoveCalendarCollection() throws Exception {
GtfsRelationalDao dao = transform("{'op':'remove', 'match':{'collection':'calendar', 'service_id':'sid1'}}");
assertNull(dao.getCalendarForServiceId(new AgencyAndId("a0", "sid1")));
assertNull(dao.getTripForId(new AgencyAndId("a0", "t1")));
}
Aggregations