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());
}
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());
}
Aggregations