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 remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
…024-12-02
- Loading branch information
Showing
7 changed files
with
65 additions
and
15 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
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
48 changes: 48 additions & 0 deletions
48
...ication/src/test/java/org/opentripplanner/apis/gtfs/datafetchers/BookingInfoImplTest.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,48 @@ | ||
package org.opentripplanner.apis.gtfs.datafetchers; | ||
|
||
import static graphql.execution.ExecutionContextBuilder.newExecutionContextBuilder; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import graphql.execution.ExecutionId; | ||
import graphql.schema.DataFetchingEnvironment; | ||
import graphql.schema.DataFetchingEnvironmentImpl; | ||
import java.time.Duration; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.transit.model.timetable.booking.BookingInfo; | ||
|
||
class BookingInfoImplTest { | ||
|
||
private static final BookingInfoImpl SUBJECT = new BookingInfoImpl(); | ||
private static final Duration TEN_MINUTES = Duration.ofMinutes(10); | ||
|
||
@Test | ||
void emptyDurations() 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() | ||
); | ||
assertEquals(600, SUBJECT.minimumBookingNoticeSeconds().get(env)); | ||
assertEquals(600, SUBJECT.maximumBookingNoticeSeconds().get(env)); | ||
} | ||
|
||
private DataFetchingEnvironment dataFetchingEnvironment(BookingInfo bookingInfo) { | ||
var executionContext = newExecutionContextBuilder() | ||
.executionId(ExecutionId.from(this.getClass().getName())) | ||
.build(); | ||
return DataFetchingEnvironmentImpl | ||
.newDataFetchingEnvironment(executionContext) | ||
.source(bookingInfo) | ||
.build(); | ||
} | ||
} |
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