-
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
55661fa
commit 0c1a651
Showing
13 changed files
with
107 additions
and
42 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
44 changes: 44 additions & 0 deletions
44
src/ext-test/java/org/opentripplanner/ext/flex/trip/UnscheduledDrivingDurationTest.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.ext.flex.trip; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.opentripplanner.street.model._data.StreetModelForTest.V1; | ||
import static org.opentripplanner.street.model._data.StreetModelForTest.V2; | ||
import static org.opentripplanner.transit.model._data.TransitModelForTest.id; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner._support.geometry.LineStrings; | ||
import org.opentripplanner.ext.flex.FlexStopTimesForTest; | ||
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPath; | ||
import org.opentripplanner.ext.flex.flexpathcalculator.FlexPathCalculator; | ||
import org.opentripplanner.model.StopTime; | ||
|
||
class UnscheduledDrivingDurationTest { | ||
|
||
static final FlexPathCalculator STATIC_CALCULATOR = (fromv, tov, fromStopIndex, toStopIndex) -> | ||
new FlexPath(10_000, (int) Duration.ofMinutes(10).toSeconds(), () -> LineStrings.SIMPLE); | ||
private static final StopTime STOP_TIME = FlexStopTimesForTest.area("10:00", "18:00"); | ||
|
||
@Test | ||
void noModifier() { | ||
var trip = UnscheduledTrip.of(id("1")).withStopTimes(List.of(STOP_TIME)).build(); | ||
|
||
var calculator = trip.flexPathCalculator(STATIC_CALCULATOR); | ||
var path = calculator.calculateFlexPath(V1, V2, 0, 0); | ||
assertEquals(600, path.durationSeconds); | ||
} | ||
|
||
@Test | ||
void withModifier() { | ||
var trip = UnscheduledTrip | ||
.of(id("1")) | ||
.withStopTimes(List.of(STOP_TIME)) | ||
.withDurationModifier(new DurationModifier(Duration.ofMinutes(2), 1.5f)) | ||
.build(); | ||
|
||
var calculator = trip.flexPathCalculator(STATIC_CALCULATOR); | ||
var path = calculator.calculateFlexPath(V1, V2, 0, 0); | ||
assertEquals(1020, path.durationSeconds); | ||
} | ||
} |
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
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