Skip to content

Commit

Permalink
Update to newest version of GTFS Flex location groups
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Feb 1, 2024
1 parent bd51be9 commit 464a440
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@
<dependency>
<groupId>org.onebusaway</groupId>
<artifactId>onebusaway-gtfs</artifactId>
<version>1.4.10</version>
<version>1.4.15</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.opentripplanner.gtfs.mapping;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.junit.jupiter.api.Test;
import org.onebusaway.gtfs.model.AgencyAndId;
import org.onebusaway.gtfs.model.LocationGroup;
import org.onebusaway.gtfs.model.Stop;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.service.StopModel;

class LocationGroupMapperTest {

private static final String NAME = "A GROUP";

@Test
void map() {
var builder = StopModel.of();
var mapper = new LocationGroupMapper(
new StopMapper(new TranslationHelper(), id -> null, builder),
new LocationMapper(builder),
builder
);

var lg = new LocationGroup();
lg.setId(id("group-1"));
lg.setName(NAME);

var stop = new Stop();
stop.setId(id("stop-1"));
stop.setLat(1);
stop.setLon(1);

lg.addLocation(stop);
var groupStop = mapper.map(lg);
assertEquals(NAME, groupStop.getName().toString());
assertEquals(
Set.of(new FeedScopedId("1", "stop-1")),
groupStop.getChildLocations().stream().map(StopLocation::getId).collect(Collectors.toSet())
);
}

@Nonnull
private static AgencyAndId id(String id) {
return new AgencyAndId("1", id);
}
}

0 comments on commit 464a440

Please sign in to comment.