Skip to content

Set defaults of the modes WALK, even if one and not the others are set - #5675

Merged
eibakke merged 5 commits into
opentripplanner:dev-2.xfrom
entur:access-egress-defaults
Feb 9, 2024
Merged

Set defaults of the modes WALK, even if one and not the others are set#5675
eibakke merged 5 commits into
opentripplanner:dev-2.xfrom
entur:access-egress-defaults

Conversation

@eibakke

@eibakke eibakke commented Feb 8, 2024

Copy link
Copy Markdown
Contributor

Summary

This PR changes the behavior of the modes field so that the "WALK" defaults are applied also when some of the access, egress, and direct modes are set. Previously the default would only be applied if none of the three are set.

Unit tests

Added new unittest for the mapping of GraphQL modes to OTP internal modes.

Documentation

Updated javadoc.

@eibakke
eibakke requested a review from a team as a code owner February 8, 2024 13:47
@codecov

codecov Bot commented Feb 8, 2024

Copy link
Copy Markdown

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (026e39e) 67.62% compared to head (5b89d9d) 67.63%.

Files Patch % Lines
...er/apis/transmodel/mapping/RequestModesMapper.java 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             dev-2.x    #5675      +/-   ##
=============================================
+ Coverage      67.62%   67.63%   +0.01%     
- Complexity     16293    16299       +6     
=============================================
  Files           1886     1886              
  Lines          71549    71552       +3     
  Branches        7384     7387       +3     
=============================================
+ Hits           48383    48393      +10     
+ Misses         20661    20654       -7     
  Partials        2505     2505              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment thread src/main/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapper.java Outdated

@leonardehrenfried leonardehrenfried left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are tiny, nitpicky things you can improve but really no blockers.


@Test
void testMapRequestModesEmptyMapReturnsDefaults() {
Map<String, StreetMode> inputModes = new HashMap<>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Map<String, StreetMode> inputModes = new HashMap<>();
Map<String, StreetMode> inputModes = Map.of()

Comment on lines +39 to +41
Map<String, StreetMode> inputModes = new HashMap<>();

inputModes.put("egressMode", StreetMode.CAR);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Map<String, StreetMode> inputModes = new HashMap<>();
inputModes.put("egressMode", StreetMode.CAR);
Map<String, StreetMode> inputModes = Map.of("egressMode", StreetMode.CAR);

Comment on lines +52 to +54
Map<String, StreetMode> inputModes = new HashMap<>();

inputModes.put("directMode", StreetMode.CAR);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Map<String, StreetMode> inputModes = new HashMap<>();
inputModes.put("directMode", StreetMode.CAR);
Map<String, StreetMode> inputModes = Map.of("directMode", StreetMode.CAR);

@leonardehrenfried

Copy link
Copy Markdown
Member

Thanks, if you like the Map.of() style then stay consistent within one file.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

@leonardehrenfried leonardehrenfried changed the title Make the defaults of the modes WALK, even if one and not the others are set Set defaults of the modes WALK, even if one and not the others are set Feb 9, 2024
@leonardehrenfried leonardehrenfried added the !Bug Apply to issues describing a bug and PRs witch fixes it. label Feb 9, 2024
@eibakke
eibakke merged commit b7d037e into opentripplanner:dev-2.x Feb 9, 2024
@eibakke
eibakke deleted the access-egress-defaults branch February 9, 2024 14:28
t2gran pushed a commit that referenced this pull request Feb 9, 2024
@t2gran t2gran added this to the 2.5 (next release) milestone Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

!Bug Apply to issues describing a bug and PRs witch fixes it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants