|
| 1 | +package org.opentripplanner.updater.trip.siri.moduletests.update; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertFalse; |
| 4 | +import static org.junit.Assert.assertTrue; |
| 5 | +import static org.opentripplanner.updater.spi.UpdateResultAssertions.assertSuccess; |
| 6 | + |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | +import org.opentripplanner.transit.model._data.TransitTestEnvironment; |
| 9 | +import org.opentripplanner.transit.model._data.TransitTestEnvironmentBuilder; |
| 10 | +import org.opentripplanner.transit.model._data.TripInput; |
| 11 | +import org.opentripplanner.transit.model.site.RegularStop; |
| 12 | +import org.opentripplanner.updater.trip.RealtimeTestConstants; |
| 13 | +import org.opentripplanner.updater.trip.SiriTestHelper; |
| 14 | +import uk.org.siri.siri21.CallStatusEnumeration; |
| 15 | + |
| 16 | +class ArrivalStatusTest implements RealtimeTestConstants { |
| 17 | + |
| 18 | + private final TransitTestEnvironmentBuilder ENV_BUILDER = TransitTestEnvironment.of(); |
| 19 | + private final RegularStop STOP_A = ENV_BUILDER.stop(STOP_A_ID); |
| 20 | + private final RegularStop STOP_B = ENV_BUILDER.stop(STOP_B_ID); |
| 21 | + private final RegularStop STOP_C = ENV_BUILDER.stop(STOP_C_ID); |
| 22 | + |
| 23 | + private final TripInput TRIP_INPUT = TripInput.of(TRIP_1_ID) |
| 24 | + .withWithTripOnServiceDate(TRIP_1_ID) |
| 25 | + .addStop(STOP_A, "0:10", "0:10") |
| 26 | + .addStop(STOP_B, "0:20", "0:20") |
| 27 | + .addStop(STOP_C, "0:30", "0:30"); |
| 28 | + |
| 29 | + /// Verify handling of ArrivalStatus == ARRIVED |
| 30 | + @Test |
| 31 | + void testUpdateJourneyWithArrivalStatusArrived() { |
| 32 | + var env = ENV_BUILDER.addTrip(TRIP_INPUT).build(); |
| 33 | + var siri = SiriTestHelper.of(env); |
| 34 | + var update = siri |
| 35 | + .etBuilder() |
| 36 | + .withDatedVehicleJourneyRef(TRIP_1_ID) |
| 37 | + .withRecordedCalls(builder -> builder.call(STOP_A).departAimedActual("00:10", "00:10")) |
| 38 | + .withEstimatedCalls(builder -> |
| 39 | + builder |
| 40 | + .call(STOP_B) |
| 41 | + .departAimedExpected("00:20", "00:20") |
| 42 | + .withArrivalStatus(CallStatusEnumeration.ARRIVED) |
| 43 | + .call(STOP_C) |
| 44 | + .arriveAimedExpected("00:30", "00:30") |
| 45 | + ) |
| 46 | + .buildEstimatedTimetableDeliveries(); |
| 47 | + |
| 48 | + var result = siri.applyEstimatedTimetable(update); |
| 49 | + assertSuccess(result); |
| 50 | + |
| 51 | + var tt = env.tripData(TRIP_1_ID).tripTimes(); |
| 52 | + assertTrue(tt.hasArrived(0)); |
| 53 | + assertTrue(tt.hasDeparted(0)); |
| 54 | + assertTrue(tt.hasArrived(1)); |
| 55 | + assertFalse(tt.hasDeparted(1)); |
| 56 | + assertFalse(tt.hasArrived(2)); |
| 57 | + assertFalse(tt.hasDeparted(2)); |
| 58 | + } |
| 59 | +} |
0 commit comments