OneBusAway / onebusaway-gtfs-modules

A Java-based library for reading, writing, and transforming public transit data in the GTFS format, including database support.

Home Page:https://github.com/OneBusAway/onebusaway-gtfs-modules/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating route_id updates AgencyAndId object and not the route's id.

romainguefveneu opened this issue · comments

Summary:

Updating route_id updates AgencyAndId object and not the route's id, leading to have the agency code postfixed to the new route id.

Steps to reproduce:

  @Test
  public void testUpdateRouteId() throws Exception {
    _factory.addModificationsFromString("{'op':'update', "
            + "'match':{'file':'routes.txt'}, "
            + "'update':{'route_id':'s/r/route/'}}");

    GtfsTransformStrategy transform = _transformer.getLastTransform();
    TransformContext context = new TransformContext();
    GtfsMutableRelationalDao dao = new GtfsRelationalDaoImpl();

    Route route = new Route();
    route.setId(new AgencyAndId("a0", "r0"));
    dao.saveEntity(route);

    transform.run(context, dao);

    assertEquals("route0", route.getId().getId());
  }

Expected behavior:

It should transforms r0 into route0

Observed behavior:

It transforms r0 into a0_route0

Platform:

macOS 10.15.5
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
onebusaway-gtfs-modules 1.3.89-SNAPSHOT