Search in sources :

Example 1 with MatchAndTransform

use of org.onebusaway.gtfs_transformer.factory.EntitiesTransformStrategy.MatchAndTransform in project onebusaway-gtfs-modules by OneBusAway.

the class TransformFactoryTest method testFileMatch.

@Test
public void testFileMatch() throws IOException, TransformSpecificationException {
    _factory.addModificationsFromString("{'op':'remove', 'match':{'file':'routes.txt', 'shortName':'10'}}");
    GtfsTransformStrategy transform = _transformer.getLastTransform();
    assertEquals(EntitiesTransformStrategy.class, transform.getClass());
    EntitiesTransformStrategy strategy = (EntitiesTransformStrategy) transform;
    List<MatchAndTransform> transforms = strategy.getModifications();
    assertEquals(1, transforms.size());
}
Also used : MatchAndTransform(org.onebusaway.gtfs_transformer.factory.EntitiesTransformStrategy.MatchAndTransform) GtfsTransformStrategy(org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy) Test(org.junit.Test)

Example 2 with MatchAndTransform

use of org.onebusaway.gtfs_transformer.factory.EntitiesTransformStrategy.MatchAndTransform 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

Test (org.junit.Test)2 MatchAndTransform (org.onebusaway.gtfs_transformer.factory.EntitiesTransformStrategy.MatchAndTransform)2 GtfsTransformStrategy (org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy)2 Route (org.onebusaway.gtfs.model.Route)1 EntityMatch (org.onebusaway.gtfs_transformer.match.EntityMatch)1 EntityTransformStrategy (org.onebusaway.gtfs_transformer.services.EntityTransformStrategy)1