|
2 | 2 |
|
3 | 3 | import static com.google.transit.realtime.GtfsRealtime.TripDescriptor.ScheduleRelationship.ADDED;
|
4 | 4 | import static com.google.transit.realtime.GtfsRealtime.TripDescriptor.ScheduleRelationship.CANCELED;
|
5 |
| -import static com.google.transit.realtime.GtfsRealtime.TripDescriptor.ScheduleRelationship.DELETED; |
6 | 5 | import static com.google.transit.realtime.GtfsRealtime.TripDescriptor.ScheduleRelationship.SCHEDULED;
|
7 | 6 | import static com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SKIPPED;
|
8 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
9 | 8 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
10 | 9 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
11 | 10 | import static org.junit.jupiter.api.Assertions.assertNotSame;
|
12 |
| -import static org.junit.jupiter.api.Assertions.assertNull; |
13 | 11 | import static org.junit.jupiter.api.Assertions.assertSame;
|
14 | 12 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
15 | 13 | import static org.opentripplanner.updater.trip.BackwardsDelayPropagationType.REQUIRED_NO_DATA;
|
@@ -565,126 +563,6 @@ public void scheduledTripWithSkippedAndNoData() {
|
565 | 563 | assertTrue(newTripTimes.isNoDataStop(2));
|
566 | 564 | }
|
567 | 565 | }
|
568 |
| - |
569 |
| - /** |
570 |
| - * Test realtime system behavior under one very particular case from issue #5725. |
571 |
| - * When applying differential realtime updates, an update may cancel some stops on a trip. A |
572 |
| - * later update may then revert the trip back to its originally scheduled sequence of stops. |
573 |
| - * When this happens, we expect the trip to be associated with a new trip pattern (where some |
574 |
| - * stops have no pickup or dropoff) then dissociated from that new pattern and re-associated |
575 |
| - * with its originally scheduled pattern. Any trip times that were created in timetables under |
576 |
| - * the new stop-skipping trip pattern should also be removed. |
577 |
| - */ |
578 |
| - @Test |
579 |
| - public void scheduledTripWithPreviouslySkipped() { |
580 |
| - // Create update with a skipped stop at first |
581 |
| - String scheduledTripId = "1.1"; |
582 |
| - |
583 |
| - var skippedBuilder = new TripUpdateBuilder( |
584 |
| - scheduledTripId, |
585 |
| - SERVICE_DATE, |
586 |
| - SCHEDULED, |
587 |
| - transitModel.getTimeZone() |
588 |
| - ) |
589 |
| - .addDelayedStopTime(1, 0) |
590 |
| - .addSkippedStop(2) |
591 |
| - .addDelayedStopTime(3, 90); |
592 |
| - |
593 |
| - var tripUpdate = skippedBuilder.build(); |
594 |
| - |
595 |
| - var updater = defaultUpdater(); |
596 |
| - |
597 |
| - // apply the update with a skipped stop |
598 |
| - updater.applyTripUpdates( |
599 |
| - TRIP_MATCHER_NOOP, |
600 |
| - REQUIRED_NO_DATA, |
601 |
| - false, |
602 |
| - List.of(tripUpdate), |
603 |
| - feedId |
604 |
| - ); |
605 |
| - |
606 |
| - // Force a snapshot commit. This is done to mimic normal behaviour where a new update arrives |
607 |
| - // after the original snapshot has been committed |
608 |
| - updater.commitTimetableSnapshot(true); |
609 |
| - |
610 |
| - // Create update to the same trip but now the skipped stop is no longer skipped |
611 |
| - var scheduledBuilder = new TripUpdateBuilder( |
612 |
| - scheduledTripId, |
613 |
| - SERVICE_DATE, |
614 |
| - SCHEDULED, |
615 |
| - transitModel.getTimeZone() |
616 |
| - ) |
617 |
| - .addDelayedStopTime(1, 0) |
618 |
| - .addDelayedStopTime(2, 60, 80) |
619 |
| - .addDelayedStopTime(3, 90, 90); |
620 |
| - |
621 |
| - tripUpdate = scheduledBuilder.build(); |
622 |
| - |
623 |
| - // apply the update with the previously skipped stop now scheduled |
624 |
| - updater.applyTripUpdates( |
625 |
| - TRIP_MATCHER_NOOP, |
626 |
| - REQUIRED_NO_DATA, |
627 |
| - false, |
628 |
| - List.of(tripUpdate), |
629 |
| - feedId |
630 |
| - ); |
631 |
| - |
632 |
| - // Check that the there is no longer a realtime added trip pattern for the trip and that the |
633 |
| - // stoptime updates have gone through |
634 |
| - var snapshot = updater.getTimetableSnapshot(); |
635 |
| - { |
636 |
| - final TripPattern newTripPattern = snapshot.getRealtimeAddedTripPattern( |
637 |
| - new FeedScopedId(feedId, scheduledTripId), |
638 |
| - SERVICE_DATE |
639 |
| - ); |
640 |
| - assertNull(newTripPattern); |
641 |
| - |
642 |
| - final FeedScopedId tripId = new FeedScopedId(feedId, scheduledTripId); |
643 |
| - final Trip trip = transitModel.getTransitModelIndex().getTripForId().get(tripId); |
644 |
| - final TripPattern originalTripPattern = transitModel |
645 |
| - .getTransitModelIndex() |
646 |
| - .getPatternForTrip() |
647 |
| - .get(trip); |
648 |
| - |
649 |
| - final Timetable originalTimetableForToday = snapshot.resolve( |
650 |
| - originalTripPattern, |
651 |
| - SERVICE_DATE |
652 |
| - ); |
653 |
| - final Timetable originalTimetableScheduled = snapshot.resolve(originalTripPattern, null); |
654 |
| - |
655 |
| - assertNotSame(originalTimetableForToday, originalTimetableScheduled); |
656 |
| - |
657 |
| - final int originalTripIndexScheduled = originalTimetableScheduled.getTripIndex(tripId); |
658 |
| - assertTrue( |
659 |
| - originalTripIndexScheduled > -1, |
660 |
| - "Original trip should be found in scheduled time table" |
661 |
| - ); |
662 |
| - final TripTimes originalTripTimesScheduled = originalTimetableScheduled.getTripTimes( |
663 |
| - originalTripIndexScheduled |
664 |
| - ); |
665 |
| - assertFalse( |
666 |
| - originalTripTimesScheduled.isCanceledOrDeleted(), |
667 |
| - "Original trip times should not be canceled in scheduled time table" |
668 |
| - ); |
669 |
| - assertEquals(RealTimeState.SCHEDULED, originalTripTimesScheduled.getRealTimeState()); |
670 |
| - |
671 |
| - final int originalTripIndexForToday = originalTimetableForToday.getTripIndex(tripId); |
672 |
| - assertTrue( |
673 |
| - originalTripIndexForToday > -1, |
674 |
| - "Original trip should be found in time table for service date" |
675 |
| - ); |
676 |
| - final TripTimes originalTripTimesForToday = originalTimetableForToday.getTripTimes( |
677 |
| - originalTripIndexForToday |
678 |
| - ); |
679 |
| - assertEquals(RealTimeState.UPDATED, originalTripTimesForToday.getRealTimeState()); |
680 |
| - assertEquals(0, originalTripTimesForToday.getArrivalDelay(0)); |
681 |
| - assertEquals(0, originalTripTimesForToday.getDepartureDelay(0)); |
682 |
| - assertEquals(60, originalTripTimesForToday.getArrivalDelay(1)); |
683 |
| - assertEquals(80, originalTripTimesForToday.getDepartureDelay(1)); |
684 |
| - assertEquals(90, originalTripTimesForToday.getArrivalDelay(2)); |
685 |
| - assertEquals(90, originalTripTimesForToday.getDepartureDelay(2)); |
686 |
| - } |
687 |
| - } |
688 | 566 | }
|
689 | 567 |
|
690 | 568 | @Nested
|
@@ -900,97 +778,6 @@ public void repeatedlyAddedTripWithNewRoute() {
|
900 | 778 | assertSame(firstRoute, secondRoute);
|
901 | 779 | assertNotNull(transitModel.getTransitModelIndex().getRouteForId(firstRoute.getId()));
|
902 | 780 | }
|
903 |
| - |
904 |
| - static List<Arguments> cancelingAddedTripTestCases() { |
905 |
| - return List.of( |
906 |
| - // TODO we might want to change the behaviour so that only the trip without pattern is |
907 |
| - // persisted if the added trip is cancelled |
908 |
| - Arguments.of(CANCELED, RealTimeState.CANCELED), |
909 |
| - Arguments.of(DELETED, RealTimeState.DELETED) |
910 |
| - ); |
911 |
| - } |
912 |
| - |
913 |
| - /** |
914 |
| - * Test behavior of the realtime system in a case related to #5725 that is discussed at: |
915 |
| - * https://github.com/opentripplanner/OpenTripPlanner/pull/5726#discussion_r1521653840 |
916 |
| - * When a trip is added by a realtime message, in the realtime data indexes a corresponding |
917 |
| - * trip pattern should be associated with the stops that trip visits. When a subsequent |
918 |
| - * realtime message cancels or deletes that trip, the pattern should continue to be present in |
919 |
| - * the realtime data indexes, and it should still contain the previously added trip, but that |
920 |
| - * trip should be marked as having canceled or deleted status. At no point should the trip |
921 |
| - * added by realtime data be present in the trip pattern for scheduled service. |
922 |
| - */ |
923 |
| - @ParameterizedTest |
924 |
| - @MethodSource("cancelingAddedTripTestCases") |
925 |
| - public void cancelingAddedTrip( |
926 |
| - ScheduleRelationship scheduleRelationship, |
927 |
| - RealTimeState expectedState |
928 |
| - ) { |
929 |
| - var builder = new TripUpdateBuilder( |
930 |
| - addedTripId, |
931 |
| - SERVICE_DATE, |
932 |
| - ADDED, |
933 |
| - transitModel.getTimeZone() |
934 |
| - ); |
935 |
| - |
936 |
| - builder.addStopTime("A", 30).addStopTime("C", 40).addStopTime("E", 55); |
937 |
| - |
938 |
| - var tripUpdate = builder.build(); |
939 |
| - |
940 |
| - var updater = defaultUpdater(); |
941 |
| - |
942 |
| - // WHEN |
943 |
| - updater.applyTripUpdates( |
944 |
| - TRIP_MATCHER_NOOP, |
945 |
| - REQUIRED_NO_DATA, |
946 |
| - FULL_DATASET, |
947 |
| - List.of(tripUpdate), |
948 |
| - feedId |
949 |
| - ); |
950 |
| - |
951 |
| - // THEN |
952 |
| - assertAddedTrip(SERVICE_DATE, this.addedTripId, updater, true); |
953 |
| - |
954 |
| - var tripDescriptorBuilder = TripDescriptor.newBuilder(); |
955 |
| - tripDescriptorBuilder.setTripId(addedTripId); |
956 |
| - tripDescriptorBuilder.setScheduleRelationship(scheduleRelationship); |
957 |
| - |
958 |
| - tripDescriptorBuilder.setStartDate(ServiceDateUtils.asCompactString(SERVICE_DATE)); |
959 |
| - tripUpdate = TripUpdate.newBuilder().setTrip(tripDescriptorBuilder).build(); |
960 |
| - |
961 |
| - // WHEN |
962 |
| - updater.applyTripUpdates( |
963 |
| - TRIP_MATCHER_NOOP, |
964 |
| - REQUIRED_NO_DATA, |
965 |
| - FULL_DATASET, |
966 |
| - List.of(tripUpdate), |
967 |
| - feedId |
968 |
| - ); |
969 |
| - |
970 |
| - // THEN |
971 |
| - var snapshot = updater.getTimetableSnapshot(); |
972 |
| - var stopA = transitModel.getStopModel().getRegularStop(new FeedScopedId(feedId, "A")); |
973 |
| - // Get the trip pattern of the added trip which goes through stopA |
974 |
| - var patternsAtA = snapshot.getPatternsForStop(stopA); |
975 |
| - |
976 |
| - assertNotNull(patternsAtA, "Added trip pattern should be found"); |
977 |
| - var tripPattern = patternsAtA.stream().findFirst().get(); |
978 |
| - |
979 |
| - final Timetable forToday = snapshot.resolve(tripPattern, SERVICE_DATE); |
980 |
| - final Timetable schedule = snapshot.resolve(tripPattern, null); |
981 |
| - |
982 |
| - assertNotSame(forToday, schedule); |
983 |
| - |
984 |
| - final int forTodayAddedTripIndex = forToday.getTripIndex(addedTripId); |
985 |
| - assertTrue( |
986 |
| - forTodayAddedTripIndex > -1, |
987 |
| - "Added trip should be found in time table for the service date" |
988 |
| - ); |
989 |
| - assertEquals(expectedState, forToday.getTripTimes(forTodayAddedTripIndex).getRealTimeState()); |
990 |
| - |
991 |
| - final int scheduleTripIndex = schedule.getTripIndex(addedTripId); |
992 |
| - assertEquals(-1, scheduleTripIndex, "Added trip should not be found in scheduled time table"); |
993 |
| - } |
994 | 781 | }
|
995 | 782 |
|
996 | 783 | @Nonnull
|
|
0 commit comments