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 acfda2b4136..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; 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()); } 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); + } } 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,,,,,,