Skip to content

Commit 863c0cd

Browse files
committed
add test for #6391
1 parent 4c3983b commit 863c0cd

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

application/src/test/java/org/opentripplanner/updater/trip/TripUpdateBuilder.java

+32
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,30 @@ public TripUpdateBuilder addDelayedStopTime(int stopSequence, int delay) {
6565
return addStopTime(null, -1, stopSequence, delay, delay, DEFAULT_SCHEDULE_RELATIONSHIP, null);
6666
}
6767

68+
public TripUpdateBuilder addDelayedArrivalStopTime(int stopSequence, int arrivalDelay) {
69+
return addStopTime(
70+
null,
71+
-1,
72+
stopSequence,
73+
arrivalDelay,
74+
NO_DELAY,
75+
DEFAULT_SCHEDULE_RELATIONSHIP,
76+
null
77+
);
78+
}
79+
80+
public TripUpdateBuilder addDelayedDepartureStopTime(int stopSequence, int departureDelay) {
81+
return addStopTime(
82+
null,
83+
-1,
84+
stopSequence,
85+
NO_DELAY,
86+
departureDelay,
87+
DEFAULT_SCHEDULE_RELATIONSHIP,
88+
null
89+
);
90+
}
91+
6892
public TripUpdateBuilder addDelayedStopTime(
6993
int stopSequence,
7094
int arrivalDelay,
@@ -166,6 +190,14 @@ private TripUpdateBuilder addStopTime(
166190
departureBuilder.setDelay(departureDelay);
167191
}
168192

193+
if (!arrivalBuilder.hasTime() && !arrivalBuilder.hasDelay()) {
194+
stopTimeUpdateBuilder.clearArrival();
195+
}
196+
197+
if (!departureBuilder.hasTime() && !departureBuilder.hasDelay()) {
198+
stopTimeUpdateBuilder.clearDeparture();
199+
}
200+
169201
return this;
170202
}
171203

application/src/test/java/org/opentripplanner/updater/trip/moduletests/delay/DelayedTest.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ void singleStopDelay() {
7474
void complexDelay() {
7575
var tripInput = TripInput
7676
.of(TRIP_2_ID)
77-
.addStop(STOP_A1, "0:01:00", "0:01:01")
78-
.addStop(STOP_B1, "0:01:10", "0:01:11")
79-
.addStop(STOP_C1, "0:01:20", "0:01:21")
77+
.addStop(STOP_A1, "0:00:00", "0:00:00")
78+
.addStop(STOP_B1, "0:05:00", "0:10:00") // 5-minute dwell
79+
.addStop(STOP_C1, "0:15:00", "0:16:00")
80+
.addStop(STOP_D1, "0:20:00", "0:20:00")
8081
.build();
8182
var env = RealtimeTestEnvironment.gtfs().addTrip(tripInput).build();
8283

8384
var tripUpdate = new TripUpdateBuilder(TRIP_2_ID, SERVICE_DATE, SCHEDULED, TIME_ZONE)
8485
.addDelayedStopTime(0, 0)
85-
.addDelayedStopTime(1, 60, 80)
86-
.addDelayedStopTime(2, 90, 90)
86+
.addDelayedArrivalStopTime(1, 900) // 00:20 arr
87+
.addDelayedStopTime(2, 540) // 00:24 arr / 00:25 dep
88+
.addDelayedDepartureStopTime(3, 420) // 00:27 dep
8789
.build();
8890

8991
assertSuccess(env.applyTripUpdate(tripUpdate));
@@ -119,11 +121,11 @@ void complexDelay() {
119121
);
120122

121123
assertEquals(
122-
"SCHEDULED | A1 0:01 0:01:01 | B1 0:01:10 0:01:11 | C1 0:01:20 0:01:21",
124+
"SCHEDULED | A1 0:00 0:00 | B1 0:05 0:10 | C1 0:15 0:16 | D1 0:20 0:20",
123125
env.getScheduledTimetable(TRIP_2_ID)
124126
);
125127
assertEquals(
126-
"UPDATED | A1 0:01 0:01:01 | B1 0:02:10 0:02:31 | C1 0:02:50 0:02:51",
128+
"UPDATED | A1 0:00 0:00 | B1 0:20 0:20 | C1 0:24 0:25 | D1 0:27 0:27",
127129
env.getRealtimeTimetable(TRIP_2_ID)
128130
);
129131
}

0 commit comments

Comments
 (0)