Skip to content

Commit 8f2c6c5

Browse files
committed
Add module test for cancelled recorded call
1 parent d1bec06 commit 8f2c6c5

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.opentripplanner.updater.trip.siri.moduletests.cancellation;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.opentripplanner.updater.spi.UpdateResultAssertions.assertSuccess;
5+
6+
import org.junit.jupiter.api.Test;
7+
import org.opentripplanner.transit.model._data.TransitTestEnvironment;
8+
import org.opentripplanner.transit.model._data.TransitTestEnvironmentBuilder;
9+
import org.opentripplanner.transit.model._data.TripInput;
10+
import org.opentripplanner.transit.model.site.RegularStop;
11+
import org.opentripplanner.updater.trip.RealtimeTestConstants;
12+
import org.opentripplanner.updater.trip.SiriTestHelper;
13+
14+
/**
15+
* When a RecordedCall has both cancellation=true and an actual departure time, the cancelled
16+
* state should take precedence over the recorded state. This matches the legacy SIRI adapter
17+
* behavior where [C] is shown instead of [R].
18+
*/
19+
class CancelledRecordedCallTest implements RealtimeTestConstants {
20+
21+
private final TransitTestEnvironmentBuilder ENV_BUILDER = TransitTestEnvironment.of();
22+
private final RegularStop STOP_A = ENV_BUILDER.stop(STOP_A_ID);
23+
private final RegularStop STOP_B = ENV_BUILDER.stop(STOP_B_ID);
24+
25+
private final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID)
26+
.withWithTripOnServiceDate(TRIP_1_ID)
27+
.addStop(STOP_A, "0:01:00", "0:01:01")
28+
.addStop(STOP_B, "0:01:10", "0:01:11");
29+
30+
/**
31+
* A RecordedCall with both cancellation=true and an actual departure time should show [C]
32+
* (cancelled), not [R] (recorded). Cancelled takes precedence.
33+
*/
34+
@Test
35+
void cancelledRecordedCallShouldShowCancelled() {
36+
var env = ENV_BUILDER.addTrip(TRIP_INPUT).build();
37+
var siri = SiriTestHelper.of(env);
38+
39+
var updates = siri
40+
.etBuilder()
41+
.withDatedVehicleJourneyRef(TRIP_1_ID)
42+
.withRecordedCalls(builder ->
43+
builder.call(STOP_A).withIsCancellation(true).departAimedActual("00:01:01", "00:01:01")
44+
)
45+
.withEstimatedCalls(builder ->
46+
builder.call(STOP_B).arriveAimedExpected("00:01:10", "00:01:10")
47+
)
48+
.buildEstimatedTimetableDeliveries();
49+
50+
var result = siri.applyEstimatedTimetable(updates);
51+
52+
assertSuccess(result);
53+
assertEquals(
54+
"MODIFIED | A [C] 0:01:01 0:01:01 | B 0:01:10 0:01:10",
55+
env.tripData(TRIP_1_ID).showTimetable()
56+
);
57+
}
58+
}

0 commit comments

Comments
 (0)