Skip to content

Commit 7b149dc

Browse files
committed
refactor: Update TripPattern to enforce feed ID consistency
1 parent b25c7ab commit 7b149dc

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/TestStopConsolidationModel.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.opentripplanner.ext.stopconsolidation;
22

3-
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id;
4-
53
import java.util.List;
64
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
75
import org.opentripplanner.transit.model.framework.Deduplicator;
@@ -39,7 +37,7 @@ class TestStopConsolidationModel {
3937
.withId(new FeedScopedId(SECONDARY_FEED_ID, "secondary-stop-D"))
4038
.build();
4139

42-
static final TripPattern PATTERN = TripPattern.of(id("123"))
40+
static final TripPattern PATTERN = TripPattern.of(new FeedScopedId(SECONDARY_FEED_ID, "123"))
4341
.withRoute(ROUTE)
4442
.withStopPattern(STOP_PATTERN)
4543
.build();

application/src/main/java/org/opentripplanner/transit/model/network/TripPattern.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ public final class TripPattern
142142

143143
this.hopGeometries = builder.hopGeometries();
144144
this.routingTripPattern = new RoutingTripPattern(this);
145+
146+
getId().requireSameFeedId(route.getId());
145147
}
146148

147149
public static TripPatternBuilder of(FeedScopedId id) {
@@ -445,7 +447,7 @@ public TripPattern clone() {
445447
*/
446448
public String getFeedId() {
447449
// The feed id is the same as the agency id on the route, this allows us to obtain it from there.
448-
return route.getId().getFeedId();
450+
return getId().getFeedId();
449451
}
450452

451453
public RoutingTripPattern getRoutingTripPattern() {

application/src/test/java/org/opentripplanner/model/TripPatternTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public TripPattern setupTripPattern(
105105
var stopPattern = builder.build();
106106
var route = TimetableRepositoryForTest.route("R1").build();
107107

108-
return TripPattern.of(new FeedScopedId("Test", "T1"))
108+
return TripPattern.of(new FeedScopedId(route.getId().getFeedId(), "T1"))
109109
.withRoute(route)
110110
.withStopPattern(stopPattern)
111111
.withOriginalTripPattern(originalTripPattern)

application/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private TripPattern getOriginalPattern(TestTripPattern pattern) {
282282
stopTimes.add(stopTime);
283283
}
284284

285-
var builder = TripPattern.of(new FeedScopedId("TestFeed", "TestId"))
285+
var builder = TripPattern.of(new FeedScopedId(pattern.route().getId().getFeedId(), "TestId"))
286286
.withRoute(pattern.route())
287287
.withStopPattern(new StopPattern(stopTimes));
288288
return builder.build();

0 commit comments

Comments
 (0)