Skip to content

Commit e7ae470

Browse files
committed
More doc and method name changes based on review
1 parent 4d73ce7 commit e7ae470

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

src/ext/java/org/opentripplanner/ext/siri/SiriTimetableSnapshotSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private Result<TripUpdate, UpdateError> handleModifiedTrip(
356356

357357
// Also check whether trip id has been used for previously ADDED/MODIFIED trip message and
358358
// remove the previously created trip
359-
this.buffer.removeRealtimeAddedTripPatternAndTimetablesForTrip(trip.getId(), serviceDate);
359+
this.buffer.revertTripToScheduledTripPattern(trip.getId(), serviceDate);
360360

361361
return updateResult;
362362
}

src/main/java/org/opentripplanner/model/TimetableSnapshot.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,7 @@ public void clear(String feedId) {
303303
* @return true if the trip was found to be shifted to a different trip pattern by a realtime
304304
* message and an attempt was made to re-associate it with its originally scheduled trip pattern.
305305
*/
306-
public boolean removeRealtimeAddedTripPatternAndTimetablesForTrip(
307-
FeedScopedId tripId,
308-
LocalDate serviceDate
309-
) {
306+
public boolean revertTripToScheduledTripPattern(FeedScopedId tripId, LocalDate serviceDate) {
310307
boolean success = false;
311308

312309
final TripPattern pattern = getRealtimeAddedTripPattern(tripId, serviceDate);

src/main/java/org/opentripplanner/updater/trip/TimetableSnapshotSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public UpdateResult applyTripUpdates(
290290
cancelPreviouslyAddedTrip(tripId, serviceDate, cancelationType);
291291
// Remove previous realtime updates for this trip. This is necessary to avoid previous
292292
// stop pattern modifications from persisting
293-
this.buffer.removeRealtimeAddedTripPatternAndTimetablesForTrip(tripId, serviceDate);
293+
this.buffer.revertTripToScheduledTripPattern(tripId, serviceDate);
294294
}
295295

296296
uIndex += 1;

src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotSourceTest.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ private TripPattern assertAddedTrip(
10131013
boolean forceSnapshotCommit
10141014
) {
10151015
var stopA = transitModel.getStopModel().getRegularStop(new FeedScopedId(feedId, "A"));
1016-
// Get trip pattern of last (most recently added) outgoing edge
1016+
// Get the trip pattern of the added trip which goes through stopA
10171017
var snapshot = updater.getTimetableSnapshot(forceSnapshotCommit);
10181018
var patternsAtA = snapshot.getPatternsForStop(stopA);
10191019

@@ -1184,7 +1184,7 @@ public void repeatedlyAddedTripWithNewRoute() {
11841184
assertNotNull(transitModel.getTransitModelIndex().getRouteForId(firstRoute.getId()));
11851185
}
11861186

1187-
static List<Arguments> addedRemovalTestCase() {
1187+
static List<Arguments> cancelingAddedTripTestCases() {
11881188
return List.of(
11891189
// TODO we might want to change the behaviour so that only the trip without pattern is
11901190
// persisted if the added trip is cancelled
@@ -1204,7 +1204,7 @@ static List<Arguments> addedRemovalTestCase() {
12041204
* added by realtime data be present in the trip pattern for scheduled service.
12051205
*/
12061206
@ParameterizedTest
1207-
@MethodSource("addedRemovalTestCase")
1207+
@MethodSource("cancelingAddedTripTestCases")
12081208
public void cancelingAddedTrip(
12091209
ScheduleRelationship scheduleRelationship,
12101210
RealTimeState expectedState
@@ -1234,8 +1234,6 @@ public void cancelingAddedTrip(
12341234
// THEN
12351235
assertAddedTrip(SERVICE_DATE, this.addedTripId, updater, true);
12361236

1237-
builder = new TripUpdateBuilder(addedTripId, SERVICE_DATE, ADDED, transitModel.getTimeZone());
1238-
12391237
var tripDescriptorBuilder = TripDescriptor.newBuilder();
12401238
tripDescriptorBuilder.setTripId(addedTripId);
12411239
tripDescriptorBuilder.setScheduleRelationship(scheduleRelationship);
@@ -1253,9 +1251,9 @@ public void cancelingAddedTrip(
12531251
);
12541252

12551253
// THEN
1256-
// Get trip pattern of last (most recently added) outgoing edge
12571254
var snapshot = updater.getTimetableSnapshot(true);
12581255
var stopA = transitModel.getStopModel().getRegularStop(new FeedScopedId(feedId, "A"));
1256+
// Get the trip pattern of the added trip which goes through stopA
12591257
var patternsAtA = snapshot.getPatternsForStop(stopA);
12601258

12611259
assertNotNull(patternsAtA, "Added trip pattern should be found");
@@ -1269,7 +1267,7 @@ public void cancelingAddedTrip(
12691267
final int forTodayAddedTripIndex = forToday.getTripIndex(addedTripId);
12701268
assertTrue(
12711269
forTodayAddedTripIndex > -1,
1272-
"Added trip should not be found in time table for service date"
1270+
"Added trip should be found in time table for the service date"
12731271
);
12741272
assertEquals(expectedState, forToday.getTripTimes(forTodayAddedTripIndex).getRealTimeState());
12751273

0 commit comments

Comments
 (0)