Skip to content

Commit 89cc39a

Browse files
Merge pull request opentripplanner#6716 from leonardehrenfried/fix-null
Make leg's startTime, endTime, serviceDate required
2 parents 48c09a2 + 0f564e9 commit 89cc39a

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

application/src/ext-test/java/org/opentripplanner/ext/stopconsolidation/model/ConsolidatedStopLegBuilderTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id;
66

77
import java.time.LocalDate;
8+
import java.time.ZonedDateTime;
89
import java.util.List;
910
import java.util.Set;
1011
import org.junit.jupiter.api.Test;
@@ -21,6 +22,7 @@
2122

2223
class ConsolidatedStopLegBuilderTest implements PlanTestConstants {
2324

25+
private static final ZonedDateTime TIME = ZonedDateTime.parse("2025-06-25T08:33:36+02:00");
2426
private static final Set<TransitAlert> ALERTS = Set.of(
2527
TransitAlert.of(id("alert")).withDescriptionText(I18NString.of("alert")).build()
2628
);
@@ -30,11 +32,13 @@ class ConsolidatedStopLegBuilderTest implements PlanTestConstants {
3032
private static final ScheduledTransitLeg SCHEDULED_TRANSIT_LEG =
3133
new ScheduledTransitLegBuilder<>()
3234
.withZoneId(ZoneIds.BERLIN)
33-
.withServiceDate(LocalDate.of(2025, 1, 15))
3435
.withTripPattern(PATTERN)
3536
.withBoardStopIndexInPattern(0)
3637
.withDistanceMeters(1000)
3738
.withAlightStopIndexInPattern(1)
39+
.withStartTime(TIME)
40+
.withEndTime(TIME)
41+
.withServiceDate(TIME.toLocalDate())
3842
.build();
3943
private static final List<FareProductUse> FARES = List.of(FARE_PRODUCT_USE);
4044

application/src/main/java/org/opentripplanner/model/plan/leg/ScheduledTransitLeg.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,9 @@ protected ScheduledTransitLeg(ScheduledTransitLegBuilder<?> builder) {
9494
"alightStopPosInPattern"
9595
);
9696

97-
// TODO - Add requireNonNull for start-time. Some tests fails when this is done, these tests
98-
// should be fixed.
99-
this.startTime = builder.startTime();
100-
// TODO - Add requireNonNull for end-tTime. Some tests fails when this is done, these tests
101-
// should be fixed.
102-
this.endTime = builder.endTime();
103-
104-
// TODO - Add requireNonNull for service-date. Some tests fails when this is done, these tests
105-
// should be fixed.
106-
this.serviceDate = builder.serviceDate();
97+
this.startTime = Objects.requireNonNull(builder.startTime());
98+
this.endTime = Objects.requireNonNull(builder.endTime());
99+
this.serviceDate = Objects.requireNonNull(builder.serviceDate());
107100
this.zoneId = Objects.requireNonNull(builder.zoneId());
108101

109102
this.tripOnServiceDate = builder.tripOnServiceDate();

application/src/test/java/org/opentripplanner/raptorlegacy/_data/transit/TestTripSchedule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
public class TestTripSchedule implements TripSchedule {
2626

2727
private static final int DEFAULT_DEPARTURE_DELAY = 10;
28+
private static final LocalDate DATE = LocalDate.of(2025, 6, 25);
2829
private final DefaultTripPattern pattern;
2930
private final int[] arrivalTimes;
3031
private final int[] departureTimes;
@@ -113,7 +114,7 @@ public String toString() {
113114

114115
@Override
115116
public LocalDate getServiceDate() {
116-
return null;
117+
return DATE;
117118
}
118119

119120
@Override

0 commit comments

Comments
 (0)