diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java index 0060e6ad7e1..f6633818b3d 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImpl.java @@ -30,6 +30,11 @@ public DataFetcher latestBookingTime() { return environment -> getSource(environment).getLatestBookingTime(); } + @Override + public DataFetcher maximumBookingNotice() { + return env -> getSource(env).getMaximumBookingNotice().orElse(null); + } + @Override public DataFetcher maximumBookingNoticeSeconds() { return environment -> @@ -41,6 +46,11 @@ public DataFetcher message() { return environment -> getSource(environment).getMessage(); } + @Override + public DataFetcher minimumBookingNotice() { + return env -> getSource(env).getMinimumBookingNotice().orElse(null); + } + @Override public DataFetcher minimumBookingNoticeSeconds() { return environment -> diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java index dd74347b928..6528d8ee286 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java @@ -221,10 +221,14 @@ public interface GraphQLBookingInfo { public DataFetcher latestBookingTime(); + public DataFetcher maximumBookingNotice(); + public DataFetcher maximumBookingNoticeSeconds(); public DataFetcher message(); + public DataFetcher minimumBookingNotice(); + public DataFetcher minimumBookingNoticeSeconds(); public DataFetcher pickupMessage(); diff --git a/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls b/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls index a131b95fc8e..f92a8191018 100644 --- a/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls +++ b/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls @@ -279,12 +279,16 @@ type BookingInfo { earliestBookingTime: BookingTime "When is the latest time the service can be booked" latestBookingTime: BookingTime + "Maximum duration before travel to make the request." + maximumBookingNotice: Duration "Maximum number of seconds before travel to make the request" - maximumBookingNoticeSeconds: Long + maximumBookingNoticeSeconds: Long @deprecated(reason : "Use `maximumBookingNotice`") "A general message for those booking the service" message: String + "Minimum duration before travel to make the request" + minimumBookingNotice: Duration "Minimum number of seconds before travel to make the request" - minimumBookingNoticeSeconds: Long + minimumBookingNoticeSeconds: Long @deprecated(reason : "Use `minimumBookingNotice`") "A message specific to the pick up" pickupMessage: String } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java index 1103024aa61..d721a73939b 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.java @@ -15,27 +15,40 @@ class BookingInfoImplTest { private static final BookingInfoImpl SUBJECT = new BookingInfoImpl(); private static final Duration TEN_MINUTES = Duration.ofMinutes(10); + private static final BookingInfo WITH_NOTICE_DURATIONS = BookingInfo + .of() + .withMinimumBookingNotice(TEN_MINUTES) + .withMaximumBookingNotice(TEN_MINUTES) + .build(); @Test - void emptyDurations() throws Exception { + void emptyNoticeSeconds() throws Exception { var env = dataFetchingEnvironment(BookingInfo.of().build()); assertNull(SUBJECT.minimumBookingNoticeSeconds().get(env)); assertNull(SUBJECT.maximumBookingNoticeSeconds().get(env)); } @Test - void durations() throws Exception { - var env = dataFetchingEnvironment( - BookingInfo - .of() - .withMinimumBookingNotice(TEN_MINUTES) - .withMaximumBookingNotice(TEN_MINUTES) - .build() - ); + void emptyNoticeDurations() throws Exception { + var env = dataFetchingEnvironment(BookingInfo.of().build()); + assertNull(SUBJECT.minimumBookingNotice().get(env)); + assertNull(SUBJECT.maximumBookingNotice().get(env)); + } + + @Test + void seconds() throws Exception { + var env = dataFetchingEnvironment(WITH_NOTICE_DURATIONS); assertEquals(600, SUBJECT.minimumBookingNoticeSeconds().get(env)); assertEquals(600, SUBJECT.maximumBookingNoticeSeconds().get(env)); } + @Test + void durations() throws Exception { + var env = dataFetchingEnvironment(WITH_NOTICE_DURATIONS); + assertEquals(TEN_MINUTES, SUBJECT.minimumBookingNotice().get(env)); + assertEquals(TEN_MINUTES, SUBJECT.maximumBookingNotice().get(env)); + } + private DataFetchingEnvironment dataFetchingEnvironment(BookingInfo bookingInfo) { var executionContext = newExecutionContextBuilder() .executionId(ExecutionId.from(this.getClass().getName()))