OpenTripPlanner/application/src/ext-test/java/org/opentripplanner/ext/flex/flexpathcalculator/TimePenaltyCalculatorTest.java
Leonard Ehrenfried 89f5a535a3
Move tests to street module
I forgot about these in a previous commit.
2026-02-16 10:58:53 +01:00

35 lines
1.3 KiB
Java

package org.opentripplanner.ext.flex.flexpathcalculator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.opentripplanner._support.geometry.LineStrings;
import org.opentripplanner.routing.api.request.framework.TimePenalty;
import org.opentripplanner.street.model.StreetModelForTest;
class TimePenaltyCalculatorTest {
private static final int THIRTY_MINS_IN_SECONDS = (int) Duration.ofMinutes(30).toSeconds();
@Test
void calculate() {
FlexPathCalculator delegate = (fromv, tov, boardStopPosition, alightStopPosition) ->
new FlexPath(10_000, THIRTY_MINS_IN_SECONDS, () -> LineStrings.SIMPLE);
var mod = TimePenalty.of(Duration.ofMinutes(10), 1.5f);
var calc = new TimePenaltyCalculator(delegate, mod);
var path = calc.calculateFlexPath(StreetModelForTest.V1, StreetModelForTest.V2, 0, 5);
assertEquals(3300, path.durationSeconds);
}
@Test
void nullValue() {
FlexPathCalculator delegate = (fromv, tov, boardStopPosition, alightStopPosition) -> null;
var mod = TimePenalty.of(Duration.ofMinutes(10), 1.5f);
var calc = new TimePenaltyCalculator(delegate, mod);
var path = calc.calculateFlexPath(StreetModelForTest.V1, StreetModelForTest.V2, 0, 5);
assertNull(path);
}
}