Skip to content

Commit

Permalink
Co-Authored-By: Leonard Ehrenfried <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
jspetrak committed Mar 12, 2024
1 parent 2da2564 commit 72db7e8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
4 changes: 1 addition & 3 deletions src/main/java/org/opentripplanner/client/OtpApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public TripPlan plan(TripPlanParameters req) throws IOException {
req.time().toLocalDate().toString(),
req.time().toLocalTime().truncatedTo(ChronoUnit.SECONDS).toString(),
req.searchDirection().isArriveBy(),
req.searchWindow().isPresent()
? String.format("searchWindow : %d", req.searchWindow().get().toMinutes())
: "",
req.searchWindow().map(sw -> "searchWindow : %d".formatted(sw.toSeconds())).orElse(""),
req.walkReluctance(),
req.wheelchair());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

import jakarta.annotation.Nullable;
import org.opentripplanner.client.model.PlaceParameter;
import org.opentripplanner.client.model.RequestMode;
import org.opentripplanner.client.validation.CollectionUtils;
Expand All @@ -16,6 +18,7 @@ public final class TripPlanParameters {
private final int numItineraries;
private final Set<RequestMode> modes;
private final SearchDirection searchDirection;
@Nullable
private final Duration searchWindow;
private final float walkReluctance;
private final boolean wheelchair;
Expand All @@ -29,20 +32,16 @@ public TripPlanParameters(
SearchDirection searchDirection,
Duration searchWindow,
float walkReluctance,
boolean wheelchair) {
Objects.requireNonNull(fromPlace);
Objects.requireNonNull(toPlace);
Objects.requireNonNull(time);
Objects.requireNonNull(modes);
boolean wheelchair
) {
CollectionUtils.assertHasValue(modes);
Objects.requireNonNull(searchDirection);

this.fromPlace = fromPlace;
this.toPlace = toPlace;
this.time = time;
this.fromPlace = Objects.requireNonNull(fromPlace);
this.toPlace = Objects.requireNonNull(toPlace);
this.time = Objects.requireNonNull(time);
this.numItineraries = numItineraries;
this.modes = modes;
this.searchDirection = searchDirection;
this.modes = Objects.requireNonNull(modes);
this.searchDirection = Objects.requireNonNull(searchDirection);
this.searchWindow = searchWindow;
this.walkReluctance = walkReluctance;
this.wheelchair = wheelchair;
Expand Down
21 changes: 11 additions & 10 deletions src/test/java/org/opentripplanner/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.opentripplanner.StationParameters.OSLO_WEST;

import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
Expand Down Expand Up @@ -94,22 +95,22 @@ public void planPlaceToPlaceWithSearchWindow() throws IOException {
.withTime(LocalDateTime.now())
.withModes(RequestMode.TRANSIT)
.withNumberOfItineraries(1)
.withSearchWindow(java.time.Duration.ofDays(1))
.withSearchWindow(Duration.ofDays(1))
.build());

LOG.info("Received {} itineraries", result.itineraries().size());
assertEquals(1, result.itineraries().size());
LOG.info("Received {} itineraries", result.itineraries().size());
assertEquals(1, result.itineraries().size());

assertNotNull(result.itineraries().get(0).legs().get(0).startTime());
assertNotNull(result.itineraries().get(0).legs().get(0).startTime());

var leg = result.itineraries().get(0).legs().get(0);
var leg = result.itineraries().get(0).legs().get(0);

var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
assertFalse(transitLeg.from().stop().isEmpty());
assertFalse(transitLeg.to().stop().isEmpty());
assertNotNull(transitLeg.from().stop().get().id());
var transitLeg = result.transitItineraries().get(0).transitLegs().get(0);
assertFalse(transitLeg.from().stop().isEmpty());
assertFalse(transitLeg.to().stop().isEmpty());
assertNotNull(transitLeg.from().stop().get().id());

assertEquals(List.of(), leg.fareProducts());
assertEquals(List.of(), leg.fareProducts());
}

@Test
Expand Down

0 comments on commit 72db7e8

Please sign in to comment.