diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index 5cae15849ef..9c2e42fb118 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -177,7 +177,7 @@ jobs: # schema hasn't changed. # example commit: https://github.com/opentripplanner/docs/commit/45e6ddf8e4a4 - SCHEMA_FILE_MODIFIED=`git log -n 1 --pretty=format:%ct src/ext/resources/gtfsgraphqlapi/schema.graphqls` + SCHEMA_FILE_MODIFIED=`git log -n 1 --pretty=format:%ct src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls` echo "schema modified at ${SCHEMA_FILE_MODIFIED}" git checkout $LOCAL_BRANCH DOCS_MODIFIED=`git log -n 1 --pretty=format:%ct api/dev-2.x/graphql-gtfs/introduction.html` @@ -204,7 +204,7 @@ jobs: with: node-version: 16 - name: Run code generator - working-directory: src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated + working-directory: src/main/java/org/opentripplanner/apis/gtfs/generated run: | yarn install yarn generate diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index 72ec3f24f38..7c95ba05555 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -29,7 +29,7 @@ jobs: sleep: 15 - name: portland # have to sleep longer since computing geofencing zones takes a while - sleep: 80 + sleep: 125 steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 20bb5c45fb1..582511ce7f2 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ GTFS and OpenStreetMap). It applies real-time updates and alerts with immediate clients, finding itineraries that account for disruptions and service changes. Note that this branch contains **OpenTripPlanner 2**, the second major version of OTP, which has -been under development since Q2 2018. The latest version of OTP is v2.2.0, released in November 2022. +been under development since 2018. The latest version of OTP is v2.4.0, released in September 2023. -If you do not want to test or explore this version, please switch to the final 1.x release -tag `v1.5.0` or the `dev-1.x` branch for any patches and bugfixes applied to the v1.5.0 release. +If you do not want to use this version, please switch to the final 1.x release +tag `v1.5.0` or the `dev-1.x` branch. ## Performance Test diff --git a/doc-templates/GraphQL-Tutorial.md b/doc-templates/GraphQL-Tutorial.md index fd3d901b576..51f0ef7880a 100644 --- a/doc-templates/GraphQL-Tutorial.md +++ b/doc-templates/GraphQL-Tutorial.md @@ -8,10 +8,10 @@ # GraphQL tutorial This document will give you a quick start tutorial on how to get started with OTP's GraphQL APIs. For -this tutorial we will be using the [GTFS GraphQL API](sandbox/GtfsGraphQlApi.md) as this is the most commonly used one. +this tutorial we will be using the [GTFS GraphQL API](GTFS-GraphQL-API.md) as this is the most commonly used one. First of all, make sure that you've loaded street and transit data into your instance by following -the [basic tutorial](Basic-Tutorial.md) +the [basic tutorial](../Basic-Tutorial.md) ## Visual GraphQL API client @@ -20,7 +20,7 @@ started OTP, visit [http://localhost:8080/graphiql](http://localhost:8080/graphi It should look like this: -![GraphiQL](images/graphiql.png) +![GraphiQL](../images/graphiql.png) ## Sending your first query @@ -35,12 +35,12 @@ side panel. Now would be a good time to explore the auto-complete capabilities of the tool by moving the cursor into the query panel and hitting Ctrl-Space to see what other query parameters are possible. -![GraphiQL](images/graphiql-autocomplete.png) +![GraphiQL](../images/graphiql-autocomplete.png) The explorer also has documentation built into it. If you hover your pointer over a property on the left hand side you can see its documentation. -![GraphiQL](images/graphiql-documentation.png) +![GraphiQL](../images/graphiql-documentation.png) ## A more advanced query @@ -51,4 +51,4 @@ Most people want to get routing results out of OTP, so lets see the query for th Again, please use the autocomplete and documentation viewers to figure out what each input parameter and property means. -More examples for a variety of queries can also be found [in the test code](https://github.com/opentripplanner/OpenTripPlanner/tree/dev-2.x/src/ext-test/resources/gtfsgraphqlapi/queries). \ No newline at end of file +More examples for a variety of queries can also be found [in the test code](https://github.com/opentripplanner/OpenTripPlanner/tree/dev-2.x/src/test/resources/org/opentripplanner/apis/gtfs/queries). \ No newline at end of file diff --git a/docs/Basic-Tutorial.md b/docs/Basic-Tutorial.md index 788c85aaad0..6373355d15f 100644 --- a/docs/Basic-Tutorial.md +++ b/docs/Basic-Tutorial.md @@ -201,4 +201,4 @@ You can run the OTP .jar file with the `--help` option for a full list of comman ## Exploring the API -If you want to learn how to use OTP's API's, check out the [GraphQL tutorial](GraphQL-Tutorial.md). \ No newline at end of file +If you want to learn how to use OTP's API's, check out the [GraphQL tutorial](apis/GraphQL-Tutorial.md). \ No newline at end of file diff --git a/docs/Changelog.md b/docs/Changelog.md index 5240802ac9e..56d47aae729 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -11,6 +11,9 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle - Fix rental scooter access [#5361](https://github.com/opentripplanner/OpenTripPlanner/pull/5361) - De-duplicate stops returned by `stopsByRadius` [#5366](https://github.com/opentripplanner/OpenTripPlanner/pull/5366) - Fix value mapping for bikesAllowed in GTFS GraphQL API [#5368](https://github.com/opentripplanner/OpenTripPlanner/pull/5368) +- Apply correct traversal permissions to barrier vertex [#5369](https://github.com/opentripplanner/OpenTripPlanner/pull/5369) +- Move GTFS GraphQL API out of the sandbox [#5339](https://github.com/opentripplanner/OpenTripPlanner/pull/5339) +- Transmodel GraphQL API for pass-through searches [#5320](https://github.com/opentripplanner/OpenTripPlanner/pull/5320) [](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE) ## 2.4.0 (2023-09-13) diff --git a/docs/Configuration.md b/docs/Configuration.md index 5a33c70fd43..5073dafed31 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -228,7 +228,7 @@ Here is a list of all features which can be toggled on/off and their default val | `ConsiderPatternsForDirectTransfers` | Enable limiting transfers so that there is only a single transfer to each pattern. | ✓️ | | | `DebugClient` | Enable the debug web client located at the root of the web server. | ✓️ | | | `FloatingBike` | Enable floating bike routing. | ✓️ | | -| `GtfsGraphQlApi` | Enable GTFS GraphQL API. | ✓️ | ✓️ | +| `GtfsGraphQlApi` | Enable GTFS GraphQL API. | ✓️ | | | `MinimumTransferTimeIsDefinitive` | If the minimum transfer time is a lower bound (default) or the definitive time for the transfer. Set this to `true` if you want to set a transfer time lower than what OTP derives from OSM data. | | | | `OptimizeTransfers` | OTP will inspect all itineraries found and optimize where (which stops) the transfer will happen. Waiting time, priority and guaranteed transfers are taken into account. | ✓️ | | | `ParallelRouting` | Enable performing parts of the trip planning in parallel. | | | diff --git a/docs/ReleaseChecklist.md b/docs/ReleaseChecklist.md index 6a46c0074cb..7702a60e51c 100644 --- a/docs/ReleaseChecklist.md +++ b/docs/ReleaseChecklist.md @@ -87,6 +87,20 @@ manually is more tedious, but keeps eyes on each step and is less prone to failu * Mention the new version number. * Provide links to the new developer documentation. * Provide links to the artifacts directory on Maven Central. +* Prepare for the next release in GitHub by renaming the released milestone and creating a new + milestone for the next release. Then make sure all issues and PRs are tagged with the correct + milestone. + * Close open PRs older than 2 years, make sure the milestone is set to `Rejected`. + * Rename the old milestone from `x.y (Next Release)` to `x.y`. All issues and PRs assigned to + this milestone are automatically updated. + * Create a new milestone: `x.y+1 (Next Release)` + * All PullRequests SHOULD have a milestone (except some very old ones) + * Assign all *open* PRs to this new milestone `x.y+1 (Next Release)`. + * Assign all *closed* PRs without a milestone in the release to the released milestone + `x.y`. Make sure NOT to include very old PRs or PRs merged after the release(if any). + * Some issues have a milestone, but not all. + * Move all open issues with the released milestone `x.y` to the next release + `x.y+1 (Next Release)`. ## Artifact Signing diff --git a/docs/RoutingModes.md b/docs/RoutingModes.md index 88148d370e5..6267b4b0321 100644 --- a/docs/RoutingModes.md +++ b/docs/RoutingModes.md @@ -106,7 +106,7 @@ Used for street-level cable cars where the cable runs beneath the car. Private car trips shared with others. -This is currently not specified in GTFS so we use the mode type values 1500-1560 which are in the range of private taxis. +This is currently not specified in GTFS so we use the mode type values 1550-1560 which are in the range of private taxis.

COACH

diff --git a/docs/SandboxExtension.md b/docs/SandboxExtension.md index 7914c8abeb0..55ee214979a 100644 --- a/docs/SandboxExtension.md +++ b/docs/SandboxExtension.md @@ -14,7 +14,6 @@ provided "as is". - [Geocoder API](sandbox/GeocoderAPI.md) - Adds an API to search for corners, stops and stations. - [Transfer analyser](sandbox/transferanalyzer.md) - Module used for analyzing the transfers between nearby stops generated by routing via OSM data. -- [GTFS GraphQL API](sandbox/GtfsGraphQlApi.md) - HSL's GraphQL API used by the Digitransit project. - [Transmodel API](sandbox/TransmodelApi.md) - Enturs GraphQL Transmodel API. - [SIRI Updater](sandbox/SiriUpdater.md) - Update OTP with realtime information from a Transmodel SIRI data source. - [SIRI Azure Updater](sandbox/SiriAzureUpdater.md) - fetch SIRI realtime data through *Azure Service Bus* diff --git a/docs/Version-Comparison.md b/docs/Version-Comparison.md index 86d8d1e3e01..ce04016417b 100644 --- a/docs/Version-Comparison.md +++ b/docs/Version-Comparison.md @@ -52,7 +52,8 @@ the EU profile, and generalization to the EU profile should be feasible once it | SIRI Realtime | no | yes | | Elevation data | TIFF and NED | TIFF and NED | | One-to-many routing,
isochrones and scripting | yes | no | -| Java version | 8+ | 11+ | +| Isochrones | yes | yes | +| Java version | 8+ | 17+ | | Multiple regions per server | yes | no | | Hot reloading of graphs | yes | no | | Street (OSM) routing algorithm | Generalized cost A* | Generalized cost A* | @@ -125,7 +126,7 @@ OTP2 to simplify the code base and make it easier to reason about security. Less parameters are available on the OTP2 REST API than in OTP1. Often there is no practical loss of functionality, just a different way of expressing things due to the new routing algorithms. A summary of parameters that have been removed and their replacements can be found in the [migration -guide](Version-Comparison.md#Migration guide) +guide](Version-Comparison.md#migration-guide) ## OTP Trip planning and Transit index APIs @@ -136,7 +137,7 @@ GraphQL API, the only supported way of sending requests to the OTP routing engin Details of those two APIs are available at the following pages: -- [GTFS GraphQL API](sandbox/GtfsGraphQlApi.md) - HSL's GraphQL API used by the Digitransit +- [GTFS GraphQL API](apis/GTFS-GraphQL-API.md) - HSL's GraphQL API used by the Digitransit project. - [Transmodel API](sandbox/TransmodelApi.md) - Entur´s Transmodel API diff --git a/docs/Apis.md b/docs/apis/Apis.md similarity index 67% rename from docs/Apis.md rename to docs/apis/Apis.md index 1bb89c1cc2a..4d6c7f46694 100644 --- a/docs/Apis.md +++ b/docs/apis/Apis.md @@ -2,23 +2,23 @@ Several services are built upon OTP's routing and transit data indexing engines. They expose these APIs: -The [GTFS GraphQL API](sandbox/GtfsGraphQlApi.md) has been used by the Digitransit and otp-react-redux +The [GTFS GraphQL API](GTFS-GraphQL-API.md) has been used by the Digitransit and otp-react-redux projects as a general purpose routing and transit data API in production for many years. If your input data is mostly GTFS then this is probably the best choice as it uses the same vocabulary. -The [Transmodel GraphQL API](sandbox/TransmodelApi.md) is used at +The [Transmodel GraphQL API](../sandbox/TransmodelApi.md) is used at Entur in production since 2020. Like the GTFS GraphQL API it is also a general purpose API. If your input data is mostly NeTeX then you might want to investigate this API as it uses the [Transmodel vocabulary](https://en.wikipedia.org/wiki/Transmodel) to describe its entities. -The [Vector tiles API](sandbox/MapboxVectorTilesApi.md) is a special purpose API for displaying +The [Vector tiles API](../sandbox/MapboxVectorTilesApi.md) is a special purpose API for displaying entities on a vector map. -The [Actuator API](sandbox/ActuatorAPI.md) provides endpoints for checking the health status of the +The [Actuator API](../sandbox/ActuatorAPI.md) provides endpoints for checking the health status of the OTP instance and reading live application metrics. -The [Geocoder API](sandbox/GeocoderAPI.md) allows you to geocode street corners and stop names. +The [Geocoder API](../sandbox/GeocoderAPI.md) allows you to geocode street corners and stop names. ## Legacy APIs (to be removed) diff --git a/docs/apis/GTFS-GraphQL-API.md b/docs/apis/GTFS-GraphQL-API.md new file mode 100644 index 00000000000..a9937afc6b2 --- /dev/null +++ b/docs/apis/GTFS-GraphQL-API.md @@ -0,0 +1,43 @@ +# GTFS GraphQL API + +The GTFS GraphQL API is a general purpose API which was created for the Digitransit project and is +used heavily by [digitransit-ui](https://github.com/HSLdevcom/digitransit-ui). + +[otp-react-redux](https://github.com/opentripplanner/otp-react-redux) has also migrated to this API in 2023. + +## URLs + - GraphQL endpoint: [`http://localhost:8080/otp/routers/default/index/graphql`](http://localhost:8080/otp/routers/default/index/graphql) + - HTML schema documentation: [https://docs.opentripplanner.org/api/dev-2.x/graphql-gtfs/](https://docs.opentripplanner.org/api/dev-2.x/graphql-gtfs/) + - Built-in visual GraphQL client: [http://localhost:8080/graphiql](http://localhost:8080/graphiql) + +## Built-in API client + +A browser based GraphQL API client is available at [http://localhost:8080/graphiql](http://localhost:8080/graphiql) + +![GraphiQL](../images/graphiql.png) + +**`curl` example** + +A complete example that fetches the list of all stops from OTP is: + +``` +curl --request POST \ + --url http://localhost:8080/otp/routers/default/index/graphql \ + --header 'Content-Type: application/json' \ + --header 'OTPTimeout: 180000' \ + --data '{"query":"query stops {\n stops {\n gtfsId\n name\n }\n}\n","operationName":"stops"}' +``` +## Configuration + +The API is enabled by default. + +If you want to disable it, do it in `otp-config.json`: + +```json +// otp-config.json +{ + "otpFeatures" : { + "GtfsGraphQlApi": false + } +} +``` \ No newline at end of file diff --git a/docs/GraphQL-Tutorial.md b/docs/apis/GraphQL-Tutorial.md similarity index 86% rename from docs/GraphQL-Tutorial.md rename to docs/apis/GraphQL-Tutorial.md index e70294fcebd..8df6d6f38ee 100644 --- a/docs/GraphQL-Tutorial.md +++ b/docs/apis/GraphQL-Tutorial.md @@ -8,10 +8,10 @@ # GraphQL tutorial This document will give you a quick start tutorial on how to get started with OTP's GraphQL APIs. For -this tutorial we will be using the [GTFS GraphQL API](sandbox/GtfsGraphQlApi.md) as this is the most commonly used one. +this tutorial we will be using the [GTFS GraphQL API](GTFS-GraphQL-API.md) as this is the most commonly used one. First of all, make sure that you've loaded street and transit data into your instance by following -the [basic tutorial](Basic-Tutorial.md) +the [basic tutorial](../Basic-Tutorial.md) ## Visual GraphQL API client @@ -20,7 +20,7 @@ started OTP, visit [http://localhost:8080/graphiql](http://localhost:8080/graphi It should look like this: -![GraphiQL](images/graphiql.png) +![GraphiQL](../images/graphiql.png) ## Sending your first query @@ -54,12 +54,12 @@ side panel. Now would be a good time to explore the auto-complete capabilities of the tool by moving the cursor into the query panel and hitting Ctrl-Space to see what other query parameters are possible. -![GraphiQL](images/graphiql-autocomplete.png) +![GraphiQL](../images/graphiql-autocomplete.png) The explorer also has documentation built into it. If you hover your pointer over a property on the left hand side you can see its documentation. -![GraphiQL](images/graphiql-documentation.png) +![GraphiQL](../images/graphiql-documentation.png) ## A more advanced query @@ -71,9 +71,9 @@ Most people want to get routing results out of OTP, so lets see the query for th ```graphql { plan( - # these coordinate are in Portland, change this to YOUR origin + # these coordinates are in Portland, change this to YOUR origin from: { lat: 45.5552, lon: -122.6534 } - # these coordinate are in Portland, change this to YOUR destination + # these coordinates are in Portland, change this to YOUR destination to: { lat: 45.4908, lon: -122.5519 } # use the correct date and time of your request date: "2023-02-15", @@ -127,4 +127,4 @@ Most people want to get routing results out of OTP, so lets see the query for th Again, please use the autocomplete and documentation viewers to figure out what each input parameter and property means. -More examples for a variety of queries can also be found [in the test code](https://github.com/opentripplanner/OpenTripPlanner/tree/dev-2.x/src/ext-test/resources/gtfsgraphqlapi/queries). \ No newline at end of file +More examples for a variety of queries can also be found [in the test code](https://github.com/opentripplanner/OpenTripPlanner/tree/dev-2.x/src/test/resources/org/opentripplanner/apis/gtfs/queries). \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt index 5cd0396ae85..1474504e154 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -mkdocs==1.5.2 -mkdocs-material==9.1.17 +mkdocs==1.5.3 +mkdocs-material==9.4.2 mike@git+https://github.com/jimporter/mike.git@f0522f245e64687dd18384fbd86b721175711474 mkdocs-no-sitemap-plugin==0.0.1 diff --git a/docs/sandbox/GtfsGraphQlApi.md b/docs/sandbox/GtfsGraphQlApi.md deleted file mode 100644 index 8175e65a0d5..00000000000 --- a/docs/sandbox/GtfsGraphQlApi.md +++ /dev/null @@ -1,85 +0,0 @@ -# GTFS GraphQL API - -The GTFS GraphQL API was created for the Digitransit project and is used heavily by -[digitransit-ui](https://github.com/HSLdevcom/digitransit-ui). - -As of 2023 [otp-rr](https://github.com/opentripplanner/otp-react-redux) is in the process of -migrating to this API. - -## Contact Info - -- Digitransit team, HSL, Helsinki, Finland -- Kyyti, Helsinki, Finland -- IBI, USA - -## URLs - - GraphQL endpoint: `http://localhost:8080/otp/routers/default/index/graphql` - - HTML schema documentation: [https://docs.opentripplanner.org/api/dev-2.x/graphql-gtfs/](https://docs.opentripplanner.org/api/dev-2.x/graphql-gtfs/) - - Built-in visual GraphQL client: [http://localhost:8080/graphiql](http://localhost:8080/graphiql) - -## Built-in API client - -A browser based GraphQL API client is available at [http://localhost:8080/graphiql](http://localhost:8080/graphiql) - -![GraphiQL](../images/graphiql.png) - -**`curl` example** - -A complete example that fetches the list of all stops from OTP is: - -``` -curl --request POST \ - --url http://localhost:8080/otp/routers/default/index/graphql \ - --header 'Content-Type: application/json' \ - --header 'OTPTimeout: 180000' \ - --data '{"query":"query stops {\n stops {\n gtfsId\n name\n }\n}\n","operationName":"stops"}' -``` -## Configuration - -The API is enabled by default. - -If you want to disable it, do it in `otp-config.json`: - -```json -// otp-config.json -{ - "otpFeatures" : { - "GtfsGraphQlApi": false - } -} -``` - -## OTP2 Official GraphQL API (Not available) - -We **plan** to make a new offical OTP2 API, replacing the REST API. The plan is to base the new API -on this API and the [Transmodel GraphQL API](TransmodelApi.md). The new API will most likely have two -"translations": A GTFS version and a Transmodel version, we will try to keep the semantics the same. - -## Changelog - -- Initial version of GTFS Graph QL API (September 2020) -- Added ids parameter to bikeRentalStations query (May 2021, [#3450](https://github.com/opentripplanner/OpenTripPlanner/pull/3450)) -- Added capacity and allowOverloading fields to bike rental stations (not yet properly implemented) (May 2021, [#3450](https://github.com/opentripplanner/OpenTripPlanner/pull/3450)) -- Updated documentation and process for generating Java code from GraphQL schema definition (May 2021, [#3450](https://github.com/opentripplanner/OpenTripPlanner/pull/3450)) -- Implemented modeWeight and added debugItineraryFilter to plan query. Added systemNotices to itineraries (May 2021, [#3503](https://github.com/opentripplanner/OpenTripPlanner/pull/3503)) -- Updated to ignore modes which are not valid in OTP2 (June 2021, [#3464](https://github.com/opentripplanner/OpenTripPlanner/pull/3464)) -- Add Leg#walkingBike (June 2021, [#3550](https://github.com/opentripplanner/OpenTripPlanner/pull/3550)) -- Add GBFS bike rental URIs to bike rental stations (June 2021, [#3543](https://github.com/opentripplanner/OpenTripPlanner/pull/3543)) -- Properly implement all bike rental station fields and add allowPickup, allowPickupNow, allowDropoffNow and operative fields (October 2021, [#3632](https://github.com/opentripplanner/OpenTripPlanner/pull/3632)) -- Create RentalVehicle, VehicleRentalStation and VehicleRentalUris types. Deprecate BikeRentalStation and BikeRentalStationUris types (October 2021, [#3632](https://github.com/opentripplanner/OpenTripPlanner/pull/3632)) -- Create VehicleParking type. Deprecate BikePark and CarPark types (November 2021, [#3480](https://github.com/opentripplanner/OpenTripPlanner/pull/3480)) -- Update and implement Alert type and alerts query. Add ACCESSIBILITY_ISSUE to AlertEffectType enum (November 2021, [#3747](https://github.com/opentripplanner/OpenTripPlanner/pull/3747)) -- Add geometries for stops (December 2021, [#3757](https://github.com/opentripplanner/OpenTripPlanner/pull/3757)) -- Add RouteType and Unknown entities and implement alerts fields (add add alerts field to Feed) (December 2021, [#3780](https://github.com/opentripplanner/OpenTripPlanner/pull/3780)) -- Take free-floating vehicles into account when computing state (February 2022, [#3857](https://github.com/opentripplanner/OpenTripPlanner/pull/3857)) -- Fix issue with GraphQL code generator (February 2022, [#3881](https://github.com/opentripplanner/OpenTripPlanner/pull/3881)) -- Add GBFS form factors for `rentalVehicle` (April 2022, [#4062](https://github.com/opentripplanner/OpenTripPlanner/pull/4062)) -- Implement allowedBikeRentalNetworks while deprecating it and add allowedVehicleRentalNetworks and bannedVehicleRentalNetworks. (July 2022, [#4279](https://github.com/opentripplanner/OpenTripPlanner/pull/4279)) -- Filters place types in GTFS GraphQL API so that a bike park type is not returned if a vehicle parking has no bicycle spaces and car park type is not returned if a parking has no car spaces. (July 2022, [#4296](https://github.com/opentripplanner/OpenTripPlanner/pull/4296)) -- Include departures with skipped stops in the Stop type's stopTimesForPattern query. (July 2022, [#4299](https://github.com/opentripplanner/OpenTripPlanner/pull/4299)) -- Add built-in GraphQL client. (October 2022, [#4499](https://github.com/opentripplanner/OpenTripPlanner/pull/4499)) -- Implement support for omitCanceled parameter in some stop's stoptime queries (October 2022, [#4504]([#4504](https://github.com/opentripplanner/OpenTripPlanner/pull/4504))) -- Rename unpreferredRouteCost to unpreferredCost (October 2022, [#4543](https://github.com/opentripplanner/OpenTripPlanner/pull/4543)) -- Make plan fetcher async (December 2022, [#4676](https://github.com/opentripplanner/OpenTripPlanner/pull/4676)) -- Fix alerts query severity, effect and cause filters (February 2023, [#4909](https://github.com/opentripplanner/OpenTripPlanner/pull/4909)) -- Use accept-language header instead of the default route request locale in the plan query (March 2023, [#4971](https://github.com/opentripplanner/OpenTripPlanner/pull/4971)) diff --git a/docs/sandbox/TransmodelApi.md b/docs/sandbox/TransmodelApi.md index bfde88c886c..5069966bdbd 100644 --- a/docs/sandbox/TransmodelApi.md +++ b/docs/sandbox/TransmodelApi.md @@ -73,7 +73,7 @@ at: `http://localhost:8080/otp/routers/default/transmodel/index/graphql` ### OTP2 Official GraphQL API (Not available) We **plan** to make a new offical OTP2 API, replacing the REST API. The plan is to base the new API -on this API and the [GTFS GraphQL API](GtfsGraphQlApi.md). The new API will most likely have two +on this API and the [GTFS GraphQL API](../apis/GTFS-GraphQL-API.md). The new API will most likely have two "translations": A GTFS version and a Transmodel version, we will try to keep the semantics the same. ### Configuration diff --git a/magidoc.mjs b/magidoc.mjs index 814ca3e8435..44997e3fc9d 100644 --- a/magidoc.mjs +++ b/magidoc.mjs @@ -1,7 +1,7 @@ export default { introspection: { type: 'sdl', - paths: ['src/ext/resources/gtfsgraphqlapi/schema.graphqls'], + paths: ['src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls'], }, website: { template: 'carbon-multi-page', @@ -24,12 +24,12 @@ at http://localhost:8080/graphiql ![GraphiQL screenshot](https://docs.opentripplanner.org/en/dev-2.x/images/graphiql.png) -## Activation +## Configuration -This API used to be off by default but since June '23 that has changed. +This API is activated by default. To learn how to deactivate it, read the -[documentation](https://docs.opentripplanner.org/en/dev-2.x/sandbox/GtfsGraphQlApi/). +[documentation](https://docs.opentripplanner.org/en/dev-2.x/apis/GTFS-GraphQ-API/). `, }], appTitle: 'OTP GTFS GraphQL API', diff --git a/mkdocs.yml b/mkdocs.yml index 27d0a6b2b1e..65e9c236be1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -64,8 +64,9 @@ nav: - Troubleshooting: 'Troubleshooting-Routing.md' - Comparing OTP2 to OTP1: 'Version-Comparison.md' - APIs: - - Introduction: 'Apis.md' - - GraphQL Tutorial: 'GraphQL-Tutorial.md' + - Introduction: 'apis/Apis.md' + - GraphQL Tutorial: 'apis/GraphQL-Tutorial.md' + - GTFS GraphQL API: 'apis/GTFS-GraphQL-API.md' - Configuration: - Introduction: 'Configuration.md' - Build: 'BuildConfiguration.md' @@ -92,7 +93,6 @@ nav: - Actuator API: 'sandbox/ActuatorAPI.md' - Direct Transfer Analyzer: 'sandbox/transferanalyzer.md' - Google Cloud Storage: 'sandbox/GoogleCloudStorage.md' - - GTFS GraphQL API: 'sandbox/GtfsGraphQlApi.md' - Transmodel(NeTEx) GraphQL API: 'sandbox/TransmodelApi.md' - SIRI Updaters: 'sandbox/SiriUpdater.md' - SIRI Updater (Azure): 'sandbox/SiriAzureUpdater.md' diff --git a/pom.xml b/pom.xml index afe0af5a35d..71a62274d1c 100644 --- a/pom.xml +++ b/pom.xml @@ -59,14 +59,14 @@ 120 29.2 - 2.48 + 2.48.1 2.15.2 3.1.3 5.10.0 1.11.4 5.5.3 1.4.11 - 9.7.0 + 9.8.0 2.0.9 2.0.14 1.22 @@ -452,7 +452,7 @@ com.google.cloud.tools jib-maven-plugin - 3.3.2 + 3.4.0 org.opentripplanner.standalone.OTPMain @@ -746,7 +746,7 @@ org.mockito mockito-core - 5.5.0 + 5.6.0 test @@ -987,7 +987,7 @@ org.opentripplanner otp-client - 0.0.10 + 0.0.16 test diff --git a/renovate.json5 b/renovate.json5 index fe941f8f550..934001eae04 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -87,7 +87,9 @@ "org.apache.maven.plugins:maven-gpg-plugin", "org.apache.maven.plugins:maven-source-plugin", "io.github.git-commit-id:git-commit-id-maven-plugin", - "com.hubspot.maven.plugins:prettier-maven-plugin" + "com.hubspot.maven.plugins:prettier-maven-plugin", + "com.google.cloud.tools:jib-maven-plugin", + "org.apache.maven.plugins:maven-shade-plugin" ], "matchPackagePrefixes": [ "org.junit.jupiter:", diff --git a/smoke-tests/denver/router-config.json b/smoke-tests/denver/router-config.json index ed80cb617b2..e68a9cc7629 100644 --- a/smoke-tests/denver/router-config.json +++ b/smoke-tests/denver/router-config.json @@ -3,8 +3,7 @@ { "type": "vehicle-positions", "url": "https://www.rtd-denver.com/files/gtfs-rt/VehiclePosition.pb", - "feedId": "denver", - "frequencySec": 60 + "feedId": "denver" } ] } \ No newline at end of file diff --git a/smoke-tests/portland/otp-config.json b/smoke-tests/portland/otp-config.json index 084070b312c..7b0d1828144 100644 --- a/smoke-tests/portland/otp-config.json +++ b/smoke-tests/portland/otp-config.json @@ -1,5 +1,4 @@ { "otpFeatures" : { - "SandboxAPILegacyGraphQLApi": true } } \ No newline at end of file diff --git a/smoke-tests/portland/router-config.json b/smoke-tests/portland/router-config.json index 13387faff95..a6c1b64b90c 100644 --- a/smoke-tests/portland/router-config.json +++ b/smoke-tests/portland/router-config.json @@ -3,23 +3,29 @@ "updaters": [ { "type": "real-time-alerts", - "frequencySec": 60, "earlyStartSec": 864000, "url": "https://trimet.org/transweb/ws/V1/FeedSpecAlerts/includeFuture/true/suppressSystemWideAlerts/true/", "feedId": "TriMet" }, { "type": "stop-time-updater", - "frequencySec": 30, + "frequency": "30s", "url": "https://trimet.org/transweb/ws/V1/TripUpdate", "feedId": "TriMet" }, { "type": "vehicle-rental", - "frequencySec": 90, + "frequency": "90s", "sourceType": "gbfs", "url": "https://mds.bird.co/gbfs/v2/public/portland/gbfs.json", "geofencingZones": "true" + }, + { + "type": "vehicle-rental", + "frequency": "90s", + "sourceType": "gbfs", + "url": "https://gbfs.spin.pm/api/gbfs/v2_3/portland/gbfs", + "geofencingZones": "true" } ] } \ No newline at end of file diff --git a/smoke-tests/septa/otp-config.json b/smoke-tests/septa/otp-config.json index 084070b312c..7b0d1828144 100644 --- a/smoke-tests/septa/otp-config.json +++ b/smoke-tests/septa/otp-config.json @@ -1,5 +1,4 @@ { "otpFeatures" : { - "SandboxAPILegacyGraphQLApi": true } } \ No newline at end of file diff --git a/src/ext-test/java/org/opentripplanner/ext/fares/FaresFilterTest.java b/src/ext-test/java/org/opentripplanner/ext/fares/FaresFilterTest.java index ea0b0020e5c..2e47c486925 100644 --- a/src/ext-test/java/org/opentripplanner/ext/fares/FaresFilterTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/fares/FaresFilterTest.java @@ -20,7 +20,7 @@ public class FaresFilterTest implements PlanTestConstants { @Test - public void shouldAddFare() { + void shouldAddFare() { final int ID = 1; Itinerary i1 = newItinerary(A, 0) diff --git a/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java b/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java index 0938d0572ef..9b02e9d0dd7 100644 --- a/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/fares/impl/AtlantaFareServiceTest.java @@ -1,6 +1,9 @@ package org.opentripplanner.ext.fares.impl; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opentripplanner.ext.fares.impl.AtlantaFareService.COBB_AGENCY_ID; import static org.opentripplanner.ext.fares.impl.AtlantaFareService.GCT_AGENCY_ID; import static org.opentripplanner.ext.fares.impl.AtlantaFareService.MARTA_AGENCY_ID; @@ -10,7 +13,6 @@ import static org.opentripplanner.transit.model.basic.Money.usDollars; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeAll; @@ -20,6 +22,7 @@ import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.model.fare.ItineraryFares; +import org.opentripplanner.model.plan.Itinerary; import org.opentripplanner.model.plan.Leg; import org.opentripplanner.model.plan.Place; import org.opentripplanner.model.plan.PlanTestConstants; @@ -34,16 +37,20 @@ public class AtlantaFareServiceTest implements PlanTestConstants { public static final Money DEFAULT_TEST_RIDE_PRICE = usDollars(3.49f); + private static final String FEED_ID = "A"; private static AtlantaFareService atlFareService; @BeforeAll public static void setUpClass() { - Map regularFareRules = new HashMap<>(); + Map regularFareRules = Map.of( + new FeedScopedId(FEED_ID, "regular"), + FareModelForTest.INSIDE_CITY_CENTER_SET + ); atlFareService = new TestAtlantaFareService(regularFareRules.values()); } @Test - public void fromMartaTransfers() { + void fromMartaTransfers() { List rides = List.of(getLeg(MARTA_AGENCY_ID, 0), getLeg(XPRESS_AGENCY_ID, 1)); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE); @@ -69,7 +76,7 @@ void nullShortName() { } @Test - public void fromCobbTransfers() { + void fromCobbTransfers() { List rides = List.of(getLeg(COBB_AGENCY_ID, 0), getLeg(MARTA_AGENCY_ID, 1)); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE); @@ -98,13 +105,13 @@ public void fromCobbTransfers() { } @Test - public void fromGctTransfers() { + void fromGctTransfers() { List rides = List.of(getLeg(GCT_AGENCY_ID, 0), getLeg(MARTA_AGENCY_ID, 1)); calculateFare(rides, DEFAULT_TEST_RIDE_PRICE); } @Test - public void tooManyLegs() { + void tooManyLegs() { List rides = List.of( getLeg(MARTA_AGENCY_ID, 0), getLeg(MARTA_AGENCY_ID, 1), @@ -158,7 +165,7 @@ public void tooManyLegs() { } @Test - public void expiredTransfer() { + void expiredTransfer() { List rides = List.of( getLeg(MARTA_AGENCY_ID, 0), getLeg(MARTA_AGENCY_ID, 1), @@ -179,7 +186,7 @@ public void expiredTransfer() { } @Test - public void useStreetcar() { + void useStreetcar() { var STREETCAR_PRICE = DEFAULT_TEST_RIDE_PRICE.minus(usDollars(1)); List rides = List.of( getLeg(MARTA_AGENCY_ID, 0), @@ -199,6 +206,18 @@ public void useStreetcar() { calculateFare(rides, DEFAULT_TEST_RIDE_PRICE.plus(usDollars(1)).plus(STREETCAR_PRICE)); } + @Test + void fullItinerary() { + var itin = createItinerary(MARTA_AGENCY_ID, "1", 0); + var fares = atlFareService.calculateFares(itin); + assertNotNull(fares); + assertTrue(fares.getLegProducts().isEmpty()); + var itineraryProducts = fares.getItineraryProducts(); + assertFalse(itineraryProducts.isEmpty()); + var fp = itineraryProducts.stream().filter(p -> p.name().equals("regular")).findAny().get(); + assertEquals(Money.usDollars(3.49f), fp.price()); + } + /** * These tests are designed to specifically validate ATL fares. Since these fares are hard-coded, * it is acceptable to make direct calls to the ATL fare service with predefined routes. Where the @@ -230,25 +249,30 @@ private static Leg getLeg(String agencyId, String shortName, long startTimeMins) } private static Leg createLeg(String agencyId, String shortName, long startTimeMins) { + final var itin = createItinerary(agencyId, shortName, startTimeMins); + return itin.getLegs().get(0); + } + + private static Itinerary createItinerary(String agencyId, String shortName, long startTimeMins) { Agency agency = Agency - .of(new FeedScopedId("A", agencyId)) + .of(new FeedScopedId(FEED_ID, agencyId)) .withName(agencyId) .withTimezone(ZoneIds.NEW_YORK.getId()) .build(); // Set up stops RegularStop firstStop = RegularStop - .of(new FeedScopedId("A", "1")) + .of(new FeedScopedId(FEED_ID, "1")) .withCoordinate(new WgsCoordinate(1, 1)) .withName(new NonLocalizedString("first stop")) .build(); RegularStop lastStop = RegularStop - .of(new FeedScopedId("A", "2")) + .of(new FeedScopedId(FEED_ID, "2")) .withCoordinate(new WgsCoordinate(1, 2)) .withName(new NonLocalizedString("last stop")) .build(); - FeedScopedId routeFeedScopeId = new FeedScopedId("A", "123"); + FeedScopedId routeFeedScopeId = new FeedScopedId(FEED_ID, "123"); Route route = Route .of(routeFeedScopeId) .withAgency(agency) @@ -261,8 +285,7 @@ private static Leg createLeg(String agencyId, String shortName, long startTimeMi var itin = newItinerary(Place.forStop(firstStop), start) .bus(route, 1, start, T11_12, Place.forStop(lastStop)) .build(); - - return itin.getLegs().get(0); + return itin; } private static class TestAtlantaFareService extends AtlantaFareService { diff --git a/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java b/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java index 779ea7bd4b7..768e586da31 100644 --- a/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/fares/impl/DefaultFareServiceTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opentripplanner.ext.fares.impl.FareModelForTest.AIRPORT_STOP; import static org.opentripplanner.ext.fares.impl.FareModelForTest.AIRPORT_TO_CITY_CENTER_SET; import static org.opentripplanner.ext.fares.impl.FareModelForTest.CITY_CENTER_A_STOP; @@ -25,6 +26,9 @@ class DefaultFareServiceTest implements PlanTestConstants { + private static final Money TEN_DOLLARS = Money.usDollars(10); + private static final Money TWENTY_DOLLARS = Money.usDollars(20); + @Test void noRules() { var service = new DefaultFareService(); @@ -46,7 +50,19 @@ void simpleZoneBasedFare() { var price = fare.getFare(FareType.regular); - assertEquals(Money.usDollars(10), price); + assertEquals(TEN_DOLLARS, price); + + var fp = fare.getItineraryProducts().get(0); + assertEquals(TEN_DOLLARS, fp.price()); + assertEquals("F:regular", fp.id().toString()); + + var lp = fare.legProductsFromComponents(); + assertEquals(1, lp.size()); + var product = lp.values().iterator().next().product(); + assertEquals(TEN_DOLLARS, product.price()); + + // the leg products from the components and the "true" leg products are different collections + assertTrue(fare.getLegProducts().isEmpty()); } @Test @@ -73,7 +89,23 @@ void shouldNotCombineInterlinedLegs() { var price = fare.getFare(FareType.regular); - assertEquals(Money.usDollars(20), price); + assertEquals(TWENTY_DOLLARS, price); + + assertTrue(fare.getLegProducts().isEmpty()); + + var legProductsFromComponents = fare.legProductsFromComponents(); + + var firstLeg = itin.getLegs().get(0); + var products = List.copyOf(legProductsFromComponents.get(firstLeg)); + + assertEquals(TEN_DOLLARS, products.get(0).product().price()); + + var secondLeg = itin.getLegs().get(1); + products = List.copyOf(legProductsFromComponents.get(secondLeg)); + assertEquals(TEN_DOLLARS, products.get(0).product().price()); + + assertEquals(1, fare.getItineraryProducts().size()); + assertEquals(TWENTY_DOLLARS, fare.getItineraryProducts().get(0).price()); } @Test @@ -97,10 +129,13 @@ void unknownLeg() { var component = components.get(0); assertEquals(AIRPORT_TO_CITY_CENTER_SET.getFareAttribute().getId(), component.fareId()); - assertEquals(Money.usDollars(10), component.price()); + assertEquals(TEN_DOLLARS, component.price()); var firstBusLeg = itin.firstTransitLeg().get(); assertEquals(List.of(firstBusLeg), component.legs()); + + var legProductsFromComponent = fare.legProductsFromComponents(); + assertEquals(1, legProductsFromComponent.size()); } @Test @@ -127,7 +162,7 @@ void multipleFeeds() { resultComponents ); - assertEquals(Money.usDollars(20), resultPrice); + assertEquals(TWENTY_DOLLARS, resultPrice); } @Test @@ -155,7 +190,7 @@ void multipleFeedsWithTransfersWithinFeed() { resultComponents ); - assertEquals(Money.usDollars(20), resultPrice); + assertEquals(TWENTY_DOLLARS, resultPrice); } @Test diff --git a/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java b/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java index 64c78e64f32..939d05cb2c2 100644 --- a/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/fares/impl/FaresIntegrationTest.java @@ -22,6 +22,7 @@ import org.opentripplanner.routing.core.FareType; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.standalone.api.OtpServerRequestContext; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.basic.Money; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.service.TransitModel; @@ -107,7 +108,9 @@ public void testPortland() { @Test public void testFareComponent() { - TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.FARE_COMPONENT_GTFS); + TestOtpModel model = ConstantsForTests.buildGtfsGraph( + ResourceLoader.of(this).file("farecomponents.gtfs.zip") + ); Graph graph = model.graph(); TransitModel transitModel = model.transitModel(); String feedId = transitModel.getFeedIds().iterator().next(); diff --git a/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java b/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java index d590f43ebe6..0a7ec4754e6 100644 --- a/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/fares/impl/HSLFareServiceTest.java @@ -92,7 +92,7 @@ private static List createTestCases() { float ABCD_PRICE = 5.70f; float D_PRICE = 2.80f; - HSLFareServiceImpl hslFareService = new HSLFareServiceImpl(); + HSLFareService hslFareService = new HSLFareService(); int fiveMinutes = 60 * 5; // Fare attributes @@ -446,7 +446,7 @@ void unknownFare() { FareRuleSet ruleSetAB = new FareRuleSet(fareAttributeAB); - var service = new HSLFareServiceImpl(); + var service = new HSLFareService(); service.addFareRules(FareType.regular, List.of(ruleSetAB)); // outside HSL's fare zones, should return null diff --git a/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java b/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java index 9e8376ec635..385b4e96e2c 100644 --- a/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/fares/impl/OrcaFareServiceTest.java @@ -1,6 +1,7 @@ package org.opentripplanner.ext.fares.impl; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.opentripplanner.ext.fares.impl.OrcaFareService.COMM_TRANS_AGENCY_ID; import static org.opentripplanner.ext.fares.impl.OrcaFareService.KC_METRO_AGENCY_ID; @@ -19,7 +20,6 @@ import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; @@ -37,6 +37,7 @@ import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.model.fare.FareProductUse; import org.opentripplanner.model.fare.ItineraryFares; +import org.opentripplanner.model.plan.Itinerary; import org.opentripplanner.model.plan.Leg; import org.opentripplanner.model.plan.Place; import org.opentripplanner.routing.core.FareType; @@ -55,12 +56,16 @@ public class OrcaFareServiceTest { private static final Money HALF_FERRY_FARE = usDollars(3.05f); private static final Money ORCA_REGULAR_FARE = usDollars(2.50f); private static final Money ORCA_SPECIAL_FARE = usDollars(1.50f); + private static final String FEED_ID = "A"; private static TestOrcaFareService orcaFareService; public static final Money DEFAULT_TEST_RIDE_PRICE = usDollars(3.49f); @BeforeAll public static void setUpClass() { - Map regularFareRules = new HashMap<>(); + Map regularFareRules = Map.of( + new FeedScopedId(FEED_ID, "regular"), + FareModelForTest.INSIDE_CITY_CENTER_SET + ); orcaFareService = new TestOrcaFareService(regularFareRules.values()); } @@ -114,7 +119,7 @@ private static void assertLegFareEquals( * Test to confirm the correct transfer cost per fare type within a single agency. */ @Test - public void calculateFareForSingleAgency() { + void calculateFareForSingleAgency() { List rides = List.of(getLeg(COMM_TRANS_AGENCY_ID, "400", 0)); calculateFare(rides, regular, DEFAULT_TEST_RIDE_PRICE); calculateFare(rides, FareType.senior, TWO_DOLLARS); @@ -130,7 +135,7 @@ public void calculateFareForSingleAgency() { * as the highest fare where Orca can be used. */ @Test - public void calculateFareWithNoFreeTransfer() { + void calculateFareWithNoFreeTransfer() { List rides = List.of( getLeg(KITSAP_TRANSIT_AGENCY_ID, 0), getLeg(WASHINGTON_STATE_FERRIES_AGENCY_ID, 1), @@ -161,7 +166,7 @@ public void calculateFareWithNoFreeTransfer() { * Check to make sure the fare by leg is calculated properly for a trip with two rides. */ @Test - public void calculateFareByLeg() { + void calculateFareByLeg() { List rides = List.of(getLeg(KITSAP_TRANSIT_AGENCY_ID, 0), getLeg(COMM_TRANS_AGENCY_ID, 2)); ItineraryFares fares = new ItineraryFares(); orcaFareService.populateFare(fares, USD, FareType.electronicRegular, rides, null); @@ -177,7 +182,7 @@ public void calculateFareByLeg() { * the new two hour window and will be free. */ @Test - public void calculateFareThatExceedsTwoHourFreeTransferWindow() { + void calculateFareThatExceedsTwoHourFreeTransferWindow() { List rides = List.of( getLeg(KITSAP_TRANSIT_AGENCY_ID, 0), getLeg(KITSAP_TRANSIT_AGENCY_ID, 30), @@ -207,7 +212,7 @@ public void calculateFareThatExceedsTwoHourFreeTransferWindow() { * trip! */ @Test - public void calculateFareThatIncludesNoFreeTransfers() { + void calculateFareThatIncludesNoFreeTransfers() { List rides = List.of( getLeg(KITSAP_TRANSIT_AGENCY_ID, 0), getLeg(WASHINGTON_STATE_FERRIES_AGENCY_ID, 30, "VashonIsland-Fauntelroy"), @@ -245,7 +250,7 @@ public void calculateFareThatIncludesNoFreeTransfers() { * Total trip time is 4h 30m. This is equivalent to three transfer windows and therefore three Orca fare charges. */ @Test - public void calculateFareThatExceedsTwoHourFreeTransferWindowTwice() { + void calculateFareThatExceedsTwoHourFreeTransferWindowTwice() { List rides = List.of( getLeg(KITSAP_TRANSIT_AGENCY_ID, 0), getLeg(KITSAP_TRANSIT_AGENCY_ID, 30), @@ -272,7 +277,7 @@ public void calculateFareThatExceedsTwoHourFreeTransferWindowTwice() { * all subsequent transfers will come under one transfer window and only one Orca discount charge will apply. */ @Test - public void calculateFareThatStartsWithACashFare() { + void calculateFareThatStartsWithACashFare() { List rides = List.of( getLeg(WASHINGTON_STATE_FERRIES_AGENCY_ID, 0), getLeg(KITSAP_TRANSIT_AGENCY_ID, 30), @@ -298,7 +303,7 @@ public void calculateFareThatStartsWithACashFare() { * Single trip with Kitsap transit fast ferry east to confirm correct non Orca fares are applied. */ @Test - public void calculateFareForKitsapFastFerryEastAgency() { + void calculateFareForKitsapFastFerryEastAgency() { List rides = List.of(getLeg(KITSAP_TRANSIT_AGENCY_ID, 0, 4, "Kitsap Fast Ferry", "east")); calculateFare(rides, regular, TWO_DOLLARS); calculateFare(rides, FareType.senior, TWO_DOLLARS); @@ -313,7 +318,7 @@ public void calculateFareForKitsapFastFerryEastAgency() { * Single trip (Point Defiance - Tahlequah) with WSF transit to confirm correct non Orca fares are applied. */ @Test - public void calculateFareForWSFPtToTahlequah() { + void calculateFareForWSFPtToTahlequah() { List rides = List.of( getLeg(WASHINGTON_STATE_FERRIES_AGENCY_ID, 0, "Point Defiance - Tahlequah") ); @@ -330,7 +335,7 @@ public void calculateFareForWSFPtToTahlequah() { * Single trip with Link Light Rail to ensure distance fare is calculated correctly. */ @Test - public void calculateFareForLightRailLeg() { + void calculateFareForLightRailLeg() { List rides = List.of( getLeg(SOUND_TRANSIT_AGENCY_ID, "1-Line", 0, "Roosevelt Station", "Int'l Dist/Chinatown") ); @@ -357,7 +362,7 @@ public void calculateFareForLightRailLeg() { } @Test - public void calculateFareForSounderLeg() { + void calculateFareForSounderLeg() { List rides = List.of( getLeg(SOUND_TRANSIT_AGENCY_ID, "S Line", 0, "King Street Station", "Auburn Station") ); @@ -388,7 +393,7 @@ public void calculateFareForSounderLeg() { * Make sure that we get ST's bus fare and not the contracted agency's fare. */ @Test - public void calculateSoundTransitBusFares() { + void calculateSoundTransitBusFares() { List rides = List.of( getLeg(COMM_TRANS_AGENCY_ID, "512", 0), getLeg(PIERCE_COUNTY_TRANSIT_AGENCY_ID, "594", 120), @@ -418,7 +423,7 @@ public void calculateSoundTransitBusFares() { } @Test - public void calculateCashFreeTransferKCMetro() { + void calculateCashFreeTransferKCMetro() { List rides = List.of( getLeg(KC_METRO_AGENCY_ID, 0), getLeg(KC_METRO_AGENCY_ID, 20), @@ -436,7 +441,7 @@ public void calculateCashFreeTransferKCMetro() { } @Test - public void calculateTransferExtension() { + void calculateTransferExtension() { List rides = List.of( getLeg(SOUND_TRANSIT_AGENCY_ID, "1-Line", 0, "Int'l Dist/Chinatown", "Roosevelt Station"), // 2.50 getLeg(SOUND_TRANSIT_AGENCY_ID, "1-Line", 60, "Roosevelt Station", "Angle Lake Station"), // 3.25, should extend transfer @@ -499,6 +504,37 @@ void nullShortName(FareType type) { assertNotNull(fare.getFare(type)); } + @Test + void fullItinerary() { + var itinerary = createItinerary( + WASHINGTON_STATE_FERRIES_AGENCY_ID, + "1-Line", + 0, + 1, + "route1", + "trip1", + null, + "first stop", + "last stop" + ); + var fares = orcaFareService.calculateFares(itinerary); + assertNotNull(fares); + + assertFalse(fares.getItineraryProducts().isEmpty()); + assertFalse(fares.getLegProducts().isEmpty()); + + var firstLeg = itinerary.getLegs().get(0); + var uses = fares.getLegProducts().get(firstLeg); + assertEquals(7, uses.size()); + + var regular = uses + .stream() + .filter(u -> u.product().category().name().equals("regular")) + .toList() + .get(0); + assertEquals(Money.usDollars(3.49f), regular.product().price()); + } + private static Leg getLeg(String agencyId, long startTimeMins) { return createLeg(agencyId, "-1", 3, startTimeMins, "test", "test", ""); } @@ -581,26 +617,52 @@ private static Leg createLeg( @Nullable String routeLongName, String firstStopName, String lastStopName + ) { + final var itin = createItinerary( + agencyId, + shortName, + transitMode, + startTimeMins, + routeId, + tripId, + routeLongName, + firstStopName, + lastStopName + ); + + return itin.getLegs().get(0); + } + + private static Itinerary createItinerary( + String agencyId, + String shortName, + int transitMode, + long startTimeMins, + String routeId, + String tripId, + @Nullable String routeLongName, + String firstStopName, + String lastStopName ) { Agency agency = Agency - .of(new FeedScopedId("A", agencyId)) + .of(new FeedScopedId(FEED_ID, agencyId)) .withName(agencyId) .withTimezone(ZoneIds.NEW_YORK.getId()) .build(); // Set up stops RegularStop firstStop = RegularStop - .of(new FeedScopedId("A", "1")) + .of(new FeedScopedId(FEED_ID, "1")) .withCoordinate(new WgsCoordinate(1, 1)) .withName(new NonLocalizedString(firstStopName)) .build(); RegularStop lastStop = RegularStop - .of(new FeedScopedId("A", "2")) + .of(new FeedScopedId(FEED_ID, "2")) .withCoordinate(new WgsCoordinate(1, 2)) .withName(new NonLocalizedString(lastStopName)) .build(); - FeedScopedId routeFeedScopeId = new FeedScopedId("A", routeId); + FeedScopedId routeFeedScopeId = new FeedScopedId(FEED_ID, routeId); NonLocalizedString longName = null; if (routeLongName != null) { longName = new NonLocalizedString(routeLongName); @@ -619,8 +681,7 @@ private static Leg createLeg( var itin = newItinerary(Place.forStop(firstStop), start) .transit(route, tripId, start, T11_12, 5, 7, Place.forStop(lastStop), null, null, null) .build(); - - return itin.getLegs().get(0); + return itin; } private static class TestOrcaFareService extends OrcaFareService { diff --git a/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java b/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java index daf912a420a..8a927673eca 100644 --- a/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/flex/FlexIntegrationTest.java @@ -3,13 +3,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.opentripplanner.graph_builder.module.FakeGraph.getFileForResource; import static org.opentripplanner.routing.api.request.StreetMode.FLEXIBLE; import static org.opentripplanner.street.search.TraverseMode.WALK; import static org.opentripplanner.transit.model.basic.TransitMode.BUS; import java.io.File; -import java.net.URISyntaxException; import java.time.Duration; import java.time.Instant; import java.time.ZonedDateTime; @@ -36,6 +34,7 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.request.filter.AllowAllTransitFilter; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.service.TransitModel; /** @@ -58,16 +57,15 @@ public class FlexIntegrationTest { @BeforeAll static void setup() { OTPFeature.enableFeatures(Map.of(OTPFeature.FlexRouting, true)); - var osmPath = getAbsolutePath(FlexTest.COBB_OSM); - var cobblincGtfsPath = getAbsolutePath(FlexTest.COBB_BUS_30_GTFS); - var martaGtfsPath = getAbsolutePath(FlexTest.MARTA_BUS_856_GTFS); - var flexGtfsPath = getAbsolutePath(FlexTest.COBB_FLEX_GTFS); - - TestOtpModel model = ConstantsForTests.buildOsmGraph(osmPath); + TestOtpModel model = ConstantsForTests.buildOsmGraph(FlexTest.COBB_OSM); graph = model.graph(); transitModel = model.transitModel(); - addGtfsToGraph(graph, transitModel, List.of(cobblincGtfsPath, martaGtfsPath, flexGtfsPath)); + addGtfsToGraph( + graph, + transitModel, + List.of(FlexTest.COBB_BUS_30_GTFS, FlexTest.MARTA_BUS_856_GTFS, FlexTest.COBB_FLEX_GTFS) + ); service = TestServerContext.createServerContext(graph, transitModel).routingService(); } @@ -176,21 +174,9 @@ static void teardown() { OTPFeature.enableFeatures(Map.of(OTPFeature.FlexRouting, false)); } - private static String getAbsolutePath(String cobbOsm) { - try { - return getFileForResource(cobbOsm).getAbsolutePath(); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - private static void addGtfsToGraph( - Graph graph, - TransitModel transitModel, - List gtfsFiles - ) { + private static void addGtfsToGraph(Graph graph, TransitModel transitModel, List gtfsFiles) { // GTFS - var gtfsBundles = gtfsFiles.stream().map(f -> new GtfsBundle(new File(f))).toList(); + var gtfsBundles = gtfsFiles.stream().map(GtfsBundle::new).toList(); GtfsModule gtfsModule = new GtfsModule( gtfsBundles, transitModel, diff --git a/src/ext-test/java/org/opentripplanner/ext/flex/FlexTest.java b/src/ext-test/java/org/opentripplanner/ext/flex/FlexTest.java index f2cb72ed3da..48b66eb54dd 100644 --- a/src/ext-test/java/org/opentripplanner/ext/flex/FlexTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/flex/FlexTest.java @@ -4,7 +4,6 @@ import gnu.trove.set.hash.TIntHashSet; import java.io.File; -import java.net.URISyntaxException; import java.time.LocalDate; import java.time.LocalTime; import java.util.List; @@ -12,23 +11,27 @@ import org.opentripplanner.TestOtpModel; import org.opentripplanner.ext.flex.flexpathcalculator.DirectFlexPathCalculator; import org.opentripplanner.framework.application.OTPFeature; -import org.opentripplanner.graph_builder.module.FakeGraph; import org.opentripplanner.gtfs.graphbuilder.GtfsBundle; import org.opentripplanner.gtfs.graphbuilder.GtfsModule; import org.opentripplanner.model.calendar.ServiceDateInterval; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; public abstract class FlexTest { - protected static final String ASPEN_GTFS = "/flex/aspen-flex-on-demand.gtfs.zip"; - protected static final String COBB_FLEX_GTFS = "/flex/cobblinc-scheduled-deviated-flex.gtfs.zip"; - protected static final String COBB_BUS_30_GTFS = "/flex/cobblinc-bus-30-only.gtfs.zip"; - protected static final String MARTA_BUS_856_GTFS = "/flex/marta-bus-856-only.gtfs.zip"; - protected static final String LINCOLN_COUNTY_GBFS = "/flex/lincoln-county-flex.gtfs.zip"; - protected static final String COBB_OSM = "/flex/cobb-county.filtered.osm.pbf"; + private static final ResourceLoader RES = ResourceLoader.of(FlexTest.class); + + protected static final File ASPEN_GTFS = RES.file("aspen-flex-on-demand.gtfs.zip"); + protected static final File COBB_FLEX_GTFS = RES.file( + "cobblinc-scheduled-deviated-flex.gtfs.zip" + ); + protected static final File COBB_BUS_30_GTFS = RES.file("cobblinc-bus-30-only.gtfs.zip"); + protected static final File MARTA_BUS_856_GTFS = RES.file("marta-bus-856-only.gtfs.zip"); + protected static final File LINCOLN_COUNTY_GBFS = RES.file("lincoln-county-flex.gtfs.zip"); + protected static final File COBB_OSM = RES.file("cobb-county.filtered.osm.pbf"); protected static final DirectFlexPathCalculator calculator = new DirectFlexPathCalculator(); protected static final LocalDate serviceDate = LocalDate.of(2021, 4, 11); @@ -39,14 +42,7 @@ public abstract class FlexTest { new TIntHashSet() ); - protected static TestOtpModel buildFlexGraph(String fileName) { - File file = null; - try { - file = FakeGraph.getFileForResource(fileName); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - + protected static TestOtpModel buildFlexGraph(File file) { var deduplicator = new Deduplicator(); var graph = new Graph(deduplicator); var transitModel = new TransitModel(new StopModel(), deduplicator); diff --git a/src/ext-test/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapperTest.java b/src/ext-test/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapperTest.java index 2d8a03c5ce4..1549a1feab9 100644 --- a/src/ext-test/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapperTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapperTest.java @@ -1,9 +1,12 @@ package org.opentripplanner.ext.transmodelapi.mapping; import static graphql.execution.ExecutionContextBuilder.newExecutionContextBuilder; +import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.opentripplanner.framework.time.TimeUtils.time; +import static org.opentripplanner.model.plan.TestItineraryBuilder.newItinerary; import graphql.ExecutionInput; import graphql.execution.ExecutionId; @@ -11,18 +14,26 @@ import graphql.schema.DataFetchingEnvironmentImpl; import io.micrometer.core.instrument.Metrics; import java.time.Duration; -import java.util.Arrays; +import java.time.LocalDate; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.opentripplanner._support.time.ZoneIds; import org.opentripplanner.ext.transmodelapi.TransmodelRequestContext; +import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; +import org.opentripplanner.model.calendar.CalendarServiceData; +import org.opentripplanner.model.plan.Itinerary; +import org.opentripplanner.model.plan.Leg; +import org.opentripplanner.model.plan.Place; import org.opentripplanner.model.plan.PlanTestConstants; +import org.opentripplanner.model.plan.ScheduledTransitLeg; import org.opentripplanner.raptor.configure.RaptorConfig; +import org.opentripplanner.routing.api.request.PassThroughPoint; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.StreetMode; import org.opentripplanner.routing.api.request.preference.StreetPreferences; @@ -36,7 +47,14 @@ import org.opentripplanner.standalone.config.RouterConfig; import org.opentripplanner.standalone.server.DefaultServerRequestContext; import org.opentripplanner.test.support.VariableSource; +import org.opentripplanner.transit.model._data.TransitModelForTest; +import org.opentripplanner.transit.model.framework.Deduplicator; +import org.opentripplanner.transit.model.network.Route; +import org.opentripplanner.transit.model.network.TripPattern; +import org.opentripplanner.transit.model.site.RegularStop; +import org.opentripplanner.transit.model.site.StopLocation; import org.opentripplanner.transit.service.DefaultTransitService; +import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; public class TripRequestMapperTest implements PlanTestConstants { @@ -44,12 +62,43 @@ public class TripRequestMapperTest implements PlanTestConstants { static final TransmodelRequestContext context; private static final Duration MAX_FLEXIBLE = Duration.ofMinutes(20); + private static final Function STOP_TO_ID = s -> s.getId().toString(); + + private static final Route route1 = TransitModelForTest.route("route1").build(); + private static final Route route2 = TransitModelForTest.route("route2").build(); + + private static final RegularStop stop1 = TransitModelForTest.stopForTest("ST:stop1", 1, 1); + private static final RegularStop stop2 = TransitModelForTest.stopForTest("ST:stop2", 2, 1); + private static final RegularStop stop3 = TransitModelForTest.stopForTest("ST:stop3", 3, 1); + static { var graph = new Graph(); - var transitModel = new TransitModel(); + var itinerary = newItinerary(Place.forStop(stop1), time("11:00")) + .bus(route1, 1, time("11:05"), time("11:20"), Place.forStop(stop2)) + .bus(route2, 2, time("11:20"), time("11:40"), Place.forStop(stop3)) + .build(); + var patterns = itineraryPatterns(itinerary); + var stopModel = StopModel + .of() + .withRegularStop(stop1) + .withRegularStop(stop2) + .withRegularStop(stop3) + .build(); + + var transitModel = new TransitModel(stopModel, new Deduplicator()); transitModel.initTimeZone(ZoneIds.STOCKHOLM); + var calendarServiceData = new CalendarServiceData(); + LocalDate serviceDate = itinerary.startTime().toLocalDate(); + patterns.forEach(pattern -> { + transitModel.addTripPattern(pattern.getId(), pattern); + final int serviceCode = pattern.getScheduledTimetable().getTripTimes(0).getServiceCode(); + transitModel.getServiceCodes().put(pattern.getId(), serviceCode); + calendarServiceData.putServiceDatesForServiceId(pattern.getId(), List.of(serviceDate)); + }); + + transitModel.updateCalendarServiceData(true, calendarServiceData, DataImportIssueStore.NOOP); + transitModel.index(); final var transitService = new DefaultTransitService(transitModel); - var defaultRequest = new RouteRequest(); // Change defaults for FLEXIBLE to a lower value than the default 45m. This should restrict the @@ -243,6 +292,42 @@ public void testBikeTriangleFactorsHasNoEffect(BicycleOptimizeType bot) { assertEquals(TimeSlopeSafetyTriangle.DEFAULT, req1.preferences().bike().optimizeTriangle()); } + @Test + void testPassThroughPoints() { + TransitIdMapper.clearFixedFeedId(); + + final List PTP1 = List.of(stop1, stop2, stop3).stream().map(STOP_TO_ID).toList(); + final List PTP2 = List.of(stop2, stop3, stop1).stream().map(STOP_TO_ID).toList(); + final Map arguments = Map.of( + "passThroughPoints", + List.of(Map.of("name", "PTP1", "placeIds", PTP1), Map.of("placeIds", PTP2, "name", "PTP2")) + ); + + final List points = TripRequestMapper + .createRequest(executionContext(arguments)) + .getPassThroughPoints(); + assertEquals(PTP1, points.get(0).stopLocations().stream().map(STOP_TO_ID).toList()); + assertEquals("PTP1", points.get(0).name()); + assertEquals(PTP2, points.get(1).stopLocations().stream().map(STOP_TO_ID).toList()); + assertEquals("PTP2", points.get(1).name()); + } + + @Test + void testPassThroughPointsNoMatch() { + TransitIdMapper.clearFixedFeedId(); + + final Map arguments = Map.of( + "passThroughPoints", + List.of(Map.of("placeIds", List.of("F:XX:NonExisting"))) + ); + + final RuntimeException ex = assertThrows( + RuntimeException.class, + () -> TripRequestMapper.createRequest(executionContext(arguments)) + ); + assertEquals("No match for F:XX:NonExisting.", ex.getMessage()); + } + private DataFetchingEnvironment executionContext(Map arguments) { ExecutionInput executionInput = ExecutionInput .newExecutionInput() @@ -265,4 +350,14 @@ private DataFetchingEnvironment executionContext(Map arguments) return env; } + + private static List itineraryPatterns(final Itinerary itinerary) { + return itinerary + .getLegs() + .stream() + .filter(Leg::isScheduledTransitLeg) + .map(Leg::asScheduledTransitLeg) + .map(ScheduledTransitLeg::getTripPattern) + .collect(toList()); + } } diff --git a/src/test/resources/gtfs/farecomponents.gtfs.zip b/src/ext-test/resources/org/opentripplanner/ext/fares/impl/farecomponents.gtfs.zip similarity index 100% rename from src/test/resources/gtfs/farecomponents.gtfs.zip rename to src/ext-test/resources/org/opentripplanner/ext/fares/impl/farecomponents.gtfs.zip diff --git a/src/ext-test/resources/flex/aspen-flex-on-demand.gtfs.zip b/src/ext-test/resources/org/opentripplanner/ext/flex/aspen-flex-on-demand.gtfs.zip similarity index 100% rename from src/ext-test/resources/flex/aspen-flex-on-demand.gtfs.zip rename to src/ext-test/resources/org/opentripplanner/ext/flex/aspen-flex-on-demand.gtfs.zip diff --git a/src/ext-test/resources/flex/cobb-county.filtered.osm.pbf b/src/ext-test/resources/org/opentripplanner/ext/flex/cobb-county.filtered.osm.pbf similarity index 100% rename from src/ext-test/resources/flex/cobb-county.filtered.osm.pbf rename to src/ext-test/resources/org/opentripplanner/ext/flex/cobb-county.filtered.osm.pbf diff --git a/src/ext-test/resources/flex/cobblinc-bus-30-only.gtfs.zip b/src/ext-test/resources/org/opentripplanner/ext/flex/cobblinc-bus-30-only.gtfs.zip similarity index 100% rename from src/ext-test/resources/flex/cobblinc-bus-30-only.gtfs.zip rename to src/ext-test/resources/org/opentripplanner/ext/flex/cobblinc-bus-30-only.gtfs.zip diff --git a/src/ext-test/resources/flex/cobblinc-scheduled-deviated-flex.gtfs.zip b/src/ext-test/resources/org/opentripplanner/ext/flex/cobblinc-scheduled-deviated-flex.gtfs.zip similarity index 100% rename from src/ext-test/resources/flex/cobblinc-scheduled-deviated-flex.gtfs.zip rename to src/ext-test/resources/org/opentripplanner/ext/flex/cobblinc-scheduled-deviated-flex.gtfs.zip diff --git a/src/ext-test/resources/flex/lincoln-county-flex.gtfs.zip b/src/ext-test/resources/org/opentripplanner/ext/flex/lincoln-county-flex.gtfs.zip similarity index 100% rename from src/ext-test/resources/flex/lincoln-county-flex.gtfs.zip rename to src/ext-test/resources/org/opentripplanner/ext/flex/lincoln-county-flex.gtfs.zip diff --git a/src/ext-test/resources/flex/marta-bus-856-only.gtfs.zip b/src/ext-test/resources/org/opentripplanner/ext/flex/marta-bus-856-only.gtfs.zip similarity index 100% rename from src/ext-test/resources/flex/marta-bus-856-only.gtfs.zip rename to src/ext-test/resources/org/opentripplanner/ext/flex/marta-bus-856-only.gtfs.zip diff --git a/src/ext/graphql/transmodelapi/schema.graphql b/src/ext/graphql/transmodelapi/schema.graphql index f568c46f7fc..28ca9cd129b 100644 --- a/src/ext/graphql/transmodelapi/schema.graphql +++ b/src/ext/graphql/transmodelapi/schema.graphql @@ -818,6 +818,8 @@ type QueryType { numTripPatterns: Int = 50, "Use the cursor to go to the next \"page\" of itineraries. Copy the cursor from the last response and keep the original request as is. This will enable you to search for itineraries in the next or previous time-window." pageCursor: String, + "The list of points the journey is required to pass through." + passThroughPoints: [PassThroughPoint!], """ Whether non-optimal transit paths at the destination should be returned. Let c be the existing minimum pareto optimal generalized-cost to beat. Then a trip with cost c' is @@ -1935,6 +1937,18 @@ input Modes { transportModes: [TransportModes] } +"Defines one point which the journey must pass through." +input PassThroughPoint { + "Optional name of the pass-through point for debugging and logging. It is not used in routing." + name: String + """ + The list of *stop location ids* which define the pass-through point. At least one id is required. + Quay, StopPlace, multimodal StopPlace, and GroupOfStopPlaces are supported location types. + The journey must pass through at least one of these entities - not all of them. + """ + placeIds: [String!] +} + "A combination of street mode and penalty for time and cost." input PenaltyForStreetMode { """ @@ -2028,7 +2042,7 @@ input ViaLocationInput { maxSlack: Duration = "PT1H" "The minimum time the user wants to stay in the via location before continuing his journey" minSlack: Duration = "PT5M" - "The name of the location. This is pass-through informationand is not used in routing." + "The name of the location. This is pass-through information and is not used in routing." name: String "The id of an element in the OTP model. Currently supports Quay, StopPlace, multimodal StopPlace, and GroupOfStopPlaces." place: String diff --git a/src/ext/java/org/opentripplanner/ext/fares/FaresToItineraryMapper.java b/src/ext/java/org/opentripplanner/ext/fares/FaresToItineraryMapper.java index 3dc64cb1587..c253b730611 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/FaresToItineraryMapper.java +++ b/src/ext/java/org/opentripplanner/ext/fares/FaresToItineraryMapper.java @@ -1,9 +1,11 @@ package org.opentripplanner.ext.fares; +import com.google.common.collect.Multimap; import org.opentripplanner.framework.collection.ListUtils; import org.opentripplanner.model.fare.FareProductUse; import org.opentripplanner.model.fare.ItineraryFares; import org.opentripplanner.model.plan.Itinerary; +import org.opentripplanner.model.plan.Leg; import org.opentripplanner.model.plan.ScheduledTransitLeg; /** @@ -21,13 +23,17 @@ public static void addFaresToLegs(ItineraryFares fares, Itinerary i) { }) .toList(); + final Multimap legProductsFromComponents = fares.legProductsFromComponents(); + i .getLegs() .stream() .filter(ScheduledTransitLeg.class::isInstance) .forEach(l -> { var legInstances = fares.getLegProducts().get(l); - l.setFareProducts(ListUtils.combine(itineraryInstances, legInstances)); + l.setFareProducts( + ListUtils.combine(itineraryInstances, legProductsFromComponents.get(l), legInstances) + ); }); } } diff --git a/src/ext/java/org/opentripplanner/ext/fares/impl/AtlantaFareService.java b/src/ext/java/org/opentripplanner/ext/fares/impl/AtlantaFareService.java index 5235be01596..d2d9d3e2a1b 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/impl/AtlantaFareService.java +++ b/src/ext/java/org/opentripplanner/ext/fares/impl/AtlantaFareService.java @@ -374,6 +374,16 @@ public AtlantaFareService(Collection regularFareRules) { addFareRules(FareType.electronicSenior, regularFareRules); } + /** + * In the base class only the rules for a specific feed are selected and then passed to the + * fare engine, however here we want to explicitly compute fares across feed boundaries. + */ + @Nullable + @Override + protected Collection fareRulesForFeed(FareType fareType, String feedId) { + return fareRulesPerType.get(fareType); + } + @Override public boolean populateFare( ItineraryFares fare, diff --git a/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java b/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java index 744782f7b56..583eca3f4e8 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java +++ b/src/ext/java/org/opentripplanner/ext/fares/impl/DefaultFareService.java @@ -17,6 +17,7 @@ import org.opentripplanner.ext.fares.model.FareAttribute; import org.opentripplanner.ext.fares.model.FareRuleSet; import org.opentripplanner.ext.flex.FlexibleTransitLeg; +import org.opentripplanner.model.fare.FareProduct; import org.opentripplanner.model.fare.ItineraryFares; import org.opentripplanner.model.plan.Itinerary; import org.opentripplanner.model.plan.Leg; @@ -107,34 +108,20 @@ public ItineraryFares calculateFares(Itinerary itinerary) { var fareLegsByFeed = fareLegs .stream() .collect(Collectors.groupingBy(leg -> leg.getAgency().getId().getFeedId())); - var fareRulesByTypeAndFeed = fareRulesPerType - .entrySet() - .stream() - .collect( - Collectors.toMap( - Map.Entry::getKey, - rules -> - rules - .getValue() - .stream() - .collect(Collectors.groupingBy(rule -> rule.getFareAttribute().getId().getFeedId())) - ) - ); ItineraryFares fare = ItineraryFares.empty(); boolean hasFare = false; for (FareType fareType : fareRulesPerType.keySet()) { List components = new ArrayList<>(); List fares = new ArrayList<>(); - ItineraryFares currentFare = ItineraryFares.empty(); boolean legWithoutRulesFound = false; boolean legsWithoutMatchingRulesFound = false; - boolean fareTypeHasFare = false; for (String feedId : fareLegsByFeed.keySet()) { - var fareRules = fareRulesByTypeAndFeed.get(fareType).get(feedId); + ItineraryFares currentFare = ItineraryFares.empty(); + var fareRules = fareRulesForFeed(fareType, feedId); // Get the currency from the first fareAttribute, assuming that all tickets use the same currency. - if (fareRules != null && fareRules.size() > 0) { + if (fareRules != null && !fareRules.isEmpty()) { Currency currency = Currency.getInstance( fareRules.iterator().next().getFareAttribute().getCurrencyType() ); @@ -153,11 +140,25 @@ public ItineraryFares calculateFares(Itinerary itinerary) { components.addAll(currentFare.getComponents(fareType)); fare.addFare(fareType, currentFare.getFare(fareType)); + + currentFare + .getLegProducts() + .entries() + .forEach(entry -> fare.addFareProduct(entry.getKey(), entry.getValue().product())); + fares.add(currentFare.getFare(fareType)); // If all the legs are from one feed, consider itinerary products if (fareLegs.equals(fareLegsByFeed.get(feedId))) { - fare.addItineraryProducts(currentFare.getItineraryProducts()); + currentFare + .getFareTypes() + .forEach(type -> { + var money = currentFare.getFare(type); + var fareProduct = FareProduct + .of(new FeedScopedId(feedId, type.name()), type.name(), money) + .build(); + fare.addItineraryProducts(List.of(fareProduct)); + }); } } else { legWithoutRulesFound = true; @@ -192,6 +193,27 @@ public ItineraryFares calculateFares(Itinerary itinerary) { return hasFare ? fare : null; } + /** + * For a given fareType and feedId return the applicable fare rule sets. + */ + @Nullable + protected Collection fareRulesForFeed(FareType fareType, String feedId) { + var fareRulesByTypeAndFeed = fareRulesPerType + .entrySet() + .stream() + .collect( + Collectors.toMap( + Map.Entry::getKey, + rules -> + rules + .getValue() + .stream() + .collect(Collectors.groupingBy(rule -> rule.getFareAttribute().getId().getFeedId())) + ) + ); + return fareRulesByTypeAndFeed.get(fareType).get(feedId); + } + /** * Builds the Fare object for the given currency, fareType and fareRules. *

diff --git a/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceImpl.java b/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java similarity index 96% rename from src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceImpl.java rename to src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java index ba62e899f70..159d3384dc4 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceImpl.java +++ b/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareService.java @@ -3,9 +3,7 @@ import com.google.common.collect.Sets; import java.time.Duration; import java.time.ZonedDateTime; -import java.util.ArrayList; import java.util.Collection; -import java.util.Currency; import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -14,11 +12,8 @@ import org.opentripplanner.ext.fares.model.FareAttribute; import org.opentripplanner.ext.fares.model.FareRuleSet; import org.opentripplanner.ext.fares.model.RouteOriginDestination; -import org.opentripplanner.model.fare.ItineraryFares; -import org.opentripplanner.model.plan.Itinerary; import org.opentripplanner.model.plan.Leg; import org.opentripplanner.model.plan.ScheduledTransitLeg; -import org.opentripplanner.routing.core.FareComponent; import org.opentripplanner.routing.core.FareType; import org.opentripplanner.transit.model.basic.Money; import org.slf4j.Logger; @@ -28,9 +23,9 @@ * This fare service module handles single feed HSL ticket pricing logic. */ -public class HSLFareServiceImpl extends DefaultFareService { +public class HSLFareService extends DefaultFareService { - private static final Logger LOG = LoggerFactory.getLogger(HSLFareServiceImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(HSLFareService.class); // this is not Float.MAX_VALUE to avoid overflow which would then make debugging harder public static final Money MAX_PRICE = Money.euros(999999f); diff --git a/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceFactory.java b/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceFactory.java index 81d53291b1e..6a87f36f386 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceFactory.java +++ b/src/ext/java/org/opentripplanner/ext/fares/impl/HSLFareServiceFactory.java @@ -14,7 +14,7 @@ public class HSLFareServiceFactory extends DefaultFareServiceFactory { - private static final Logger LOG = LoggerFactory.getLogger(HSLFareServiceImpl.class); + private static final Logger LOG = LoggerFactory.getLogger(HSLFareService.class); @Override protected void fillFareRules( @@ -76,7 +76,7 @@ protected void fillFareRules( } public FareService makeFareService() { - HSLFareServiceImpl fareService = new HSLFareServiceImpl(); + HSLFareService fareService = new HSLFareService(); fareService.addFareRules(FareType.regular, regularFareRules.values()); if (LOG.isDebugEnabled()) { for (FareRuleSet ruleSet : regularFareRules.values()) { diff --git a/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java b/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java index fbad6e290bc..6bc0ad668cf 100644 --- a/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java +++ b/src/ext/java/org/opentripplanner/ext/fares/impl/OrcaFareService.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import javax.annotation.Nullable; import org.opentripplanner.ext.fares.model.FareRuleSet; import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.model.fare.FareMedium; @@ -547,6 +548,16 @@ private static void addLegFareProduct( } } + /** + * In the base class only the rules for a specific feed are selected and then passed to the + * fare engine, however here we want to explicitly compute fares across feed boundaries. + */ + @Nullable + @Override + protected Collection fareRulesForFeed(FareType fareType, String feedId) { + return fareRulesPerType.get(fareType); + } + /** * Check if trip falls within the transfer time window. * @param freeTransferStartTime diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopRelationshipImpl.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopRelationshipImpl.java deleted file mode 100644 index 1fccf47e828..00000000000 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopRelationshipImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; - -import graphql.schema.DataFetcher; -import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers.GraphQLStopRelationship; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLVehicleStopStatus; -import org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition.StopRelationship; - -public class StopRelationshipImpl implements GraphQLStopRelationship { - - @Override - public DataFetcher status() { - return env -> - switch (getSource(env).status()) { - case INCOMING_AT -> GraphQLVehicleStopStatus.INCOMING_AT; - case IN_TRANSIT_TO -> GraphQLVehicleStopStatus.IN_TRANSIT_TO; - case STOPPED_AT -> GraphQLVehicleStopStatus.STOPPED_AT; - }; - } - - @Override - public DataFetcher stop() { - return env -> getSource(env).stop(); - } - - private StopRelationship getSource(DataFetchingEnvironment environment) { - return environment.getSource(); - } -} diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/RideHailingProvider.java b/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/RideHailingProvider.java deleted file mode 100644 index 2d4310da9e0..00000000000 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/RideHailingProvider.java +++ /dev/null @@ -1,3 +0,0 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.model; - -public record RideHailingProvider(String id) {} diff --git a/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java b/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java index 83b7d04c34f..8b33d71ab96 100644 --- a/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java +++ b/src/ext/java/org/opentripplanner/ext/siri/SiriTripPatternCache.java @@ -190,7 +190,7 @@ public boolean equals(Object thatObject) { return false; } StopPatternServiceDateKey that = (StopPatternServiceDateKey) thatObject; - return (this.stopPattern.equals(that.stopPattern) & this.serviceDate.equals(that.serviceDate)); + return (this.stopPattern.equals(that.stopPattern) && this.serviceDate.equals(that.serviceDate)); } } @@ -215,6 +215,6 @@ public boolean equals(Object thatObject) { return false; } TripServiceDateKey that = (TripServiceDateKey) thatObject; - return (this.trip.equals(that.trip) & this.serviceDate.equals(that.serviceDate)); + return (this.trip.equals(that.trip) && this.serviceDate.equals(that.serviceDate)); } } diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/PassThroughLocationMapper.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/PassThroughLocationMapper.java new file mode 100644 index 00000000000..76bd1464e0f --- /dev/null +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/PassThroughLocationMapper.java @@ -0,0 +1,48 @@ +package org.opentripplanner.ext.transmodelapi.mapping; + +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; + +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.opentripplanner.routing.api.request.PassThroughPoint; +import org.opentripplanner.transit.service.TransitService; + +class PassThroughLocationMapper { + + static List toLocations( + final TransitService transitService, + final List> passThroughPoints + ) { + return passThroughPoints + .stream() + .map(p -> handlePoint(transitService, p)) + .filter(Objects::nonNull) + .collect(toList()); + // TODO Propagate an error if a stopplace is unknown and fails lookup. + } + + private static PassThroughPoint handlePoint( + final TransitService transitService, + Map map + ) { + final List stops = (List) map.get("placeIds"); + final String name = (String) map.get("name"); + if (stops == null) { + return null; + } + + return stops + .stream() + .map(TransitIdMapper::mapIDToDomain) + .flatMap(id -> { + var stopLocations = transitService.getStopOrChildStops(id); + if (stopLocations.isEmpty()) { + throw new RuntimeException("No match for %s.".formatted(id)); + } + return stopLocations.stream(); + }) + .collect(collectingAndThen(toList(), sls -> new PassThroughPoint(sls, name))); + } +} diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TransitIdMapper.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TransitIdMapper.java index 42976bd2a2f..615439e7957 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TransitIdMapper.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TransitIdMapper.java @@ -98,4 +98,15 @@ public static String setupFixedFeedId(Collection + * For use from tests only. + * + * @see #setupFixedFeedId(Collection) + */ + public static void clearFixedFeedId() { + fixedFeedId = null; + } } diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapper.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapper.java index e1c7d750f26..2ee2d5b2eda 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapper.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/mapping/TripRequestMapper.java @@ -17,6 +17,7 @@ import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.standalone.api.OtpServerRequestContext; import org.opentripplanner.transit.model.framework.FeedScopedId; +import org.opentripplanner.transit.service.TransitService; public class TripRequestMapper { @@ -40,6 +41,13 @@ public static RouteRequest createRequest(DataFetchingEnvironment environment) { "to", (Map v) -> request.setTo(GenericLocationMapper.toGenericLocation(v)) ); + final TransitService transitService = context.getTransitService(); + callWith.argument( + "passThroughPoints", + (List> v) -> { + request.setPassThroughPoints(PassThroughLocationMapper.toLocations(transitService, v)); + } + ); callWith.argument( "dateTime", diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/PassThroughPointInputType.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/PassThroughPointInputType.java new file mode 100644 index 00000000000..55873844a5f --- /dev/null +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/PassThroughPointInputType.java @@ -0,0 +1,39 @@ +package org.opentripplanner.ext.transmodelapi.model.framework; + +import graphql.Scalars; +import graphql.schema.GraphQLInputObjectField; +import graphql.schema.GraphQLInputObjectType; +import graphql.schema.GraphQLList; +import graphql.schema.GraphQLNonNull; + +public class PassThroughPointInputType { + + public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType + .newInputObject() + .name("PassThroughPoint") + .description("Defines one point which the journey must pass through.") + .field( + GraphQLInputObjectField + .newInputObjectField() + .name("name") + .description( + "Optional name of the pass-through point for debugging and logging. It is not used in routing." + ) + .type(Scalars.GraphQLString) + .build() + ) + .field( + GraphQLInputObjectField + .newInputObjectField() + .name("placeIds") + .description( + """ + The list of *stop location ids* which define the pass-through point. At least one id is required. + Quay, StopPlace, multimodal StopPlace, and GroupOfStopPlaces are supported location types. + The journey must pass through at least one of these entities - not all of them.""" + ) + .type(new GraphQLList(new GraphQLNonNull(Scalars.GraphQLString))) + .build() + ) + .build(); +} diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/TripQuery.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/TripQuery.java index d4c4e424c43..8fa4fa31512 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/TripQuery.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/TripQuery.java @@ -15,6 +15,7 @@ import org.opentripplanner.ext.transmodelapi.model.EnumTypes; import org.opentripplanner.ext.transmodelapi.model.TransportModeSlack; import org.opentripplanner.ext.transmodelapi.model.framework.LocationInputType; +import org.opentripplanner.ext.transmodelapi.model.framework.PassThroughPointInputType; import org.opentripplanner.ext.transmodelapi.model.framework.PenaltyForStreetModeType; import org.opentripplanner.ext.transmodelapi.support.GqlUtil; import org.opentripplanner.routing.api.request.preference.RoutingPreferences; @@ -150,6 +151,14 @@ public static GraphQLFieldDefinition create( .type(new GraphQLNonNull(LocationInputType.INPUT_TYPE)) .build() ) + .argument( + GraphQLArgument + .newArgument() + .name("passThroughPoints") + .description("The list of points the journey is required to pass through.") + .type(new GraphQLList(new GraphQLNonNull(PassThroughPointInputType.INPUT_TYPE))) + .build() + ) .argument( GraphQLArgument .newArgument() diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/ViaLocationInputType.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/ViaLocationInputType.java index 278a0dbeabd..fe5a3cf19e4 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/ViaLocationInputType.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/plan/ViaLocationInputType.java @@ -26,7 +26,7 @@ public static GraphQLInputObjectType create(GqlUtil gqlUtil) { .name("name") .description( "The name of the location. This is pass-through information" + - "and is not used in routing." + " and is not used in routing." ) .type(Scalars.GraphQLString) .build() diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java index 55a325d7431..31664170a04 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslFacilitiesDownloader.java @@ -86,7 +86,7 @@ private List parseJSON( JsonNode rootNode = mapper.readTree(facilitiesString); - if (!jsonParsePath.equals("")) { + if (!jsonParsePath.isEmpty()) { String delimiter = "/"; String[] parseElement = jsonParsePath.split(delimiter); for (String s : parseElement) { diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java index 959523247e4..1ef0ef3597b 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubToVehicleParkingGroupMapper.java @@ -46,7 +46,7 @@ public Map parseHub(JsonNode jsonNode) { .fieldNames() .forEachRemaining(lang -> { String name = nameNode.path(lang).asText(); - if (!name.equals("")) { + if (!name.isEmpty()) { translations.put(lang, nameNode.path(lang).asText()); } }); diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java index 06a275de9ae..c5712e2067e 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslHubsDownloader.java @@ -79,7 +79,7 @@ private Map parseJSON(InputStream dataStream) JsonNode rootNode = mapper.readTree(hubsString); - if (!jsonParsePath.equals("")) { + if (!jsonParsePath.isEmpty()) { String delimiter = "/"; String[] parseElement = jsonParsePath.split(delimiter); for (String s : parseElement) { diff --git a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java index 0e41f0ed09d..1f69458dd1f 100644 --- a/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java +++ b/src/ext/java/org/opentripplanner/ext/vehicleparking/hslpark/HslParkToVehicleParkingMapper.java @@ -84,7 +84,7 @@ public VehicleParking parsePark( .fieldNames() .forEachRemaining(lang -> { String name = nameNode.path(lang).asText(); - if (!name.equals("")) { + if (!name.isEmpty()) { translations.put(lang, nameNode.path(lang).asText()); } }); diff --git a/src/main/java/org/opentripplanner/api/configuration/APIEndpoints.java b/src/main/java/org/opentripplanner/api/configuration/APIEndpoints.java index c52a3717f78..7873724dcf4 100644 --- a/src/main/java/org/opentripplanner/api/configuration/APIEndpoints.java +++ b/src/main/java/org/opentripplanner/api/configuration/APIEndpoints.java @@ -24,9 +24,9 @@ import org.opentripplanner.api.resource.Routers; import org.opentripplanner.api.resource.ServerInfo; import org.opentripplanner.api.resource.UpdaterStatusResource; +import org.opentripplanner.apis.gtfs.GtfsGraphQLAPI; import org.opentripplanner.ext.actuator.ActuatorAPI; import org.opentripplanner.ext.geocoder.GeocoderResource; -import org.opentripplanner.ext.gtfsgraphqlapi.GtfsGraphQLAPI; import org.opentripplanner.ext.parkAndRideApi.ParkAndRideResource; import org.opentripplanner.ext.reportapi.resource.ReportResource; import org.opentripplanner.ext.transmodelapi.TransmodelAPI; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLRequestContext.java b/src/main/java/org/opentripplanner/apis/gtfs/GraphQLRequestContext.java similarity index 97% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLRequestContext.java rename to src/main/java/org/opentripplanner/apis/gtfs/GraphQLRequestContext.java index 166aa93fd35..82424276930 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLRequestContext.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/GraphQLRequestContext.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import javax.annotation.Nonnull; import org.opentripplanner.routing.api.RoutingService; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLScalars.java b/src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java similarity index 98% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLScalars.java rename to src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java index 4aa4a2dfac6..07292cfca08 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLScalars.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/GraphQLScalars.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import com.bedatadriven.jackson.datatype.jts.JtsModule; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLUtils.java b/src/main/java/org/opentripplanner/apis/gtfs/GraphQLUtils.java similarity index 87% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLUtils.java rename to src/main/java/org/opentripplanner/apis/gtfs/GraphQLUtils.java index b0d1d65e971..18f5a7730d5 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLUtils.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/GraphQLUtils.java @@ -1,13 +1,13 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import java.time.Instant; import java.util.Locale; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLFilterPlaceType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLFormFactor; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLInputField; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRoutingErrorCode; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLFilterPlaceType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLFormFactor; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLInputField; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLRoutingErrorCode; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLTransitMode; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLWheelchairBoarding; import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.routing.api.response.InputField; import org.opentripplanner.routing.api.response.RoutingErrorCode; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GtfsGraphQLAPI.java b/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java similarity index 97% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GtfsGraphQLAPI.java rename to src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java index 0f6b1f165b4..20d15b1cfe8 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GtfsGraphQLAPI.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLAPI.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import com.fasterxml.jackson.databind.ObjectMapper; import graphql.ExecutionResult; @@ -26,8 +26,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -// TODO move to org.opentripplanner.api.resource, this is a Jersey resource class - @Path("/routers/{ignoreRouterId}/index/graphql") @Produces(MediaType.APPLICATION_JSON) // One @Produces annotation for all endpoints. public class GtfsGraphQLAPI { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GtfsGraphQLIndex.java b/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java similarity index 62% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GtfsGraphQLIndex.java rename to src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java index 9a8651a2389..d7b936a6198 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/GtfsGraphQLIndex.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java @@ -1,6 +1,5 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; -import com.google.common.io.Resources; import graphql.ExecutionInput; import graphql.ExecutionResult; import graphql.GraphQL; @@ -17,75 +16,75 @@ import io.micrometer.core.instrument.Metrics; import jakarta.ws.rs.core.Response; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.opentripplanner.api.json.GraphQLResponseSerializer; +import org.opentripplanner.apis.gtfs.datafetchers.AgencyImpl; +import org.opentripplanner.apis.gtfs.datafetchers.AlertEntityTypeResolver; +import org.opentripplanner.apis.gtfs.datafetchers.AlertImpl; +import org.opentripplanner.apis.gtfs.datafetchers.BikeParkImpl; +import org.opentripplanner.apis.gtfs.datafetchers.BikeRentalStationImpl; +import org.opentripplanner.apis.gtfs.datafetchers.BookingInfoImpl; +import org.opentripplanner.apis.gtfs.datafetchers.BookingTimeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.CarParkImpl; +import org.opentripplanner.apis.gtfs.datafetchers.ContactInfoImpl; +import org.opentripplanner.apis.gtfs.datafetchers.CoordinatesImpl; +import org.opentripplanner.apis.gtfs.datafetchers.CurrencyImpl; +import org.opentripplanner.apis.gtfs.datafetchers.DefaultFareProductImpl; +import org.opentripplanner.apis.gtfs.datafetchers.DepartureRowImpl; +import org.opentripplanner.apis.gtfs.datafetchers.FareProductTypeResolver; +import org.opentripplanner.apis.gtfs.datafetchers.FareProductUseImpl; +import org.opentripplanner.apis.gtfs.datafetchers.FeedImpl; +import org.opentripplanner.apis.gtfs.datafetchers.GeometryImpl; +import org.opentripplanner.apis.gtfs.datafetchers.ItineraryImpl; +import org.opentripplanner.apis.gtfs.datafetchers.LegImpl; +import org.opentripplanner.apis.gtfs.datafetchers.MoneyImpl; +import org.opentripplanner.apis.gtfs.datafetchers.NodeTypeResolver; +import org.opentripplanner.apis.gtfs.datafetchers.OpeningHoursImpl; +import org.opentripplanner.apis.gtfs.datafetchers.PatternImpl; +import org.opentripplanner.apis.gtfs.datafetchers.PlaceImpl; +import org.opentripplanner.apis.gtfs.datafetchers.PlaceInterfaceTypeResolver; +import org.opentripplanner.apis.gtfs.datafetchers.PlanImpl; +import org.opentripplanner.apis.gtfs.datafetchers.QueryTypeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.RentalVehicleImpl; +import org.opentripplanner.apis.gtfs.datafetchers.RentalVehicleTypeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.RideHailingEstimateImpl; +import org.opentripplanner.apis.gtfs.datafetchers.RouteImpl; +import org.opentripplanner.apis.gtfs.datafetchers.RouteTypeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.RoutingErrorImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StopGeometriesImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StopImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StopOnRouteImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StopOnTripImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StopRelationshipImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StoptimeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.StoptimesInPatternImpl; +import org.opentripplanner.apis.gtfs.datafetchers.SystemNoticeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.TicketTypeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.TranslatedStringImpl; +import org.opentripplanner.apis.gtfs.datafetchers.TripImpl; +import org.opentripplanner.apis.gtfs.datafetchers.UnknownImpl; +import org.opentripplanner.apis.gtfs.datafetchers.VehicleParkingImpl; +import org.opentripplanner.apis.gtfs.datafetchers.VehiclePositionImpl; +import org.opentripplanner.apis.gtfs.datafetchers.VehicleRentalStationImpl; +import org.opentripplanner.apis.gtfs.datafetchers.debugOutputImpl; +import org.opentripplanner.apis.gtfs.datafetchers.elevationProfileComponentImpl; +import org.opentripplanner.apis.gtfs.datafetchers.fareComponentImpl; +import org.opentripplanner.apis.gtfs.datafetchers.fareImpl; +import org.opentripplanner.apis.gtfs.datafetchers.placeAtDistanceImpl; +import org.opentripplanner.apis.gtfs.datafetchers.serviceTimeRangeImpl; +import org.opentripplanner.apis.gtfs.datafetchers.stepImpl; +import org.opentripplanner.apis.gtfs.datafetchers.stopAtDistanceImpl; +import org.opentripplanner.apis.gtfs.model.StopPosition; import org.opentripplanner.ext.actuator.MicrometerGraphQLInstrumentation; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.AgencyImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.AlertEntityTypeResolver; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.AlertImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.BikeParkImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.BikeRentalStationImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.BookingInfoImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.BookingTimeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.CarParkImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.ContactInfoImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.CoordinatesImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.CurrencyImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.DefaultFareProductImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.DepartureRowImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.FareProductTypeResolver; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.FareProductUseImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.FeedImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.GeometryImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.ItineraryImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.LegImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.MoneyImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.NodeTypeResolver; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.OpeningHoursImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.PatternImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.PlaceImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.PlaceInterfaceTypeResolver; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.PlanImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.QueryTypeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.RentalVehicleImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.RentalVehicleTypeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.RideHailingEstimateImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.RouteImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.RouteTypeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.RoutingErrorImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StopGeometriesImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StopImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StopOnRouteImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StopOnTripImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StopRelationshipImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StoptimeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.StoptimesInPatternImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.SystemNoticeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.TicketTypeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.TranslatedStringImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.TripImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.UnknownImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.VehicleParkingImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.VehiclePositionImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.VehicleRentalStationImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.debugOutputImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.elevationProfileComponentImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.fareComponentImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.fareImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.placeAtDistanceImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.serviceTimeRangeImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.stepImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.stopAtDistanceImpl; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopPosition; import org.opentripplanner.framework.application.OTPFeature; import org.opentripplanner.framework.concurrent.OtpRequestThreadFactory; import org.slf4j.Logger; @@ -103,9 +102,8 @@ class GtfsGraphQLIndex { protected static GraphQLSchema buildSchema() { try { - URL url = Resources.getResource("gtfsgraphqlapi/schema.graphqls"); - String sdl = Resources.toString(url, StandardCharsets.UTF_8); - TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(sdl); + URL url = Objects.requireNonNull(GtfsGraphQLIndex.class.getResource("schema.graphqls")); + TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(url.openStream()); IntrospectionTypeWiring typeWiring = new IntrospectionTypeWiring(typeRegistry); RuntimeWiring runtimeWiring = RuntimeWiring .newRuntimeWiring() @@ -118,6 +116,7 @@ protected static GraphQLSchema buildSchema() { .type("PlaceInterface", type -> type.typeResolver(new PlaceInterfaceTypeResolver())) .type("StopPosition", type -> type.typeResolver(new StopPosition() {})) .type("FareProduct", type -> type.typeResolver(new FareProductTypeResolver())) + .type("AlertEntity", type -> type.typeResolver(new AlertEntityTypeResolver())) .type(typeWiring.build(AgencyImpl.class)) .type(typeWiring.build(AlertImpl.class)) .type(typeWiring.build(BikeParkImpl.class)) @@ -157,7 +156,6 @@ protected static GraphQLSchema buildSchema() { .type(typeWiring.build(VehicleRentalStationImpl.class)) .type(typeWiring.build(RentalVehicleImpl.class)) .type(typeWiring.build(RentalVehicleTypeImpl.class)) - .type("AlertEntity", type -> type.typeResolver(new AlertEntityTypeResolver())) .type(typeWiring.build(StopOnRouteImpl.class)) .type(typeWiring.build(StopOnTripImpl.class)) .type(typeWiring.build(UnknownImpl.class)) diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/IntrospectionTypeWiring.java b/src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java similarity index 98% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/IntrospectionTypeWiring.java rename to src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java index 9d63199450f..78a6619a6b9 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/IntrospectionTypeWiring.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/IntrospectionTypeWiring.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import graphql.language.ObjectTypeDefinition; import graphql.language.TypeDefinition; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AgencyImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AgencyImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java index d9ce3c03dbf..8a6d55bb078 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AgencyImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AgencyImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; @@ -7,9 +7,9 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.routing.alertpatch.EntitySelector; import org.opentripplanner.routing.alertpatch.TransitAlert; import org.opentripplanner.routing.services.TransitAlertService; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AlertEntityTypeResolver.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AlertEntityTypeResolver.java similarity index 81% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AlertEntityTypeResolver.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AlertEntityTypeResolver.java index 4fd0f964d2a..210cfbca27a 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AlertEntityTypeResolver.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AlertEntityTypeResolver.java @@ -1,13 +1,13 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.TypeResolutionEnvironment; import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLSchema; import graphql.schema.TypeResolver; -import org.opentripplanner.ext.gtfsgraphqlapi.model.RouteTypeModel; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnRouteModel; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnTripModel; -import org.opentripplanner.ext.gtfsgraphqlapi.model.UnknownModel; +import org.opentripplanner.apis.gtfs.model.RouteTypeModel; +import org.opentripplanner.apis.gtfs.model.StopOnRouteModel; +import org.opentripplanner.apis.gtfs.model.StopOnTripModel; +import org.opentripplanner.apis.gtfs.model.UnknownModel; import org.opentripplanner.transit.model.network.Route; import org.opentripplanner.transit.model.network.TripPattern; import org.opentripplanner.transit.model.organization.Agency; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AlertImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AlertImpl.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AlertImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AlertImpl.java index b9e7c650b93..90db8ef1605 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/AlertImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/AlertImpl.java @@ -1,7 +1,7 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; -import static org.opentripplanner.ext.gtfsgraphqlapi.mapping.AlertEffectMapper.getGraphQLEffect; -import static org.opentripplanner.ext.gtfsgraphqlapi.mapping.SeverityMapper.getGraphQLSeverity; +import static org.opentripplanner.apis.gtfs.mapping.AlertEffectMapper.getGraphQLEffect; +import static org.opentripplanner.apis.gtfs.mapping.SeverityMapper.getGraphQLSeverity; import graphql.relay.Relay; import graphql.schema.DataFetcher; @@ -13,16 +13,16 @@ import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertEffectType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.AlertCauseMapper; -import org.opentripplanner.ext.gtfsgraphqlapi.model.RouteTypeModel; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnRouteModel; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnTripModel; -import org.opentripplanner.ext.gtfsgraphqlapi.model.UnknownModel; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertEffectType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; +import org.opentripplanner.apis.gtfs.mapping.AlertCauseMapper; +import org.opentripplanner.apis.gtfs.model.RouteTypeModel; +import org.opentripplanner.apis.gtfs.model.StopOnRouteModel; +import org.opentripplanner.apis.gtfs.model.StopOnTripModel; +import org.opentripplanner.apis.gtfs.model.UnknownModel; import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.framework.i18n.TranslatedString; import org.opentripplanner.routing.alertpatch.EntitySelector; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BikeParkImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BikeParkImpl.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BikeParkImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BikeParkImpl.java index f0e07a0d61e..81166034ee5 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BikeParkImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BikeParkImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.model.calendar.openinghours.OHCalendar; import org.opentripplanner.routing.vehicle_parking.VehicleParking; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BikeRentalStationImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BikeRentalStationImpl.java similarity index 96% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BikeRentalStationImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BikeRentalStationImpl.java index fc8545d4979..147b361986a 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BikeRentalStationImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BikeRentalStationImpl.java @@ -1,10 +1,10 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.List; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BookingInfoImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java similarity index 91% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BookingInfoImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java index af06f4fbcab..9ba2c21f62d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BookingInfoImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.BookingInfo; import org.opentripplanner.model.BookingTime; import org.opentripplanner.transit.model.organization.ContactInfo; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BookingTimeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingTimeImpl.java similarity index 82% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BookingTimeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingTimeImpl.java index 796b7a6dadd..8c6e581eba4 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/BookingTimeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingTimeImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.time.format.DateTimeFormatter; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.BookingTime; public class BookingTimeImpl implements GraphQLDataFetchers.GraphQLBookingTime { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CarParkImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CarParkImpl.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CarParkImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CarParkImpl.java index a03e56b668c..ff990b4f65c 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CarParkImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CarParkImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.model.calendar.openinghours.OHCalendar; import org.opentripplanner.routing.vehicle_parking.VehicleParking; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/ContactInfoImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/ContactInfoImpl.java similarity index 89% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/ContactInfoImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/ContactInfoImpl.java index 1ec1a645b26..d19b661942f 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/ContactInfoImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/ContactInfoImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.transit.model.organization.ContactInfo; public class ContactInfoImpl implements GraphQLDataFetchers.GraphQLContactInfo { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CoordinatesImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CoordinatesImpl.java similarity index 79% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CoordinatesImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CoordinatesImpl.java index de4651f0bb1..7d12ea237b7 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CoordinatesImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CoordinatesImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import org.locationtech.jts.geom.Coordinate; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; public class CoordinatesImpl implements GraphQLDataFetchers.GraphQLCoordinates { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CurrencyImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CurrencyImpl.java similarity index 79% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CurrencyImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CurrencyImpl.java index b4f853dd885..77bbfdaa687 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/CurrencyImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/CurrencyImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.Currency; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; public class CurrencyImpl implements GraphQLDataFetchers.GraphQLCurrency { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/DefaultFareProductImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DefaultFareProductImpl.java similarity index 88% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/DefaultFareProductImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DefaultFareProductImpl.java index 0ba4f21fbc5..86b988fcb21 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/DefaultFareProductImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DefaultFareProductImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.fare.FareMedium; import org.opentripplanner.model.fare.FareProduct; import org.opentripplanner.model.fare.RiderCategory; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/DepartureRowImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java similarity index 86% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/DepartureRowImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java index 86aa90d90c4..64b84c4c132 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/DepartureRowImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/DepartureRowImpl.java @@ -1,13 +1,13 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.time.Duration; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.GraphQLUtils; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.model.TripTimeOnDate; import org.opentripplanner.routing.graphfinder.PatternAtStop; import org.opentripplanner.routing.stoptimes.ArrivalDeparture; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FareProductTypeResolver.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FareProductTypeResolver.java similarity index 90% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FareProductTypeResolver.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FareProductTypeResolver.java index dc862108fbe..2a1a4c3baa0 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FareProductTypeResolver.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FareProductTypeResolver.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.TypeResolutionEnvironment; import graphql.schema.GraphQLObjectType; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FareProductUseImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FareProductUseImpl.java similarity index 81% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FareProductUseImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FareProductUseImpl.java index a8d374dda4a..8d9c82bdf63 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FareProductUseImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FareProductUseImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.fare.FareProduct; import org.opentripplanner.model.fare.FareProductUse; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FeedImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java similarity index 90% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FeedImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java index 8db18f45700..7d7c62136b6 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/FeedImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; @@ -6,9 +6,9 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.routing.alertpatch.EntitySelector; import org.opentripplanner.routing.alertpatch.TransitAlert; import org.opentripplanner.routing.services.TransitAlertService; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/GeometryImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/GeometryImpl.java similarity index 82% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/GeometryImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/GeometryImpl.java index a1f7a4268eb..863e17f3544 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/GeometryImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/GeometryImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import org.locationtech.jts.geom.Geometry; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.framework.geometry.EncodedPolyline; public class GeometryImpl implements GraphQLDataFetchers.GraphQLGeometry { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/ItineraryImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/ItineraryImpl.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/ItineraryImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/ItineraryImpl.java index 5ea0ff8f895..afc78479de1 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/ItineraryImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/ItineraryImpl.java @@ -1,12 +1,12 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.NumberMapper; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.mapping.NumberMapper; import org.opentripplanner.model.SystemNotice; import org.opentripplanner.model.fare.ItineraryFares; import org.opentripplanner.model.plan.Itinerary; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/LegImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java similarity index 96% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/LegImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java index 8b1e0fa77f7..b13f6123d4d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/LegImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/LegImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; @@ -7,10 +7,10 @@ import java.util.stream.Collectors; import org.locationtech.jts.geom.Geometry; import org.opentripplanner.api.mapping.LocalDateMapper; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.NumberMapper; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.mapping.NumberMapper; import org.opentripplanner.ext.ridehailing.model.RideEstimate; import org.opentripplanner.ext.ridehailing.model.RideHailingLeg; import org.opentripplanner.framework.graphql.GraphQLUtils; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/MoneyImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/MoneyImpl.java similarity index 80% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/MoneyImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/MoneyImpl.java index 15f97ddb729..9dbebc13ff2 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/MoneyImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/MoneyImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.Currency; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.transit.model.basic.Money; public class MoneyImpl implements GraphQLDataFetchers.GraphQLMoney { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/NodeTypeResolver.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/NodeTypeResolver.java similarity index 98% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/NodeTypeResolver.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/NodeTypeResolver.java index c63f4a6b611..437d75e03e9 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/NodeTypeResolver.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/NodeTypeResolver.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.TypeResolutionEnvironment; import graphql.language.InlineFragment; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/OpeningHoursImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/OpeningHoursImpl.java similarity index 85% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/OpeningHoursImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/OpeningHoursImpl.java index 382e2170a41..9960c90fcb6 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/OpeningHoursImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/OpeningHoursImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.calendar.openinghours.OHCalendar; import org.opentripplanner.model.calendar.openinghours.OsmOpeningHoursSupport; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PatternImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java similarity index 96% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PatternImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java index f38a024b721..ad16e8718d2 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PatternImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PatternImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import gnu.trove.set.TIntSet; import graphql.relay.Relay; @@ -14,9 +14,9 @@ import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.LineString; import org.opentripplanner.api.support.SemanticHash; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.framework.time.ServiceDateUtils; import org.opentripplanner.routing.alertpatch.EntitySelector; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlaceImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlaceImpl.java similarity index 92% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlaceImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlaceImpl.java index c9a40debbb2..ce3ca0986b1 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlaceImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlaceImpl.java @@ -1,11 +1,11 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLVertexType; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopPosition; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopPosition.PositionAtStop; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLVertexType; +import org.opentripplanner.apis.gtfs.model.StopPosition; +import org.opentripplanner.apis.gtfs.model.StopPosition.PositionAtStop; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.model.plan.Place; import org.opentripplanner.model.plan.StopArrival; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlaceInterfaceTypeResolver.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlaceInterfaceTypeResolver.java similarity index 77% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlaceInterfaceTypeResolver.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlaceInterfaceTypeResolver.java index d79e758cd4c..67ec004759d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlaceInterfaceTypeResolver.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlaceInterfaceTypeResolver.java @@ -1,6 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; - -import static org.opentripplanner.ext.gtfsgraphqlapi.datafetchers.NodeTypeResolver.queryContainsFragment; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.TypeResolutionEnvironment; import graphql.schema.GraphQLObjectType; @@ -21,16 +19,22 @@ public GraphQLObjectType getType(TypeResolutionEnvironment environment) { if (o instanceof VehicleParking) { var vehicleParking = (VehicleParking) o; - if (queryContainsFragment("BikePark", environment) && vehicleParking.hasBicyclePlaces()) { + if ( + NodeTypeResolver.queryContainsFragment("BikePark", environment) && + vehicleParking.hasBicyclePlaces() + ) { return schema.getObjectType("BikePark"); } - if (queryContainsFragment("CarPark", environment) && vehicleParking.hasAnyCarPlaces()) { + if ( + NodeTypeResolver.queryContainsFragment("CarPark", environment) && + vehicleParking.hasAnyCarPlaces() + ) { return schema.getObjectType("CarPark"); } return schema.getObjectType("VehicleParking"); } if (o instanceof VehicleRentalStation) { - if (queryContainsFragment("BikeRentalStation", environment)) { + if (NodeTypeResolver.queryContainsFragment("BikeRentalStation", environment)) { return schema.getObjectType("BikeRentalStation"); } return schema.getObjectType("VehicleRentalStation"); diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlanImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlanImpl.java similarity index 96% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlanImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlanImpl.java index 064bd071dd6..4e5c4584495 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/PlanImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/PlanImpl.java @@ -1,11 +1,11 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.stream.Collectors; import org.opentripplanner.api.mapping.PlannerErrorMapper; import org.opentripplanner.api.resource.DebugOutput; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.plan.Itinerary; import org.opentripplanner.model.plan.StopArrival; import org.opentripplanner.model.plan.pagecursor.PageCursor; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/QueryTypeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java similarity index 97% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/QueryTypeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java index ad1907016e6..dfa4a60ce1c 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/QueryTypeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; -import static org.opentripplanner.ext.gtfsgraphqlapi.mapping.AlertCauseMapper.getGraphQLCause; -import static org.opentripplanner.ext.gtfsgraphqlapi.mapping.AlertEffectMapper.getGraphQLEffect; -import static org.opentripplanner.ext.gtfsgraphqlapi.mapping.SeverityMapper.getGraphQLSeverity; +import static org.opentripplanner.apis.gtfs.mapping.AlertCauseMapper.getGraphQLCause; +import static org.opentripplanner.apis.gtfs.mapping.AlertEffectMapper.getGraphQLEffect; +import static org.opentripplanner.apis.gtfs.mapping.SeverityMapper.getGraphQLSeverity; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimaps; @@ -24,15 +24,15 @@ import java.util.stream.Stream; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.GraphQLUtils; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLQueryTypeStopsByRadiusArgs; +import org.opentripplanner.apis.gtfs.mapping.RouteRequestMapper; import org.opentripplanner.ext.fares.impl.DefaultFareService; import org.opentripplanner.ext.fares.impl.GtfsFaresService; import org.opentripplanner.ext.fares.model.FareRuleSet; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLQueryTypeStopsByRadiusArgs; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.RouteRequestMapper; import org.opentripplanner.framework.time.ServiceDateUtils; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.gtfs.mapping.DirectionMapper; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RentalVehicleImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RentalVehicleImpl.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RentalVehicleImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RentalVehicleImpl.java index ead62691036..53c3ba1343d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RentalVehicleImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RentalVehicleImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.service.vehiclerental.model.RentalVehicleType; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; import org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RentalVehicleTypeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RentalVehicleTypeImpl.java similarity index 82% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RentalVehicleTypeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RentalVehicleTypeImpl.java index 04e3d8470a2..204410644b3 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RentalVehicleTypeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RentalVehicleTypeImpl.java @@ -1,10 +1,10 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers.GraphQLRentalVehicleType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLFormFactor; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLPropulsionType; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers.GraphQLRentalVehicleType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLFormFactor; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLPropulsionType; import org.opentripplanner.service.vehiclerental.model.RentalVehicleType; public class RentalVehicleTypeImpl implements GraphQLRentalVehicleType { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RideHailingEstimateImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RideHailingEstimateImpl.java similarity index 82% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RideHailingEstimateImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RideHailingEstimateImpl.java index 0b36f182fe1..9813a3324ca 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RideHailingEstimateImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RideHailingEstimateImpl.java @@ -1,10 +1,10 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.time.Duration; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.model.RideHailingProvider; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.model.RideHailingProvider; import org.opentripplanner.ext.ridehailing.model.RideEstimate; import org.opentripplanner.transit.model.basic.Money; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java similarity index 92% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java index 2453257cdf6..56775024e0b 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; @@ -7,13 +7,13 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.GraphQLUtils; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLBikesAllowed; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLTransitMode; +import org.opentripplanner.apis.gtfs.mapping.BikesAllowedMapper; import org.opentripplanner.routing.alertpatch.EntitySelector; import org.opentripplanner.routing.alertpatch.TransitAlert; import org.opentripplanner.routing.services.TransitAlertService; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteTypeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java similarity index 83% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteTypeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java index db1f2d95878..bd8b9a7e019 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RouteTypeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RouteTypeImpl.java @@ -1,11 +1,11 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.model.RouteTypeModel; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.model.RouteTypeModel; import org.opentripplanner.transit.model.network.Route; import org.opentripplanner.transit.model.organization.Agency; import org.opentripplanner.transit.service.TransitService; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RoutingErrorImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RoutingErrorImpl.java similarity index 75% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RoutingErrorImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RoutingErrorImpl.java index 88cb4142800..7c516930888 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/RoutingErrorImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RoutingErrorImpl.java @@ -1,12 +1,12 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; -import static org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils.toGraphQL; +import static org.opentripplanner.apis.gtfs.GraphQLUtils.toGraphQL; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import org.opentripplanner.api.mapping.PlannerErrorMapper; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.routing.api.response.RoutingError; public class RoutingErrorImpl implements GraphQLDataFetchers.GraphQLRoutingError { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopGeometriesImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopGeometriesImpl.java similarity index 82% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopGeometriesImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopGeometriesImpl.java index e1cbdfbe567..d463dfa2007 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopGeometriesImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopGeometriesImpl.java @@ -1,10 +1,10 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.ArrayList; import org.locationtech.jts.geom.Geometry; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers.GraphQLStopGeometries; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers.GraphQLStopGeometries; public class StopGeometriesImpl implements GraphQLStopGeometries { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java similarity index 92% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java index 99a6af7a140..9353027439b 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; @@ -14,12 +14,10 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLStopAlertType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.GraphQLUtils; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.framework.time.ServiceDateUtils; import org.opentripplanner.model.StopTimesInPattern; import org.opentripplanner.model.TripTimeOnDate; @@ -49,12 +47,12 @@ public DataFetcher> alerts() { FeedScopedId id = getValue(environment, StopLocation::getId, AbstractTransitEntity::getId); if (types != null) { Collection alerts = new ArrayList<>(); - if (types.contains(GraphQLStopAlertType.STOP)) { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.STOP)) { alerts.addAll(alertService.getStopAlerts(id)); } if ( - types.contains(GraphQLStopAlertType.STOP_ON_ROUTES) || - types.contains(GraphQLStopAlertType.STOP_ON_TRIPS) + types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_ROUTES) || + types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_TRIPS) ) { alerts.addAll( alertService @@ -66,12 +64,12 @@ public DataFetcher> alerts() { .stream() .anyMatch(entity -> ( - types.contains(GraphQLStopAlertType.STOP_ON_ROUTES) && + types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_ROUTES) && entity instanceof StopAndRoute stopAndRoute && stopAndRoute.stopId().equals(id) ) || ( - types.contains(GraphQLStopAlertType.STOP_ON_TRIPS) && + types.contains(GraphQLTypes.GraphQLStopAlertType.STOP_ON_TRIPS) && entity instanceof EntitySelector.StopAndTrip stopAndTrip && stopAndTrip.stopId().equals(id) ) @@ -81,12 +79,12 @@ public DataFetcher> alerts() { ); } if ( - types.contains(GraphQLStopAlertType.PATTERNS) || - types.contains(GraphQLStopAlertType.TRIPS) + types.contains(GraphQLTypes.GraphQLStopAlertType.PATTERNS) || + types.contains(GraphQLTypes.GraphQLStopAlertType.TRIPS) ) { getPatterns(environment) .forEach(pattern -> { - if (types.contains(GraphQLStopAlertType.PATTERNS)) { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.PATTERNS)) { alerts.addAll( alertService.getDirectionAndRouteAlerts( pattern.getDirection(), @@ -94,7 +92,7 @@ public DataFetcher> alerts() { ) ); } - if (types.contains(GraphQLStopAlertType.TRIPS)) { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.TRIPS)) { pattern .scheduledTripsAsStream() .forEach(trip -> alerts.addAll(alertService.getTripAlerts(trip.getId(), null))); @@ -102,15 +100,15 @@ public DataFetcher> alerts() { }); } if ( - types.contains(GraphQLStopAlertType.ROUTES) || - types.contains(GraphQLStopAlertType.AGENCIES_OF_ROUTES) + types.contains(GraphQLTypes.GraphQLStopAlertType.ROUTES) || + types.contains(GraphQLTypes.GraphQLStopAlertType.AGENCIES_OF_ROUTES) ) { getRoutes(environment) .forEach(route -> { - if (types.contains(GraphQLStopAlertType.ROUTES)) { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.ROUTES)) { alerts.addAll(alertService.getRouteAlerts(route.getId())); } - if (types.contains(GraphQLStopAlertType.AGENCIES_OF_ROUTES)) { + if (types.contains(GraphQLTypes.GraphQLStopAlertType.AGENCIES_OF_ROUTES)) { alerts.addAll(alertService.getAgencyAlerts(route.getAgency().getId())); } }); @@ -463,7 +461,7 @@ public DataFetcher vehicleType() { } @Override - public DataFetcher wheelchairBoarding() { + public DataFetcher wheelchairBoarding() { return environment -> { var boarding = getValue( environment, diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopOnRouteImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopOnRouteImpl.java similarity index 73% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopOnRouteImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopOnRouteImpl.java index e76a58d14d7..e1b7f814eb4 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopOnRouteImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopOnRouteImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnRouteModel; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.model.StopOnRouteModel; import org.opentripplanner.transit.model.network.Route; public class StopOnRouteImpl implements GraphQLDataFetchers.GraphQLStopOnRoute { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopOnTripImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopOnTripImpl.java similarity index 73% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopOnTripImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopOnTripImpl.java index 74c0469cbdd..aa96397d34c 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StopOnTripImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopOnTripImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnTripModel; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.model.StopOnTripModel; import org.opentripplanner.transit.model.timetable.Trip; public class StopOnTripImpl implements GraphQLDataFetchers.GraphQLStopOnTrip { diff --git a/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopRelationshipImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopRelationshipImpl.java new file mode 100644 index 00000000000..3625c025148 --- /dev/null +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopRelationshipImpl.java @@ -0,0 +1,29 @@ +package org.opentripplanner.apis.gtfs.datafetchers; + +import graphql.schema.DataFetcher; +import graphql.schema.DataFetchingEnvironment; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition.StopRelationship; + +public class StopRelationshipImpl implements GraphQLDataFetchers.GraphQLStopRelationship { + + @Override + public DataFetcher status() { + return env -> + switch (getSource(env).status()) { + case INCOMING_AT -> GraphQLTypes.GraphQLVehicleStopStatus.INCOMING_AT; + case IN_TRANSIT_TO -> GraphQLTypes.GraphQLVehicleStopStatus.IN_TRANSIT_TO; + case STOPPED_AT -> GraphQLTypes.GraphQLVehicleStopStatus.STOPPED_AT; + }; + } + + @Override + public DataFetcher stop() { + return env -> getSource(env).stop(); + } + + private StopRelationship getSource(DataFetchingEnvironment environment) { + return environment.getSource(); + } +} diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StoptimeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java similarity index 96% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StoptimeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java index 6632e10d74d..a74d4f9461d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StoptimeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.model.StopTime; import org.opentripplanner.model.TripTimeOnDate; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StoptimesInPatternImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimesInPatternImpl.java similarity index 83% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StoptimesInPatternImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimesInPatternImpl.java index ecbaf7c24d8..6f76e8fee71 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/StoptimesInPatternImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimesInPatternImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.StopTimesInPattern; import org.opentripplanner.model.TripTimeOnDate; import org.opentripplanner.transit.model.network.TripPattern; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/SystemNoticeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/SystemNoticeImpl.java similarity index 79% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/SystemNoticeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/SystemNoticeImpl.java index a108ef05e22..4721b41b9e1 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/SystemNoticeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/SystemNoticeImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.SystemNotice; public class SystemNoticeImpl implements GraphQLDataFetchers.GraphQLSystemNotice { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TicketTypeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TicketTypeImpl.java similarity index 91% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TicketTypeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TicketTypeImpl.java index c5012c693cf..1d1c0082126 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TicketTypeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TicketTypeImpl.java @@ -1,11 +1,11 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.ext.fares.model.FareRuleSet; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; public class TicketTypeImpl implements GraphQLDataFetchers.GraphQLTicketType { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TranslatedStringImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TranslatedStringImpl.java similarity index 80% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TranslatedStringImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TranslatedStringImpl.java index bdb874dcb66..2cb8bf2cb97 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TranslatedStringImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TranslatedStringImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.Map; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; public class TranslatedStringImpl implements GraphQLDataFetchers.GraphQLTranslatedString { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java similarity index 95% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java index adab6fe169d..3be84cb37de 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/TripImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; @@ -16,13 +16,12 @@ import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.LineString; import org.opentripplanner.api.support.SemanticHash; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLUtils; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.BikesAllowedMapper; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.GraphQLUtils; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLBikesAllowed; +import org.opentripplanner.apis.gtfs.mapping.BikesAllowedMapper; import org.opentripplanner.framework.time.ServiceDateUtils; import org.opentripplanner.model.Timetable; import org.opentripplanner.model.TripTimeOnDate; @@ -365,7 +364,7 @@ public DataFetcher tripShortName() { } @Override - public DataFetcher wheelchairAccessible() { + public DataFetcher wheelchairAccessible() { return environment -> GraphQLUtils.toGraphQL(getSource(environment).getWheelchairBoarding()); } diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/UnknownImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/UnknownImpl.java similarity index 66% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/UnknownImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/UnknownImpl.java index 7e9c5cc4b4a..afb41ae0e8a 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/UnknownImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/UnknownImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.model.UnknownModel; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.model.UnknownModel; public class UnknownImpl implements GraphQLDataFetchers.GraphQLUnknown { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehicleParkingImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehicleParkingImpl.java similarity index 95% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehicleParkingImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehicleParkingImpl.java index eb89c0ac816..0b55beac689 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehicleParkingImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehicleParkingImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.model.calendar.openinghours.OHCalendar; import org.opentripplanner.routing.vehicle_parking.VehicleParking; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehiclePositionImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehiclePositionImpl.java similarity index 86% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehiclePositionImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehiclePositionImpl.java index 861c4b61310..0118eaa4a1a 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehiclePositionImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehiclePositionImpl.java @@ -1,13 +1,13 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers.GraphQLVehiclePosition; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition; import org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition.StopRelationship; import org.opentripplanner.transit.model.timetable.Trip; -public class VehiclePositionImpl implements GraphQLVehiclePosition { +public class VehiclePositionImpl implements GraphQLDataFetchers.GraphQLVehiclePosition { @Override public DataFetcher heading() { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehicleRentalStationImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehicleRentalStationImpl.java similarity index 95% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehicleRentalStationImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehicleRentalStationImpl.java index be3dd2b86c5..c1256f15c3f 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/VehicleRentalStationImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/VehicleRentalStationImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace; import org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/debugOutputImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/debugOutputImpl.java similarity index 88% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/debugOutputImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/debugOutputImpl.java index 4ac67031ef8..aa6e24c04f9 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/debugOutputImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/debugOutputImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import org.opentripplanner.api.resource.DebugOutput; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; public class debugOutputImpl implements GraphQLDataFetchers.GraphQLDebugOutput { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/elevationProfileComponentImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/elevationProfileComponentImpl.java similarity index 81% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/elevationProfileComponentImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/elevationProfileComponentImpl.java index 8acd294fd3d..12cfd7eddc4 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/elevationProfileComponentImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/elevationProfileComponentImpl.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.model.plan.ElevationProfile; public class elevationProfileComponentImpl diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/fareComponentImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/fareComponentImpl.java similarity index 87% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/fareComponentImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/fareComponentImpl.java index 586e7b68dcf..a8c1b4d38f5 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/fareComponentImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/fareComponentImpl.java @@ -1,10 +1,10 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.stream.Collectors; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.routing.core.FareComponent; import org.opentripplanner.transit.model.network.Route; import org.opentripplanner.transit.service.TransitService; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/fareImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/fareImpl.java similarity index 87% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/fareImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/fareImpl.java index 2ff0aca03a8..e1986d215be 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/fareImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/fareImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import java.util.Map; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.routing.core.FareComponent; import org.opentripplanner.transit.model.basic.Money; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/placeAtDistanceImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/placeAtDistanceImpl.java similarity index 94% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/placeAtDistanceImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/placeAtDistanceImpl.java index 89489134b31..4c137cd3769 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/placeAtDistanceImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/placeAtDistanceImpl.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.execution.TypeResolutionParameters; import graphql.relay.Relay; @@ -9,7 +9,7 @@ import graphql.schema.GraphQLInterfaceType; import graphql.schema.GraphQLObjectType; import graphql.schema.TypeResolver; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.routing.graphfinder.PlaceAtDistance; public class placeAtDistanceImpl implements GraphQLDataFetchers.GraphQLPlaceAtDistance { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/serviceTimeRangeImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/serviceTimeRangeImpl.java similarity index 77% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/serviceTimeRangeImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/serviceTimeRangeImpl.java index 45d6356688b..fe0ec3f56ee 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/serviceTimeRangeImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/serviceTimeRangeImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.transit.service.TransitService; public class serviceTimeRangeImpl implements GraphQLDataFetchers.GraphQLServiceTimeRange { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/stepImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/stepImpl.java similarity index 78% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/stepImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/stepImpl.java index ed724c13609..6bd51ae5f29 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/stepImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/stepImpl.java @@ -1,12 +1,11 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAbsoluteDirection; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRelativeDirection; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.DirectionMapper; -import org.opentripplanner.ext.gtfsgraphqlapi.mapping.StreetNoteMapper; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.mapping.DirectionMapper; +import org.opentripplanner.apis.gtfs.mapping.StreetNoteMapper; import org.opentripplanner.model.plan.ElevationProfile.Step; import org.opentripplanner.model.plan.WalkStep; import org.opentripplanner.routing.alertpatch.TransitAlert; @@ -14,7 +13,7 @@ public class stepImpl implements GraphQLDataFetchers.GraphQLStep { @Override - public DataFetcher absoluteDirection() { + public DataFetcher absoluteDirection() { return environment -> getSource(environment).getAbsoluteDirection().map(DirectionMapper::map).orElse(null); } @@ -65,7 +64,7 @@ public DataFetcher lon() { } @Override - public DataFetcher relativeDirection() { + public DataFetcher relativeDirection() { return environment -> DirectionMapper.map(getSource(environment).getRelativeDirection()); } diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/stopAtDistanceImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/stopAtDistanceImpl.java similarity index 86% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/stopAtDistanceImpl.java rename to src/main/java/org/opentripplanner/apis/gtfs/datafetchers/stopAtDistanceImpl.java index 1b599696181..192c4fa17c8 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/stopAtDistanceImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/stopAtDistanceImpl.java @@ -1,9 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import graphql.relay.Relay; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; import org.opentripplanner.routing.graphfinder.NearbyStop; public class stopAtDistanceImpl implements GraphQLDataFetchers.GraphQLStopAtDistance { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java b/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java similarity index 95% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java rename to src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java index 171e648dbcd..d0562215f70 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLDataFetchers.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java @@ -1,5 +1,5 @@ //THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -package org.opentripplanner.ext.gtfsgraphqlapi.generated; +package org.opentripplanner.apis.gtfs.generated; import graphql.relay.Connection; import graphql.relay.Edge; @@ -10,18 +10,18 @@ import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.opentripplanner.api.resource.DebugOutput; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAbsoluteDirection; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertCauseType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertEffectType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLBikesAllowed; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLInputField; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLRelativeDirection; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLRoutingErrorCode; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLTransitMode; +import org.opentripplanner.apis.gtfs.model.RideHailingProvider; +import org.opentripplanner.apis.gtfs.model.StopPosition; import org.opentripplanner.ext.fares.model.FareRuleSet; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAbsoluteDirection; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertCauseType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertEffectType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLInputField; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRelativeDirection; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRoutingErrorCode; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode; -import org.opentripplanner.ext.gtfsgraphqlapi.model.RideHailingProvider; -import org.opentripplanner.ext.gtfsgraphqlapi.model.StopPosition; import org.opentripplanner.ext.ridehailing.model.RideEstimate; import org.opentripplanner.model.StopTimesInPattern; import org.opentripplanner.model.SystemNotice; @@ -752,9 +752,9 @@ public interface GraphQLRentalVehicle { } public interface GraphQLRentalVehicleType { - public DataFetcher formFactor(); + public DataFetcher formFactor(); - public DataFetcher propulsionType(); + public DataFetcher propulsionType(); } /** An estimate for a ride on a hailed vehicle, like an Uber car. */ @@ -901,7 +901,7 @@ public interface GraphQLStop { public DataFetcher vehicleType(); - public DataFetcher wheelchairBoarding(); + public DataFetcher wheelchairBoarding(); public DataFetcher zoneId(); } @@ -1057,7 +1057,7 @@ public interface GraphQLTrip { public DataFetcher tripShortName(); - public DataFetcher wheelchairAccessible(); + public DataFetcher wheelchairAccessible(); } /** This is used for alert entities that we don't explicitly handle or they are missing. */ diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLTypes.java b/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java similarity index 99% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLTypes.java rename to src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java index 3861f0e49ef..3593145e274 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/GraphQLTypes.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java @@ -1,5 +1,5 @@ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -package org.opentripplanner.ext.gtfsgraphqlapi.generated; +package org.opentripplanner.apis.gtfs.generated; import java.util.List; import java.util.Map; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/README.md b/src/main/java/org/opentripplanner/apis/gtfs/generated/README.md similarity index 100% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/README.md rename to src/main/java/org/opentripplanner/apis/gtfs/generated/README.md diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml b/src/main/java/org/opentripplanner/apis/gtfs/generated/graphql-codegen.yml similarity index 70% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml rename to src/main/java/org/opentripplanner/apis/gtfs/generated/graphql-codegen.yml index 6605044b36a..14d00ec1bd4 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/graphql-codegen.yml +++ b/src/main/java/org/opentripplanner/apis/gtfs/generated/graphql-codegen.yml @@ -1,4 +1,4 @@ -schema: ../../../../../../resources/gtfsgraphqlapi/schema.graphqls +schema: ../../../../../../resources/org/opentripplanner/apis/gtfs/schema.graphqls generates: GraphQLTypes.java: @@ -18,7 +18,7 @@ generates: className: GraphQLDataFetchers config: - package: org.opentripplanner.ext.gtfsgraphqlapi.generated + package: org.opentripplanner.apis.gtfs.generated typesPrefix: GraphQL scalars: ID: graphql.relay.Relay.ResolvedGlobalId @@ -27,20 +27,20 @@ config: GeoJson: org.locationtech.jts.geom.Geometry Duration: java.time.Duration mappers: - AbsoluteDirection: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAbsoluteDirection#GraphQLAbsoluteDirection + AbsoluteDirection: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAbsoluteDirection#GraphQLAbsoluteDirection Agency: org.opentripplanner.transit.model.organization.Agency#Agency - RouteType: org.opentripplanner.ext.gtfsgraphqlapi.model.RouteTypeModel#RouteTypeModel + RouteType: org.opentripplanner.apis.gtfs.model.RouteTypeModel#RouteTypeModel Alert: org.opentripplanner.routing.alertpatch.TransitAlert#TransitAlert - AlertCauseType: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertCauseType#GraphQLAlertCauseType - AlertEffectType: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertEffectType#GraphQLAlertEffectType - AlertSeverityLevelType: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertSeverityLevelType#GraphQLAlertSeverityLevelType + AlertCauseType: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertCauseType#GraphQLAlertCauseType + AlertEffectType: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertEffectType#GraphQLAlertEffectType + AlertSeverityLevelType: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertSeverityLevelType#GraphQLAlertSeverityLevelType BikePark: org.opentripplanner.routing.vehicle_parking.VehicleParking#VehicleParking BikeRentalStation: org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace#VehicleRentalPlace BikeRentalStationUris: org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris#VehicleRentalStationUris VehicleRentalStation: org.opentripplanner.service.vehiclerental.model.VehicleRentalStation#VehicleRentalStation RentalVehicle: org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle#VehicleRentalVehicle VehicleRentalUris: org.opentripplanner.service.vehiclerental.model.VehicleRentalStationUris#VehicleRentalStationUris - BikesAllowed: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed#GraphQLBikesAllowed + BikesAllowed: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLBikesAllowed#GraphQLBikesAllowed BookingInfo: org.opentripplanner.model.BookingInfo BookingTime: org.opentripplanner.model.BookingTime CarPark: org.opentripplanner.routing.vehicle_parking.VehicleParking#VehicleParking @@ -54,11 +54,11 @@ config: fareComponent: org.opentripplanner.routing.core.FareComponent#FareComponent Feed: String Geometry: org.locationtech.jts.geom.Geometry#Geometry - InputField: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLInputField#GraphQLInputField + InputField: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLInputField#GraphQLInputField Itinerary: org.opentripplanner.model.plan.Itinerary#Itinerary Leg: org.opentripplanner.model.plan.Leg#Leg Mode: String - TransitMode: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLTransitMode#GraphQLTransitMode + TransitMode: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLTransitMode#GraphQLTransitMode PageInfo: Object Pattern: org.opentripplanner.transit.model.network.TripPattern#TripPattern PickupDropoffType: String @@ -68,24 +68,24 @@ config: placeAtDistanceEdge: graphql.relay.Edge#Edge Plan: graphql.execution.DataFetcherResult RealtimeState: String - RelativeDirection: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRelativeDirection#GraphQLRelativeDirection + RelativeDirection: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLRelativeDirection#GraphQLRelativeDirection Route: org.opentripplanner.transit.model.network.Route#Route RoutingError: org.opentripplanner.routing.api.response.RoutingError#RoutingError - RoutingErrorCode: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRoutingErrorCode#GraphQLRoutingErrorCode + RoutingErrorCode: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLRoutingErrorCode#GraphQLRoutingErrorCode serviceTimeRange: Object step: org.opentripplanner.model.plan.WalkStep#WalkStep Stop: Object # Can be either Stop or Station stopAtDistance: org.opentripplanner.routing.graphfinder.NearbyStop#NearbyStop stopAtDistanceConnection: graphql.relay.Connection#Connection stopAtDistanceEdge: graphql.relay.Edge#Edge - StopOnRoute: org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnRouteModel#StopOnRouteModel - StopOnTrip: org.opentripplanner.ext.gtfsgraphqlapi.model.StopOnTripModel#StopOnTripModel + StopOnRoute: org.opentripplanner.apis.gtfs.model.StopOnRouteModel#StopOnRouteModel + StopOnTrip: org.opentripplanner.apis.gtfs.model.StopOnTripModel#StopOnTripModel Stoptime: org.opentripplanner.model.TripTimeOnDate#TripTimeOnDate StoptimesInPattern: org.opentripplanner.model.StopTimesInPattern#StopTimesInPattern TicketType: org.opentripplanner.ext.fares.model.FareRuleSet#FareRuleSet TranslatedString: java.util.Map#Map.Entry Trip: org.opentripplanner.transit.model.timetable.Trip#Trip - Unknown: org.opentripplanner.ext.gtfsgraphqlapi.model.UnknownModel#UnknownModel + Unknown: org.opentripplanner.apis.gtfs.model.UnknownModel#UnknownModel VehicleParking: org.opentripplanner.routing.vehicle_parking.VehicleParking#VehicleParking VehicleParkingSpaces: org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces#VehicleParkingSpaces VehicleParkingState: org.opentripplanner.routing.vehicle_parking.VehicleParkingState#VehicleParkingState @@ -93,17 +93,17 @@ config: SystemNotice: org.opentripplanner.model.SystemNotice#SystemNotice VehiclePosition: org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition#RealtimeVehiclePosition StopRelationship: org.opentripplanner.service.vehiclepositions.model.RealtimeVehiclePosition.StopRelationship#StopRelationship - WheelchairBoarding: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLWheelchairBoarding - FormFactor: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLFormFactor - PropulsionType: org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLPropulsionType + WheelchairBoarding: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLWheelchairBoarding + FormFactor: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLFormFactor + PropulsionType: org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLPropulsionType RentalVehicleType: org.opentripplanner.service.vehiclerental.model.RentalVehicleType#RentalVehicleType OpeningHours: org.opentripplanner.model.calendar.openinghours.OHCalendar#OHCalendar RideHailingEstimate: org.opentripplanner.ext.ridehailing.model.RideEstimate#RideEstimate - RideHailingProvider: org.opentripplanner.ext.gtfsgraphqlapi.model.RideHailingProvider#RideHailingProvider + RideHailingProvider: org.opentripplanner.apis.gtfs.model.RideHailingProvider#RideHailingProvider Currency: java.util.Currency#Currency Money: org.opentripplanner.transit.model.basic.Money#Money FareProductUse: org.opentripplanner.model.fare.FareProductUse#FareProductUse FareProduct: org.opentripplanner.model.fare.FareProduct#FareProduct FareMedium: org.opentripplanner.model.fare.FareMedium#FareMedium RiderCategory: org.opentripplanner.model.fare.RiderCategory#RiderCategory - StopPosition: org.opentripplanner.ext.gtfsgraphqlapi.model.StopPosition#StopPosition + StopPosition: org.opentripplanner.apis.gtfs.model.StopPosition#StopPosition diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/package.json b/src/main/java/org/opentripplanner/apis/gtfs/generated/package.json similarity index 100% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/package.json rename to src/main/java/org/opentripplanner/apis/gtfs/generated/package.json diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/yarn.lock b/src/main/java/org/opentripplanner/apis/gtfs/generated/yarn.lock similarity index 100% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/generated/yarn.lock rename to src/main/java/org/opentripplanner/apis/gtfs/generated/yarn.lock diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/AlertCauseMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/AlertCauseMapper.java similarity index 75% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/AlertCauseMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/AlertCauseMapper.java index f45bd8dd1d2..eff6479e93c 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/AlertCauseMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/AlertCauseMapper.java @@ -1,7 +1,7 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertCauseType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertCauseType; import org.opentripplanner.routing.alertpatch.AlertCause; /** @@ -13,9 +13,9 @@ public class AlertCauseMapper { * Returns GraphQL API string counter part for internal {@link AlertCause} enum. Defaults to * returning UNKNOWN_CAUSE. */ - public static GraphQLTypes.GraphQLAlertCauseType getGraphQLCause(AlertCause cause) { + public static GraphQLAlertCauseType getGraphQLCause(AlertCause cause) { if (cause == null) { - return GraphQLTypes.GraphQLAlertCauseType.UNKNOWN_CAUSE; + return GraphQLAlertCauseType.UNKNOWN_CAUSE; } return switch (cause) { case UNKNOWN_CAUSE -> GraphQLAlertCauseType.UNKNOWN_CAUSE; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/AlertEffectMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/AlertEffectMapper.java similarity index 86% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/AlertEffectMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/AlertEffectMapper.java index 232c3e3e663..022dd6cde26 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/AlertEffectMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/AlertEffectMapper.java @@ -1,6 +1,7 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertEffectType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertEffectType; import org.opentripplanner.routing.alertpatch.AlertEffect; /** diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/BikesAllowedMapper.java similarity index 74% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/BikesAllowedMapper.java index ad7019ac343..cd04601d599 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/BikesAllowedMapper.java @@ -1,7 +1,7 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import javax.annotation.Nonnull; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLBikesAllowed; import org.opentripplanner.transit.model.network.BikeAccess; public class BikesAllowedMapper { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/DirectionMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapper.java similarity index 87% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/DirectionMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapper.java index 3a906601cbd..1deb6e3bb0e 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/DirectionMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapper.java @@ -1,8 +1,9 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import javax.annotation.Nonnull; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAbsoluteDirection; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLRelativeDirection; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAbsoluteDirection; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLRelativeDirection; import org.opentripplanner.model.plan.AbsoluteDirection; import org.opentripplanner.model.plan.RelativeDirection; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/NumberMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/NumberMapper.java similarity index 84% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/NumberMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/NumberMapper.java index 877baad8105..ddb6bf31a03 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/NumberMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/NumberMapper.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import javax.annotation.Nullable; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/RouteRequestMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/RouteRequestMapper.java similarity index 99% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/RouteRequestMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/RouteRequestMapper.java index 0c45851d9a1..9b8d8e02dec 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/RouteRequestMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/RouteRequestMapper.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import graphql.schema.DataFetchingEnvironment; import java.time.Duration; @@ -15,7 +15,7 @@ import org.opentripplanner.api.common.LocationStringParser; import org.opentripplanner.api.parameter.QualifiedMode; import org.opentripplanner.api.parameter.QualifiedModeSet; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; import org.opentripplanner.framework.graphql.GraphQLUtils; import org.opentripplanner.model.GenericLocation; import org.opentripplanner.routing.api.request.RouteRequest; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/SeverityMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/SeverityMapper.java similarity index 75% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/SeverityMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/SeverityMapper.java index fb2d5d6f03a..27bcca99e57 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/SeverityMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/SeverityMapper.java @@ -1,6 +1,6 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes.GraphQLAlertSeverityLevelType; import org.opentripplanner.routing.alertpatch.AlertSeverity; /** @@ -9,7 +9,7 @@ public class SeverityMapper { /** - * Returns GraphQL API string counter part for internal {@link AlertSeverity} enum. Defaults + * Returns GraphQL API counterpart for internal {@link AlertSeverity} enum. Defaults * to returning UNKNOWN_SEVERITY. */ public static GraphQLAlertSeverityLevelType getGraphQLSeverity(AlertSeverity severity) { diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/StreetNoteMapper.java b/src/main/java/org/opentripplanner/apis/gtfs/mapping/StreetNoteMapper.java similarity index 95% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/StreetNoteMapper.java rename to src/main/java/org/opentripplanner/apis/gtfs/mapping/StreetNoteMapper.java index 713d6766cc0..baa601c7448 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/StreetNoteMapper.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/mapping/StreetNoteMapper.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import org.opentripplanner.api.mapping.StreetNoteMaperMapper; import org.opentripplanner.framework.i18n.NonLocalizedString; diff --git a/src/main/java/org/opentripplanner/apis/gtfs/model/RideHailingProvider.java b/src/main/java/org/opentripplanner/apis/gtfs/model/RideHailingProvider.java new file mode 100644 index 00000000000..27f80ecb218 --- /dev/null +++ b/src/main/java/org/opentripplanner/apis/gtfs/model/RideHailingProvider.java @@ -0,0 +1,3 @@ +package org.opentripplanner.apis.gtfs.model; + +public record RideHailingProvider(String id) {} diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/RouteTypeModel.java b/src/main/java/org/opentripplanner/apis/gtfs/model/RouteTypeModel.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/RouteTypeModel.java rename to src/main/java/org/opentripplanner/apis/gtfs/model/RouteTypeModel.java index 25cf92d3078..8b428ef41e3 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/RouteTypeModel.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/model/RouteTypeModel.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.model; +package org.opentripplanner.apis.gtfs.model; import org.opentripplanner.transit.model.organization.Agency; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopOnRouteModel.java b/src/main/java/org/opentripplanner/apis/gtfs/model/StopOnRouteModel.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopOnRouteModel.java rename to src/main/java/org/opentripplanner/apis/gtfs/model/StopOnRouteModel.java index 56e079123d2..3d085f4e7eb 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopOnRouteModel.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/model/StopOnRouteModel.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.model; +package org.opentripplanner.apis.gtfs.model; import org.opentripplanner.transit.model.network.Route; import org.opentripplanner.transit.model.site.StopLocation; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopOnTripModel.java b/src/main/java/org/opentripplanner/apis/gtfs/model/StopOnTripModel.java similarity index 93% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopOnTripModel.java rename to src/main/java/org/opentripplanner/apis/gtfs/model/StopOnTripModel.java index 93c56e97171..1df27d8b86d 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopOnTripModel.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/model/StopOnTripModel.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.model; +package org.opentripplanner.apis.gtfs.model; import org.opentripplanner.transit.model.site.StopLocation; import org.opentripplanner.transit.model.timetable.Trip; diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopPosition.java b/src/main/java/org/opentripplanner/apis/gtfs/model/StopPosition.java similarity index 84% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopPosition.java rename to src/main/java/org/opentripplanner/apis/gtfs/model/StopPosition.java index e836bf1ae0f..6050953cc4e 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/StopPosition.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/model/StopPosition.java @@ -1,8 +1,8 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.model; +package org.opentripplanner.apis.gtfs.model; import graphql.TypeResolutionEnvironment; import graphql.schema.GraphQLObjectType; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLDataFetchers; +import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers; public interface StopPosition extends GraphQLDataFetchers.GraphQLStopPosition { record PositionAtStop(int position) implements StopPosition {} diff --git a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/UnknownModel.java b/src/main/java/org/opentripplanner/apis/gtfs/model/UnknownModel.java similarity index 87% rename from src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/UnknownModel.java rename to src/main/java/org/opentripplanner/apis/gtfs/model/UnknownModel.java index 5ab9b40c1a5..d5c70c70dce 100644 --- a/src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/model/UnknownModel.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/model/UnknownModel.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.model; +package org.opentripplanner.apis.gtfs.model; /** * Class for unknown entities. Either no entity was defined or an entity that we don't support yet diff --git a/src/main/java/org/opentripplanner/framework/application/OTPFeature.java b/src/main/java/org/opentripplanner/framework/application/OTPFeature.java index 0854032a665..0652fb667a8 100644 --- a/src/main/java/org/opentripplanner/framework/application/OTPFeature.java +++ b/src/main/java/org/opentripplanner/framework/application/OTPFeature.java @@ -29,7 +29,7 @@ public enum OTPFeature { ), DebugClient(true, false, "Enable the debug web client located at the root of the web server."), FloatingBike(true, false, "Enable floating bike routing."), - GtfsGraphQlApi(true, true, "Enable GTFS GraphQL API."), + GtfsGraphQlApi(true, false, "Enable GTFS GraphQL API."), /** * If this feature flag is switched on, then the minimum transfer time is not the minimum transfer * time, but the definitive transfer time. Use this to override what we think the transfer will diff --git a/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java b/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java index b440ac32979..27725f5ddf4 100644 --- a/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java +++ b/src/main/java/org/opentripplanner/framework/geometry/GeometryUtils.java @@ -249,7 +249,7 @@ public static Geometry convertGeoJsonToJtsGeometry(GeoJsonObject geoJsonGeom) int i = 0; for (List geoJsonPath : geoJsonMultiLineString.getCoordinates()) { org.geojson.LineString geoJsonLineString = new org.geojson.LineString( - geoJsonPath.toArray(new LngLatAlt[geoJsonPath.size()]) + geoJsonPath.toArray(new LngLatAlt[0]) ); jtsLineStrings[i++] = (LineString) convertGeoJsonToJtsGeometry(geoJsonLineString); } diff --git a/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java b/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java index aa8bd3d5f69..bb602adb472 100644 --- a/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java +++ b/src/main/java/org/opentripplanner/framework/io/JsonDataListDownloader.java @@ -89,7 +89,7 @@ private List parseJSON(InputStream dataStream) throws IllegalArgumentExceptio ObjectMapper mapper = new ObjectMapper(); JsonNode rootNode = mapper.readTree(rentalString); - if (!jsonParsePath.equals("")) { + if (!jsonParsePath.isEmpty()) { String delimiter = "/"; String[] parseElement = jsonParsePath.split(delimiter); for (String s : parseElement) { diff --git a/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java b/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java index 360ad9f5865..17b0f9d5367 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/geometry/GeometryProcessor.java @@ -80,7 +80,7 @@ public List createHopGeometries(Trip trip) { if ( trip.getShapeId() == null || trip.getShapeId().getId() == null || - trip.getShapeId().getId().equals("") + trip.getShapeId().getId().isEmpty() ) { return null; } diff --git a/src/main/java/org/opentripplanner/graph_builder/module/interlining/InterlineProcessor.java b/src/main/java/org/opentripplanner/graph_builder/module/interlining/InterlineProcessor.java index dae2f54f1d5..25aaa8413b6 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/interlining/InterlineProcessor.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/interlining/InterlineProcessor.java @@ -53,13 +53,19 @@ public InterlineProcessor( this.staySeatedNotAllowed = staySeatedNotAllowed; this.maxInterlineDistance = maxInterlineDistance > 0 ? maxInterlineDistance : 200; this.issueStore = issueStore; - this.transitServiceStart = calendarServiceData.getFirstDate(); + this.transitServiceStart = calendarServiceData.getFirstDate().orElse(null); this.daysInTransitService = - (int) ChronoUnit.DAYS.between(transitServiceStart, calendarServiceData.getLastDate()) + 1; + calendarServiceData + .getLastDate() + .map(lastDate -> (int) ChronoUnit.DAYS.between(transitServiceStart, lastDate) + 1) + .orElse(0); this.calendarServiceData = calendarServiceData; } public List run(Collection tripPatterns) { + if (daysInTransitService == 0) { + return List.of(); + } var interlinedTrips = this.getInterlinedTrips(tripPatterns); var transfers = interlinedTrips .entries() diff --git a/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java index 6f35bc59ab6..d3024a144f5 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java @@ -119,9 +119,7 @@ public void buildGraph() { areas.add(ae.getArea()); } for (AreaEdgeList a : areas) { - for (Vertex v : a.visibilityVertices()) { - visibilityVertices.add(v); - } + visibilityVertices.addAll(a.visibilityVertices()); } int removed = 0; diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java index fd3f697a8e1..a7bcc9ccb94 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/osm/AreaGroup.java @@ -66,9 +66,7 @@ public AreaGroup(Collection areas) { } } GeometryFactory geometryFactory = GeometryUtils.getGeometryFactory(); - Geometry allPolygons = geometryFactory.createMultiPolygon( - allRings.toArray(new Polygon[allRings.size()]) - ); + Geometry allPolygons = geometryFactory.createMultiPolygon(allRings.toArray(new Polygon[0])); this.union = allPolygons.union(); if (this.union instanceof GeometryCollection coll) { diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmFilter.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmFilter.java deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java index 1f54820a912..9cc15d191fc 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmModule.java @@ -30,6 +30,7 @@ import org.opentripplanner.street.model.StreetTraversalPermission; import org.opentripplanner.street.model.edge.StreetEdge; import org.opentripplanner.street.model.edge.StreetEdgeBuilder; +import org.opentripplanner.street.model.vertex.BarrierVertex; import org.opentripplanner.street.model.vertex.IntersectionVertex; import org.opentripplanner.street.model.vertex.Vertex; import org.slf4j.Logger; @@ -143,6 +144,7 @@ private void build() { buildBasicGraph(); buildWalkableAreas(!params.areaVisibility()); + validateBarriers(); if (params.staticParkAndRide()) { List areaGroups = groupAreas(osmdb.getParkAndRideAreas()); @@ -400,6 +402,11 @@ private void buildBasicGraph() { LOG.info(progress.completeMessage()); } + private void validateBarriers() { + List vertices = graph.getVerticesOfType(BarrierVertex.class); + vertices.forEach(bv -> bv.makeBarrierAtEndReachable()); + } + private void setWayName(OSMWithTags way) { if (!way.hasTag("name")) { I18NString creativeName = way.getOsmProvider().getWayPropertySet().getCreativeNameForWay(way); diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java index 1c126809501..9804c2d646f 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/osm/Ring.java @@ -115,7 +115,7 @@ private Polygon calculateJtsPolygon() { lrholelist.add(ring); } } - LinearRing[] lrholes = lrholelist.toArray(new LinearRing[lrholelist.size()]); + LinearRing[] lrholes = lrholelist.toArray(new LinearRing[0]); return factory.createPolygon(shell, lrholes); } diff --git a/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java b/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java index 206cfbd3f13..6d5e635d59c 100644 --- a/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java +++ b/src/main/java/org/opentripplanner/inspector/raster/NoThruTrafficEdgeRenderer.java @@ -47,7 +47,7 @@ public Optional renderEdge(Edge e) { label += " car"; colorIndex += 4; } - if (!label.equals("")) { + if (!label.isEmpty()) { label = "No" + label + " thru traffic"; } diff --git a/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java b/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java index 374993b1433..b007fa08ea1 100644 --- a/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java +++ b/src/main/java/org/opentripplanner/model/calendar/CalendarServiceData.java @@ -73,20 +73,12 @@ public void add(CalendarServiceData other) { } } - public LocalDate getFirstDate() { - return serviceIdsByDate - .keySet() - .stream() - .min(LocalDate::compareTo) - .orElseThrow(() -> new IllegalStateException("No service data is available")); + public Optional getFirstDate() { + return serviceIdsByDate.keySet().stream().min(LocalDate::compareTo); } - public LocalDate getLastDate() { - return serviceIdsByDate - .keySet() - .stream() - .max(LocalDate::compareTo) - .orElseThrow(() -> new IllegalStateException("No service data is available")); + public Optional getLastDate() { + return serviceIdsByDate.keySet().stream().max(LocalDate::compareTo); } /* private methods */ diff --git a/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java b/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java index bb71db1ecae..0f9f815efe6 100644 --- a/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java +++ b/src/main/java/org/opentripplanner/model/fare/ItineraryFares.java @@ -1,5 +1,6 @@ package org.opentripplanner.model.fare; +import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; @@ -10,6 +11,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opentripplanner.framework.lang.Sandbox; import org.opentripplanner.framework.tostring.ToStringBuilder; @@ -102,24 +104,6 @@ public void addFare(FareType fareType, Money money) { @Deprecated public void addFareComponent(FareType fareType, List components) { this.components.replaceValues(fareType, components); - - for (var c : components) { - var firstLegStartTime = c.legs().get(0).getStartTime(); - for (var leg : c.legs()) { - final FareProduct fareProduct = new FareProduct( - c.fareId(), - fareType.name(), - c.price(), - null, - null, - null - ); - legProducts.put( - leg, - new FareProductUse(fareProduct.uniqueInstanceId(firstLegStartTime), fareProduct) - ); - } - } } /** @@ -203,4 +187,33 @@ public void addFareProduct(Leg leg, FareProduct fareProduct) { public void addFareProduct(Leg leg, Collection fareProduct) { fareProduct.forEach(fp -> addFareProduct(leg, fp)); } + + /** + * Convert the fare received via the deprecated {@link FareComponent} to leg products. This + * inverts the relationship: + * - fare component has several legs + * - leg product is a mapping from leg to a list of fare products + */ + @Nonnull + public Multimap legProductsFromComponents() { + Multimap legProductsFromComponents = HashMultimap.create(); + for (var type : getFareTypes()) { + var components = getComponents(type); + + for (var c : components) { + var firstLegStartTime = c.legs().get(0).getStartTime(); + for (var leg : c.legs()) { + final FareProduct fareProduct = FareProduct + .of(c.fareId(), type.name(), c.price()) + .build(); + + legProductsFromComponents.put( + leg, + new FareProductUse(fareProduct.uniqueInstanceId(firstLegStartTime), fareProduct) + ); + } + } + } + return legProductsFromComponents; + } } diff --git a/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java b/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java index c8c87f383d0..9aef9e4bd01 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java +++ b/src/main/java/org/opentripplanner/openstreetmap/model/OSMLevel.java @@ -69,7 +69,7 @@ public static OSMLevel fromString( /* get short and long level names by splitting on = character */ String shortName = ""; String longName = ""; - Integer indexEquals = spec.indexOf('='); + int indexEquals = spec.indexOf('='); if (indexEquals >= 1) { shortName = spec.substring(0, indexEquals); longName = spec.substring(indexEquals + 1); diff --git a/src/main/java/org/opentripplanner/openstreetmap/model/OSMNode.java b/src/main/java/org/opentripplanner/openstreetmap/model/OSMNode.java index 53a47298dae..a1897d87124 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/model/OSMNode.java +++ b/src/main/java/org/opentripplanner/openstreetmap/model/OSMNode.java @@ -1,9 +1,13 @@ package org.opentripplanner.openstreetmap.model; +import java.util.Set; import org.locationtech.jts.geom.Coordinate; +import org.opentripplanner.street.model.StreetTraversalPermission; public class OSMNode extends OSMWithTags { + static final Set MOTOR_VEHICLE_BARRIERS = Set.of("bollard", "bar", "chain"); + public double lat; public double lon; @@ -34,13 +38,12 @@ public boolean hasCrossingTrafficLight() { return hasTag("crossing") && "traffic_signals".equals(getTag("crossing")); } - /** - * Checks if this node is bollard + /* Checks if this node is a barrier which prevents motor vehicle traffic * * @return true if it is */ - public boolean isBollard() { - return isTag("barrier", "bollard"); + public boolean isMotorVehicleBarrier() { + return isOneOfTags("barrier", MOTOR_VEHICLE_BARRIERS); } /** @@ -50,7 +53,7 @@ public boolean isBollard() { */ public boolean isBarrier() { return ( - isBollard() || + isMotorVehicleBarrier() || isPedestrianExplicitlyDenied() || isBicycleExplicitlyDenied() || isMotorcarExplicitlyDenied() || @@ -59,6 +62,18 @@ public boolean isBarrier() { ); } + /** + * Consider barrier tag in permissions. Leave the rest for the super class. + */ + @Override + public StreetTraversalPermission overridePermissions(StreetTraversalPermission def) { + StreetTraversalPermission permission = def; + if (isMotorVehicleBarrier()) { + permission = permission.remove(StreetTraversalPermission.CAR); + } + return super.overridePermissions(permission); + } + @Override public String url() { return String.format("https://www.openstreetmap.org/node/%d", getId()); diff --git a/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java b/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java index ed8819303d3..4b4883544d4 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java +++ b/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java @@ -46,6 +46,8 @@ public class OSMWithTags { "escape" ); + static final Set LEVEL_TAGS = Set.of("level", "layer"); + /* To save memory this is only created when an entity actually has tags. */ private Map tags; @@ -55,8 +57,6 @@ public class OSMWithTags { private OsmProvider osmProvider; - static final Set levelTags = Set.of("level", "layer"); - public static boolean isFalse(String tagValue) { return ("no".equals(tagValue) || "0".equals(tagValue) || "false".equals(tagValue)); } @@ -589,7 +589,7 @@ private boolean isTagDeniedAccess(String tagName) { * Some entities can have a semicolon separated list of levels (e.g. elevators) */ public Set getLevels() { - var levels = getMultiTagValues(levelTags); + var levels = getMultiTagValues(LEVEL_TAGS); if (levels.isEmpty()) { // default return Set.of("0"); diff --git a/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java b/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java index 06d5f895777..376614b1093 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java +++ b/src/main/java/org/opentripplanner/openstreetmap/wayproperty/WayPropertySet.java @@ -336,7 +336,7 @@ public Float getMetersSecondFromSpeed(String speed) { } String units = m.group(2); - if (units == null || units.equals("")) units = "kmh"; + if (units == null || units.isEmpty()) units = "kmh"; // we'll be doing quite a few string comparisons here units = units.intern(); diff --git a/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java b/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java index 5b0b95c7671..18e2966e9c5 100644 --- a/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java +++ b/src/main/java/org/opentripplanner/raptor/api/request/PassThroughPoint.java @@ -4,6 +4,7 @@ import java.util.BitSet; import java.util.Objects; import java.util.stream.IntStream; +import javax.annotation.Nullable; /** * A collection of stop indexes used to define a pass through-point. @@ -11,13 +12,15 @@ public class PassThroughPoint { private final int[] stops; + private final String name; - public PassThroughPoint(int[] stops) { + public PassThroughPoint(int[] stops, @Nullable String name) { Objects.requireNonNull(stops); if (stops.length == 0) { throw new IllegalArgumentException("At least one stop is required"); } this.stops = Arrays.copyOf(stops, stops.length); + this.name = name; } /** @@ -43,6 +46,8 @@ public int hashCode() { @Override public String toString() { - return "(stops: " + Arrays.toString(stops) + ")"; + return ( + (name == null ? "(" : "(name: '" + name + "', ") + "stops: " + Arrays.toString(stops) + ")" + ); } } diff --git a/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java b/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java index 497bac3bbfd..5f946b1d775 100644 --- a/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java +++ b/src/main/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapper.java @@ -348,9 +348,12 @@ private ZonedDateTime createZonedDateTime(int timeInSeconds) { * Include transfer leg in itinerary if the path is a "physical" path-leg between two stops, like * walk or bicycle. Do NOT include it if it represents a stay-seated transfer. See more details in * https://github.com/opentripplanner/OpenTripPlanner/issues/5086. + * TODO: the logic should be revisited when adding support for transfer between on-board flex + * access and transit. */ private boolean includeTransferInItinerary(Leg transitLegBeforeTransfer) { return ( + transitLegBeforeTransfer == null || transitLegBeforeTransfer.getTransferToNextLeg() == null || !transitLegBeforeTransfer.getTransferToNextLeg().getTransferConstraint().isStaySeated() ); diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index 729cf839a27..e938471d808 100644 --- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -1,5 +1,8 @@ package org.opentripplanner.routing.algorithm.raptoradapter.transit.mappers; +import static java.util.function.Predicate.not; +import static java.util.stream.Collectors.collectingAndThen; +import static java.util.stream.Collectors.toList; import static org.opentripplanner.raptor.api.request.Optimization.PARALLEL; import io.micrometer.core.instrument.MeterRegistry; @@ -7,16 +10,21 @@ import java.time.Instant; import java.time.ZonedDateTime; import java.util.Collection; +import java.util.List; +import java.util.Optional; import org.opentripplanner.framework.application.OTPFeature; import org.opentripplanner.raptor.api.model.RaptorAccessEgress; import org.opentripplanner.raptor.api.model.RaptorConstants; import org.opentripplanner.raptor.api.request.Optimization; +import org.opentripplanner.raptor.api.request.PassThroughPoint; +import org.opentripplanner.raptor.api.request.PassThroughPoints; import org.opentripplanner.raptor.api.request.RaptorRequest; import org.opentripplanner.raptor.api.request.RaptorRequestBuilder; import org.opentripplanner.raptor.rangeraptor.SystemErrDebugLogger; import org.opentripplanner.routing.algorithm.raptoradapter.router.performance.PerformanceTimersForRaptor; import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule; import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.transit.model.site.StopLocation; public class RaptorRequestMapper { @@ -105,12 +113,25 @@ private RaptorRequest doMap() { if (preferences.transfer().maxAdditionalTransfers() != null) { searchParams.numberOfAdditionalTransfers(preferences.transfer().maxAdditionalTransfers()); } + + final Optional passThroughPoints = request + .getPassThroughPoints() + .stream() + .map(p -> { + final int[] stops = p.stopLocations().stream().mapToInt(StopLocation::getIndex).toArray(); + return new PassThroughPoint(stops, p.name()); + }) + .collect(collectingAndThen(toList(), Optional::ofNullable)) + .filter(not(List::isEmpty)) + .map(PassThroughPoints::new); + builder.withMultiCriteria(mcBuilder -> { preferences .transit() .raptor() .relaxGeneralizedCostAtDestination() .ifPresent(mcBuilder::withRelaxCostAtDestination); + passThroughPoints.ifPresent(pt -> mcBuilder.withPassThroughPoints(pt)); }); for (Optimization optimization : preferences.transit().raptor().optimizations()) { diff --git a/src/main/java/org/opentripplanner/routing/api/request/PassThroughPoint.java b/src/main/java/org/opentripplanner/routing/api/request/PassThroughPoint.java new file mode 100644 index 00000000000..fa63c2e5668 --- /dev/null +++ b/src/main/java/org/opentripplanner/routing/api/request/PassThroughPoint.java @@ -0,0 +1,28 @@ +package org.opentripplanner.routing.api.request; + +import java.util.List; +import javax.annotation.Nullable; +import org.opentripplanner.transit.model.site.StopLocation; + +/** + * Defines one pass-through point which the journey must pass through. + */ +public record PassThroughPoint(List stopLocations, @Nullable String name) { + /** + * Get the one or multiple stops of the pass-through point, of which only one is required to be + * passed through. + */ + @Override + public List stopLocations() { + return stopLocations; + } + + /** + * Get an optional name of the pass-through point for debugging and logging. + */ + @Override + @Nullable + public String name() { + return name; + } +} diff --git a/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index 357afbe9ff8..4dabf5c0d86 100644 --- a/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -8,6 +8,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.function.Consumer; @@ -53,6 +54,8 @@ public class RouteRequest implements Cloneable, Serializable { private GenericLocation to; + private List passThroughPoints = Collections.emptyList(); + private Instant dateTime = Instant.now(); private Duration searchWindow; @@ -295,6 +298,14 @@ public void setTo(GenericLocation to) { this.to = to; } + public List getPassThroughPoints() { + return passThroughPoints; + } + + public void setPassThroughPoints(final List passThroughPoints) { + this.passThroughPoints = passThroughPoints; + } + /** * This is the time/duration in seconds from the earliest-departure-time(EDT) to * latest-departure-time(LDT). In case of a reverse search it will be the time from earliest to diff --git a/src/main/java/org/opentripplanner/service/vehiclerental/VehicleRentalService.java b/src/main/java/org/opentripplanner/service/vehiclerental/VehicleRentalService.java index 473f210ab4b..93fe12a1c7c 100644 --- a/src/main/java/org/opentripplanner/service/vehiclerental/VehicleRentalService.java +++ b/src/main/java/org/opentripplanner/service/vehiclerental/VehicleRentalService.java @@ -9,7 +9,7 @@ /** * The read-only service for getting information about rental vehicles. - * + *

* For writing data see {@link VehicleRentalRepository} */ public interface VehicleRentalService { @@ -32,7 +32,7 @@ public interface VehicleRentalService { * over a set, but we could use a spatial index if the number of vehicle rental stations is high * enough for performance to be a concern. */ - List getVehicleRentalStationForEnvelope( + List getVehicleRentalStationForEnvelope( double minLon, double minLat, double maxLon, diff --git a/src/main/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalService.java b/src/main/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalService.java index 1c888f8e21a..996f4cbcc9d 100644 --- a/src/main/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalService.java +++ b/src/main/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalService.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Stream; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Envelope; import org.opentripplanner.service.vehiclerental.VehicleRentalRepository; @@ -54,12 +55,7 @@ public VehicleRentalVehicle getVehicleRentalVehicle(FeedScopedId id) { @Override public List getVehicleRentalStations() { - return rentalPlaces - .values() - .stream() - .filter(VehicleRentalStation.class::isInstance) - .map(VehicleRentalStation.class::cast) - .toList(); + return getVehicleRentalStationsAsStream().toList(); } @Override @@ -100,7 +96,7 @@ public boolean hasRentalBikes() { } @Override - public List getVehicleRentalStationForEnvelope( + public List getVehicleRentalStationForEnvelope( double minLon, double minLat, double maxLon, @@ -111,10 +107,16 @@ public List getVehicleRentalStationForEnvelope( new Coordinate(maxLon, maxLat) ); + return getVehicleRentalStationsAsStream() + .filter(b -> envelope.contains(new Coordinate(b.getLongitude(), b.getLatitude()))) + .toList(); + } + + private Stream getVehicleRentalStationsAsStream() { return rentalPlaces .values() .stream() - .filter(b -> envelope.contains(new Coordinate(b.getLongitude(), b.getLatitude()))) - .toList(); + .filter(VehicleRentalStation.class::isInstance) + .map(VehicleRentalStation.class::cast); } } diff --git a/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java b/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java index 5722c9cc3a6..0b84c361fb4 100644 --- a/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java +++ b/src/main/java/org/opentripplanner/standalone/OtpStartupInfo.java @@ -36,7 +36,7 @@ private static String info() { public static void logInfo() { // This is good when aggregating logs across multiple load balanced instances of OTP // Hint: a regexp filter like "^OTP (START|SHUTTING)" will list nodes going up/down - LOG.info("OTP STARTING UP ({})", projectInfo().getVersionString()); + LOG.info("OTP STARTING UP ({}) using Java {}", projectInfo().getVersionString(), javaVersion()); Runtime .getRuntime() .addShutdownHook( @@ -56,4 +56,8 @@ public static void main(String[] args) { private static String line(String text) { return text + NEW_LINE; } + + private static String javaVersion() { + return System.getProperty("java.version"); + } } diff --git a/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java b/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java index 6f85f9d8598..cf02d127c52 100644 --- a/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java +++ b/src/main/java/org/opentripplanner/standalone/config/CommandLineParameters.java @@ -327,7 +327,7 @@ public static class PositiveInteger implements IParameterValidator { @Override public void validate(String name, String value) throws ParameterException { - Integer i = Integer.parseInt(value); + int i = Integer.parseInt(value); if (i <= 0) { String msg = String.format("%s must be a positive integer.", name); throw new ParameterException(msg); diff --git a/src/main/java/org/opentripplanner/street/model/vertex/BarrierVertex.java b/src/main/java/org/opentripplanner/street/model/vertex/BarrierVertex.java index 13b7335fda5..a7ad6d3830b 100644 --- a/src/main/java/org/opentripplanner/street/model/vertex/BarrierVertex.java +++ b/src/main/java/org/opentripplanner/street/model/vertex/BarrierVertex.java @@ -16,9 +16,8 @@ */ public class BarrierVertex extends OsmVertex { - //According to OSM default permissions are access=no, foot=yes, bicycle=yes public static final StreetTraversalPermission defaultBarrierPermissions = - StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE; + StreetTraversalPermission.ALL; private StreetTraversalPermission barrierPermissions; public BarrierVertex(double x, double y, long nodeId) { @@ -33,4 +32,36 @@ public StreetTraversalPermission getBarrierPermissions() { public void setBarrierPermissions(StreetTraversalPermission barrierPermissions) { this.barrierPermissions = barrierPermissions; } + + /* + * Barrier vertex at the end of a way does not make sense, because + * it creates discontinuity of routing in a single point. + * This method examines if traversal limitations can be removed. + * The logic examines edges referring to the vertex, so it should be + * applied only after the vertex has been linked to the graph. + */ + public void makeBarrierAtEndReachable() { + var edgeCount = this.getDegreeOut() + this.getDegreeIn(); + var needsFix = false; + if (edgeCount == 1) { + // only one edge connects the vertex, must be end point + needsFix = true; + } else if (edgeCount == 2) { + var out = this.getOutgoing(); + var in = this.getIncoming(); + if ( + // if only outgoing edges or incoming edges -> vertex does not act as a pass-through point and barrier makes no sense + out.isEmpty() || + in.isEmpty() || + // in+out edge pair connects the vertex to a single adjacent vertex -> must be street end point + out.iterator().next().getToVertex() == + in.iterator().next().getFromVertex() + ) { + needsFix = true; + } + } + if (needsFix) { + this.barrierPermissions = StreetTraversalPermission.ALL; + } + } } diff --git a/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java b/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java index 1dfc87e03b9..e25cb435887 100644 --- a/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java +++ b/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java @@ -77,7 +77,7 @@ public String enumValueDescription() { case CARPOOL -> """ Private car trips shared with others. - This is currently not specified in GTFS so we use the mode type values 1500-1560 which are in the range of private taxis. + This is currently not specified in GTFS so we use the mode type values 1550-1560 which are in the range of private taxis. """; case TAXI -> "Using a taxi service"; }; diff --git a/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java b/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java index 31c453056af..41e28e616d8 100644 --- a/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java +++ b/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java @@ -231,6 +231,11 @@ public StopLocation getStopLocation(FeedScopedId id) { return transitModel.getStopModel().getStopLocation(id); } + @Override + public Collection getStopOrChildStops(FeedScopedId id) { + return transitModel.getStopModel().findStopOrChildStops(id); + } + @Override public Collection listStopLocationGroups() { OTPRequestTimeoutException.checkForTimeout(); diff --git a/src/main/java/org/opentripplanner/transit/service/TransitService.java b/src/main/java/org/opentripplanner/transit/service/TransitService.java index 78c867ac83e..d0664aa292d 100644 --- a/src/main/java/org/opentripplanner/transit/service/TransitService.java +++ b/src/main/java/org/opentripplanner/transit/service/TransitService.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Stream; import org.locationtech.jts.geom.Envelope; import org.opentripplanner.ext.flex.FlexIndex; import org.opentripplanner.model.FeedInfo; @@ -98,6 +97,8 @@ public interface TransitService { StopLocation getStopLocation(FeedScopedId parseId); + Collection getStopOrChildStops(FeedScopedId id); + Collection listStopLocationGroups(); StopLocationsGroup getStopLocationsGroup(FeedScopedId id); diff --git a/src/ext/resources/gtfsgraphqlapi/schema.graphqls b/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls similarity index 100% rename from src/ext/resources/gtfsgraphqlapi/schema.graphqls rename to src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls diff --git a/src/test/java/org/opentripplanner/ConstantsForTests.java b/src/test/java/org/opentripplanner/ConstantsForTests.java index 6e719b487c5..b7bc4ccf7ac 100644 --- a/src/test/java/org/opentripplanner/ConstantsForTests.java +++ b/src/test/java/org/opentripplanner/ConstantsForTests.java @@ -39,6 +39,7 @@ import org.opentripplanner.standalone.config.OtpConfigLoader; import org.opentripplanner.street.search.TraverseMode; import org.opentripplanner.street.search.TraverseModeSet; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.service.StopModel; @@ -46,63 +47,33 @@ public class ConstantsForTests { - public static final String CALTRAIN_GTFS = "src/test/resources/gtfs/caltrain_gtfs.zip"; + private static final ResourceLoader RES = ResourceLoader.of(ConstantsForTests.class); - public static final String NETEX_MINIMAL = "src/test/resources/netex/netex_minimal.zip"; + public static final File CALTRAIN_GTFS = RES.file("/gtfs/caltrain_gtfs.zip"); - private static final String PORTLAND_GTFS = "src/test/resources/portland/portland.gtfs.zip"; + private static final File PORTLAND_GTFS = RES.file("/portland/portland.gtfs.zip"); - public static final String PORTLAND_CENTRAL_OSM = - "src/test/resources/portland/portland-central-filtered.osm.pbf"; + private static final File PORTLAND_CENTRAL_OSM = RES.file( + "/portland/portland-central-filtered.osm.pbf" + ); private static final String PORTLAND_BIKE_SHARE_CSV = "src/test/resources/portland/portland-vehicle-rental.csv"; - private static final String PORTLAND_NED = "src/test/resources/portland/portland-ned.tif"; - private static final String PORTLAND_NED_WITH_NODATA = "src/test/resources/portland/portland-ned-nodata.tif"; - private static final String OSLO_EAST_OSM = "src/test/resources/oslo-east-filtered.osm.pbf"; - - public static final String KCM_GTFS = "src/test/resources/gtfs/kcm_gtfs.zip"; + private static final File OSLO_EAST_OSM = RES.file("oslo-east-filtered.osm.pbf"); - public static final String FAKE_GTFS = "src/test/resources/testagency"; + public static final File SIMPLE_GTFS = RES.file("/gtfs/simple/"); - public static final String FARE_COMPONENT_GTFS = - "src/test/resources/gtfs/farecomponents.gtfs.zip"; - - public static final String SHAPE_DIST_GTFS = "src/test/resources/gtfs/shape_dist_traveled/"; + public static final File SHAPE_DIST_GTFS = RES.file("/gtfs/shape_dist_traveled/"); private static final String NETEX_NORDIC_DIR = "src/test/resources/netex/nordic"; private static final String NETEX_NORDIC_FILENAME = "netex_minimal.zip"; private static final String NETEX_EPIP_DIR = "src/test/resources/netex/epip/"; private static final String NETEX_EPIP_DATA_DIR = NETEX_EPIP_DIR + "netex_epip_minimal/"; - /* Stuttgart area, Germany */ - public static final String DEUFRINGEN_OSM = - "src/test/resources/germany/deufringen-minimal.osm.pbf"; - public static final String BOEBLINGEN_OSM = - "src/test/resources/germany/boeblingen-minimal.osm.pbf"; - public static final String VVS_BUS_764_ONLY = - "src/test/resources/germany/vvs-bus-764-only.gtfs.zip"; - public static final String VVS_BUS_751_ONLY = - "src/test/resources/germany/vvs-bus-751-only.gtfs.zip"; - public static final String HERRENBERG_HINDENBURG_STR_UNDER_CONSTRUCTION_OSM = - "src/test/resources/germany/herrenberg-hindenburgstr-under-construction.osm.pbf"; - public static final String HERRENBERG_BARRIER_GATES_OSM = - "src/test/resources/germany/herrenberg-barrier-gates.osm.pbf"; - public static final String HERRENBERG_OSM = - "src/test/resources/germany/herrenberg-minimal.osm.pbf"; - public static final String ISLAND_PRUNE_OSM = - "src/test/resources/germany/herrenberg-island-prune-nothru.osm.pbf"; - public static final String ADAPTIVE_PRUNE_OSM = "src/test/resources/isoiiluoto.pbf"; - - /* filenames encoded with cp437 and utf8 */ - public static final String UMLAUT_CP437_ZIP = "src/test/resources/umlaut-cp437.zip"; - public static final String UMLAUT_TXT = "ümläüt.txt"; - public static final String UMLAUT_UTF8_ZIP = "src/test/resources/umlaut-utf8.zip"; - public static final String UMLAUT_UTF8_ZIP_NO_EFS = "src/test/resources/umlaut-utf8-no-efs.zip"; private static final CompositeDataSource NETEX_MINIMAL_DATA_SOURCE = new ZipFileDataSource( new File(NETEX_NORDIC_DIR, NETEX_NORDIC_FILENAME), @@ -151,8 +122,7 @@ public static TestOtpModel buildNewPortlandGraph(boolean withElevation) { var transitModel = new TransitModel(new StopModel(), deduplicator); // Add street data from OSM { - File osmFile = new File(PORTLAND_CENTRAL_OSM); - OsmProvider osmProvider = new OsmProvider(osmFile, false); + OsmProvider osmProvider = new OsmProvider(PORTLAND_CENTRAL_OSM, false); OsmModule osmModule = OsmModule .of(osmProvider, graph) .withStaticParkAndRide(true) @@ -189,14 +159,13 @@ public static TestOtpModel buildNewPortlandGraph(boolean withElevation) { } } - public static TestOtpModel buildOsmGraph(String osmPath) { + public static TestOtpModel buildOsmGraph(File osmFile) { try { var deduplicator = new Deduplicator(); var stopModel = new StopModel(); var graph = new Graph(deduplicator); var transitModel = new TransitModel(stopModel, deduplicator); // Add street data from OSM - File osmFile = new File(osmPath); OsmProvider osmProvider = new OsmProvider(osmFile, true); OsmModule osmModule = OsmModule.of(osmProvider, graph).build(); osmModule.buildGraph(); @@ -206,7 +175,7 @@ public static TestOtpModel buildOsmGraph(String osmPath) { } } - public static TestOtpModel buildOsmAndGtfsGraph(String osmPath, String gtfsPath) { + public static TestOtpModel buildOsmAndGtfsGraph(File osmPath, File gtfsPath) { var otpModel = buildOsmGraph(osmPath); addGtfsToGraph( @@ -223,19 +192,16 @@ public static TestOtpModel buildOsmAndGtfsGraph(String osmPath, String gtfsPath) return otpModel; } - public static TestOtpModel buildGtfsGraph(String gtfsPath) { + public static TestOtpModel buildGtfsGraph(File gtfsPath) { return buildGtfsGraph(gtfsPath, new DefaultFareServiceFactory()); } - public static TestOtpModel buildGtfsGraph( - String gtfsPath, - FareServiceFactory fareServiceFactory - ) { + public static TestOtpModel buildGtfsGraph(File gtfsFile, FareServiceFactory fareServiceFactory) { var deduplicator = new Deduplicator(); var stopModel = new StopModel(); var graph = new Graph(deduplicator); var transitModel = new TransitModel(stopModel, deduplicator); - addGtfsToGraph(graph, transitModel, gtfsPath, fareServiceFactory, null); + addGtfsToGraph(graph, transitModel, gtfsFile, fareServiceFactory, null); return new TestOtpModel(graph, transitModel); } @@ -247,9 +213,7 @@ public static TestOtpModel buildNewMinimalNetexGraph() { var transitModel = new TransitModel(stopModel, deduplicator); // Add street data from OSM { - File osmFile = new File(OSLO_EAST_OSM); - - OsmProvider osmProvider = new OsmProvider(osmFile, false); + OsmProvider osmProvider = new OsmProvider(OSLO_EAST_OSM, false); OsmModule osmModule = OsmModule.of(osmProvider, graph).build(); osmModule.buildGraph(); } @@ -298,11 +262,11 @@ public synchronized TestOtpModel getCachedPortlandGraphWithElevation() { public static void addGtfsToGraph( Graph graph, TransitModel transitModel, - String file, + File file, FareServiceFactory fareServiceFactory, @Nullable String feedId ) { - var bundle = new GtfsBundle(new File(file)); + var bundle = new GtfsBundle(file); bundle.setFeedId(new GtfsFeedId.Builder().id(feedId).build()); var module = new GtfsModule( diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLIndexTest.java b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIndexTest.java similarity index 97% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLIndexTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/GraphQLIndexTest.java index a55ccaca0fd..0013f7df202 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLIndexTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIndexTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotSame; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLIntegrationTest.java b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java similarity index 98% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLIntegrationTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java index c57a05735c0..bd3c10f491e 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLIntegrationTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -229,7 +229,7 @@ public TransitAlertService getTransitAlertService() { ); } - @FilePatternSource(pattern = "src/ext-test/resources/gtfsgraphqlapi/queries/*.graphql") + @FilePatternSource(pattern = "src/test/resources/org/opentripplanner/apis/gtfs/queries/*.graphql") @ParameterizedTest(name = "Check GraphQL query in {0}") void graphQL(Path path) throws IOException { var query = Files.readString(path); diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLScalarsTest.java b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLScalarsTest.java similarity index 96% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLScalarsTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/GraphQLScalarsTest.java index dbeebdfeded..90b35a31b9f 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/GraphQLScalarsTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLScalarsTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/TestRoutingService.java b/src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java similarity index 96% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/TestRoutingService.java rename to src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java index 714bfdbcdb8..57c965eb3f1 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/TestRoutingService.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/TestRoutingService.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi; +package org.opentripplanner.apis.gtfs; import java.time.Instant; import java.time.OffsetDateTime; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/QueryTypeImplTest.java b/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java similarity index 97% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/QueryTypeImplTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java index 9bec527bc78..e223b53844a 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/datafetchers/QueryTypeImplTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/QueryTypeImplTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.datafetchers; +package org.opentripplanner.apis.gtfs.datafetchers; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -6,7 +6,7 @@ import java.util.Map; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes; +import org.opentripplanner.apis.gtfs.generated.GraphQLTypes; import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.routing.alertpatch.AlertCause; import org.opentripplanner.routing.alertpatch.AlertEffect; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java b/src/test/java/org/opentripplanner/apis/gtfs/mapping/BikesAllowedMapperTest.java similarity index 89% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/mapping/BikesAllowedMapperTest.java index ba1b6a2a5f8..5ed267f1f4f 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/mapping/BikesAllowedMapperTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/DirectionMapperTest.java b/src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java similarity index 92% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/DirectionMapperTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java index f97a5e69772..2c69f3dca46 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/DirectionMapperTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/mapping/DirectionMapperTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/RouteRequestMapperTest.java b/src/test/java/org/opentripplanner/apis/gtfs/mapping/RouteRequestMapperTest.java similarity index 97% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/RouteRequestMapperTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/mapping/RouteRequestMapperTest.java index c9ea4666b06..c6e69cecf4f 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/RouteRequestMapperTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/mapping/RouteRequestMapperTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import static graphql.execution.ExecutionContextBuilder.newExecutionContextBuilder; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -19,9 +19,9 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.opentripplanner._support.time.ZoneIds; +import org.opentripplanner.apis.gtfs.GraphQLRequestContext; +import org.opentripplanner.apis.gtfs.TestRoutingService; import org.opentripplanner.ext.fares.impl.DefaultFareService; -import org.opentripplanner.ext.gtfsgraphqlapi.GraphQLRequestContext; -import org.opentripplanner.ext.gtfsgraphqlapi.TestRoutingService; import org.opentripplanner.model.plan.PlanTestConstants; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.preference.TimeSlopeSafetyTriangle; diff --git a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/StreetNoteMapperTest.java b/src/test/java/org/opentripplanner/apis/gtfs/mapping/StreetNoteMapperTest.java similarity index 97% rename from src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/StreetNoteMapperTest.java rename to src/test/java/org/opentripplanner/apis/gtfs/mapping/StreetNoteMapperTest.java index 5c7cd8be008..3ba6affb59e 100644 --- a/src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/StreetNoteMapperTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/mapping/StreetNoteMapperTest.java @@ -1,4 +1,4 @@ -package org.opentripplanner.ext.gtfsgraphqlapi.mapping; +package org.opentripplanner.apis.gtfs.mapping; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java b/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java index f050928ba92..1205179d28b 100644 --- a/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java +++ b/src/test/java/org/opentripplanner/astar/model/BinHeapTest.java @@ -73,9 +73,7 @@ public void testCompareHeaps() throws InterruptedException { // First determine the expected results using a plain old PriorityQueue expected = new ArrayList<>(N); PriorityQueue q = new PriorityQueue<>(N); - for (Integer j : input) { - q.add(j); - } + q.addAll(input); while (!q.isEmpty()) { expected.add(q.remove()); } diff --git a/src/test/java/org/opentripplanner/datastore/file/ZipFileDataSourceTest.java b/src/test/java/org/opentripplanner/datastore/file/ZipFileDataSourceTest.java index ba1fc8977eb..da46fc430b6 100644 --- a/src/test/java/org/opentripplanner/datastore/file/ZipFileDataSourceTest.java +++ b/src/test/java/org/opentripplanner/datastore/file/ZipFileDataSourceTest.java @@ -22,18 +22,24 @@ import org.opentripplanner.ConstantsForTests; import org.opentripplanner.datastore.api.CompositeDataSource; import org.opentripplanner.datastore.api.DataSource; +import org.opentripplanner.test.support.ResourceLoader; public class ZipFileDataSourceTest { // Sometime close to 2000-01-01 private static final long TIME = 30 * 365 * 24 * 60 * 60 * 1000L; - private static final String FILENAME = ConstantsForTests.CALTRAIN_GTFS; + private static final ResourceLoader RES = ResourceLoader.of(ZipFileDataSourceTest.class); + /* filenames encoded with cp437 and utf8 */ + public static final File UMLAUT_CP437_ZIP = RES.file("umlaut-cp437.zip"); + public static final String UMLAUT_TXT = "ümläüt.txt"; + public static final File UMLAUT_UTF8_ZIP = RES.file("umlaut-utf8.zip"); + public static final File UMLAUT_UTF8_ZIP_NO_EFS = RES.file("umlaut-utf8-no-efs.zip"); @Test public void testAccessorsForNoneExistingFile() throws IOException { // Given: - File target = new File(FILENAME); - File copyTarget = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; + File copyTarget = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipFileDataSource(target, GTFS); CompositeDataSource copySubject = new ZipFileDataSource(copyTarget, GTFS); String expectedPath = target.getPath(); @@ -62,7 +68,7 @@ public void testAccessorsForNoneExistingFile() throws IOException { @Test public void testIO() throws IOException { // Given: - File target = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipFileDataSource(target, GTFS); Collection content = subject.content(); @@ -91,7 +97,7 @@ public void testIO() throws IOException { @Test public void testEntryProperties() { // Given: - File target = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipFileDataSource(target, GTFS); DataSource entry = subject.entry("trips.txt"); @@ -108,7 +114,7 @@ public void testEntryProperties() { @Test public void testUnsupportedDelete() { // Given: - File target = new File(FILENAME); + var target = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipFileDataSource(target, GTFS); // When: delete entry is not implemented @@ -118,25 +124,22 @@ public void testUnsupportedDelete() { @Test public void testEntryEncoding() { // has worked before #4835, for verification remove the attempt to set to code page to cp437 - File target = new File(ConstantsForTests.UMLAUT_UTF8_ZIP); - CompositeDataSource subject = new ZipFileDataSource(target, GTFS); + CompositeDataSource subject = new ZipFileDataSource(UMLAUT_UTF8_ZIP, GTFS); DataSource entry = subject.content().iterator().next(); - assertEquals(ConstantsForTests.UMLAUT_TXT, entry.name()); + assertEquals(UMLAUT_TXT, entry.name()); // has worked before #4835, for verification remove the attempt to set to code page to cp437 - target = new File(ConstantsForTests.UMLAUT_UTF8_ZIP_NO_EFS); - subject = new ZipFileDataSource(target, GTFS); + subject = new ZipFileDataSource(UMLAUT_UTF8_ZIP_NO_EFS, GTFS); entry = subject.content().iterator().next(); - assertEquals(ConstantsForTests.UMLAUT_TXT, entry.name()); + assertEquals(UMLAUT_TXT, entry.name()); // only works after #4835, will fail with "Invalid CEN header (bad entry name)" when verifying - target = new File(ConstantsForTests.UMLAUT_CP437_ZIP); - subject = new ZipFileDataSource(target, GTFS); + subject = new ZipFileDataSource(UMLAUT_CP437_ZIP, GTFS); entry = subject.content().iterator().next(); - assertEquals(ConstantsForTests.UMLAUT_TXT, entry.name()); + assertEquals(UMLAUT_TXT, entry.name()); } /* @@ -147,14 +150,14 @@ public void testEntryEncoding() { public static void main(String[] args) throws FileNotFoundException, IOException { /* cp437 encoded file names in zip */ final ZipArchiveOutputStream zos = new ZipArchiveOutputStream( - new FileOutputStream(ConstantsForTests.UMLAUT_CP437_ZIP) + new FileOutputStream(UMLAUT_CP437_ZIP) ); /* set original ZIP character encoding aka OEM-US or DOS-US */ zos.setEncoding("Cp437"); final byte[] data = {}; - ZipArchiveEntry entry = new ZipArchiveEntry(ConstantsForTests.UMLAUT_TXT); + ZipArchiveEntry entry = new ZipArchiveEntry(UMLAUT_TXT); entry.setSize(data.length); entry.setTime(FileTime.fromMillis(0)); zos.putArchiveEntry(entry); @@ -165,12 +168,12 @@ public static void main(String[] args) throws FileNotFoundException, IOException /* utf-8 encoded file names in zip */ final ZipArchiveOutputStream zos2 = new ZipArchiveOutputStream( - new FileOutputStream(ConstantsForTests.UMLAUT_UTF8_ZIP) + new FileOutputStream(UMLAUT_UTF8_ZIP) ); /* explicitely set Apache Commons default for documentation */ zos2.setEncoding("utf-8"); - ZipArchiveEntry entry2 = new ZipArchiveEntry(ConstantsForTests.UMLAUT_TXT); + ZipArchiveEntry entry2 = new ZipArchiveEntry(UMLAUT_TXT); entry2.setSize(data.length); entry2.setTime(FileTime.fromMillis(0)); zos2.putArchiveEntry(entry2); @@ -185,14 +188,14 @@ public static void main(String[] args) throws FileNotFoundException, IOException * http://web.archive.org/web/20150718122844/https://blogs.oracle.com/xuemingshen/entry/non_utf_8_encoding_in */ final ZipArchiveOutputStream zos3 = new ZipArchiveOutputStream( - new FileOutputStream(ConstantsForTests.UMLAUT_UTF8_ZIP_NO_EFS) + new FileOutputStream(UMLAUT_UTF8_ZIP_NO_EFS) ); /* explicitely set Apache Commons default for documentation */ zos3.setEncoding("utf-8"); /* no EFS flag! */ zos3.setUseLanguageEncodingFlag(false); - ZipArchiveEntry entry3 = new ZipArchiveEntry(ConstantsForTests.UMLAUT_TXT); + ZipArchiveEntry entry3 = new ZipArchiveEntry(UMLAUT_TXT); entry3.setSize(data.length); entry3.setTime(FileTime.fromMillis(0)); zos3.putArchiveEntry(entry3); diff --git a/src/test/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecoratorTest.java b/src/test/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecoratorTest.java index b6d82edea41..09479d85478 100644 --- a/src/test/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecoratorTest.java +++ b/src/test/java/org/opentripplanner/datastore/file/ZipStreamDataSourceDecoratorTest.java @@ -21,7 +21,6 @@ class ZipStreamDataSourceDecoratorTest { private static final long TIME = 30 * 365 * 24 * 60 * 60 * 1000L; - private static final String FILENAME = ConstantsForTests.CALTRAIN_GTFS; static final List EXPECTED_ZIP_ENTRIES = List.of( "trips.txt", "agency.txt", @@ -61,8 +60,8 @@ class ZipStreamDataSourceDecoratorTest { @Test void testAccessorsForNoneExistingFile() throws IOException { // Given: - File target = new File(FILENAME); - File copyTarget = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; + File copyTarget = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipStreamDataSourceDecorator( new FileDataSource(target, GTFS) ); @@ -93,7 +92,7 @@ void testAccessorsForNoneExistingFile() throws IOException { @Test void testIO() throws IOException { // Given: - File target = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipStreamDataSourceDecorator( new FileDataSource(target, GTFS) ); @@ -119,7 +118,7 @@ void testIO() throws IOException { @Test void testMaxZipEntrySizeInMemory() throws IOException { - File target = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; // force offloading to disk by setting maxZipEntrySizeInMemory=1 CompositeDataSource subject = new ZipStreamDataSourceDecorator( new FileDataSource(target, GTFS), @@ -142,7 +141,7 @@ void testMaxZipEntrySizeInMemory() throws IOException { @Test void testEntryProperties() { // Given: - File target = new File(FILENAME); + File target = ConstantsForTests.CALTRAIN_GTFS; CompositeDataSource subject = new ZipStreamDataSourceDecorator( new FileDataSource(target, GTFS) ); diff --git a/src/test/java/org/opentripplanner/generate/doc/GraphQLTutorialDocTest.java b/src/test/java/org/opentripplanner/generate/doc/GraphQLTutorialDocTest.java index caba9a0e009..bf2b092e092 100644 --- a/src/test/java/org/opentripplanner/generate/doc/GraphQLTutorialDocTest.java +++ b/src/test/java/org/opentripplanner/generate/doc/GraphQLTutorialDocTest.java @@ -22,7 +22,7 @@ public class GraphQLTutorialDocTest { private static final File TEMPLATE = new File(TEMPLATE_ROOT, "GraphQL-Tutorial.md"); - private static final File OUT_FILE = new File(DOCS_ROOT, "GraphQL-Tutorial.md"); + private static final File OUT_FILE = new File(DOCS_ROOT + "/apis", "GraphQL-Tutorial.md"); /** * NOTE! This test updates the {@code docs/GraphQlTutorial.md} document based on the latest @@ -37,8 +37,8 @@ public void updateTutorialDoc() throws IOException { String doc = readFile(TEMPLATE); String original = readFile(OUT_FILE); - var routeQuery = getGraphQlQuery("gtfsgraphqlapi/queries/routes.graphql"); - var planQuery = getGraphQlQuery("gtfsgraphqlapi/queries/plan.graphql"); + var routeQuery = getGraphQlQuery("routes.graphql"); + var planQuery = getGraphQlQuery("plan.graphql"); doc = replaceSection(doc, "route-query", routeQuery); doc = replaceSection(doc, "plan-query", planQuery); @@ -49,7 +49,7 @@ public void updateTutorialDoc() throws IOException { @Nonnull private static String getGraphQlQuery(String resourceName) throws IOException { - var url = Resources.getResource(resourceName); + var url = Resources.getResource("org/opentripplanner/apis/gtfs/queries/" + resourceName); var query = TemplateUtil.graphQlExample(Resources.toString(url, StandardCharsets.UTF_8)); assertNotNull(query); return query; diff --git a/src/test/java/org/opentripplanner/graph_builder/module/GtfsModuleTest.java b/src/test/java/org/opentripplanner/graph_builder/module/GtfsModuleTest.java index 253e9882fc4..c628a14ad43 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/GtfsModuleTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/GtfsModuleTest.java @@ -3,10 +3,8 @@ import static graphql.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; -import java.io.File; import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -17,6 +15,7 @@ import org.opentripplanner.gtfs.graphbuilder.GtfsModule; import org.opentripplanner.model.calendar.ServiceDateInterval; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; @@ -27,7 +26,7 @@ class GtfsModuleTest { public void addShapesForFrequencyTrips() { var model = buildTestModel(); - var bundle = new GtfsBundle(new File(ConstantsForTests.FAKE_GTFS)); + var bundle = new GtfsBundle(ConstantsForTests.SIMPLE_GTFS); var module = new GtfsModule( List.of(bundle), model.transitModel, @@ -68,7 +67,7 @@ record TestModels(Graph graph, TransitModel transitModel) {} class Interlining { static GtfsBundle bundle(String feedId) { - var b = new GtfsBundle(new File("src/test/resources/gtfs/interlining")); + var b = new GtfsBundle(ResourceLoader.of(GtfsModuleTest.class).file("/gtfs/interlining")); b.setFeedId(new GtfsFeedId.Builder().id(feedId).build()); return b; } diff --git a/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java b/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java index 0195fa9f9ca..980c33d6164 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModuleTest.java @@ -9,7 +9,6 @@ import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; -import org.opentripplanner.ConstantsForTests; import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.graph_builder.module.osm.OsmModule; import org.opentripplanner.openstreetmap.OsmProvider; @@ -23,6 +22,7 @@ import org.opentripplanner.street.model.vertex.Vertex; import org.opentripplanner.street.model.vertex.VertexFactory; import org.opentripplanner.street.model.vertex.VertexLabel; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.test.support.VariableSource; import org.opentripplanner.transit.model._data.TransitModelForTest; import org.opentripplanner.transit.model.basic.TransitMode; @@ -37,7 +37,9 @@ */ class OsmBoardingLocationsModuleTest { - File file = new File(ConstantsForTests.HERRENBERG_OSM); + File file = ResourceLoader + .of(OsmBoardingLocationsModuleTest.class) + .file("herrenberg-minimal.osm.pbf"); RegularStop platform = TransitModelForTest .stop("de:08115:4512:4:101") .withCoordinate(48.59328, 8.86128) diff --git a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java index 57b8e018662..832045b6469 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java @@ -5,11 +5,11 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.opentripplanner.ConstantsForTests; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.graph_builder.module.osm.OsmModule; import org.opentripplanner.openstreetmap.OsmProvider; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; @@ -26,7 +26,7 @@ public class AdaptivePruningTest { @BeforeAll static void setup() { - graph = buildOsmGraph(ConstantsForTests.ADAPTIVE_PRUNE_OSM); + graph = buildOsmGraph(ResourceLoader.of(AdaptivePruningTest.class).file("isoiiluoto.pbf")); } @Test @@ -65,14 +65,13 @@ public void mainGraphIsNotRemoved() { ); } - private static Graph buildOsmGraph(String osmPath) { + private static Graph buildOsmGraph(File file) { try { var deduplicator = new Deduplicator(); var graph = new Graph(deduplicator); var transitModel = new TransitModel(new StopModel(), deduplicator); // Add street data from OSM - File osmFile = new File(osmPath); - OsmProvider osmProvider = new OsmProvider(osmFile, true); + OsmProvider osmProvider = new OsmProvider(file, true); OsmModule osmModule = OsmModule.of(osmProvider, graph).withEdgeNamer(new TestNamer()).build(); osmModule.buildGraph(); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java index 6fd7c752ee5..53a2d60fe0f 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java @@ -6,12 +6,12 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.opentripplanner.ConstantsForTests; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.graph_builder.module.osm.OsmModule; import org.opentripplanner.openstreetmap.OsmProvider; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.street.model.edge.StreetEdge; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; @@ -22,7 +22,12 @@ public class PruneNoThruIslandsTest { @BeforeAll static void setup() { - graph = buildOsmGraph(ConstantsForTests.ISLAND_PRUNE_OSM); + graph = + buildOsmGraph( + ResourceLoader + .of(PruneNoThruIslandsTest.class) + .file("herrenberg-island-prune-nothru.osm.pbf") + ); } @Test @@ -63,13 +68,12 @@ public void pruneFloatingBikeAndWalkIsland() { ); } - private static Graph buildOsmGraph(String osmPath) { + private static Graph buildOsmGraph(File osmFile) { try { var deduplicator = new Deduplicator(); var graph = new Graph(deduplicator); var transitModel = new TransitModel(new StopModel(), deduplicator); // Add street data from OSM - File osmFile = new File(osmPath); OsmProvider osmProvider = new OsmProvider(osmFile, true); OsmModule osmModule = OsmModule.of(osmProvider, graph).withEdgeNamer(new TestNamer()).build(); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java b/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java index 2c2f4092278..41a74fb2dd3 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/linking/LinkingTest.java @@ -3,12 +3,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.opentripplanner.graph_builder.module.FakeGraph.addExtraStops; -import static org.opentripplanner.graph_builder.module.FakeGraph.addRegularStopGrid; -import static org.opentripplanner.graph_builder.module.FakeGraph.buildGraphNoTransit; -import static org.opentripplanner.graph_builder.module.FakeGraph.link; +import static org.opentripplanner.graph_builder.module.linking.TestGraph.addExtraStops; +import static org.opentripplanner.graph_builder.module.linking.TestGraph.addRegularStopGrid; +import static org.opentripplanner.graph_builder.module.linking.TestGraph.link; -import java.net.URISyntaxException; +import java.io.File; import java.util.Comparator; import java.util.List; import org.junit.jupiter.api.Test; @@ -19,6 +18,8 @@ import org.opentripplanner.framework.geometry.GeometryUtils; import org.opentripplanner.framework.geometry.SphericalDistanceLibrary; import org.opentripplanner.framework.i18n.NonLocalizedString; +import org.opentripplanner.graph_builder.module.osm.OsmModule; +import org.opentripplanner.openstreetmap.OsmProvider; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.street.model.StreetTraversalPermission; import org.opentripplanner.street.model._data.StreetModelForTest; @@ -29,6 +30,9 @@ import org.opentripplanner.street.model.vertex.StreetVertex; import org.opentripplanner.street.model.vertex.TransitStopVertex; import org.opentripplanner.street.model.vertex.Vertex; +import org.opentripplanner.test.support.ResourceLoader; +import org.opentripplanner.transit.model.framework.Deduplicator; +import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; public class LinkingTest { @@ -106,7 +110,7 @@ public void testSplitting() { * We do this by building the graphs and then comparing the stop tree caches. */ @Test - public void testStopsLinkedIdentically() throws URISyntaxException { + public void testStopsLinkedIdentically() { // build the graph without the added stops TestOtpModel model = buildGraphNoTransit(); Graph g1 = model.graph(); @@ -143,6 +147,22 @@ public void testStopsLinkedIdentically() throws URISyntaxException { } } + /** Build a graph in Columbus, OH with no transit */ + public static TestOtpModel buildGraphNoTransit() { + var deduplicator = new Deduplicator(); + var stopModel = new StopModel(); + var gg = new Graph(deduplicator); + var transitModel = new TransitModel(stopModel, deduplicator); + + File file = ResourceLoader.of(LinkingTest.class).file("columbus.osm.pbf"); + OsmProvider provider = new OsmProvider(file, false); + + OsmModule osmModule = OsmModule.of(provider, gg).build(); + + osmModule.buildGraph(); + return new TestOtpModel(gg, transitModel); + } + private static List outgoingStls(final TransitStopVertex tsv) { return tsv .getOutgoing() diff --git a/src/test/java/org/opentripplanner/graph_builder/module/FakeGraph.java b/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java similarity index 64% rename from src/test/java/org/opentripplanner/graph_builder/module/FakeGraph.java rename to src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java index b4dfb63d203..f4de2291397 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/FakeGraph.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/linking/TestGraph.java @@ -1,15 +1,6 @@ -package org.opentripplanner.graph_builder.module; +package org.opentripplanner.graph_builder.module.linking; -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; import java.util.List; -import org.opentripplanner.TestOtpModel; -import org.opentripplanner.graph_builder.module.osm.OsmModule; -import org.opentripplanner.gtfs.graphbuilder.GtfsBundle; -import org.opentripplanner.gtfs.graphbuilder.GtfsModule; -import org.opentripplanner.model.calendar.ServiceDateInterval; -import org.opentripplanner.openstreetmap.OsmProvider; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.linking.LinkingDirection; import org.opentripplanner.routing.linking.VertexLinker; @@ -19,46 +10,14 @@ import org.opentripplanner.street.search.TraverseMode; import org.opentripplanner.street.search.TraverseModeSet; import org.opentripplanner.transit.model._data.TransitModelForTest; -import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.model.site.RegularStop; -import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; /** * Get graphs of Columbus Ohio with real OSM streets and a synthetic transit system for use in * testing. */ -public class FakeGraph { - - /** Build a graph in Columbus, OH with no transit */ - public static TestOtpModel buildGraphNoTransit() throws URISyntaxException { - var deduplicator = new Deduplicator(); - var stopModel = new StopModel(); - var gg = new Graph(deduplicator); - var transitModel = new TransitModel(stopModel, deduplicator); - - File file = getFileForResource("columbus.osm.pbf"); - OsmProvider provider = new OsmProvider(file, false); - - OsmModule osmModule = OsmModule.of(provider, gg).build(); - - osmModule.buildGraph(); - return new TestOtpModel(gg, transitModel); - } - - public static File getFileForResource(String resource) throws URISyntaxException { - URL resourceUrl = FakeGraph.class.getResource(resource); - return new File(resourceUrl.toURI()); - } - - /** - * This introduces a 1MB test resource but is only used by TestIntermediatePlaces. - */ - public static void addPerpendicularRoutes(Graph graph, TransitModel transitModel) - throws URISyntaxException { - var input = List.of(new GtfsBundle(getFileForResource("addPerpendicularRoutes.gtfs.zip"))); - new GtfsModule(input, transitModel, graph, ServiceDateInterval.unbounded()).buildGraph(); - } +class TestGraph { /** Add a regular grid of stops to the graph */ public static void addRegularStopGrid(Graph graph) { diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/OpenStreetMapParserTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/OpenStreetMapParserTest.java index f0a3b8254f0..b0073475699 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/OpenStreetMapParserTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/OpenStreetMapParserTest.java @@ -5,21 +5,18 @@ import gnu.trove.list.TLongList; import java.io.File; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.openstreetmap.OsmProvider; import org.opentripplanner.openstreetmap.model.OSMNode; import org.opentripplanner.openstreetmap.model.OSMWay; +import org.opentripplanner.test.support.ResourceLoader; public class OpenStreetMapParserTest { @Test public void testBinaryParser() { - File osmFile = new File( - URLDecoder.decode(getClass().getResource("map.osm.pbf").getPath(), StandardCharsets.UTF_8) - ); + File osmFile = ResourceLoader.of(this).file("map.osm.pbf"); OsmProvider pr = new OsmProvider(osmFile, true); OsmDatabase osmdb = new OsmDatabase(DataImportIssueStore.NOOP); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java index c0c7a68cc37..091652a2dbf 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/OsmModuleTest.java @@ -10,8 +10,6 @@ import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN; import java.io.File; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -37,23 +35,25 @@ import org.opentripplanner.routing.impl.GraphPathFinder; import org.opentripplanner.street.model.edge.Edge; import org.opentripplanner.street.model.edge.StreetEdge; +import org.opentripplanner.street.model.vertex.BarrierVertex; import org.opentripplanner.street.model.vertex.IntersectionVertex; import org.opentripplanner.street.model.vertex.VehicleParkingEntranceVertex; import org.opentripplanner.street.model.vertex.Vertex; import org.opentripplanner.street.model.vertex.VertexLabel; import org.opentripplanner.street.search.state.State; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; public class OsmModuleTest { + private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of(OsmModuleTest.class); + @Test public void testGraphBuilder() { var deduplicator = new Deduplicator(); var gg = new Graph(deduplicator); - File file = new File( - URLDecoder.decode(getClass().getResource("map.osm.pbf").getFile(), StandardCharsets.UTF_8) - ); + File file = RESOURCE_LOADER.file("map.osm.pbf"); OsmProvider provider = new OsmProvider(file, true); @@ -111,12 +111,7 @@ public void testBuildGraphDetailed() { var deduplicator = new Deduplicator(); var gg = new Graph(deduplicator); - File file = new File( - URLDecoder.decode( - getClass().getResource("NYC_small.osm.pbf").getFile(), - StandardCharsets.UTF_8 - ) - ); + File file = RESOURCE_LOADER.file("NYC_small.osm.pbf"); OsmProvider provider = new OsmProvider(file, true); OsmModule osmModule = OsmModule.of(provider, gg).withAreaVisibility(true).build(); @@ -303,12 +298,37 @@ void createArtificalEntrancesToUnlikedParkingLots() { }); } + /** + * Test that a barrier vertex at ending street will get no access limit + */ + @Test + void testBarrierAtEnd() { + var deduplicator = new Deduplicator(); + var graph = new Graph(deduplicator); + + File file = RESOURCE_LOADER.file("accessno-at-end.pbf"); + OsmProvider provider = new OsmProvider(file, false); + OsmModule loader = OsmModule.of(provider, graph).build(); + loader.buildGraph(); + + Vertex start = graph.getVertex(VertexLabel.osm(1)); + Vertex end = graph.getVertex(VertexLabel.osm(3)); + + assertNotNull(start); + assertNotNull(end); + assertEquals(end.getClass(), BarrierVertex.class); + var barrier = (BarrierVertex) end; + + // assert that pruning removed traversal restrictions + assertEquals(barrier.getBarrierPermissions(), ALL); + } + @Nonnull private Graph buildParkingLots() { var graph = new Graph(); var providers = Stream .of("B+R.osm.pbf", "P+R.osm.pbf") - .map(f -> new File(getClass().getResource(f).getFile())) + .map(RESOURCE_LOADER::file) .map(f -> new OsmProvider(f, false)) .toList(); var module = OsmModule @@ -333,12 +353,7 @@ private void testBuildingAreas(boolean skipVisibility) { var deduplicator = new Deduplicator(); var graph = new Graph(deduplicator); - File file = new File( - URLDecoder.decode( - getClass().getResource("usf_area.osm.pbf").getFile(), - StandardCharsets.UTF_8 - ) - ); + File file = RESOURCE_LOADER.file("usf_area.osm.pbf"); OsmProvider provider = new OsmProvider(file, false); OsmModule loader = OsmModule.of(provider, graph).withAreaVisibility(!skipVisibility).build(); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java index 81fc6d84d6e..9d3ea5a1d81 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/PlatformLinkerTest.java @@ -3,15 +3,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; -import org.opentripplanner.graph_builder.module.FakeGraph; import org.opentripplanner.openstreetmap.OsmProvider; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.street.model.edge.AreaEdge; import org.opentripplanner.street.model.vertex.Vertex; import org.opentripplanner.street.model.vertex.VertexLabel; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; public class PlatformLinkerTest { @@ -27,12 +25,7 @@ public void testLinkEntriesToPlatforms() { var deduplicator = new Deduplicator(); var gg = new Graph(deduplicator); - File file = new File( - URLDecoder.decode( - FakeGraph.class.getResource("osm/skoyen.osm.pbf").getFile(), - StandardCharsets.UTF_8 - ) - ); + File file = ResourceLoader.of(this).file("skoyen.osm.pbf"); OsmProvider provider = new OsmProvider(file, false); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/TestIntermediatePlaces.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/TestIntermediatePlaces.java deleted file mode 100644 index 484854477cc..00000000000 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/TestIntermediatePlaces.java +++ /dev/null @@ -1,372 +0,0 @@ -package org.opentripplanner.graph_builder.module.osm; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.opentripplanner.routing.api.request.StreetMode.CAR; -import static org.opentripplanner.routing.api.request.StreetMode.NOT_SET; - -import java.time.Instant; -import java.time.ZoneId; -import java.util.List; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.opentripplanner.TestOtpModel; -import org.opentripplanner.astar.model.GraphPath; -import org.opentripplanner.graph_builder.module.FakeGraph; -import org.opentripplanner.model.GenericLocation; -import org.opentripplanner.model.modes.ExcludeAllTransitFilter; -import org.opentripplanner.model.plan.Itinerary; -import org.opentripplanner.model.plan.Leg; -import org.opentripplanner.model.plan.Place; -import org.opentripplanner.model.plan.TripPlan; -import org.opentripplanner.routing.algorithm.mapping.GraphPathToItineraryMapper; -import org.opentripplanner.routing.algorithm.mapping.TripPlanMapper; -import org.opentripplanner.routing.api.request.RequestModes; -import org.opentripplanner.routing.api.request.RouteRequest; -import org.opentripplanner.routing.api.request.request.filter.AllowAllTransitFilter; -import org.opentripplanner.routing.api.request.request.filter.TransitFilter; -import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.impl.GraphPathFinder; -import org.opentripplanner.street.model.edge.Edge; -import org.opentripplanner.street.model.vertex.Vertex; -import org.opentripplanner.street.search.TemporaryVerticesContainer; -import org.opentripplanner.street.search.state.State; -import org.opentripplanner.transit.service.TransitModel; - -/** - * Tests for planning with intermediate places - * TODO OTP2 - Test is too close to the implementation and will need to be reimplemented. - */ -@Disabled -public class TestIntermediatePlaces { - - /** - * The spatial deviation that we allow in degrees - */ - public static final double DELTA = 0.005; - - private static ZoneId timeZone; - - private static GraphPathFinder graphPathFinder; - - private static Graph graph; - - private static GraphPathToItineraryMapper graphPathToItineraryMapper; - - @BeforeAll - public static void setUp() { - try { - TestOtpModel model = FakeGraph.buildGraphNoTransit(); - graph = model.graph(); - TransitModel transitModel = model.transitModel(); - FakeGraph.addPerpendicularRoutes(graph, transitModel); - FakeGraph.link(graph, transitModel); - model.index(); - TestIntermediatePlaces.graphPathFinder = new GraphPathFinder(null); - timeZone = transitModel.getTimeZone(); - - graphPathToItineraryMapper = - new GraphPathToItineraryMapper( - timeZone, - graph.streetNotesService, - graph.ellipsoidToGeoidDifference - ); - } catch (Exception e) { - e.printStackTrace(); - assert false : "Could not add transit data: " + e.toString(); - } - } - - @Test - public void testWithoutIntermediatePlaces() { - GenericLocation fromLocation = new GenericLocation(39.93080, -82.98522); - GenericLocation toLocation = new GenericLocation(39.96383, -82.96291); - GenericLocation[] intermediateLocations = {}; - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().build(), - List.of(ExcludeAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().build(), - List.of(ExcludeAllTransitFilter.of()), - true - ); - } - - @Test - @Disabled - public void testOneIntermediatePlace() { - GenericLocation fromLocation = new GenericLocation(39.93080, -82.98522); - GenericLocation toLocation = new GenericLocation(39.96383, -82.96291); - GenericLocation[] intermediateLocations = { new GenericLocation(39.92099, -82.95570) }; - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().build(), - List.of(ExcludeAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().build(), - List.of(ExcludeAllTransitFilter.of()), - true - ); - } - - @Test - @Disabled - public void testTwoIntermediatePlaces() { - GenericLocation fromLocation = new GenericLocation(39.93080, -82.98522); - GenericLocation toLocation = new GenericLocation(39.96383, -82.96291); - GenericLocation[] intermediateLocations = new GenericLocation[2]; - intermediateLocations[0] = new GenericLocation(39.92099, -82.95570); - intermediateLocations[1] = new GenericLocation(39.96146, -82.99552); - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().withDirectMode(CAR).build(), - List.of(ExcludeAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().withDirectMode(CAR).build(), - List.of(ExcludeAllTransitFilter.of()), - true - ); - } - - @Test - public void testTransitWithoutIntermediatePlaces() { - GenericLocation fromLocation = new GenericLocation(39.9308, -83.0118); - GenericLocation toLocation = new GenericLocation(39.9998, -83.0198); - GenericLocation[] intermediateLocations = {}; - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.defaultRequestModes(), - List.of(AllowAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.defaultRequestModes(), - List.of(AllowAllTransitFilter.of()), - true - ); - } - - @Test - public void testThreeBusStopPlaces() { - GenericLocation fromLocation = new GenericLocation(39.9058, -83.1341); - GenericLocation toLocation = new GenericLocation(39.9058, -82.8841); - GenericLocation[] intermediateLocations = { new GenericLocation(39.9058, -82.9841) }; - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().withDirectMode(NOT_SET).build(), - List.of(AllowAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.of().withDirectMode(NOT_SET).build(), - List.of(AllowAllTransitFilter.of()), - true - ); - } - - @Test - public void testTransitOneIntermediatePlace() { - GenericLocation fromLocation = new GenericLocation(39.9108, -83.0118); - GenericLocation toLocation = new GenericLocation(39.9698, -83.0198); - GenericLocation[] intermediateLocations = { new GenericLocation(39.9948, -83.0148) }; - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.defaultRequestModes(), - List.of(AllowAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.defaultRequestModes(), - List.of(AllowAllTransitFilter.of()), - true - ); - } - - @Test - public void testTransitTwoIntermediatePlaces() { - GenericLocation fromLocation = new GenericLocation(39.9908, -83.0118); - GenericLocation toLocation = new GenericLocation(39.9998, -83.0198); - GenericLocation[] intermediateLocations = new GenericLocation[2]; - intermediateLocations[0] = new GenericLocation(40.0000, -82.900); - intermediateLocations[1] = new GenericLocation(39.9100, -83.100); - - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.defaultRequestModes(), - List.of(AllowAllTransitFilter.of()), - false - ); - handleRequest( - fromLocation, - toLocation, - intermediateLocations, - RequestModes.defaultRequestModes(), - List.of(AllowAllTransitFilter.of()), - true - ); - } - - private void handleRequest( - GenericLocation from, - GenericLocation to, - GenericLocation[] via, - RequestModes modes, - List filters, - boolean arriveBy - ) { - RouteRequest request = new RouteRequest(); - request.journey().setModes(modes); - request.journey().transit().setFilters(filters); - request.setDateTime("2016-04-20", "13:00", timeZone); - request.setArriveBy(arriveBy); - request.setFrom(from); - request.setTo(to); - for (GenericLocation intermediateLocation : via) { - // TODO VIA - Replace with a RouteViaRequest - //options.addIntermediatePlace(intermediateLocation); - } - try ( - var temporaryVertices = new TemporaryVerticesContainer( - graph, - request, - request.journey().access().mode(), - request.journey().egress().mode() - ) - ) { - List> paths = graphPathFinder.graphPathFinderEntryPoint( - request, - temporaryVertices - ); - - assertNotNull(paths); - assertFalse(paths.isEmpty()); - List itineraries = graphPathToItineraryMapper.mapItineraries(paths); - TripPlan plan = TripPlanMapper.mapTripPlan(request, itineraries); - assertLocationIsVeryCloseToPlace(from, plan.from); - assertLocationIsVeryCloseToPlace(to, plan.to); - assertTrue(1 <= plan.itineraries.size()); - for (Itinerary itinerary : plan.itineraries) { - validateIntermediatePlacesVisited(itinerary, via); - assertTrue(via.length < itinerary.getLegs().size()); - validateLegsTemporally(request, itinerary); - validateLegsSpatially(plan, itinerary); - - // technically this is not 100% right but should work of a test - if (!filters.contains(ExcludeAllTransitFilter.of())) { - assertTrue(itinerary.getTransitDuration().toSeconds() > 0); - } - } - } - } - - // Check that every via location is visited in the right order - private void validateIntermediatePlacesVisited(Itinerary itinerary, GenericLocation[] via) { - int legIndex = 0; - - for (GenericLocation location : via) { - Leg leg; - do { - assertTrue( - legIndex < itinerary.getLegs().size(), - "Intermediate location was not an endpoint of any leg" - ); - leg = itinerary.getLegs().get(legIndex); - legIndex++; - } while ( - Math.abs(leg.getTo().coordinate.latitude() - location.lat) > DELTA || - Math.abs(leg.getTo().coordinate.longitude() - location.lng) > DELTA - ); - } - } - - // Check that the end point of a leg is also the start point of the next leg - private void validateLegsSpatially(TripPlan plan, Itinerary itinerary) { - Place place = plan.from; - for (Leg leg : itinerary.getLegs()) { - assertEquals(place.coordinate, leg.getFrom().coordinate); - place = leg.getTo(); - } - assertEquals(place.coordinate, plan.to.coordinate); - } - - // Check that the start time and end time of each leg are consistent - private void validateLegsTemporally(RouteRequest request, Itinerary itinerary) { - Instant departTime; - Instant arriveTime; - if (request.arriveBy()) { - departTime = itinerary.getLegs().get(0).getStartTime().toInstant(); - arriveTime = request.dateTime(); - } else { - departTime = request.dateTime(); - arriveTime = itinerary.getLegs().get(itinerary.getLegs().size() - 1).getEndTime().toInstant(); - } - long sumOfDuration = 0; - for (Leg leg : itinerary.getLegs()) { - assertFalse(departTime.isAfter(leg.getStartTime().toInstant())); - assertFalse(leg.getStartTime().isAfter(leg.getEndTime())); - - departTime = leg.getEndTime().toInstant(); - sumOfDuration += leg.getDuration().toSeconds(); - } - sumOfDuration += itinerary.getWaitingDuration().toSeconds(); - - assertFalse(departTime.isAfter(arriveTime)); - - // Check the total duration of the legs, - int accuracy = itinerary.getLegs().size(); // allow 1 second per leg for rounding errors - assertEquals(sumOfDuration, itinerary.getDuration().toSeconds(), accuracy); - } - - private void assertLocationIsVeryCloseToPlace(GenericLocation location, Place place) { - assertEquals(location.lat, place.coordinate.latitude(), DELTA); - assertEquals(location.lng, place.coordinate.longitude(), DELTA); - } -} diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java index 0e0fa3df0f9..4cdada95e4b 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/TriangleInequalityTest.java @@ -8,8 +8,6 @@ import static org.opentripplanner.routing.api.request.StreetMode.CAR; import java.io.File; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import java.util.List; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -32,6 +30,7 @@ import org.opentripplanner.street.search.state.State; import org.opentripplanner.street.search.strategy.DominanceFunctions; import org.opentripplanner.street.search.strategy.EuclideanRemainingWeightHeuristic; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; public class TriangleInequalityTest { @@ -49,12 +48,7 @@ public class TriangleInequalityTest { public static void onlyOnce() { graph = new Graph(new Deduplicator()); - File file = new File( - URLDecoder.decode( - TriangleInequalityTest.class.getResource("NYC_small.osm.pbf").getFile(), - StandardCharsets.UTF_8 - ) - ); + File file = ResourceLoader.of(TriangleInequalityTest.class).file("NYC_small.osm.pbf"); OsmProvider provider = new OsmProvider(file, true); OsmModule osmModule = OsmModule.of(provider, graph).withAreaVisibility(true).build(); osmModule.buildGraph(); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java index 0cabf2a8ecb..2b4b5411cf7 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/UnconnectedAreasTest.java @@ -3,11 +3,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.io.File; import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.graph_builder.issue.service.DefaultDataImportIssueStore; @@ -19,12 +17,17 @@ import org.opentripplanner.street.model.edge.VehicleParkingEdge; import org.opentripplanner.street.model.vertex.VehicleParkingEntranceVertex; import org.opentripplanner.street.model.vertex.VertexLabel; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; public class UnconnectedAreasTest { + private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of( + UnconnectedAreasTest.class + ); + /** * The P+R.osm.pbf file contains 2 park and ride, one a single way area and the other a * multipolygon with a hole. Both are not linked to any street, apart from three roads that @@ -157,11 +160,7 @@ private Graph buildOSMGraph(String osmFileName, DataImportIssueStore issueStore) var stopModel = new StopModel(); var graph = new Graph(deduplicator); var transitModel = new TransitModel(stopModel, deduplicator); - var fileUrl = getClass().getResource(osmFileName); - Assertions.assertNotNull(fileUrl); - File file = new File(fileUrl.getFile()); - - OsmProvider provider = new OsmProvider(file, false); + OsmProvider provider = new OsmProvider(RESOURCE_LOADER.file(osmFileName), false); OsmModule loader = OsmModule .of(provider, graph) .withIssueStore(issueStore) diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java index e1221dbdcef..f921062e790 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/UnroutableTest.java @@ -2,10 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; -import java.io.File; -import java.net.URL; -import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.opentripplanner.astar.model.GraphPath; @@ -20,6 +16,7 @@ import org.opentripplanner.street.search.StreetSearchBuilder; import org.opentripplanner.street.search.state.State; import org.opentripplanner.street.search.strategy.EuclideanRemainingWeightHeuristic; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; /** @@ -38,8 +35,7 @@ public void setUp() throws Exception { var deduplicator = new Deduplicator(); graph = new Graph(deduplicator); - URL osmDataUrl = getClass().getResource("bridge_construction.osm.pbf"); - File osmDataFile = new File(URLDecoder.decode(osmDataUrl.getFile(), StandardCharsets.UTF_8)); + var osmDataFile = ResourceLoader.of(UnroutableTest.class).file("bridge_construction.osm.pbf"); OsmProvider provider = new OsmProvider(osmDataFile, true); OsmModule osmBuilder = OsmModule.of(provider, graph).withAreaVisibility(true).build(); osmBuilder.buildGraph(); diff --git a/src/test/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilderTest.java b/src/test/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilderTest.java index 8786fbdf304..4906bce930d 100644 --- a/src/test/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilderTest.java +++ b/src/test/java/org/opentripplanner/graph_builder/module/osm/WalkableAreaBuilderTest.java @@ -25,6 +25,7 @@ import org.opentripplanner.street.model.edge.AreaEdge; import org.opentripplanner.street.model.vertex.VertexLabel; import org.opentripplanner.street.model.vertex.VertexLabel.OsmNodeOnLevelLabel; +import org.opentripplanner.test.support.ResourceLoader; public class WalkableAreaBuilderTest { @@ -39,7 +40,7 @@ public Graph buildGraph(final TestInfo testInfo) { final Set boardingAreaRefTags = Set.of(); final OsmDatabase osmdb = new OsmDatabase(DataImportIssueStore.NOOP); - final File file = new File(testInfo.getTestClass().get().getResource(osmFile).getFile()); + final File file = ResourceLoader.of(WalkableAreaBuilderTest.class).file(osmFile); assertTrue(file.exists()); new OsmProvider(file, false).readOSM(osmdb); osmdb.postLoad(); diff --git a/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java b/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java index e79e993a7cb..9c07e656183 100644 --- a/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java +++ b/src/test/java/org/opentripplanner/gtfs/GtfsContextBuilder.java @@ -37,11 +37,11 @@ public GtfsContextBuilder(GtfsFeedId feedId, OtpTransitServiceBuilder transitBui this.transitBuilder = transitBuilder; } - public static GtfsContextBuilder contextBuilder(String path) throws IOException { - return contextBuilder(null, path); + public static GtfsContextBuilder contextBuilder(File file) throws IOException { + return contextBuilder(null, file); } - public static GtfsContextBuilder contextBuilder(@Nullable String defaultFeedId, String path) + public static GtfsContextBuilder contextBuilder(@Nullable String defaultFeedId, File path) throws IOException { GtfsImport gtfsImport = gtfsImport(defaultFeedId, path); GtfsFeedId feedId = gtfsImport.getFeedId(); @@ -123,8 +123,8 @@ public void repairStopTimesAndGenerateTripPatterns() { /* private stuff */ - private static GtfsImport gtfsImport(String defaultFeedId, String path) throws IOException { - return new GtfsImport(defaultFeedId, new File(path)); + private static GtfsImport gtfsImport(String defaultFeedId, File file) throws IOException { + return new GtfsImport(defaultFeedId, file); } private void repairStopTimesForEachTrip() { diff --git a/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java b/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java index 9a0c8a171ee..d0cf9f95a81 100644 --- a/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java +++ b/src/test/java/org/opentripplanner/model/TimetableSnapshotTest.java @@ -36,7 +36,7 @@ public class TimetableSnapshotTest { @BeforeAll public static void setUp() throws Exception { - TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.FAKE_GTFS); + TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.SIMPLE_GTFS); TransitModel transitModel = model.transitModel(); feedId = transitModel.getFeedIds().iterator().next(); diff --git a/src/test/java/org/opentripplanner/model/TimetableTest.java b/src/test/java/org/opentripplanner/model/TimetableTest.java index 5c579415049..80084393c08 100644 --- a/src/test/java/org/opentripplanner/model/TimetableTest.java +++ b/src/test/java/org/opentripplanner/model/TimetableTest.java @@ -50,7 +50,7 @@ public class TimetableTest { @BeforeAll public static void setUp() throws Exception { - TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.FAKE_GTFS); + TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.SIMPLE_GTFS); TransitModel transitModel = model.transitModel(); feedId = transitModel.getFeedIds().stream().findFirst().get(); diff --git a/src/test/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImplTest.java b/src/test/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImplTest.java index 2eb5f060108..135a3045c3c 100644 --- a/src/test/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImplTest.java +++ b/src/test/java/org/opentripplanner/model/calendar/impl/CalendarServiceDataFactoryImplTest.java @@ -124,7 +124,7 @@ public void testServiceGetServiceDatesForServiceId() { private static GtfsContext createCtxBuilder() throws IOException { GtfsContextBuilder ctxBuilder = contextBuilder( TransitModelForTest.FEED_ID, - ConstantsForTests.FAKE_GTFS + ConstantsForTests.SIMPLE_GTFS ); OtpTransitServiceBuilder builder = ctxBuilder .withDataImportIssueStore(DataImportIssueStore.NOOP) diff --git a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java index 070b4fe546d..9fd0bd4d8cb 100644 --- a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java +++ b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceBuilderTest.java @@ -88,7 +88,7 @@ public void testGetAllShapePoints() { /* private methods */ private static OtpTransitServiceBuilder createBuilder() throws IOException { - OtpTransitServiceBuilder builder = contextBuilder(FEED_ID, ConstantsForTests.FAKE_GTFS) + OtpTransitServiceBuilder builder = contextBuilder(FEED_ID, ConstantsForTests.SIMPLE_GTFS) .getTransitBuilder(); Agency agency = agency(builder); diff --git a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java index a0031ca3384..9ecdbbeb451 100644 --- a/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java +++ b/src/test/java/org/opentripplanner/model/impl/OtpTransitServiceImplTest.java @@ -38,7 +38,7 @@ public class OtpTransitServiceImplTest { @BeforeAll public static void setup() throws IOException { - GtfsContextBuilder contextBuilder = contextBuilder(FEED_ID, ConstantsForTests.FAKE_GTFS); + GtfsContextBuilder contextBuilder = contextBuilder(FEED_ID, ConstantsForTests.SIMPLE_GTFS); OtpTransitServiceBuilder builder = contextBuilder.getTransitBuilder(); // Supplement test data with at least one entity in all collections diff --git a/src/test/java/org/opentripplanner/openstreetmap/model/BicycleNetworkRelationsTest.java b/src/test/java/org/opentripplanner/openstreetmap/model/BicycleNetworkRelationsTest.java index be8fca3864d..3b80f0f74a4 100644 --- a/src/test/java/org/opentripplanner/openstreetmap/model/BicycleNetworkRelationsTest.java +++ b/src/test/java/org/opentripplanner/openstreetmap/model/BicycleNetworkRelationsTest.java @@ -3,11 +3,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.io.File; import org.junit.jupiter.api.Test; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; import org.opentripplanner.graph_builder.module.osm.OsmDatabase; import org.opentripplanner.openstreetmap.OsmProvider; +import org.opentripplanner.test.support.ResourceLoader; public class BicycleNetworkRelationsTest { @@ -19,10 +19,7 @@ public class BicycleNetworkRelationsTest { public void testBicycleRouteRelations() { var issueStore = DataImportIssueStore.NOOP; var osmdb = new OsmDatabase(issueStore); - var provider = new OsmProvider( - new File("src/test/resources/germany/ehningen-minimal.osm.pbf"), - true - ); + var provider = new OsmProvider(ResourceLoader.of(this).file("ehningen-minimal.osm.pbf"), true); provider.readOSM(osmdb); osmdb.postLoad(); diff --git a/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java b/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java index 08a38279a4e..0938b58240d 100644 --- a/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java +++ b/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointTest.java @@ -11,7 +11,7 @@ class PassThroughPointTest { private static final int[] STOPS = { 2, 7, 13 }; - private final PassThroughPoint subject = new PassThroughPoint(STOPS); + private final PassThroughPoint subject = new PassThroughPoint(STOPS, "PT1"); @Test void asBitSet() { @@ -29,8 +29,8 @@ void asBitSet() { @Test void testEqualsAndHashCode() { - var same = new PassThroughPoint(STOPS); - var other = new PassThroughPoint(new int[] { 2, 7 }); + var same = new PassThroughPoint(STOPS, "PT1"); + var other = new PassThroughPoint(new int[] { 2, 7 }, "PT2"); assertEquals(subject, subject); assertEquals(same, subject); @@ -42,6 +42,7 @@ void testEqualsAndHashCode() { @Test void testToString() { - assertEquals("(stops: [2, 7, 13])", subject.toString()); + assertEquals("(name: 'PT1', stops: [2, 7, 13])", subject.toString()); + assertEquals("(stops: [2, 7, 13])", new PassThroughPoint(STOPS, null).toString()); } } diff --git a/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointsTest.java b/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointsTest.java index 7968017923b..83f4dda4879 100644 --- a/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointsTest.java +++ b/src/test/java/org/opentripplanner/raptor/api/request/PassThroughPointsTest.java @@ -12,17 +12,17 @@ class PassThroughPointsTest { - private static final int[] STOPS_POINT_1 = { 2, 7, 13 }; - private static final int[] STOPS_POINT_2 = { 12 }; + private static final int[] STOPS_1 = { 2, 7, 13 }; + private static final int[] STOPS_2 = { 12 }; private final PassThroughPoints subject = new PassThroughPoints( - List.of(new PassThroughPoint(STOPS_POINT_1), new PassThroughPoint(STOPS_POINT_2)) + List.of(new PassThroughPoint(STOPS_1, "PT1"), new PassThroughPoint(STOPS_2, "PT2")) ); @Test void stream() { assertEquals( - "(stops: [2, 7, 13]), (stops: [12])", + "(name: 'PT1', stops: [2, 7, 13]), (name: 'PT2', stops: [12])", subject.stream().map(Objects::toString).collect(Collectors.joining(", ")) ); } @@ -36,10 +36,10 @@ void isEmpty() { @Test void testEqualsAndHashCode() { var same = new PassThroughPoints( - List.of(new PassThroughPoint(STOPS_POINT_1), new PassThroughPoint(STOPS_POINT_2)) + List.of(new PassThroughPoint(STOPS_1, "PT1"), new PassThroughPoint(STOPS_2, "PT2")) ); var other = new PassThroughPoints( - List.of(new PassThroughPoint(STOPS_POINT_1), new PassThroughPoint(STOPS_POINT_1)) + List.of(new PassThroughPoint(STOPS_1, "PT1"), new PassThroughPoint(STOPS_1, "PT2")) ); assertEquals(same, subject); assertNotEquals(other, subject); @@ -51,7 +51,7 @@ void testEqualsAndHashCode() { @Test void testToString() { assertEquals( - "PassThroughPoints{points: [(stops: [2, 7, 13]), (stops: [12])]}", + "PassThroughPoints{points: [(name: 'PT1', stops: [2, 7, 13]), (name: 'PT2', stops: [12])]}", subject.toString() ); } diff --git a/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java b/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java index 5d9cc03ced4..350fcc72cbd 100644 --- a/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java +++ b/src/test/java/org/opentripplanner/raptor/moduletests/J01_PassThroughTest.java @@ -91,7 +91,7 @@ public void passThroughPointOnEgress() { .withMultiCriteria(mc -> mc.withPassThroughPoints( // Include desired pass-through point in the request - new PassThroughPoints(List.of(new PassThroughPoint(new int[] { STOP_D }))) + new PassThroughPoints(List.of(new PassThroughPoint(new int[] { STOP_D }, "PT1"))) ) ) .searchParams() @@ -127,7 +127,7 @@ public void passThroughPointOnAccess() { .withMultiCriteria(mc -> // Include desired pass-through point in the request mc.withPassThroughPoints( - new PassThroughPoints(List.of(new PassThroughPoint(new int[] { STOP_A }))) + new PassThroughPoints(List.of(new PassThroughPoint(new int[] { STOP_A }, "PT1"))) ) ) .searchParams() @@ -164,7 +164,7 @@ public void passThroughPointInTheMiddle() { .withMultiCriteria(mc -> // Include desired pass-through point in the request mc.withPassThroughPoints( - new PassThroughPoints(List.of(new PassThroughPoint(new int[] { STOP_C }))) + new PassThroughPoints(List.of(new PassThroughPoint(new int[] { STOP_C }, "PT1"))) ) ) .searchParams() @@ -203,8 +203,8 @@ public void multiplePassThroughPoints() { // Include desired pass-through point in the request new PassThroughPoints( List.of( - new PassThroughPoint(new int[] { STOP_B }), - new PassThroughPoint(new int[] { STOP_D }) + new PassThroughPoint(new int[] { STOP_B }, "PT1"), + new PassThroughPoint(new int[] { STOP_D }, "PT2") ) ) ) @@ -243,8 +243,8 @@ public void passThroughOrder() { // Include desired pass-through point in the request new PassThroughPoints( List.of( - new PassThroughPoint(new int[] { STOP_B }), - new PassThroughPoint(new int[] { STOP_C }) + new PassThroughPoint(new int[] { STOP_B }, "PT1"), + new PassThroughPoint(new int[] { STOP_C }, "PT2") ) ) ) @@ -282,7 +282,7 @@ public void passThroughGroup() { // Include desired pass-through point in the request new PassThroughPoints( // Both STOP_B and STOP_C is a valid pass-through point - List.of(new PassThroughPoint(new int[] { STOP_B, STOP_C })) + List.of(new PassThroughPoint(new int[] { STOP_B, STOP_C }, "PT1")) ) ) ) diff --git a/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java b/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java index 195bb39b453..bfe4853a3d8 100644 --- a/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java +++ b/src/test/java/org/opentripplanner/raptor/rangeraptor/multicriteria/passthrough/BitSetPassThroughPointsServiceTest.java @@ -32,7 +32,9 @@ class BitSetPassThroughPointsServiceTest { private static final int STOP_31 = 6; private static final PassThroughPointsService SUBJECT = BitSetPassThroughPointsService.of( - new PassThroughPoints(List.of(new PassThroughPoint(STOPS_1), new PassThroughPoint(STOPS_2))) + new PassThroughPoints( + List.of(new PassThroughPoint(STOPS_1, "PT1"), new PassThroughPoint(STOPS_2, "PT2")) + ) ); /** * We expect the c2 value at the destination to be the same as the number of pass-through diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java b/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java index ba0c5c70f2d..2815f129fde 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/RaptorPathToItineraryMapperTest.java @@ -8,9 +8,12 @@ import java.time.LocalDateTime; import java.time.Month; import java.util.ArrayList; +import java.util.HashMap; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.opentripplanner._support.time.ZoneIds; +import org.opentripplanner.ext.flex.FlexAccessEgress; import org.opentripplanner.framework.time.TimeUtils; import org.opentripplanner.model.PickDrop; import org.opentripplanner.model.StopTime; @@ -20,12 +23,28 @@ import org.opentripplanner.raptor._data.transit.TestTransitData; import org.opentripplanner.raptor._data.transit.TestTripPattern; import org.opentripplanner.raptor._data.transit.TestTripSchedule; +import org.opentripplanner.raptor.api.model.RaptorAccessEgress; +import org.opentripplanner.raptor.api.model.RaptorTransfer; +import org.opentripplanner.raptor.api.model.RaptorTripSchedule; +import org.opentripplanner.raptor.api.path.AccessPathLeg; +import org.opentripplanner.raptor.api.path.EgressPathLeg; +import org.opentripplanner.raptor.api.path.PathLeg; import org.opentripplanner.raptor.api.path.RaptorPath; +import org.opentripplanner.raptor.api.path.TransferPathLeg; +import org.opentripplanner.raptor.path.Path; import org.opentripplanner.raptor.spi.RaptorCostCalculator; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.DefaultAccessEgress; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.DefaultRaptorTransfer; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.FlexAccessEgressAdapter; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.Transfer; +import org.opentripplanner.routing.algorithm.raptoradapter.transit.TransitLayer; import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.DefaultCostCalculator; import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.RaptorCostConverter; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.street.search.state.State; +import org.opentripplanner.street.search.state.TestStateBuilder; +import org.opentripplanner.transit.model._data.TransitModelForTest; import org.opentripplanner.transit.model.basic.TransitMode; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.model.network.Route; @@ -34,6 +53,7 @@ import org.opentripplanner.transit.model.organization.Agency; import org.opentripplanner.transit.model.site.RegularStop; import org.opentripplanner.transit.service.DefaultTransitService; +import org.opentripplanner.transit.service.StopModel; import org.opentripplanner.transit.service.TransitModel; public class RaptorPathToItineraryMapperTest { @@ -57,6 +77,10 @@ public class RaptorPathToItineraryMapperTest { STOP_COSTS ); + private static final RegularStop S1 = TransitModelForTest.stopForTest("STOP1", 0.0, 0.0); + + private static final RegularStop S2 = TransitModelForTest.stopForTest("STOP2", 1.0, 1.0); + @ParameterizedTest @ValueSource(strings = { "0", "3000", "-3000" }) public void createItineraryTestZeroDurationEgress(int LAST_LEG_COST) { @@ -82,8 +106,41 @@ public void createItineraryTestZeroDurationEgress(int LAST_LEG_COST) { ); } + /** + * Create a minimalist path FlexAccess-->Transfer-->Egress (without transit) and check that the 3 legs + * are properly mapped in the itinerary. + */ + @Test + public void createItineraryWithOnBoardFlexAccess() { + RaptorPathToItineraryMapper mapper = getRaptorPathToItineraryMapper(); + + State state = TestStateBuilder.ofWalking().streetEdge().streetEdge().build(); + FlexAccessEgress flexAccessEgress = new FlexAccessEgress(S1, null, 0, 1, null, state, true); + RaptorAccessEgress access = new FlexAccessEgressAdapter(flexAccessEgress, false); + Transfer transfer = new Transfer(S2.getIndex(), 0); + RaptorTransfer raptorTransfer = new DefaultRaptorTransfer(S1.getIndex(), 0, 0, transfer); + RaptorAccessEgress egress = new DefaultAccessEgress(S2.getIndex(), state); + PathLeg egressLeg = new EgressPathLeg<>(egress, 0, 0, 0); + PathLeg transferLeg = new TransferPathLeg<>( + S1.getIndex(), + 0, + 0, + 0, + raptorTransfer, + egressLeg + ); + AccessPathLeg accessLeg = new AccessPathLeg(access, 0, 0, 0, transferLeg); + RaptorPath path = new Path<>(0, accessLeg, 0); + // Act + var itinerary = mapper.createItinerary(path); + + // Assert + assertNotNull(itinerary); + assertEquals(3, itinerary.getLegs().size(), "The wrong number of legs was returned"); + } + private TripPattern getOriginalPattern(TestTripPattern pattern) { - ArrayList stopTimes = new ArrayList(); + ArrayList stopTimes = new ArrayList<>(); for (int i = 0; i < pattern.numberOfStopsInPattern(); i++) { var stop = RegularStop @@ -114,15 +171,31 @@ private RaptorPathToItineraryMapper getRaptorPathToItineraryMa .of(2022, Month.OCTOBER, 10, 12, 0, 0) .atZone(ZoneIds.STOCKHOLM) .toInstant(); - return new RaptorPathToItineraryMapper( + TransitModel transitModel = new TransitModel(); + transitModel.initTimeZone(ZoneIds.CET); + return new RaptorPathToItineraryMapper<>( new Graph(), - new DefaultTransitService(new TransitModel()), - null, + new DefaultTransitService(transitModel), + getTransitLayer(), dateTime.atZone(ZoneIds.CET), new RouteRequest() ); } + private static TransitLayer getTransitLayer() { + return new TransitLayer( + new HashMap<>(), + null, + null, + StopModel.of().withRegularStop(S1).withRegularStop(S2).build(), + null, + null, + null, + null, + null + ); + } + private TestTripSchedule getTestTripSchedule() { var agency = Agency .of(new FeedScopedId("TestFeed", "Auth_1")) diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/BikeRentalSnapshotTest.snap b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/BikeRentalSnapshotTest.snap index 8720de2a5a1..d9695705c71 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/BikeRentalSnapshotTest.snap +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/BikeRentalSnapshotTest.snap @@ -7,6 +7,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:32:24.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -42,29 +57,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 3 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2209, "legs": [ @@ -502,6 +495,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:38:09.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -537,29 +545,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2539, "legs": [ @@ -955,6 +941,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:40:10.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -990,29 +991,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 1805, "legs": [ @@ -1304,6 +1283,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:45:24.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -1339,29 +1333,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 3 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2209, "legs": [ @@ -1799,6 +1771,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:54:24.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -1834,29 +1821,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 3 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2209, "legs": [ @@ -2294,6 +2259,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:56:10.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -2329,29 +2309,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.accessBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 1805, "legs": [ @@ -3318,6 +3276,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:28:51.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3353,29 +3326,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2119, "legs": [ @@ -3865,6 +3816,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:35:24.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3900,29 +3866,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2503, "legs": [ @@ -4292,6 +4236,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:37:21.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -4327,29 +4286,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2351, "legs": [ @@ -4693,6 +4630,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:43:51.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -4728,29 +4680,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2119, "legs": [ @@ -5240,6 +5170,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:51:24.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -5275,29 +5220,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2563, "legs": [ @@ -5667,6 +5590,21 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "elevationLost": 0.0, "endTime": "2009-10-21T23:56:21.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -5702,29 +5640,7 @@ org.opentripplanner.routing.algorithm.mapping.BikeRentalSnapshotTest.egressBikeR "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2351, "legs": [ diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/ElevationSnapshotTest.snap b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/ElevationSnapshotTest.snap index 0b4228c8829..9713429109d 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/ElevationSnapshotTest.snap +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/ElevationSnapshotTest.snap @@ -7,6 +7,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "elevationLost": 16.15, "endTime": "2009-10-21T23:32:25.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -42,29 +57,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 3 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2282, "legs": [ @@ -506,6 +499,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "elevationLost": 3.93, "endTime": "2009-10-21T23:40:10.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -541,29 +549,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 1803, "legs": [ @@ -857,6 +843,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "elevationLost": 13.43, "endTime": "2009-10-21T23:45:25.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -892,29 +893,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2235, "legs": [ @@ -1208,6 +1187,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "elevationLost": 16.15, "endTime": "2009-10-21T23:45:25.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -1243,29 +1237,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 3 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2282, "legs": [ @@ -1707,6 +1679,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "elevationLost": 13.43, "endTime": "2009-10-21T23:54:25.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -1742,29 +1729,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2235, "legs": [ @@ -2058,6 +2023,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "elevationLost": 16.15, "endTime": "2009-10-21T23:54:25.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -2093,29 +2073,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.accessBikeRe "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 3 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2282, "legs": [ @@ -3091,6 +3049,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "elevationLost": 4.23, "endTime": "2009-10-21T23:31:21.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3126,29 +3099,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2305, "legs": [ @@ -3494,6 +3445,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "elevationLost": 23.58, "endTime": "2009-10-21T23:35:04.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3529,29 +3495,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2465, "legs": [ @@ -3923,6 +3867,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "elevationLost": 1.09, "endTime": "2009-10-21T23:37:44.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3958,29 +3917,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2396, "legs": [ @@ -4326,6 +4263,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "elevationLost": 4.76, "endTime": "2009-10-21T23:46:18.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -4361,29 +4313,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2787, "legs": [ @@ -4807,6 +4737,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "elevationLost": 4.23, "endTime": "2009-10-21T23:46:21.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -4842,29 +4787,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2305, "legs": [ @@ -5210,6 +5133,21 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "elevationLost": 23.58, "endTime": "2009-10-21T23:51:04.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -5245,29 +5183,7 @@ org.opentripplanner.routing.algorithm.mapping.ElevationSnapshotTest.transit=[ "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2525, "legs": [ diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap index 50650a89c16..4d991c93163 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/__snapshots__/TransitSnapshotTest.snap @@ -235,6 +235,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T18:38:41.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -270,29 +285,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 4281, "legs": [ @@ -727,6 +720,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T18:39:22.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -762,29 +770,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2315, "legs": [ @@ -1284,6 +1270,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T18:53:55.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -1319,29 +1320,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 4295, "legs": [ @@ -1776,6 +1755,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T18:55:32.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -1811,29 +1805,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2385, "legs": [ @@ -2333,6 +2305,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T19:08:19.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -2372,49 +2359,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - }, - { - "legIndices": [ - 2 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 3375, "legs": [ @@ -3093,6 +3038,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T18:38:40.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3128,29 +3088,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2895, "legs": [ @@ -3588,6 +3526,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T18:54:10.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -3623,29 +3576,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2925, "legs": [ @@ -4083,6 +4014,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T19:09:40.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -4118,29 +4064,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2895, "legs": [ @@ -4578,6 +4502,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T19:11:51.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -4617,49 +4556,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - }, - { - "legIndices": [ - 2 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 2957, "legs": [ @@ -5117,6 +5014,21 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "elevationLost": 0.0, "endTime": "2009-11-17T19:25:05.000+00:00", "fare": { + "coveringItinerary": [ + { + "amount": { + "cents": 200, + "currency": { + "currency": "USD", + "currencyCode": "USD", + "defaultFractionDigits": 2, + "symbol": "$" + } + }, + "id": "prt:regular", + "name": "regular" + } + ], "details": { "regular": [ { @@ -5156,49 +5068,7 @@ org.opentripplanner.routing.algorithm.mapping.TransitSnapshotTest.test_trip_plan "symbol": "$" } } - }, - "legProducts": [ - { - "legIndices": [ - 1 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - }, - { - "legIndices": [ - 2 - ], - "products": [ - { - "amount": { - "cents": 200, - "currency": { - "currency": "USD", - "currencyCode": "USD", - "defaultFractionDigits": 2, - "symbol": "$" - } - }, - "id": "prt:8", - "name": "regular" - } - ] - } - ] + } }, "generalizedCost": 3015, "legs": [ diff --git a/src/test/java/org/opentripplanner/routing/graph/DefaultRoutingServiceTest.java b/src/test/java/org/opentripplanner/routing/graph/DefaultRoutingServiceTest.java index edaa1245376..e9d286d5a92 100644 --- a/src/test/java/org/opentripplanner/routing/graph/DefaultRoutingServiceTest.java +++ b/src/test/java/org/opentripplanner/routing/graph/DefaultRoutingServiceTest.java @@ -29,7 +29,7 @@ public class DefaultRoutingServiceTest extends GtfsTest { @Override public String getFeedName() { - return "testagency"; + return "gtfs/simple"; } @Test diff --git a/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java b/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java index 27bda95f506..db11e81dabc 100644 --- a/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java +++ b/src/test/java/org/opentripplanner/routing/stoptimes/AlternativeLegsTest.java @@ -23,11 +23,11 @@ class AlternativeLegsTest extends GtfsTest { @Override public String getFeedName() { - return "testagency"; + return "gtfs/simple"; } @Test - void testPreviousLegs() throws Exception { + void testPreviousLegs() { var transitService = new DefaultTransitService(transitModel); var originalLeg = new ScheduledTransitLegReference( @@ -63,7 +63,7 @@ void testPreviousLegs() throws Exception { } @Test - void testNextLegs() throws Exception { + void testNextLegs() { var transitService = new DefaultTransitService(transitModel); var originalLeg = new ScheduledTransitLegReference( diff --git a/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java b/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java index 6158278e436..f9cf1898a19 100644 --- a/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java +++ b/src/test/java/org/opentripplanner/routing/stoptimes/StopTimesHelperTest.java @@ -28,7 +28,7 @@ class StopTimesHelperTest { @BeforeAll public static void setUp() throws Exception { - TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.FAKE_GTFS); + TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.SIMPLE_GTFS); TransitModel transitModel = model.transitModel(); transitService = new DefaultTransitService(transitModel); feedId = transitModel.getFeedIds().iterator().next(); diff --git a/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java b/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java new file mode 100644 index 00000000000..f193b65d986 --- /dev/null +++ b/src/test/java/org/opentripplanner/service/vehiclerental/internal/DefaultVehicleRentalServiceTest.java @@ -0,0 +1,40 @@ +package org.opentripplanner.service.vehiclerental.internal; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.opentripplanner.service.vehiclerental.model.TestFreeFloatingRentalVehicleBuilder; +import org.opentripplanner.service.vehiclerental.model.TestVehicleRentalStationBuilder; +import org.opentripplanner.service.vehiclerental.model.VehicleRentalStation; +import org.opentripplanner.service.vehiclerental.model.VehicleRentalVehicle; +import org.opentripplanner.transit.model.framework.FeedScopedId; + +class DefaultVehicleRentalServiceTest { + + @Test + void getVehicleRentalStationForEnvelopeShouldExcludeVehicleRentalVehicle() { + DefaultVehicleRentalService defaultVehicleRentalService = new DefaultVehicleRentalService(); + + VehicleRentalStation vehicleRentalStation = new TestVehicleRentalStationBuilder() + .withLatitude(1) + .withLongitude(1) + .build(); + defaultVehicleRentalService.addVehicleRentalStation(vehicleRentalStation); + + VehicleRentalVehicle vehicleRentalVehicle = new TestFreeFloatingRentalVehicleBuilder() + .withLatitude(2) + .withLongitude(2) + .build(); + defaultVehicleRentalService.addVehicleRentalStation(vehicleRentalVehicle); + + List vehicleRentalStationForEnvelope = defaultVehicleRentalService.getVehicleRentalStationForEnvelope( + 0, + 0, + 10, + 10 + ); + assertEquals(1, vehicleRentalStationForEnvelope.size()); + assertEquals(vehicleRentalStation, vehicleRentalStationForEnvelope.get(0)); + } +} diff --git a/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java b/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java index a6fe3da2f4a..4864fab5e43 100644 --- a/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java +++ b/src/test/java/org/opentripplanner/service/vehiclerental/model/TestFreeFloatingRentalVehicleBuilder.java @@ -8,6 +8,11 @@ public class TestFreeFloatingRentalVehicleBuilder { public static final String NETWORK_1 = "Network-1"; + public static final double DEFAULT_LATITUDE = 47.520; + public static final double DEFAULT_LONGITUDE = 19.01; + + private double latitude = DEFAULT_LATITUDE; + private double longitude = DEFAULT_LONGITUDE; private RentalVehicleType vehicleType = RentalVehicleType.getDefaultType(NETWORK_1); @@ -15,6 +20,16 @@ public static TestFreeFloatingRentalVehicleBuilder of() { return new TestFreeFloatingRentalVehicleBuilder(); } + public TestFreeFloatingRentalVehicleBuilder withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + + public TestFreeFloatingRentalVehicleBuilder withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public TestFreeFloatingRentalVehicleBuilder withVehicleScooter() { return buildVehicleType(RentalFormFactor.SCOOTER); } @@ -45,8 +60,8 @@ public VehicleRentalVehicle build() { var stationName = "free-floating-" + vehicleType.formFactor.name().toLowerCase(); vehicle.id = new FeedScopedId(NETWORK_1, stationName); vehicle.name = new NonLocalizedString(stationName); - vehicle.latitude = 47.510; - vehicle.longitude = 18.99; + vehicle.latitude = latitude; + vehicle.longitude = longitude; vehicle.vehicleType = vehicleType; return vehicle; } diff --git a/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java b/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java index 6e3d302c219..4557be813d5 100644 --- a/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java +++ b/src/test/java/org/opentripplanner/service/vehiclerental/model/TestVehicleRentalStationBuilder.java @@ -9,7 +9,11 @@ public class TestVehicleRentalStationBuilder { public static final String NETWORK_1 = "Network-1"; + public static final double DEFAULT_LATITUDE = 47.510; + public static final double DEFAULT_LONGITUDE = 18.99; + private double latitude = DEFAULT_LATITUDE; + private double longitude = DEFAULT_LONGITUDE; private int vehicles = 10; private int spaces = 10; private boolean overloadingAllowed = false; @@ -20,6 +24,16 @@ public static TestVehicleRentalStationBuilder of() { return new TestVehicleRentalStationBuilder(); } + public TestVehicleRentalStationBuilder withLatitude(double latitude) { + this.latitude = latitude; + return this; + } + + public TestVehicleRentalStationBuilder withLongitude(double longitude) { + this.longitude = longitude; + return this; + } + public TestVehicleRentalStationBuilder withVehicles(int vehicles) { this.vehicles = vehicles; return this; @@ -66,8 +80,8 @@ public VehicleRentalStation build() { var stationName = "FooStation"; station.id = new FeedScopedId(NETWORK_1, stationName); station.name = new NonLocalizedString(stationName); - station.latitude = 47.510; - station.longitude = 18.99; + station.latitude = latitude; + station.longitude = longitude; station.vehiclesAvailable = vehicles; station.spacesAvailable = spaces; station.vehicleTypesAvailable = Map.of(vehicleType, vehicles); diff --git a/src/test/java/org/opentripplanner/smoketest/HoustonSmokeTest.java b/src/test/java/org/opentripplanner/smoketest/HoustonSmokeTest.java index ce60e58a8d7..1cf43de7fde 100644 --- a/src/test/java/org/opentripplanner/smoketest/HoustonSmokeTest.java +++ b/src/test/java/org/opentripplanner/smoketest/HoustonSmokeTest.java @@ -27,10 +27,12 @@ public class HoustonSmokeTest { @Test public void routeFromSouthToNorth() { var modes = Set.of(TRANSIT, WALK); - SmokeTest.basicRouteTest( + var plan = SmokeTest.basicRouteTest( new SmokeTestRequest(galvestonRoad, northLindale, modes), List.of("WALK", "BUS", "BUS", "WALK", "TRAM", "WALK") ); + + SmokeTest.assertThatAllTransitLegsHaveFareProducts(plan); } @Test diff --git a/src/test/java/org/opentripplanner/smoketest/PortlandSmokeTest.java b/src/test/java/org/opentripplanner/smoketest/PortlandSmokeTest.java index 538e4f9fc39..f55810283ca 100644 --- a/src/test/java/org/opentripplanner/smoketest/PortlandSmokeTest.java +++ b/src/test/java/org/opentripplanner/smoketest/PortlandSmokeTest.java @@ -27,10 +27,12 @@ public class PortlandSmokeTest { public void railTrip() { // this used to be across the city by since the train is interrupted in April '23 this is a // much shorter trip - SmokeTest.basicRouteTest( + var plan = SmokeTest.basicRouteTest( new SmokeTestRequest(cennentenial, hazelwood, Set.of(TRAM, WALK)), List.of("WALK", "TRAM", "WALK") ); + + SmokeTest.assertThatAllTransitLegsHaveFareProducts(plan); } /** diff --git a/src/test/java/org/opentripplanner/smoketest/SeattleSmokeTest.java b/src/test/java/org/opentripplanner/smoketest/SeattleSmokeTest.java index 737037acd2c..75c771d5b0c 100644 --- a/src/test/java/org/opentripplanner/smoketest/SeattleSmokeTest.java +++ b/src/test/java/org/opentripplanner/smoketest/SeattleSmokeTest.java @@ -32,10 +32,12 @@ public class SeattleSmokeTest { @Test public void acrossTheCity() { var modes = Set.of(TRANSIT, WALK); - SmokeTest.basicRouteTest( + var plan = SmokeTest.basicRouteTest( new SmokeTestRequest(sodo, clydeHill, modes), List.of("WALK", "BUS", "WALK", "BUS", "WALK") ); + + SmokeTest.assertThatAllTransitLegsHaveFareProducts(plan); } @Test diff --git a/src/test/java/org/opentripplanner/smoketest/SeptaSmokeTest.java b/src/test/java/org/opentripplanner/smoketest/SeptaSmokeTest.java index 5c781efbad9..3f263298c8e 100644 --- a/src/test/java/org/opentripplanner/smoketest/SeptaSmokeTest.java +++ b/src/test/java/org/opentripplanner/smoketest/SeptaSmokeTest.java @@ -1,15 +1,21 @@ package org.opentripplanner.smoketest; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opentripplanner.client.model.RequestMode.BICYCLE_RENT; import static org.opentripplanner.client.model.RequestMode.TRANSIT; import static org.opentripplanner.client.model.RequestMode.WALK; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.opentripplanner.client.model.Coordinate; +import org.opentripplanner.client.model.FareProductUse; import org.opentripplanner.smoketest.util.SmokeTestRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This smoke test expects an OTP installation running at localhost:8080 @@ -18,6 +24,8 @@ @Tag("septa") public class SeptaSmokeTest { + private static final Logger LOG = LoggerFactory.getLogger(SeptaSmokeTest.class); + Coordinate airport = new Coordinate(39.876151, -75.245189); Coordinate stPetersCemetary = new Coordinate(39.98974, -75.09515); @@ -27,10 +35,28 @@ public class SeptaSmokeTest { @Test public void routeFromAirportToNorthPhiladelphia() { var modes = Set.of(TRANSIT, WALK); - SmokeTest.basicRouteTest( + var plan = SmokeTest.basicRouteTest( new SmokeTestRequest(airport, stPetersCemetary, modes), List.of("WALK", "RAIL", "RAIL", "WALK", "SUBWAY", "WALK") ); + var products = plan + .itineraries() + .stream() + .flatMap(i -> i.legs().stream()) + .flatMap(leg -> leg.fareProducts().stream()) + .map(FareProductUse::product) + .toList(); + + assertFalse(products.isEmpty()); + + var prices = products + .stream() + .map(p -> p.price().amount().doubleValue()) + .collect(Collectors.toSet()); + + LOG.info("Received fare products {}", products); + + assertTrue(prices.contains(2.5d)); } @Test diff --git a/src/test/java/org/opentripplanner/smoketest/SmokeTest.java b/src/test/java/org/opentripplanner/smoketest/SmokeTest.java index d7de1c0891c..d7dbd924d28 100644 --- a/src/test/java/org/opentripplanner/smoketest/SmokeTest.java +++ b/src/test/java/org/opentripplanner/smoketest/SmokeTest.java @@ -3,14 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import java.io.IOException; import java.time.DayOfWeek; import java.time.LocalDate; @@ -18,15 +10,14 @@ import java.time.ZoneId; import java.time.temporal.TemporalAdjusters; import java.util.List; -import org.opentripplanner.api.json.JSONObjectMapperProvider; -import org.opentripplanner.api.resource.DebugOutput; import org.opentripplanner.client.OtpApiClient; +import org.opentripplanner.client.model.Itinerary; import org.opentripplanner.client.model.TripPlan; -import org.opentripplanner.client.model.TripPlan.Itinerary; import org.opentripplanner.client.model.VehicleRentalStation; import org.opentripplanner.client.parameters.TripPlanParameters; -import org.opentripplanner.model.fare.ItineraryFares; import org.opentripplanner.smoketest.util.SmokeTestRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This is both a utility class and a category to select or deselect smoke tests during test @@ -38,25 +29,13 @@ */ public class SmokeTest { - public static final ObjectMapper mapper; + private static final Logger LOG = LoggerFactory.getLogger(SmokeTest.class); + public static final OtpApiClient API_CLIENT = new OtpApiClient( ZoneId.of("America/New_York"), "http://localhost:8080" ); - static { - var provider = new JSONObjectMapperProvider(); - - SimpleModule module = new SimpleModule("SmokeTests"); - module.addDeserializer(ItineraryFares.class, new FareDeserializer()); - module.addDeserializer(DebugOutput.class, new DebugOutputDeserializer()); - - mapper = provider.getContext(null); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)); - mapper.registerModule(module); - } - /** * In order to have somewhat predictable results we get the route for the next Monday. *

@@ -135,29 +114,18 @@ static void assertThereArePatternsWithVehiclePositions() { } } - /** - * The Fare class is a little hard to deserialize, so we have a custom deserializer as we don't - * run any assertions against the fares. (That is done during unit tests.) - */ - static class FareDeserializer extends JsonDeserializer { - - @Override - public ItineraryFares deserialize( - JsonParser jsonParser, - DeserializationContext deserializationContext - ) { - return null; - } - } - - static class DebugOutputDeserializer extends JsonDeserializer { - - @Override - public DebugOutput deserialize( - JsonParser jsonParser, - DeserializationContext deserializationContext - ) { - return null; - } + static void assertThatAllTransitLegsHaveFareProducts(TripPlan plan) { + var transitLegs = plan.transitItineraries().stream().flatMap(i -> i.transitLegs().stream()); + transitLegs.forEach(leg -> { + assertFalse(leg.fareProducts().isEmpty(), "Leg %s should have fare products".formatted(leg)); + + LOG.info( + "Leg with mode {} from {} to {} has {} fare products.", + leg.mode(), + leg.from(), + leg.to(), + leg.fareProducts().size() + ); + }); } } diff --git a/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java b/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java index a5f37083d4a..e9b979e3b5b 100644 --- a/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java +++ b/src/test/java/org/opentripplanner/street/integration/BarrierRoutingTest.java @@ -31,6 +31,7 @@ import org.opentripplanner.routing.impl.GraphPathFinder; import org.opentripplanner.street.search.TemporaryVerticesContainer; import org.opentripplanner.street.search.TraverseMode; +import org.opentripplanner.test.support.ResourceLoader; public class BarrierRoutingTest { @@ -41,7 +42,7 @@ public class BarrierRoutingTest { @BeforeAll public static void createGraph() { TestOtpModel model = ConstantsForTests.buildOsmGraph( - ConstantsForTests.HERRENBERG_BARRIER_GATES_OSM + ResourceLoader.of(BarrierRoutingTest.class).file("herrenberg-barrier-gates.osm.pbf") ); graph = model.graph(); graph.index(model.transitModel().getStopModel()); diff --git a/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java b/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java index 9588671cd28..300615269a1 100644 --- a/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java +++ b/src/test/java/org/opentripplanner/street/integration/BicycleRoutingTest.java @@ -21,6 +21,7 @@ import org.opentripplanner.routing.impl.GraphPathFinder; import org.opentripplanner.street.search.TemporaryVerticesContainer; import org.opentripplanner.street.search.TraverseMode; +import org.opentripplanner.test.support.ResourceLoader; public class BicycleRoutingTest { @@ -28,7 +29,9 @@ public class BicycleRoutingTest { private final Graph herrenbergGraph; { - TestOtpModel model = ConstantsForTests.buildOsmGraph(ConstantsForTests.HERRENBERG_OSM); + TestOtpModel model = ConstantsForTests.buildOsmGraph( + ResourceLoader.of(BicycleRoutingTest.class).file("herrenberg-minimal.osm.pbf") + ); herrenbergGraph = model.graph(); model.transitModel().index(); diff --git a/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java b/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java index 2ed0ff6febd..471d6bf80ce 100644 --- a/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java +++ b/src/test/java/org/opentripplanner/street/integration/CarRoutingTest.java @@ -22,16 +22,20 @@ import org.opentripplanner.routing.impl.GraphPathFinder; import org.opentripplanner.street.search.TemporaryVerticesContainer; import org.opentripplanner.street.search.TraverseMode; +import org.opentripplanner.test.support.ResourceLoader; public class CarRoutingTest { static final Instant dateTime = Instant.now(); + private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of(CarRoutingTest.class); private static Graph herrenbergGraph; @BeforeAll public static void setup() { - TestOtpModel model = ConstantsForTests.buildOsmGraph(ConstantsForTests.HERRENBERG_OSM); + TestOtpModel model = ConstantsForTests.buildOsmGraph( + RESOURCE_LOADER.file("herrenberg-minimal.osm.pbf") + ); herrenbergGraph = model.index().graph(); } @@ -53,7 +57,7 @@ public static void setup() { @DisplayName("car routes can contain loops (traversing the same edge twice)") public void shouldAllowLoopCausedByTurnRestrictions() { TestOtpModel model = ConstantsForTests.buildOsmGraph( - ConstantsForTests.HERRENBERG_HINDENBURG_STR_UNDER_CONSTRUCTION_OSM + RESOURCE_LOADER.file("herrenberg-hindenburgstr-under-construction.osm.pbf") ); var hindenburgStrUnderConstruction = model.index().graph(); diff --git a/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java b/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java index 3f88182c494..28ab5e91725 100644 --- a/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java +++ b/src/test/java/org/opentripplanner/street/integration/SplitEdgeTurnRestrictionsTest.java @@ -21,6 +21,7 @@ import org.opentripplanner.routing.impl.GraphPathFinder; import org.opentripplanner.street.search.TemporaryVerticesContainer; import org.opentripplanner.street.search.TraverseMode; +import org.opentripplanner.test.support.ResourceLoader; /* * When bus stops are added to graph they split an existing edge in two parts so that an artificial @@ -45,12 +46,15 @@ public class SplitEdgeTurnRestrictionsTest { static final GenericLocation parkStrasse = new GenericLocation(48.68358, 9.00826); static final GenericLocation herrenbergerStrasse = new GenericLocation(48.68497, 9.00909); static final GenericLocation steinbeissWeg = new GenericLocation(48.68172, 9.00599); + private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of( + SplitEdgeTurnRestrictionsTest.class + ); @Test void shouldTakeDeufringenTurnRestrictionsIntoAccount() { TestOtpModel model = ConstantsForTests.buildOsmAndGtfsGraph( - ConstantsForTests.DEUFRINGEN_OSM, - ConstantsForTests.VVS_BUS_764_ONLY + RESOURCE_LOADER.file("deufringen-minimal.osm.pbf"), + RESOURCE_LOADER.file("vvs-bus-764-only.gtfs.zip") ); Graph graph = model.graph(); // https://www.openstreetmap.org/relation/10264251 has a turn restriction so when leaving Hardtheimer Weg @@ -89,8 +93,8 @@ void shouldTakeBoeblingenTurnRestrictionsIntoAccount() { // this tests that the following turn restriction is transferred correctly to the split edges // https://www.openstreetmap.org/relation/299171 TestOtpModel model = ConstantsForTests.buildOsmAndGtfsGraph( - ConstantsForTests.BOEBLINGEN_OSM, - ConstantsForTests.VVS_BUS_751_ONLY + RESOURCE_LOADER.file("boeblingen-minimal.osm.pbf"), + RESOURCE_LOADER.file("vvs-bus-751-only.gtfs.zip") ); var graph = model.graph(); diff --git a/src/test/java/org/opentripplanner/street/model/vertex/BarrierVertexTest.java b/src/test/java/org/opentripplanner/street/model/vertex/BarrierVertexTest.java index 127f34e17ca..a92d69b39f0 100644 --- a/src/test/java/org/opentripplanner/street/model/vertex/BarrierVertexTest.java +++ b/src/test/java/org/opentripplanner/street/model/vertex/BarrierVertexTest.java @@ -24,42 +24,42 @@ public class BarrierVertexTest { @Test public void testBarrierPermissions() { - OSMNode simpleBarier = new OSMNode(); - assertFalse(simpleBarier.isBollard()); - simpleBarier.addTag("barrier", "bollard"); - assertTrue(simpleBarier.isBollard()); + OSMNode simpleBarrier = new OSMNode(); + assertFalse(simpleBarrier.isMotorVehicleBarrier()); + simpleBarrier.addTag("barrier", "bollard"); + assertTrue(simpleBarrier.isMotorVehicleBarrier()); String label = "simpleBarrier"; - BarrierVertex bv = new BarrierVertex(simpleBarier.lon, simpleBarier.lat, 0); + BarrierVertex bv = new BarrierVertex(simpleBarrier.lon, simpleBarrier.lat, 0); bv.setBarrierPermissions( - simpleBarier.overridePermissions(BarrierVertex.defaultBarrierPermissions) + simpleBarrier.overridePermissions(BarrierVertex.defaultBarrierPermissions) ); assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions()); - simpleBarier.addTag("foot", "yes"); + simpleBarrier.addTag("foot", "yes"); bv.setBarrierPermissions( - simpleBarier.overridePermissions(BarrierVertex.defaultBarrierPermissions) + simpleBarrier.overridePermissions(BarrierVertex.defaultBarrierPermissions) ); assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions()); - simpleBarier.addTag("bicycle", "yes"); + simpleBarrier.addTag("bicycle", "yes"); bv.setBarrierPermissions( - simpleBarier.overridePermissions(BarrierVertex.defaultBarrierPermissions) + simpleBarrier.overridePermissions(BarrierVertex.defaultBarrierPermissions) ); assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions()); - simpleBarier.addTag("access", "no"); + simpleBarrier.addTag("access", "no"); bv.setBarrierPermissions( - simpleBarier.overridePermissions(BarrierVertex.defaultBarrierPermissions) + simpleBarrier.overridePermissions(BarrierVertex.defaultBarrierPermissions) ); assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions()); - simpleBarier.addTag("motor_vehicle", "no"); + simpleBarrier.addTag("motor_vehicle", "no"); bv.setBarrierPermissions( - simpleBarier.overridePermissions(BarrierVertex.defaultBarrierPermissions) + simpleBarrier.overridePermissions(BarrierVertex.defaultBarrierPermissions) ); assertEquals(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, bv.getBarrierPermissions()); - simpleBarier.addTag("bicycle", "no"); + simpleBarrier.addTag("bicycle", "no"); bv.setBarrierPermissions( - simpleBarier.overridePermissions(BarrierVertex.defaultBarrierPermissions) + simpleBarrier.overridePermissions(BarrierVertex.defaultBarrierPermissions) ); assertEquals(StreetTraversalPermission.PEDESTRIAN, bv.getBarrierPermissions()); @@ -94,8 +94,8 @@ public void testBarrierPermissions() { @Test public void testStreetsWithBollard() { Graph graph = new Graph(); - //default permissions are PEDESTRIAND and BICYCLE BarrierVertex bv = new BarrierVertex(2.0, 2.0, 0); + bv.setBarrierPermissions(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE); StreetVertex endVertex = StreetModelForTest.intersectionVertex("end_vertex", 1.0, 2.0); @@ -139,18 +139,18 @@ public void testStreetsWithBollard() { assertTrue(endVertex_to_bv_forward.canTraverse(TraverseMode.BICYCLE)); assertTrue(endVertex_to_bv_forward.canTraverse(TraverseMode.WALK)); - //tests bollard which doesn't allow cycling - BarrierVertex noBicycleBollard = new BarrierVertex(1.5, 1, 0); - noBicycleBollard.setBarrierPermissions(StreetTraversalPermission.PEDESTRIAN); - StreetEdge no_bike_to_endVertex = edge(noBicycleBollard, endVertex, 100, false); + //tests bollard which allows only walking + BarrierVertex onlyWalkBollard = new BarrierVertex(1.5, 1, 0); + onlyWalkBollard.setBarrierPermissions(StreetTraversalPermission.PEDESTRIAN); + StreetEdge edge = edge(onlyWalkBollard, endVertex, 100, false); - assertTrue(no_bike_to_endVertex.canTraverse(new TraverseModeSet(TraverseMode.CAR))); - assertTrue(no_bike_to_endVertex.canTraverse(new TraverseModeSet(TraverseMode.BICYCLE))); - assertTrue(no_bike_to_endVertex.canTraverse(new TraverseModeSet(TraverseMode.WALK))); + assertTrue(edge.canTraverse(new TraverseModeSet(TraverseMode.CAR))); + assertTrue(edge.canTraverse(new TraverseModeSet(TraverseMode.BICYCLE))); + assertTrue(edge.canTraverse(new TraverseModeSet(TraverseMode.WALK))); - assertFalse(no_bike_to_endVertex.canTraverse(TraverseMode.CAR)); - assertFalse(no_bike_to_endVertex.canTraverse(TraverseMode.BICYCLE)); - assertTrue(no_bike_to_endVertex.canTraverse(TraverseMode.WALK)); + assertFalse(edge.canTraverse(TraverseMode.CAR)); + assertFalse(edge.canTraverse(TraverseMode.BICYCLE)); + assertTrue(edge.canTraverse(TraverseMode.WALK)); } /** diff --git a/src/test/java/org/opentripplanner/test/support/ResourceLoader.java b/src/test/java/org/opentripplanner/test/support/ResourceLoader.java new file mode 100644 index 00000000000..74d34c573ef --- /dev/null +++ b/src/test/java/org/opentripplanner/test/support/ResourceLoader.java @@ -0,0 +1,73 @@ +package org.opentripplanner.test.support; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; + +/** + * Loads files from the resources folder relative to the package name of the class/instances + * passed to initializers. + *

+ * So if your class' package is org.opentripplanner.foo, then the corresponding resources + * must be placed in src/test/resources/org/opentripplanner/foo. + */ +public class ResourceLoader { + + private final Class clazz; + + private ResourceLoader(Class clazz) { + this.clazz = clazz; + } + + /** + * Initialize a loader with the given class' package. + */ + public static ResourceLoader of(Class clazz) { + return new ResourceLoader(clazz); + } + + /** + * Initialize a loader with the given instances' class' package. + */ + public static ResourceLoader of(Object object) { + return new ResourceLoader(object.getClass()); + } + + /** + * Return a File instance for the given path. + */ + public File file(String path) { + URL resource = url(path); + var file = new File(resource.getFile()); + assertTrue( + file.exists(), + "File '%s' not found on file system.".formatted(file.getAbsolutePath()) + ); + return file; + } + + /** + * Return a URL for the given resource. + */ + public URL url(String name) { + var resource = clazz.getResource(name); + var msg = "Resource '%s' not found in package '%s'".formatted(name, clazz.getPackageName()); + assertNotNull(resource, msg); + return resource; + } + + /** + * Return a URI for the given resource. + */ + public URI uri(String s) { + try { + return url(s).toURI(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } +} diff --git a/src/test/java/org/opentripplanner/transit/service/TransitModelTest.java b/src/test/java/org/opentripplanner/transit/service/TransitModelTest.java index 835b27b780e..95c20245f9a 100644 --- a/src/test/java/org/opentripplanner/transit/service/TransitModelTest.java +++ b/src/test/java/org/opentripplanner/transit/service/TransitModelTest.java @@ -11,6 +11,7 @@ import org.opentripplanner.graph_builder.module.TimeZoneAdjusterModule; import org.opentripplanner.model.Timetable; import org.opentripplanner.routing.graph.Graph; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.transit.model.framework.Deduplicator; import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.model.timetable.Trip; @@ -19,6 +20,7 @@ class TransitModelTest { public static final String FAKE_FEED_ID = "FAKE"; public static final FeedScopedId SAMPLE_TRIP_ID = new FeedScopedId(FAKE_FEED_ID, "1.2"); + private static final ResourceLoader RESOURCE_LOADER = ResourceLoader.of(TransitModelTest.class); @Test void validateTimeZones() { @@ -30,7 +32,7 @@ void validateTimeZones() { ConstantsForTests.addGtfsToGraph( graph, transitModel, - ConstantsForTests.FAKE_GTFS, + ConstantsForTests.SIMPLE_GTFS, new DefaultFareServiceFactory(), FAKE_FEED_ID ); @@ -51,7 +53,7 @@ void validateTimeZones() { ConstantsForTests.addGtfsToGraph( graph, transitModel, - ConstantsForTests.KCM_GTFS, + RESOURCE_LOADER.file("kcm_gtfs.zip"), new DefaultFareServiceFactory(), null ), @@ -77,7 +79,7 @@ void validateTimeZonesWithExplicitTimeZone() { ConstantsForTests.addGtfsToGraph( graph, transitModel, - ConstantsForTests.FAKE_GTFS, + ConstantsForTests.SIMPLE_GTFS, new DefaultFareServiceFactory(), FAKE_FEED_ID ); @@ -86,7 +88,7 @@ void validateTimeZonesWithExplicitTimeZone() { ConstantsForTests.addGtfsToGraph( graph, transitModel, - ConstantsForTests.KCM_GTFS, + RESOURCE_LOADER.file("kcm_gtfs.zip"), new DefaultFareServiceFactory(), null ); diff --git a/src/test/java/org/opentripplanner/transit/speed_test/package.md b/src/test/java/org/opentripplanner/transit/speed_test/package.md index ea4f1dcf620..d5e596d339f 100644 --- a/src/test/java/org/opentripplanner/transit/speed_test/package.md +++ b/src/test/java/org/opentripplanner/transit/speed_test/package.md @@ -10,17 +10,26 @@ To run the SpeedTest use the {@code --help} option to se the documentation. Ther documentation on this tool, hopefully with time, we will add more doc and maybe automate part of this test. -Example input files and setup is included in the resource test folder: +Example input files, setup and documentation is included in the resource test folder [test/ci-performance-test/](test/performance/README.md). -- {@code test/ci-performance-test/}. +## Download GTFS data: -## Running +- https://storage.googleapis.com/marduk-production/outbound/gtfs/rb_norway-aggregated-gtfs.zip +If the link above do not work you should be able to find it on the ENTUR web: + +- https://www.entur.org/ + +## Configure the test + +- Set the testDate in the speed-test-config.json + +## Run ``` mvn compiler:testCompile exec:java -Dexec.mainClass="org.opentripplanner.transit.speed_test.SpeedTest" -Dexec.classpathScope=test -Dexec.args="--dir=test/ci-performance-test/ -p md -n 4" ``` ## CI -The test is run after every merge to master. Its Github Actions workflow is defined +The test is run after every merge to dev-2.x. Its Github Actions workflow is defined in [performance-test.yml](../../../../../../../../.github/workflows/performance-test.yml). \ No newline at end of file diff --git a/src/test/java/org/opentripplanner/updater/trip/GtfsRealtimeTripUpdateSourceTest.java b/src/test/java/org/opentripplanner/updater/trip/GtfsRealtimeTripUpdateSourceTest.java index 965dbee6b15..cffb869ad43 100644 --- a/src/test/java/org/opentripplanner/updater/trip/GtfsRealtimeTripUpdateSourceTest.java +++ b/src/test/java/org/opentripplanner/updater/trip/GtfsRealtimeTripUpdateSourceTest.java @@ -5,6 +5,7 @@ import java.time.Duration; import org.junit.jupiter.api.Test; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.updater.spi.HttpHeaders; public class GtfsRealtimeTripUpdateSourceTest { @@ -18,7 +19,7 @@ public void parseFeed() { false, BackwardsDelayPropagationType.ALWAYS, "rt", - "file:src/test/resources/gtfs-rt/trip-updates/septa.pbf", + ResourceLoader.of(this).url("septa.pbf").toString(), HttpHeaders.empty() ) ); diff --git a/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotSourceTest.java b/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotSourceTest.java index 044a5d18bca..a1e499e6d02 100644 --- a/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotSourceTest.java +++ b/src/test/java/org/opentripplanner/updater/trip/TimetableSnapshotSourceTest.java @@ -66,7 +66,7 @@ public class TimetableSnapshotSourceTest { @BeforeEach public void setUp() { - TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.FAKE_GTFS); + TestOtpModel model = ConstantsForTests.buildGtfsGraph(ConstantsForTests.SIMPLE_GTFS); transitModel = model.transitModel(); feedId = transitModel.getFeedIds().stream().findFirst().get(); diff --git a/src/test/java/org/opentripplanner/updater/vehicle_position/VehiclePositionParsingTest.java b/src/test/java/org/opentripplanner/updater/vehicle_position/VehiclePositionParsingTest.java index fecbcf79fcd..f077321a0aa 100644 --- a/src/test/java/org/opentripplanner/updater/vehicle_position/VehiclePositionParsingTest.java +++ b/src/test/java/org/opentripplanner/updater/vehicle_position/VehiclePositionParsingTest.java @@ -1,41 +1,43 @@ package org.opentripplanner.updater.vehicle_position; -import java.net.URI; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.opentripplanner.test.support.ResourceLoader; import org.opentripplanner.updater.spi.HttpHeaders; public class VehiclePositionParsingTest { @Test public void parseFirstPositionsFeed() { - var vehiclePositionSource = getVehiclePositionSource("king-county-metro-1.pb"); + var vehiclePositionSource = getVehiclePositionSource("king-county-metro-1.pbf"); var positions = vehiclePositionSource.getPositions(); Assertions.assertNotNull(positions); - Assertions.assertEquals(627, positions.size()); + assertEquals(627, positions.size()); var first = positions.get(0); - Assertions.assertEquals("49195152", first.getTrip().getTripId()); + assertEquals("49195152", first.getTrip().getTripId()); } @Test public void parseSecondPositionsFeed() { - var vehiclePositionSource = getVehiclePositionSource("king-county-metro-2.pb"); + var vehiclePositionSource = getVehiclePositionSource("king-county-metro-2.pbf"); var positions = vehiclePositionSource.getPositions(); Assertions.assertNotNull(positions); - Assertions.assertEquals(570, positions.size()); + assertEquals(570, positions.size()); var first = positions.get(0); - Assertions.assertEquals("49195157", first.getTrip().getTripId()); + assertEquals("49195157", first.getTrip().getTripId()); } private GtfsRealtimeHttpVehiclePositionSource getVehiclePositionSource(String filename) { return new GtfsRealtimeHttpVehiclePositionSource( - URI.create("file:src/test/resources/gtfs-rt/vehicle-positions/" + filename), + ResourceLoader.of(this).uri(filename), HttpHeaders.empty() ); } diff --git a/src/test/resources/generateGtfs.py b/src/test/resources/generateGtfs.py deleted file mode 100755 index dd2e48f5f66..00000000000 --- a/src/test/resources/generateGtfs.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/python - -readme = """A fake GTFS feed for use in testing departure time searches. -It is used to test pickup/dropoff combinations, wheelchair boarding and headsigns at the per-trip -and per-stop levels, bicycle-allowing trips, banned routes and trips, and multiple boarding search -return values all with one feed. - -The feed describes two transit routes named A and B. -Both routes have service every 15 minutes from 06:00 until 23:00. -Trip IDs are the route name concatenated with the zero-padded first departure time, e.g. A0730. -Both routes have seven stops, with each stop serving only one route. -Stops are numbered 0 through 7, and their IDs are the route name concatenated with the stop number. -Stops A3 and B3 are located in a single station complex with ID 'xfer'. -Each stop is 10 minutes away from the previous one on its line. -Arrival times are identical to departure times at stops on route A (i.e. there is no dwell time), -but arrivals are 1 minute before departures on route B (there is a dwell of 1 minute at each stop). - -All trips allow bicycles except those during rush hour (defined as 7-9 AM and 5-7 PM). -Trips departing the first stop at x:00 and x:30 can accommodate wheelchairs, while those departing -at x:15 and x:45 cannot. Wheelchair accessibility also varies at the stop level, with odd-numbered -stops marked inaccessible. - -Starting at 10 PM stops 0 and 1 are pick-up-only, 2 through 4 allow pick-up and drop-off, -and 5 and 6 only allow drop-off. Before 10 PM, all stops allow both pick-up and drop-off. - -Trip-level headsign definitions read EAST on route A and SOUTH on route B. -Stop-level headsign definitions are provided at stops 0, 1, and 2 which append the text 'VIA XFER'. - -""" - -# 1. The wheelchair_boarding field in stops.txt is standard but optional. -# 2. The wheelchair_accessible field in trips.txt is an (optional) extension. -# http://support.google.com/transitpartners/bin/answer.py?hl=en&answer=2450962 -# 3. The trip_bikes_allowed field in trips.txt is an (optional) extension. -# https://groups.google.com/d/msg/gtfs-changes/QqaGOuNmG7o/uKpD70szrbkJ - -WHEELCHAIR_YES = 1 -WHEELCHAIR_NO = 2 -WHEELCHAIR_UNDEF = 0 -BIKE_YES = 2 -BIKE_NO = 1 -BIKE_UNDEF = 0 -LOCATION_STOP = 0 -LOCATION_STATION = 1 -PICKDROP_SCHEDULED = 0 -PICKDROP_NO = 1 -PICKDROP_PHONE = 2 -PICKDROP_COORDINATE = 3 - -# zipfile has no way to add file-like buffers (SpooledTemporaryFile is out), so we have to add the -# intermediate files from the filesystem, subclass ZipFile, or write from strings. We use the latter. -from zipfile import ZipFile -gtfs = ZipFile('generated.gtfs.zip', mode='w') - -# The agency and calendar tables are hard coded (not generated). There should be -# one agency called TEST and one service_id called ALL that runs every day of the week from -# 01-JAN-2012 through 31-DEC-2012. -agency_rows = """agency_id,agency_name,agency_url,agency_timezone -TEST,Gulf of Guinea Transit,http://www.test.com,Africa/Accra -""" -gtfs.writestr('agency.txt', agency_rows) -calendar_rows = """service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date -ALL,1,1,1,1,1,1,1,20120101,20121231 -""" -gtfs.writestr('calendar.txt', calendar_rows) - -from cStringIO import StringIO -routes_file = StringIO() -stops_file = StringIO() -import csv -routes = csv.writer(routes_file) -routes.writerow(['route_id', 'route_short_name', 'route_long_name', 'route_type']) -stops = csv.writer(stops_file) -stops.writerow(['stop_id', 'stop_name', 'stop_lat', 'stop_lon', 'location_type', 'parent_station', 'wheelchair_boarding']) -stops.writerow(['xfer', 'xfer', '1.00', '1.03', LOCATION_STATION, None, WHEELCHAIR_YES]) # station allows wheelchair access -for route in ['A', 'B'] : - routes.writerow((route, route, route, 1)) # make B a different mode for mode param testing? - if route == 'A' : - stop_lon = stop_lat = 1.00 - else : - stop_lon = stop_lat = 1.03 - for stop in range (7) : - stop_id = route + str(stop) - wheelchair = WHEELCHAIR_YES if (stop % 2 == 0) else WHEELCHAIR_NO - parent_station = 'xfer' if stop == 3 else None - row = (stop_id, stop_id, stop_lat, stop_lon, LOCATION_STOP, parent_station, wheelchair) - stops.writerow(row) - if route == 'A' : - stop_lon += 0.01000 - else : - stop_lat -= 0.01000 - -gtfs.writestr('routes.txt', routes_file.getvalue()) -gtfs.writestr('stops.txt', stops_file.getvalue()) - -def sec(h, m, s = 0) : - return (((h * 60) + m) * 60) + s - -def tstr(h, m, s = 0): - # handle (possibly negative) minute overage - s = sec(h, m, s) - m = s / 60 - s = s % 60 - h = m / 60 - m = m % 60 - return '%02d:%02d:%02d' % (h, m, s) - -trips_file = StringIO() -trips = csv.writer(trips_file) -header = ('route_id', 'service_id', 'trip_id', 'trip_headsign') -trips.writerow(header) - -stop_times_file = StringIO() -stop_times = csv.writer(stop_times_file) -header = ('trip_id', 'arrival_time', 'departure_time', 'stop_id', 'stop_sequence', 'stop_headsign', 'pickup_type', 'drop_off_type') -stop_times.writerow(header) - -for route in ['A', 'B'] : - headsign = 'EAST' if route == 'A' else 'SOUTH' - for hour in range (6, 23): - bicycle = not (hour in [7, 8, 17, 18]) - for minute in [0, 15, 30, 45] : - # print 'route %s %02d:%02d' % (route, hour, minute) - trip_id = '%s%02d%02d' % (route, hour, minute) - wheelchair_trip = minute in [0, 30] - arv = dep = minute - if route == 'B' : - arv -= 1 - row = (route, 'ALL', trip_id, headsign) - trips.writerow(row) - for stop in range (7) : - stop_id = route + str(stop) - if hour < 22 : - pickup = drop_off = PICKDROP_SCHEDULED - else : - pickup = PICKDROP_SCHEDULED if stop <= 4 else PICKDROP_NO - drop_off = PICKDROP_SCHEDULED if stop >= 2 else PICKDROP_NO - stop_headsign = headsign + ' VIA XFER' if stop < 3 else None - row = (trip_id, tstr(hour, arv), tstr(hour, dep), stop_id, stop + 100, stop_headsign, pickup, drop_off) - stop_times.writerow(row) - arv += 10 - dep += 10 - -gtfs.writestr('trips.txt', trips_file.getvalue()) -gtfs.writestr('stop_times.txt', stop_times_file.getvalue()) -gtfs.writestr('README', readme) -#interline trips back in the other direction? - - diff --git a/src/test/resources/generated.gtfs.zip b/src/test/resources/generated.gtfs.zip deleted file mode 100644 index 0786dab730b..00000000000 Binary files a/src/test/resources/generated.gtfs.zip and /dev/null differ diff --git a/src/test/resources/testagency/agency.txt b/src/test/resources/gtfs/simple/agency.txt similarity index 100% rename from src/test/resources/testagency/agency.txt rename to src/test/resources/gtfs/simple/agency.txt diff --git a/src/test/resources/testagency/calendar.txt b/src/test/resources/gtfs/simple/calendar.txt similarity index 100% rename from src/test/resources/testagency/calendar.txt rename to src/test/resources/gtfs/simple/calendar.txt diff --git a/src/test/resources/testagency/frequencies.txt b/src/test/resources/gtfs/simple/frequencies.txt similarity index 100% rename from src/test/resources/testagency/frequencies.txt rename to src/test/resources/gtfs/simple/frequencies.txt diff --git a/src/test/resources/testagency/pathways.txt b/src/test/resources/gtfs/simple/pathways.txt similarity index 100% rename from src/test/resources/testagency/pathways.txt rename to src/test/resources/gtfs/simple/pathways.txt diff --git a/src/test/resources/testagency/routes.txt b/src/test/resources/gtfs/simple/routes.txt similarity index 100% rename from src/test/resources/testagency/routes.txt rename to src/test/resources/gtfs/simple/routes.txt diff --git a/src/test/resources/testagency/shapes.txt b/src/test/resources/gtfs/simple/shapes.txt similarity index 100% rename from src/test/resources/testagency/shapes.txt rename to src/test/resources/gtfs/simple/shapes.txt diff --git a/src/test/resources/testagency/stop_times.txt b/src/test/resources/gtfs/simple/stop_times.txt similarity index 100% rename from src/test/resources/testagency/stop_times.txt rename to src/test/resources/gtfs/simple/stop_times.txt diff --git a/src/test/resources/testagency/stops.txt b/src/test/resources/gtfs/simple/stops.txt similarity index 100% rename from src/test/resources/testagency/stops.txt rename to src/test/resources/gtfs/simple/stops.txt diff --git a/src/test/resources/testagency/transfers.txt b/src/test/resources/gtfs/simple/transfers.txt similarity index 100% rename from src/test/resources/testagency/transfers.txt rename to src/test/resources/gtfs/simple/transfers.txt diff --git a/src/test/resources/testagency/trips.txt b/src/test/resources/gtfs/simple/trips.txt similarity index 100% rename from src/test/resources/testagency/trips.txt rename to src/test/resources/gtfs/simple/trips.txt diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/alerts.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/alerts.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/alerts.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/alerts.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/patterns.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/patterns.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/patterns.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/patterns.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/plan-extended.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan-extended.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/plan-extended.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan-extended.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/plan-fares.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan-fares.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/plan-fares.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan-fares.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/plan-stop-positions.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan-stop-positions.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/plan-stop-positions.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan-stop-positions.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/plan.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/plan.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/plan.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/routes.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/routes.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/routes.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/stops.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/stops.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/stops.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/stops.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/vehicle-parking.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/vehicle-parking.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/vehicle-parking.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/vehicle-parking.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/expectations/walk-steps.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/walk-steps.json similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/expectations/walk-steps.json rename to src/test/resources/org/opentripplanner/apis/gtfs/expectations/walk-steps.json diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/alerts.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/alerts.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/alerts.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/alerts.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/patterns.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/patterns.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/plan-extended.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-extended.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/plan-extended.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-extended.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/plan-fares.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-fares.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/plan-fares.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-fares.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/plan-stop-positions.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-stop-positions.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/plan-stop-positions.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/plan-stop-positions.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/plan.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan.graphql similarity index 88% rename from src/ext-test/resources/gtfsgraphqlapi/queries/plan.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/plan.graphql index ea5c6eb3407..d71c991234d 100644 --- a/src/ext-test/resources/gtfsgraphqlapi/queries/plan.graphql +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/plan.graphql @@ -1,8 +1,8 @@ { plan( - # these coordinate are in Portland, change this to YOUR origin + # these coordinates are in Portland, change this to YOUR origin from: { lat: 45.5552, lon: -122.6534 } - # these coordinate are in Portland, change this to YOUR destination + # these coordinates are in Portland, change this to YOUR destination to: { lat: 45.4908, lon: -122.5519 } # use the correct date and time of your request date: "2023-02-15", diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/routes.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/routes.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/routes.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/routes.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/stops.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/stops.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/stops.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/stops.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/vehicle-parking.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-parking.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/vehicle-parking.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/vehicle-parking.graphql diff --git a/src/ext-test/resources/gtfsgraphqlapi/queries/walk-steps.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/walk-steps.graphql similarity index 100% rename from src/ext-test/resources/gtfsgraphqlapi/queries/walk-steps.graphql rename to src/test/resources/org/opentripplanner/apis/gtfs/queries/walk-steps.graphql diff --git a/src/test/resources/umlaut-cp437.zip b/src/test/resources/org/opentripplanner/datastore/file/umlaut-cp437.zip similarity index 100% rename from src/test/resources/umlaut-cp437.zip rename to src/test/resources/org/opentripplanner/datastore/file/umlaut-cp437.zip diff --git a/src/test/resources/umlaut-utf8-no-efs.zip b/src/test/resources/org/opentripplanner/datastore/file/umlaut-utf8-no-efs.zip similarity index 100% rename from src/test/resources/umlaut-utf8-no-efs.zip rename to src/test/resources/org/opentripplanner/datastore/file/umlaut-utf8-no-efs.zip diff --git a/src/test/resources/umlaut-utf8.zip b/src/test/resources/org/opentripplanner/datastore/file/umlaut-utf8.zip similarity index 100% rename from src/test/resources/umlaut-utf8.zip rename to src/test/resources/org/opentripplanner/datastore/file/umlaut-utf8.zip diff --git a/src/test/resources/org/opentripplanner/graph_builder/module/addPerpendicularRoutes.gtfs.zip b/src/test/resources/org/opentripplanner/graph_builder/module/addPerpendicularRoutes.gtfs.zip deleted file mode 100644 index c1feca1d88f..00000000000 Binary files a/src/test/resources/org/opentripplanner/graph_builder/module/addPerpendicularRoutes.gtfs.zip and /dev/null differ diff --git a/src/test/resources/germany/herrenberg-minimal.osm.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/herrenberg-minimal.osm.pbf similarity index 100% rename from src/test/resources/germany/herrenberg-minimal.osm.pbf rename to src/test/resources/org/opentripplanner/graph_builder/module/herrenberg-minimal.osm.pbf diff --git a/src/test/resources/germany/herrenberg-island-prune-nothru.osm.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/herrenberg-island-prune-nothru.osm.pbf similarity index 100% rename from src/test/resources/germany/herrenberg-island-prune-nothru.osm.pbf rename to src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/herrenberg-island-prune-nothru.osm.pbf diff --git a/src/test/resources/isoiiluoto.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/isoiiluoto.pbf similarity index 100% rename from src/test/resources/isoiiluoto.pbf rename to src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/isoiiluoto.pbf diff --git a/src/test/resources/org/opentripplanner/graph_builder/module/columbus.osm.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/linking/columbus.osm.pbf similarity index 100% rename from src/test/resources/org/opentripplanner/graph_builder/module/columbus.osm.pbf rename to src/test/resources/org/opentripplanner/graph_builder/module/linking/columbus.osm.pbf diff --git a/src/test/resources/org/opentripplanner/graph_builder/module/osm/accessno-at-end.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/osm/accessno-at-end.pbf new file mode 100644 index 00000000000..03b93ab30d2 Binary files /dev/null and b/src/test/resources/org/opentripplanner/graph_builder/module/osm/accessno-at-end.pbf differ diff --git a/src/test/resources/org/opentripplanner/graph_builder/module/osm/otp-multipolygon-test.osm.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/osm/otp-multipolygon-test.osm.pbf deleted file mode 100644 index 754c98f1b6f..00000000000 Binary files a/src/test/resources/org/opentripplanner/graph_builder/module/osm/otp-multipolygon-test.osm.pbf and /dev/null differ diff --git a/src/test/resources/germany/ehningen-minimal.osm.pbf b/src/test/resources/org/opentripplanner/openstreetmap/model/ehningen-minimal.osm.pbf similarity index 100% rename from src/test/resources/germany/ehningen-minimal.osm.pbf rename to src/test/resources/org/opentripplanner/openstreetmap/model/ehningen-minimal.osm.pbf diff --git a/src/test/resources/oslo-east-filtered.osm.pbf b/src/test/resources/org/opentripplanner/oslo-east-filtered.osm.pbf similarity index 100% rename from src/test/resources/oslo-east-filtered.osm.pbf rename to src/test/resources/org/opentripplanner/oslo-east-filtered.osm.pbf diff --git a/src/test/resources/germany/boeblingen-minimal.osm.pbf b/src/test/resources/org/opentripplanner/street/integration/boeblingen-minimal.osm.pbf similarity index 100% rename from src/test/resources/germany/boeblingen-minimal.osm.pbf rename to src/test/resources/org/opentripplanner/street/integration/boeblingen-minimal.osm.pbf diff --git a/src/test/resources/germany/deufringen-minimal.osm.pbf b/src/test/resources/org/opentripplanner/street/integration/deufringen-minimal.osm.pbf similarity index 100% rename from src/test/resources/germany/deufringen-minimal.osm.pbf rename to src/test/resources/org/opentripplanner/street/integration/deufringen-minimal.osm.pbf diff --git a/src/test/resources/germany/herrenberg-barrier-gates.osm.pbf b/src/test/resources/org/opentripplanner/street/integration/herrenberg-barrier-gates.osm.pbf similarity index 100% rename from src/test/resources/germany/herrenberg-barrier-gates.osm.pbf rename to src/test/resources/org/opentripplanner/street/integration/herrenberg-barrier-gates.osm.pbf diff --git a/src/test/resources/germany/herrenberg-hindenburgstr-under-construction.osm.pbf b/src/test/resources/org/opentripplanner/street/integration/herrenberg-hindenburgstr-under-construction.osm.pbf similarity index 100% rename from src/test/resources/germany/herrenberg-hindenburgstr-under-construction.osm.pbf rename to src/test/resources/org/opentripplanner/street/integration/herrenberg-hindenburgstr-under-construction.osm.pbf diff --git a/src/test/resources/org/opentripplanner/street/integration/herrenberg-minimal.osm.pbf b/src/test/resources/org/opentripplanner/street/integration/herrenberg-minimal.osm.pbf new file mode 100644 index 00000000000..e57768e166b Binary files /dev/null and b/src/test/resources/org/opentripplanner/street/integration/herrenberg-minimal.osm.pbf differ diff --git a/src/test/resources/germany/vvs-bus-751-only.gtfs.zip b/src/test/resources/org/opentripplanner/street/integration/vvs-bus-751-only.gtfs.zip similarity index 100% rename from src/test/resources/germany/vvs-bus-751-only.gtfs.zip rename to src/test/resources/org/opentripplanner/street/integration/vvs-bus-751-only.gtfs.zip diff --git a/src/test/resources/germany/vvs-bus-764-only.gtfs.zip b/src/test/resources/org/opentripplanner/street/integration/vvs-bus-764-only.gtfs.zip similarity index 100% rename from src/test/resources/germany/vvs-bus-764-only.gtfs.zip rename to src/test/resources/org/opentripplanner/street/integration/vvs-bus-764-only.gtfs.zip diff --git a/src/test/resources/gtfs/kcm_gtfs.zip b/src/test/resources/org/opentripplanner/transit/service/kcm_gtfs.zip similarity index 100% rename from src/test/resources/gtfs/kcm_gtfs.zip rename to src/test/resources/org/opentripplanner/transit/service/kcm_gtfs.zip diff --git a/src/test/resources/gtfs-rt/trip-updates/septa.pbf b/src/test/resources/org/opentripplanner/updater/trip/septa.pbf similarity index 100% rename from src/test/resources/gtfs-rt/trip-updates/septa.pbf rename to src/test/resources/org/opentripplanner/updater/trip/septa.pbf diff --git a/src/test/resources/gtfs-rt/vehicle-positions/king-county-metro-1.pb b/src/test/resources/org/opentripplanner/updater/vehicle_position/king-county-metro-1.pbf similarity index 100% rename from src/test/resources/gtfs-rt/vehicle-positions/king-county-metro-1.pb rename to src/test/resources/org/opentripplanner/updater/vehicle_position/king-county-metro-1.pbf diff --git a/src/test/resources/gtfs-rt/vehicle-positions/king-county-metro-2.pb b/src/test/resources/org/opentripplanner/updater/vehicle_position/king-county-metro-2.pbf similarity index 100% rename from src/test/resources/gtfs-rt/vehicle-positions/king-county-metro-2.pb rename to src/test/resources/org/opentripplanner/updater/vehicle_position/king-county-metro-2.pbf diff --git a/src/test/resources/raptor/speedtest/norway/README.md b/src/test/resources/raptor/speedtest/norway/README.md deleted file mode 100644 index eafa49cb828..00000000000 --- a/src/test/resources/raptor/speedtest/norway/README.md +++ /dev/null @@ -1,12 +0,0 @@ -#### Download GTFS data: - -- https://storage.googleapis.com/marduk-production/outbound/gtfs/rb_norway-aggregated-gtfs.zip - -If the link above do not work you should be able to find it on the ENTUR web: - -- https://www.entur.org/ - -#### Configure the test - -- Set the testDate in the speed-test-config.json - diff --git a/src/test/resources/testagency.zip b/src/test/resources/testagency.zip deleted file mode 100644 index 8fd34458398..00000000000 Binary files a/src/test/resources/testagency.zip and /dev/null differ