Search in sources :

Example 6 with GtfsTransformStrategy

use of org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy in project onebusaway-gtfs-modules by OneBusAway.

the class TransformFactoryTest method testCalendarSimplification.

@Test
public void testCalendarSimplification() throws IOException, TransformSpecificationException {
    _factory.addModificationsFromString("{'op':'calendar_simplification'}");
    GtfsTransformStrategy transform = _transformer.getLastTransform();
    assertEquals(CalendarSimplicationStrategy.class, transform.getClass());
    CalendarSimplicationStrategy simplification = (CalendarSimplicationStrategy) transform;
    assertFalse(simplification.isUndoGoogleTransitDataFeedMergeTool());
    _factory.addModificationsFromString("{'op':'calendar_simplification', 'min_number_of_weeks_for_calendar_entry':10}");
    simplification = (CalendarSimplicationStrategy) _transformer.getLastTransform();
    assertEquals(10, simplification.getLibrary().getMinNumberOfWeeksForCalendarEntry());
    _factory.addModificationsFromString("{'op':'calendar_simplification', 'day_of_the_week_inclusion_ratio':0.1}");
    simplification = (CalendarSimplicationStrategy) _transformer.getLastTransform();
    assertEquals(0.1, simplification.getLibrary().getDayOfTheWeekInclusionRatio(), 0.0);
    _factory.addModificationsFromString("{'op':'calendar_simplification', 'undo_google_transit_data_feed_merge_tool':true}");
    simplification = (CalendarSimplicationStrategy) _transformer.getLastTransform();
    assertTrue(simplification.isUndoGoogleTransitDataFeedMergeTool());
}
Also used : CalendarSimplicationStrategy(org.onebusaway.gtfs_transformer.updates.CalendarSimplicationStrategy) GtfsTransformStrategy(org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy) Test(org.junit.Test)

Example 7 with GtfsTransformStrategy

use of org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy in project onebusaway-gtfs-modules by OneBusAway.

the class TransformFactoryTest method test.

@Test
public void test() throws IOException, TransformSpecificationException {
    _factory.addModificationsFromString("{'op':'remove', 'match':{'class':'Route', 'shortName':'10'}}");
    GtfsTransformStrategy transform = _transformer.getLastTransform();
    assertEquals(EntitiesTransformStrategy.class, transform.getClass());
    EntitiesTransformStrategy strategy = (EntitiesTransformStrategy) transform;
    List<MatchAndTransform> transforms = strategy.getModifications();
    assertEquals(1, transforms.size());
    MatchAndTransform pair = transforms.get(0);
    EntityMatch match = pair.getMatch();
    Route route = new Route();
    assertFalse(match.isApplicableToObject(route));
    route.setShortName("10");
    assertTrue(match.isApplicableToObject(route));
    EntityTransformStrategy entityTransform = pair.getTransform();
    assertEquals(RemoveEntityUpdateStrategy.class, entityTransform.getClass());
}
Also used : EntityTransformStrategy(org.onebusaway.gtfs_transformer.services.EntityTransformStrategy) MatchAndTransform(org.onebusaway.gtfs_transformer.factory.EntitiesTransformStrategy.MatchAndTransform) GtfsTransformStrategy(org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy) EntityMatch(org.onebusaway.gtfs_transformer.match.EntityMatch) Route(org.onebusaway.gtfs.model.Route) Test(org.junit.Test)

Aggregations

GtfsTransformStrategy (org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy)7 Test (org.junit.Test)5 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 Route (org.onebusaway.gtfs.model.Route)2 Trip (org.onebusaway.gtfs.model.Trip)2 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)2 MatchAndTransform (org.onebusaway.gtfs_transformer.factory.EntitiesTransformStrategy.MatchAndTransform)2 TransformContext (org.onebusaway.gtfs_transformer.services.TransformContext)2 TransformSpecificationException (org.onebusaway.gtfs_transformer.TransformSpecificationException)1 EntityMatch (org.onebusaway.gtfs_transformer.match.EntityMatch)1 EntityTransformStrategy (org.onebusaway.gtfs_transformer.services.EntityTransformStrategy)1 GtfsEntityTransformStrategy (org.onebusaway.gtfs_transformer.services.GtfsEntityTransformStrategy)1 GtfsTransformStrategyFactory (org.onebusaway.gtfs_transformer.services.GtfsTransformStrategyFactory)1 CalendarSimplicationStrategy (org.onebusaway.gtfs_transformer.updates.CalendarSimplicationStrategy)1