forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opentripplanner#5368 from ibi-group/bikes-allowed
Fix value mapping for bikesAllowed in GTFS GraphQL API
- Loading branch information
Showing
9 changed files
with
86 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ GraphQL query in the left hand panel of the page: | |
name | ||
} | ||
mode | ||
bikesAllowed | ||
} | ||
} | ||
``` | ||
|
21 changes: 21 additions & 0 deletions
21
src/ext-test/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.opentripplanner.ext.gtfsgraphqlapi.mapping; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.transit.model.network.BikeAccess; | ||
|
||
class BikesAllowedMapperTest { | ||
|
||
@Test | ||
void mapping() { | ||
Arrays | ||
.stream(BikeAccess.values()) | ||
.filter(ba -> ba != BikeAccess.UNKNOWN) | ||
.forEach(d -> { | ||
var mapped = BikesAllowedMapper.map(d); | ||
assertEquals(d.toString(), mapped.toString()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
name | ||
} | ||
mode | ||
bikesAllowed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/ext/java/org/opentripplanner/ext/gtfsgraphqlapi/mapping/BikesAllowedMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.opentripplanner.ext.gtfsgraphqlapi.mapping; | ||
|
||
import javax.annotation.Nonnull; | ||
import org.opentripplanner.ext.gtfsgraphqlapi.generated.GraphQLTypes.GraphQLBikesAllowed; | ||
import org.opentripplanner.transit.model.network.BikeAccess; | ||
|
||
public class BikesAllowedMapper { | ||
|
||
@Nonnull | ||
public static GraphQLBikesAllowed map(@Nonnull BikeAccess bikesAllowed) { | ||
return switch (bikesAllowed) { | ||
case UNKNOWN -> GraphQLBikesAllowed.NO_INFORMATION; | ||
case ALLOWED -> GraphQLBikesAllowed.ALLOWED; | ||
case NOT_ALLOWED -> GraphQLBikesAllowed.NOT_ALLOWED; | ||
}; | ||
} | ||
} |