use of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation in project onebusaway-application-modules by camsys.
the class ExtendedCalendarServiceImplTest method testGetServiceDatesForServiceIds02.
@Test
public void testGetServiceDatesForServiceIds02() {
ServiceIdActivation serviceIds = serviceIds(lsids("sA", "sB"), lsids());
Set<Date> dates = _service.getDatesForServiceIds(serviceIds);
assertEquals(1, dates.size());
assertTrue(dates.contains(new ServiceDate(2010, 9, 11).getAsDate(timeZone())));
}
use of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation in project onebusaway-application-modules by camsys.
the class ExtendedCalendarServiceImplTest method testGetServiceDatesWithinRange02.
@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());
}
use of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation in project onebusaway-application-modules by camsys.
the class ExtendedCalendarServiceImplTest method testGetServiceDatesWithinRange04.
@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());
}
use of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation in project onebusaway-application-modules by camsys.
the class ExtendedCalendarServiceImplTest method testGetServiceDatesWithinRange01.
@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());
}
use of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation in project onebusaway-application-modules by camsys.
the class BlockCalendarServiceImplTest method testGetActiveBlocksInTimeRange.
@Test
public void testGetActiveBlocksInTimeRange() {
Date serviceDateA = UnitTestingSupport.date("2010-09-07 00:00");
Date serviceDateB = UnitTestingSupport.date("2010-09-08 00:00");
Date serviceDateC = UnitTestingSupport.date("2010-09-09 00:00");
UnitTestingSupport.addDates(_calendarData, "sidA", serviceDateA, serviceDateB);
UnitTestingSupport.addDates(_calendarData, "sidB", serviceDateB, serviceDateC);
ServiceIdActivation ids_A_not_B = serviceIds(lsids("sidA"), lsids("sidB"));
ServiceIdActivation ids_B_not_A = serviceIds(lsids("sidB"), lsids("sidA"));
ServiceIdActivation ids_A_and_B = serviceIds(lsids("sidA", "sidB"), lsids());
StopEntryImpl stopA = stop("stopA", 0.0, 0.0);
StopEntryImpl stopB = stop("stopB", 0.0, 0.0);
BlockEntryImpl blockA = block("blockA");
TripEntryImpl tripA = trip("tripA", "sidA");
TripEntryImpl tripB = trip("tripB", "sidB");
stopTime(0, stopA, tripA, time(9, 00), time(9, 00), 0);
stopTime(1, stopB, tripA, time(9, 30), time(9, 30), 100);
stopTime(2, stopB, tripB, time(10, 00), time(10, 00), 200);
stopTime(3, stopA, tripB, time(10, 30), time(10, 30), 300);
linkBlockTrips(ids_A_not_B, blockA, tripA);
linkBlockTrips(ids_A_and_B, blockA, tripA, tripB);
linkBlockTrips(ids_B_not_A, blockA, tripB);
BlockConfigurationEntry bcA_A_B = findBlockConfig(blockA, ids_A_not_B);
BlockConfigurationEntry bcA_B_A = findBlockConfig(blockA, ids_B_not_A);
BlockConfigurationEntry bcA_AB = findBlockConfig(blockA, ids_A_and_B);
BlockEntryImpl blockB = block("blockB");
TripEntryImpl tripC = trip("tripC", "sidA");
TripEntryImpl tripD = trip("tripD", "sidB");
TripEntryImpl tripE = trip("tripE", "sidA");
stopTime(4, stopA, tripC, time(10, 00), time(10, 00), 0);
stopTime(5, stopB, tripC, time(10, 30), time(10, 30), 0);
stopTime(6, stopB, tripD, time(11, 00), time(11, 00), 0);
stopTime(7, stopA, tripD, time(11, 30), time(11, 30), 0);
stopTime(8, stopA, tripE, time(12, 00), time(12, 00), 0);
stopTime(9, stopB, tripE, time(12, 30), time(12, 30), 0);
linkBlockTrips(ids_A_not_B, blockB, tripC, tripE);
linkBlockTrips(ids_A_and_B, blockB, tripC, tripD, tripE);
linkBlockTrips(ids_B_not_A, blockB, tripD);
BlockConfigurationEntry bcB_A_B = findBlockConfig(blockB, ids_A_not_B);
BlockConfigurationEntry bcB_B_A = findBlockConfig(blockB, ids_B_not_A);
BlockConfigurationEntry bcB_AB = findBlockConfig(blockB, ids_A_and_B);
List<BlockTripIndex> blocks = blockTripIndices(blockA, blockB);
List<BlockLayoverIndex> layoverIndices = Collections.emptyList();
List<FrequencyBlockTripIndex> frequencyIndices = Collections.emptyList();
/**
**
*
***
*/
long time = timeFromString("2010-09-07 09:15");
List<BlockInstance> instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
BlockInstance instance = instances.get(0);
assertEquals(bcA_A_B, instance.getBlock());
assertEquals(serviceDateA.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-07 010:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcB_A_B, instance.getBlock());
assertEquals(serviceDateA.getTime(), instance.getServiceDate());
/**
**
*
***
*/
/*
* time = timeFromString("2010-09-07 011:15");
*
* instances = _service.getActiveBlocksInTimeRange(blocks, frequencyIndices,
* time, time);
*
* assertEquals(1, instances.size());
*
* instance = instances.get(0); assertEquals(bcB_A_B, instance.getBlock());
* assertEquals(serviceDateA.getTime(), instance.getServiceDate());
*/
/**
**
*
***
*/
time = timeFromString("2010-09-07 012:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcB_A_B, instance.getBlock());
assertEquals(serviceDateA.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-08 09:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcA_AB, instance.getBlock());
assertEquals(serviceDateB.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-08 10:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
Collections.sort(instances, new BlockInstanceComparator());
assertEquals(2, instances.size());
instance = instances.get(0);
assertEquals(bcA_AB, instance.getBlock());
assertEquals(serviceDateB.getTime(), instance.getServiceDate());
instance = instances.get(1);
assertEquals(bcB_AB, instance.getBlock());
assertEquals(serviceDateB.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-08 11:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcB_AB, instance.getBlock());
assertEquals(serviceDateB.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-08 12:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcB_AB, instance.getBlock());
assertEquals(serviceDateB.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-09 09:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(0, instances.size());
/**
**
*
***
*/
time = timeFromString("2010-09-09 10:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcA_B_A, instance.getBlock());
assertEquals(serviceDateC.getTime(), instance.getServiceDate());
/**
**
*
***
*/
time = timeFromString("2010-09-09 11:15");
instances = _service.getActiveBlocksInTimeRange(blocks, layoverIndices, frequencyIndices, time, time);
assertEquals(1, instances.size());
instance = instances.get(0);
assertEquals(bcB_B_A, instance.getBlock());
assertEquals(serviceDateC.getTime(), instance.getServiceDate());
}
Aggregations