-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eae78db
commit 913239d
Showing
5 changed files
with
112 additions
and
50 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/LayerFiltersTest.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,42 @@ | ||
package org.opentripplanner.ext.vectortiles.layers.stops; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.apis.gtfs.PatternTestModel; | ||
import org.opentripplanner.transit.model._data.TransitModelForTest; | ||
import org.opentripplanner.transit.model.network.TripPattern; | ||
import org.opentripplanner.transit.model.site.RegularStop; | ||
|
||
class LayerFiltersTest { | ||
|
||
private static final RegularStop STOP = TransitModelForTest.of().stop("1").build(); | ||
private static final LocalDate DATE = LocalDate.of(2024, 9, 5); | ||
private static final TripPattern PATTERN = PatternTestModel.pattern(); | ||
|
||
@Test | ||
void includeStopWithinServiceWeek() { | ||
var predicate = LayerFilters.currentServiceWeek( | ||
s -> List.of(PATTERN), | ||
trip -> List.of(DATE), | ||
() -> DATE | ||
); | ||
|
||
assertTrue(predicate.test(STOP)); | ||
} | ||
|
||
@Test | ||
void excludeOutsideServiceWeek() { | ||
var inThreeWeeks = DATE.plusDays(21); | ||
var predicate = LayerFilters.currentServiceWeek( | ||
s -> List.of(PATTERN), | ||
trip -> List.of(inThreeWeeks), | ||
() -> DATE | ||
); | ||
|
||
assertFalse(predicate.test(STOP)); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/test/java/org/opentripplanner/apis/gtfs/PatternTestModel.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,44 @@ | ||
package org.opentripplanner.apis.gtfs; | ||
|
||
import static org.opentripplanner.transit.model._data.TransitModelForTest.id; | ||
|
||
import org.opentripplanner.transit.model._data.TransitModelForTest; | ||
import org.opentripplanner.transit.model.framework.FeedScopedId; | ||
import org.opentripplanner.transit.model.network.Route; | ||
import org.opentripplanner.transit.model.network.StopPattern; | ||
import org.opentripplanner.transit.model.network.TripPattern; | ||
import org.opentripplanner.transit.model.site.RegularStop; | ||
import org.opentripplanner.transit.model.timetable.ScheduledTripTimes; | ||
import org.opentripplanner.transit.model.timetable.Trip; | ||
import org.opentripplanner.transit.service.StopModel; | ||
|
||
public class PatternTestModel { | ||
|
||
public static final Route ROUTE_1 = TransitModelForTest.route("1").build(); | ||
|
||
private static final FeedScopedId SERVICE_ID = id("service"); | ||
private static final Trip TRIP = TransitModelForTest | ||
.trip("t1") | ||
.withRoute(ROUTE_1) | ||
.withServiceId(SERVICE_ID) | ||
.build(); | ||
private static final TransitModelForTest MODEL = new TransitModelForTest(StopModel.of()); | ||
private static final RegularStop STOP_1 = MODEL.stop("1").build(); | ||
private static final StopPattern STOP_PATTERN = TransitModelForTest.stopPattern(STOP_1, STOP_1); | ||
|
||
public static TripPattern pattern() { | ||
var pattern = TransitModelForTest | ||
.tripPattern("1", ROUTE_1) | ||
.withStopPattern(STOP_PATTERN) | ||
.build(); | ||
|
||
var tt = ScheduledTripTimes | ||
.of() | ||
.withTrip(TRIP) | ||
.withArrivalTimes("10:00 10:05") | ||
.withDepartureTimes("10:00 10:05") | ||
.build(); | ||
pattern.add(tt); | ||
return pattern; | ||
} | ||
} |