From efa17914884a1c5e88d852673383ad32eb60716a Mon Sep 17 00:00:00 2001 From: Viljami Nurminen Date: Thu, 9 Mar 2023 14:48:00 +0200 Subject: [PATCH 1/5] Regenerate DataFetchers --- .../legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java index 60ad15a7940..02b9d38da66 100644 --- a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java +++ b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java @@ -50,6 +50,7 @@ import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStation; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; +import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; import org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle; import org.opentripplanner.transit.model.network.Route; import org.opentripplanner.transit.model.network.TripPattern; From abb98273d20e41228014319f50c53a45bd73256b Mon Sep 17 00:00:00 2001 From: Viljami Nurminen Date: Thu, 9 Mar 2023 15:04:04 +0200 Subject: [PATCH 2/5] Optimize imports --- .../generated/LegacyGraphQLDataFetchers.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java index 02b9d38da66..7e30c0b6d23 100644 --- a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java +++ b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/generated/LegacyGraphQLDataFetchers.java @@ -2,13 +2,10 @@ package org.opentripplanner.ext.legacygraphqlapi.generated; import graphql.relay.Connection; -import graphql.relay.Connection; -import graphql.relay.Edge; import graphql.relay.Edge; import graphql.schema.DataFetcher; import graphql.schema.TypeResolver; import java.util.Map; -import java.util.Map; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.opentripplanner.api.resource.DebugOutput; @@ -21,10 +18,6 @@ import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLRelativeDirection; import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLRoutingErrorCode; import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLTransitMode; -import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLRouteTypeModel; -import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLStopOnRouteModel; -import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLStopOnTripModel; -import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLUnknownModel; import org.opentripplanner.model.StopTimesInPattern; import org.opentripplanner.model.SystemNotice; import org.opentripplanner.model.TripTimeOnDate; @@ -40,8 +33,6 @@ import org.opentripplanner.routing.graphfinder.PatternAtStop; import org.opentripplanner.routing.graphfinder.PlaceAtDistance; import org.opentripplanner.routing.vehicle_parking.VehicleParking; -import org.opentripplanner.routing.vehicle_parking.VehicleParking; -import org.opentripplanner.routing.vehicle_parking.VehicleParking; import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces; import org.opentripplanner.routing.vehicle_parking.VehicleParkingState; import org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition; @@ -50,7 +41,6 @@ import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStation; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; -import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; import org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle; import org.opentripplanner.transit.model.network.Route; import org.opentripplanner.transit.model.network.TripPattern; From 5a3c9d43805cb5856e32254f4a0738615d43f738 Mon Sep 17 00:00:00 2001 From: Viljami Nurminen Date: Tue, 14 Mar 2023 10:19:24 +0200 Subject: [PATCH 3/5] Add a circular route to test GTFS --- src/test/resources/testagency/routes.txt | 1 + src/test/resources/testagency/stop_times.txt | 5 +++++ src/test/resources/testagency/stops.txt | 4 ++++ src/test/resources/testagency/trips.txt | 1 + 4 files changed, 11 insertions(+) diff --git a/src/test/resources/testagency/routes.txt b/src/test/resources/testagency/routes.txt index cfbc5348081..ba2bb397941 100755 --- a/src/test/resources/testagency/routes.txt +++ b/src/test/resources/testagency/routes.txt @@ -17,3 +17,4 @@ route_id,route_short_name,route_long_name,route_type,route_bikes_allowed 16,16,16,2, 17,17,17,2, 18,18,18,2, +19,19,19,3, diff --git a/src/test/resources/testagency/stop_times.txt b/src/test/resources/testagency/stop_times.txt index 65be8be1a00..8d4e6e40908 100755 --- a/src/test/resources/testagency/stop_times.txt +++ b/src/test/resources/testagency/stop_times.txt @@ -79,3 +79,8 @@ trip_id,arrival_time,departure_time,stop_id,stop_sequence,shape_dist_traveled,pi 18.1back,16:25:00,16:25:00,E,2,,0,0 18.bogus,23:20:00,23:20:00,D,1,,0,0 18.bogus,00:25:00,00:25:00,E,2,,0,0 +19.1,10:00:00,10:00:00,X,1,,0,0 +19.1,10:10:00,10:10:00,Y,2,,0,0 +19.1,10:20:00,10:20:00,Z,3,,0,0 +19.1,10:30:00,10:30:00,X,4,,0,0 +19.1,10:40:00,10:40:00,Y,5,,0,0 diff --git a/src/test/resources/testagency/stops.txt b/src/test/resources/testagency/stops.txt index 7dc7cd7c6f2..21aceacd0ad 100644 --- a/src/test/resources/testagency/stops.txt +++ b/src/test/resources/testagency/stops.txt @@ -24,3 +24,7 @@ S,S,42.03,-73,0,0, T,T,42.04,-73,0,0, U,U,13,13,0,0, V,V,16,16,0,0, +X,X,17,0,0, +Y,Y,18,0,0, +Z,Z,19,0,0, + diff --git a/src/test/resources/testagency/trips.txt b/src/test/resources/testagency/trips.txt index 9441c8c25e3..d18b02d6896 100755 --- a/src/test/resources/testagency/trips.txt +++ b/src/test/resources/testagency/trips.txt @@ -32,3 +32,4 @@ route_id,service_id,trip_id,shape_id,block_id,wheelchair_accessible,trip_bikes_a 18,alldays,18.1,,,,,N,foo 18,alldays,18.1back,,,1,,S,foo 18,alldays,18.bogus,,,,,,foo +19,alldays,19.1,,,,,, From 326059ed4b92c5d94adefd2e0fef23e3ac1da290 Mon Sep 17 00:00:00 2001 From: Viljami Nurminen Date: Tue, 14 Mar 2023 10:20:09 +0200 Subject: [PATCH 4/5] Add a test for circular routes in alternative legs --- .../stoptimes/AlternativeLegsTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java b/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java index 042fedd26d7..ca78b48a261 100644 --- a/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java +++ b/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java @@ -97,4 +97,35 @@ void testNextLegs() throws Exception { assertEquals(expectd, legs); } + + @Test + void testCircularRoutes() { + var transitService = new DefaultTransitService(transitModel); + + var originalLeg = new ScheduledTransitLegReference( + new FeedScopedId(this.feedId.getId(), "19.1"), + LocalDate.parse("2022-04-02"), + 0, + 1 + ) + .getLeg(transitService); + + final List alternativeLegs = AlternativeLegs.getAlternativeLegs( + originalLeg, + 2, + transitService, + false, + AlternativeLegsFilter.NO_FILTER + ); + var legs = Itinerary.toStr( + alternativeLegs.stream().map(Leg.class::cast).map(List::of).map(Itinerary::new).toList() + ); + + var expected = String.join( + ", ", + List.of("X ~ BUS 19 10:30 10:40 ~ Y [$-1]", "X ~ BUS 19 10:00 10:10 ~ Y [$-1]") + ); + + assertEquals(expected, legs); + } } From a4fa84c285fe710ee0f1cdd747790da678c030ae Mon Sep 17 00:00:00 2001 From: Viljami Nurminen Date: Tue, 14 Mar 2023 12:22:23 +0200 Subject: [PATCH 5/5] Fix unit tests based on testagency GTFS --- .../model/impl/OtpTransitServiceBuilderTest.java | 2 +- .../model/impl/OtpTransitServiceImplTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java index f19cdd63d7a..070b4fe546d 100644 --- a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java +++ b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java @@ -73,7 +73,7 @@ public void testGetAllFrequencies() { public void testGetRoutes() { Collection routes = subject.getRoutes().values(); - assertEquals(18, routes.size()); + assertEquals(19, routes.size()); assertEquals("Route{agency:1 BUS 1}", first(routes).toString()); } diff --git a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java index 5f8bbe0117b..f12b2fa0640 100644 --- a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java +++ b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java @@ -104,7 +104,7 @@ public void testGetAllStations() { public void testGetAllStops() { Collection stops = subject.stopModel().listRegularStops(); - assertEquals(22, stops.size()); + assertEquals(25, stops.size()); assertEquals("RegularStop{F:A A}", first(stops).toString()); } @@ -115,7 +115,7 @@ public void testGetAllStopTimes() { stopTimes.addAll(subject.getStopTimesForTrip(trip)); } - assertEquals(80, stopTimes.size()); + assertEquals(85, stopTimes.size()); assertEquals( "StopTime(seq=1 stop=F:A trip=agency:1.1 times=00:00:00-00:00:00)", first(stopTimes).toString() @@ -126,7 +126,7 @@ public void testGetAllStopTimes() { public void testGetAllTrips() { Collection trips = subject.getAllTrips(); - assertEquals(33, trips.size()); + assertEquals(34, trips.size()); assertEquals("Trip{agency:1.1 1}", first(trips).toString()); }