Package org.onebusaway.transit_data_federation.services.transit_graph

Examples of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation


  }

  @Test
  public void testGetServiceDatesForServiceIds04() {

    ServiceIdActivation serviceIds = serviceIds(lsids("sA", "sC"), lsids());

    Set<Date> dates = _service.getDatesForServiceIds(serviceIds);

    assertEquals(0, dates.size());
  }
View Full Code Here


    Mockito.when(_transitGraphDao.getAllBlocks()).thenReturn(blocks);

    _service.start();

    ServiceIdActivation serviceIds = serviceIds(lsids("sA"), lsids());
    int inFrom = time(8, 00);
    int inTo = time(20, 00);
    ServiceInterval interval = new ServiceInterval(inFrom, inFrom, inTo, inTo);
    long time = dateAsLong("2010-09-10 09:30");
View Full Code Here

    Mockito.when(_transitGraphDao.getAllBlocks()).thenReturn(blocks);

    _service.start();

    ServiceIdActivation serviceIds = serviceIds(lsids("sA"), lsids());
    int inFrom = time(8, 00);
    int inTo = time(20, 00);
    ServiceInterval interval = new ServiceInterval(inFrom, inFrom, inTo, inTo);
    long time = dateAsLong("2010-09-11 21:30");
View Full Code Here

        + _serviceIntervalBlock + "]";
  }

  private static void checkBlocksHaveSameServiceids(
      List<BlockConfigurationEntry> blocks) {
    ServiceIdActivation expected = blocks.get(0).getServiceIds();
    for (int i = 1; i < blocks.size(); i++) {
      ServiceIdActivation actual = blocks.get(i).getServiceIds();
      if (!expected.equals(actual))
        throw new IllegalArgumentException("serviceIds mismatch: expected="
            + expected + " actual=" + actual);
    }
  }
View Full Code Here

    assertEquals(tripA1, trips.get(0));
    assertEquals(tripB1, trips.get(1));
    assertEquals(tripF1, trips.get(2));
    assertEquals(tripE1, trips.get(3));
    assertEquals(tripB3, trips.get(4));
    ServiceIdActivation serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    ServiceIntervalBlock intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {0, 20, 40, 50, 80},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {10, 30, 50, 60, 80},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {20, 50, 70, 80, 90},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {20, 50, 70, 80, 100},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("a2"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(5, trips.size());
    assertEquals(tripA2, trips.get(0));
    assertEquals(tripB2, trips.get(1));
    assertEquals(tripC2, trips.get(2));
    assertEquals(tripF2, trips.get(3));
    assertEquals(tripE2, trips.get(4));
    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {30, 60, 70, 80, 90},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {30, 60, 70, 80, 90},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {40, 70, 80, 90, 100},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {40, 70, 80, 90, 100},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("c1"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(3, trips.size());
    assertEquals(tripC1, trips.get(0));
    assertEquals(tripA3, trips.get(1));
    assertEquals(tripC3, trips.get(2));
    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {40, 50, 85},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {50, 50, 85},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {60, 60, 90},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {60, 70, 95},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("d1"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(2, trips.size());
    assertEquals(tripD1, trips.get(0));
    assertEquals(tripD3, trips.get(1));
    serviceIds = index.getServiceIds();
    assertEquals(2, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s2")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {40, 100},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {50, 100},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {70, 110},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {70, 120},
        intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("d2"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(1, trips.size());
    assertEquals(tripD2, trips.get(0));
    serviceIds = index.getServiceIds();
    assertEquals(2, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s2")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {80}, intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {80}, intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {90}, intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {90}, intervalBlock.getMaxDepartures()));

    indices = grep(allIndices, aid("e3"));
    assertEquals(1, indices.size());
    index = indices.get(0);
    trips = trips(index.getTrips());
    assertEquals(2, trips.size());
    assertEquals(tripF3, trips.get(0));
    assertEquals(tripE3, trips.get(1));
    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMinArrivals()));
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMinDepartures()));
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMaxArrivals()));
    assertTrue(Arrays.equals(new int[] {100, 110},
        intervalBlock.getMaxDepartures()));

    /****
     * Test Layover Indices
     ****/

    List<BlockLayoverIndex> allLayoverIndices = factory.createLayoverIndices(Arrays.asList(
        (BlockEntry) blockF, blockE, blockD, blockC, blockB, blockA));

    List<BlockLayoverIndex> layoverIndices = grep(allLayoverIndices, aid("a2"));
    assertEquals(1, layoverIndices.size());
    BlockLayoverIndex layoverIndiex = layoverIndices.get(0);
    trips = trips(layoverIndiex.getTrips());
    assertEquals(5, trips.size());
    assertEquals(tripA2, trips.get(0));
    assertEquals(tripB2, trips.get(1));
    assertEquals(tripC2, trips.get(2));
    assertEquals(tripF2, trips.get(3));
    assertEquals(tripE2, trips.get(4));
    serviceIds = layoverIndiex.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    LayoverIntervalBlock layoverIntervalBlock = layoverIndiex.getLayoverIntervalBlock();
    assertTrue(Arrays.equals(new int[] {20, 50, 60, 70, 80},
        layoverIntervalBlock.getStartTimes()));
    assertTrue(Arrays.equals(new int[] {30, 60, 70, 80, 90},
        layoverIntervalBlock.getEndTimes()));

    layoverIndices = grep(allLayoverIndices, aid("a3"));
    assertEquals(1, layoverIndices.size());
    layoverIndiex = layoverIndices.get(0);
    trips = trips(layoverIndiex.getTrips());
    assertEquals(5, trips.size());
    assertEquals(tripA3, trips.get(0));
    assertEquals(tripB3, trips.get(1));
    assertEquals(tripC3, trips.get(2));
    assertEquals(tripF3, trips.get(3));
    assertEquals(tripE3, trips.get(4));
    serviceIds = layoverIndiex.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    layoverIntervalBlock = layoverIndiex.getLayoverIntervalBlock();
    assertTrue(Arrays.equals(new int[] {40, 70, 80, 90, 100},
        layoverIntervalBlock.getStartTimes()));
    assertTrue(Arrays.equals(new int[] {50, 80, 85, 100, 110},
        layoverIntervalBlock.getEndTimes()));

    layoverIndices = grep(allLayoverIndices, aid("d2"));
    assertEquals(1, layoverIndices.size());
    layoverIndiex = layoverIndices.get(0);
    trips = trips(layoverIndiex.getTrips());
    assertEquals(1, trips.size());
    assertEquals(tripD2, trips.get(0));
    serviceIds = layoverIndiex.getServiceIds();
    assertEquals(2, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s2")));
    layoverIntervalBlock = layoverIndiex.getLayoverIntervalBlock();
    assertTrue(Arrays.equals(new int[] {70},
        layoverIntervalBlock.getStartTimes()));
    assertTrue(Arrays.equals(new int[] {80}, layoverIntervalBlock.getEndTimes()));

    layoverIndices = grep(allLayoverIndices, aid("d3"));
    assertEquals(1, layoverIndices.size());
    layoverIndiex = layoverIndices.get(0);
    trips = trips(layoverIndiex.getTrips());
    assertEquals(1, trips.size());
    assertEquals(tripD3, trips.get(0));
    serviceIds = layoverIndiex.getServiceIds();
    assertEquals(2, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s2")));
    layoverIntervalBlock = layoverIndiex.getLayoverIntervalBlock();
    assertTrue(Arrays.equals(new int[] {90},
        layoverIntervalBlock.getStartTimes()));
    assertTrue(Arrays.equals(new int[] {100},
        layoverIntervalBlock.getEndTimes()));
View Full Code Here

    assertEquals(tripB, trips.get(3));

    List<FrequencyEntry> freqs = index.getFrequencies();
    assertEquals(Arrays.asList(freqA1, freqB1, freqA2, freqB2), freqs);

    ServiceIdActivation serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));

    FrequencyServiceIntervalBlock intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {
        time(6, 0), time(9, 0), time(15, 0), time(18, 0)},
        intervalBlock.getStartTimes()));
View Full Code Here

    assertEquals(tripA, trips.get(1));

    List<FrequencyEntry> freqs = index.getFrequencies();
    assertEquals(Arrays.asList(freqA1, freqA2), freqs);

    ServiceIdActivation serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));

    FrequencyServiceIntervalBlock intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {time(6, 0), time(15, 0)},
        intervalBlock.getStartTimes()));
    assertTrue(Arrays.equals(new int[] {time(9, 0), time(18, 0)},
        intervalBlock.getEndTimes()));

    /****
     *
     ****/

    indices = grep(allIndices, aid("b"));
    assertEquals(1, indices.size());

    index = indices.get(0);

    trips = trips(index.getTrips());
    assertEquals(2, trips.size());
    assertEquals(tripB, trips.get(0));
    assertEquals(tripB, trips.get(1));

    freqs = index.getFrequencies();
    assertEquals(Arrays.asList(freqB1, freqB2), freqs);

    serviceIds = index.getServiceIds();
    assertEquals(1, serviceIds.getActiveServiceIds().size());
    assertTrue(serviceIds.getActiveServiceIds().contains(lsid("s1")));

    intervalBlock = index.getServiceIntervalBlock();
    assertTrue(Arrays.equals(new int[] {time(8, 0), time(17, 0)},
        intervalBlock.getStartTimes()));
    assertTrue(Arrays.equals(new int[] {time(14, 0), time(20, 0)},
View Full Code Here

  public int size() {
    return _trips.size();
  }

  private static void checkTripsHaveSameServiceids(List<BlockTripEntry> trips) {
    ServiceIdActivation expected = trips.get(0).getBlockConfiguration().getServiceIds();
    for (int i = 1; i < trips.size(); i++) {
      ServiceIdActivation actual = trips.get(i).getBlockConfiguration().getServiceIds();
      if (!expected.equals(actual))
        throw new IllegalArgumentException("serviceIds mismatch: expected="
            + expected + " actual=" + actual);
    }
  }
View Full Code Here

    List<ServiceIdActivation> combinations = cache.getOverlappingServiceIdCombinations(set(
        lsidA, lsidB, lsidC,lsidD));
    assertEquals(4, combinations.size());
   
    ServiceIdActivation combo = combinations.get(0);
    assertEquals(Arrays.asList(lsidA, lsidB),combo.getActiveServiceIds());
    assertEquals(Arrays.asList(),combo.getInactiveServiceIds());
   
    combo = combinations.get(1);
    assertEquals(Arrays.asList(lsidB, lsidC),combo.getActiveServiceIds());
    assertEquals(Arrays.asList(),combo.getInactiveServiceIds());
   
    combo = combinations.get(2);
    assertEquals(Arrays.asList(lsidC, lsidD),combo.getActiveServiceIds());
    assertEquals(Arrays.asList(),combo.getInactiveServiceIds());
   
    combo = combinations.get(3);
    assertEquals(Arrays.asList(lsidA),combo.getActiveServiceIds());
    assertEquals(Arrays.asList(lsidB),combo.getInactiveServiceIds());

    combinations = cache.getOverlappingServiceIdCombinations(set(lsidA, lsidB,
        lsidC, lsidD));

    Mockito.verify(calendarService, Mockito.times(1)).getServiceDatesForServiceId(
View Full Code Here

  private Set<ServiceIdActivation> determineAllServiceIds() {
    Set<ServiceIdActivation> allServiceIds = new HashSet<ServiceIdActivation>();

    for (BlockEntry block : _transitGraphDao.getAllBlocks()) {
      for (BlockConfigurationEntry blockConfig : block.getConfigurations()) {
        ServiceIdActivation serviceIds = blockConfig.getServiceIds();
        allServiceIds.add(serviceIds);
      }
    }
    return allServiceIds;
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.