Skip to content

Commit

Permalink
More doc and method name changes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed May 24, 2024
1 parent 4d73ce7 commit e7ae470
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private Result<TripUpdate, UpdateError> handleModifiedTrip(

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

return updateResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,7 @@ public void clear(String feedId) {
* @return true if the trip was found to be shifted to a different trip pattern by a realtime
* message and an attempt was made to re-associate it with its originally scheduled trip pattern.
*/
public boolean removeRealtimeAddedTripPatternAndTimetablesForTrip(
FeedScopedId tripId,
LocalDate serviceDate
) {
public boolean revertTripToScheduledTripPattern(FeedScopedId tripId, LocalDate serviceDate) {
boolean success = false;

final TripPattern pattern = getRealtimeAddedTripPattern(tripId, serviceDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public UpdateResult applyTripUpdates(
cancelPreviouslyAddedTrip(tripId, serviceDate, cancelationType);
// Remove previous realtime updates for this trip. This is necessary to avoid previous
// stop pattern modifications from persisting
this.buffer.removeRealtimeAddedTripPatternAndTimetablesForTrip(tripId, serviceDate);
this.buffer.revertTripToScheduledTripPattern(tripId, serviceDate);
}

uIndex += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ private TripPattern assertAddedTrip(
boolean forceSnapshotCommit
) {
var stopA = transitModel.getStopModel().getRegularStop(new FeedScopedId(feedId, "A"));
// Get trip pattern of last (most recently added) outgoing edge
// Get the trip pattern of the added trip which goes through stopA
var snapshot = updater.getTimetableSnapshot(forceSnapshotCommit);
var patternsAtA = snapshot.getPatternsForStop(stopA);

Expand Down Expand Up @@ -1184,7 +1184,7 @@ public void repeatedlyAddedTripWithNewRoute() {
assertNotNull(transitModel.getTransitModelIndex().getRouteForId(firstRoute.getId()));
}

static List<Arguments> addedRemovalTestCase() {
static List<Arguments> cancelingAddedTripTestCases() {
return List.of(
// TODO we might want to change the behaviour so that only the trip without pattern is
// persisted if the added trip is cancelled
Expand All @@ -1204,7 +1204,7 @@ static List<Arguments> addedRemovalTestCase() {
* added by realtime data be present in the trip pattern for scheduled service.
*/
@ParameterizedTest
@MethodSource("addedRemovalTestCase")
@MethodSource("cancelingAddedTripTestCases")
public void cancelingAddedTrip(
ScheduleRelationship scheduleRelationship,
RealTimeState expectedState
Expand Down Expand Up @@ -1234,8 +1234,6 @@ public void cancelingAddedTrip(
// THEN
assertAddedTrip(SERVICE_DATE, this.addedTripId, updater, true);

builder = new TripUpdateBuilder(addedTripId, SERVICE_DATE, ADDED, transitModel.getTimeZone());

var tripDescriptorBuilder = TripDescriptor.newBuilder();
tripDescriptorBuilder.setTripId(addedTripId);
tripDescriptorBuilder.setScheduleRelationship(scheduleRelationship);
Expand All @@ -1253,9 +1251,9 @@ public void cancelingAddedTrip(
);

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

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

Expand Down

0 comments on commit e7ae470

Please sign in to comment.