Skip to content

Commit

Permalink
Merge pull request #5414 from entur/fix_stop_times_helper_zero_reques…
Browse files Browse the repository at this point in the history
…ted_departure

Fix stop times helper when requesting zero departure
  • Loading branch information
vpaturet authored Oct 13, 2023
2 parents dcc4037 + 80c9769 commit b3f1ae7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public static List<StopTimesInPattern> stopTimesForStop(
ArrivalDeparture arrivalDeparture,
boolean includeCancelledTrips
) {
if (numberOfDepartures <= 0) {
return List.of();
}

List<StopTimesInPattern> result = new ArrayList<>();

// Fetch all patterns, including those from realtime sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,29 @@ public static void setUp() throws Exception {
tt.getTripTimes(0).cancelTrip();
}

/**
* Case 0, requested number of departure = 0
*/
@Test
void stopTimesForStop_zeroRequestedNumberOfDeparture() {
var result = StopTimesHelper.stopTimesForStop(
transitService,
transitService.getRegularStop(stopId),
serviceDate.atStartOfDay(transitService.getTimeZone()).toInstant(),
Duration.ofHours(24),
0,
ArrivalDeparture.BOTH,
true
);

assertTrue(result.isEmpty());
}

/**
* Case 1, should find first departure for each pattern when numberOfDepartures is one
*/
@Test
void stopTimesForStop_oneDeparture() {
// Case 1, should find first departure for each pattern
var result = StopTimesHelper.stopTimesForStop(
transitService,
transitService.getRegularStop(stopId),
Expand Down

0 comments on commit b3f1ae7

Please sign in to comment.