Search in sources :

Example 6 with ServiceIdActivation

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())));
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) Date(java.util.Date) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Test(org.junit.Test)

Example 7 with ServiceIdActivation

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());
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) Date(java.util.Date) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Test(org.junit.Test)

Example 8 with ServiceIdActivation

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());
}
Also used : ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) Date(java.util.Date) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Test(org.junit.Test)

Example 9 with ServiceIdActivation

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());
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) Date(java.util.Date) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Test(org.junit.Test)

Example 10 with ServiceIdActivation

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());
}
Also used : Date(java.util.Date) TripEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl) StopEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl) BlockLayoverIndex(org.onebusaway.transit_data_federation.services.blocks.BlockLayoverIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) BlockInstance(org.onebusaway.transit_data_federation.services.blocks.BlockInstance) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) BlockEntryImpl(org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) Test(org.junit.Test)

Aggregations

ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)31 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)19 Test (org.junit.Test)17 Date (java.util.Date)16 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)8 HashSet (java.util.HashSet)7 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)7 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)7 TripEntry (org.onebusaway.transit_data_federation.services.transit_graph.TripEntry)7 ArrayList (java.util.ArrayList)6 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)6 BlockEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.BlockEntryImpl)6 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)6 Set (java.util.Set)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5 StopEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.StopEntryImpl)5 FactoryMap (org.onebusaway.collections.FactoryMap)4 FrequencyBlockStopTimeIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockStopTimeIndex)4 FrequencyBlockTripIndex (org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex)4 TimeZone (java.util.TimeZone)3