Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import org.opentripplanner.model.plan.Emission;
import org.opentripplanner.model.plan.Itinerary;
import org.opentripplanner.model.plan.Leg;
import org.opentripplanner.model.plan.LegConstructionSupport;
import org.opentripplanner.model.plan.ScheduledTransitLeg;
import org.opentripplanner.model.plan.ScheduledTransitLegBuilder;
import org.opentripplanner.model.plan.StreetLeg;
import org.opentripplanner.model.plan.leg.LegConstructionSupport;
import org.opentripplanner.model.plan.leg.ScheduledTransitLeg;
import org.opentripplanner.model.plan.leg.ScheduledTransitLegBuilder;
import org.opentripplanner.model.plan.leg.StreetLeg;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.basic.TransitMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ void testIntOutsideRangeIssue() {
assertEquals("EmissionOutsideRange", valueTooSmall.getType());
assertEquals("EmissionOutsideRange", valueTooBig.getType());
assertEquals(
"The int value '-1' for intValue is outside expected range [0 - 100]: 'F:1, -1, 1.0' (@line:2)",
"The int value '-1' for intValue is outside expected range [0, 100]: 'F:1, -1, 1.0' (@line:2)",
valueTooSmall.getMessage()
);
assertEquals(
"The int value '101' for intValue is outside expected range [0 - 100]: 'F:4, 101, 1.0' (@line:5)",
"The int value '101' for intValue is outside expected range [0, 100]: 'F:4, 101, 1.0' (@line:5)",
valueTooBig.getMessage()
);
assertEquals(2, issueStore.listIssues().size(), () -> issueStore.listIssues().toString());
Expand Down Expand Up @@ -219,11 +219,11 @@ void testDoubleOutsideRangeIssue() {
assertEquals("EmissionOutsideRange", valueTooSmall.getType());
assertEquals("EmissionOutsideRange", valueTooBig.getType());
assertEquals(
"The double value '-1.0E-6' for doubleValue is outside expected range [0.0 - 100.0): 'F:1, 1, -0.000001' (@line:2)",
"The double value '-1.0E-6' for doubleValue is outside expected range [0.0, 100.0): 'F:1, 1, -0.000001' (@line:2)",
valueTooSmall.getMessage()
);
assertEquals(
"The double value '100.0' for doubleValue is outside expected range [0.0 - 100.0): 'F:4, 4, 100.0' (@line:5)",
"The double value '100.0' for doubleValue is outside expected range [0.0, 100.0): 'F:4, 4, 100.0' (@line:5)",
valueTooBig.getMessage()
);
assertEquals(2, issueStore.listIssues().size(), () -> issueStore.listIssues().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void testCo2EmissionsFromGtfsDataSource() throws FileNotFoundException {
var issues = issueStore.listIssues();

var expected = List.of(
"The double value '-0.001' for avg_co2_per_vehicle_per_km is outside expected range [0.0 - 100000.0): '1004,-0.001,1' (@line:5)",
"The double value '0.0' for avg_passenger_count is outside expected range [0.001 - 10000.0): '1005,1,0' (@line:6)",
"The double value '-0.001' for avg_co2_per_vehicle_per_km is outside expected range [0.0, 100000.0): '1004,-0.001,1' (@line:5)",
"The double value '0.0' for avg_passenger_count is outside expected range [0.001, 10000.0): '1005,1,0' (@line:6)",
"Value for 'avg_passenger_count' is missing: '1006,1,' (@line:7)",
"Value for 'avg_co2_per_vehicle_per_km' is missing: '1007,,1' (@line:8)",
"Value for 'route_id' is missing: ',1,1' (@line:9)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void testCo2EmissionsFromGtfsDataSource() throws FileNotFoundException {
var issues = issueStore.listIssues();

var expected = List.of(
"The int value '-1' for from_stop_sequence is outside expected range [0 - 1000]: 'E1,A,-1,xyz,25.0' (@line:6)",
"The double value '-0.01' for co2 is outside expected range [0.0 - 1.0E9): 'E2,B,1,xyz,-0.01' (@line:7)"
"The int value '-1' for from_stop_sequence is outside expected range [0, 1000]: 'E1,A,-1,xyz,25.0' (@line:6)",
"The double value '-0.01' for co2 is outside expected range [0.0, 1.0E9): 'E2,B,1,xyz,-0.01' (@line:7)"
);
for (int i = 0; i < expected.size(); i++) {
assertEquals(expected.get(i), issues.get(i).getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void setUpItineraries() {
car = newItinerary(A).drive(T11_30, T11_50, B).build();
var repository = new DefaultEmissionRepository();
Map<FeedScopedId, Emission> emissions = new HashMap<>();
emissions.put(bus.firstLeg().getRoute().getId(), Emission.co2_g(0.001));
emissions.put(bus.legs().getFirst().route().getId(), Emission.co2_g(0.001));
repository.addRouteEmissions(emissions);
repository.setCarAvgCo2PerMeter(0.0015);
emissionService = new DefaultEmissionService(repository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ public TestAtlantaFareService(Collection<FareRuleSet> regularFareRules) {

@Override
protected Money getLegPrice(Leg leg, FareType fareType, Collection<FareRuleSet> fareRules) {
var routeShortName = leg.getRoute().getShortName();
var routeShortName = leg.route().getShortName();
if (routeShortName == null) {
return DEFAULT_TEST_RIDE_PRICE;
}
routeShortName = leg.getRoute().getShortName().toLowerCase();
routeShortName = leg.route().getShortName().toLowerCase();

// Testing, return default test ride price.
return switch (routeShortName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.OTHER_FEED_AGENCY;
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id;

import java.util.List;
import org.opentripplanner.ext.fares.model.FareAttribute;
import org.opentripplanner.ext.fares.model.FareRuleSet;
import org.opentripplanner.framework.geometry.WgsCoordinate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.opentripplanner.gtfs.graphbuilder.GtfsModule;
import org.opentripplanner.model.GenericLocation;
import org.opentripplanner.model.calendar.ServiceDateInterval;
import org.opentripplanner.model.modes.ExcludeAllTransitFilter;
import org.opentripplanner.model.plan.Itinerary;
import org.opentripplanner.routing.api.RoutingService;
import org.opentripplanner.routing.api.request.RouteRequest;
Expand Down Expand Up @@ -87,23 +86,23 @@ void shouldReturnARouteTransferringFromBusToFlex() {
assertEquals(WALK, walkToBus.getMode());

var bus = itin.transitLeg(1);
assertEquals(BUS, bus.getMode());
assertEquals("30", bus.getRoute().getShortName());
assertEquals(BUS, bus.mode());
assertEquals("30", bus.route().getShortName());

var transfer = itin.streetLeg(2);
assertEquals(WALK, transfer.getMode());

var flex = itin.transitLeg(3);
assertEquals(BUS, flex.getMode());
assertEquals("Zone 2", flex.getRoute().getShortName());
assertEquals(BUS, flex.mode());
assertEquals("Zone 2", flex.route().getShortName());
assertTrue(flex.isFlexibleTrip());
assertEquals(
"corner of Story Place Southwest and service road (part of Flex Zone 2)",
flex.getFrom().name.toString()
flex.from().name.toString()
);
assertEquals("Destination (part of Flex Zone 2)", flex.getTo().name.toString());
assertEquals("2021-12-02T14:30-05:00[America/New_York]", flex.getStartTime().toString());
assertEquals("2021-12-02T15:00-05:00[America/New_York]", flex.getEndTime().toString());
assertEquals("Destination (part of Flex Zone 2)", flex.to().name.toString());
assertEquals("2021-12-02T14:30-05:00[America/New_York]", flex.startTime().toString());
assertEquals("2021-12-02T15:00-05:00[America/New_York]", flex.endTime().toString());
}

@Test
Expand All @@ -116,25 +115,25 @@ void shouldReturnARouteWithTwoTransfers() {
assertEquals(5, itin.legs().size());

var firstBus = itin.transitLeg(0);
assertEquals(BUS, firstBus.getMode());
assertEquals("856", firstBus.getRoute().getShortName());
assertEquals(BUS, firstBus.mode());
assertEquals("856", firstBus.route().getShortName());

var transferToSecondBus = itin.streetLeg(1);
assertEquals(WALK, transferToSecondBus.getMode());

var secondBus = itin.transitLeg(2);
assertEquals(BUS, secondBus.getMode());
assertEquals("30", secondBus.getRoute().getShortName());
assertEquals(BUS, secondBus.mode());
assertEquals("30", secondBus.route().getShortName());

var transferToFlex = itin.streetLeg(3);
assertEquals(WALK, transferToFlex.getMode());

var finalFlex = itin.transitLeg(4);
assertEquals(BUS, finalFlex.getMode());
assertEquals("Zone 2", finalFlex.getRoute().getShortName());
assertEquals(BUS, finalFlex.mode());
assertEquals("Zone 2", finalFlex.route().getShortName());
assertTrue(finalFlex.isFlexibleTrip());
assertEquals("2021-12-02T15:00-05:00[America/New_York]", finalFlex.getStartTime().toString());
assertEquals("2021-12-02T15:30-05:00[America/New_York]", finalFlex.getEndTime().toString());
assertEquals("2021-12-02T15:00-05:00[America/New_York]", finalFlex.startTime().toString());
assertEquals("2021-12-02T15:30-05:00[America/New_York]", finalFlex.endTime().toString());
}

@Test
Expand Down Expand Up @@ -162,14 +161,14 @@ void flexDirect() {
assertEquals(WALK, walkToFlex.getMode());

var flex = itin.transitLeg(1);
assertEquals(BUS, flex.getMode());
assertEquals("Zone 2", flex.getRoute().getShortName());
assertEquals(BUS, flex.mode());
assertEquals("Zone 2", flex.route().getShortName());
assertTrue(flex.isFlexibleTrip());

assertEquals("Transfer Point for Route 30", flex.getFrom().name.toString());
assertEquals("Destination (part of Flex Zone 2)", flex.getTo().name.toString());
assertEquals("Transfer Point for Route 30", flex.from().name.toString());
assertEquals("Destination (part of Flex Zone 2)", flex.to().name.toString());

assertEquals("2021-12-02T13:00-05:00[America/New_York]", flex.getStartTime().toString());
assertEquals("2021-12-02T13:00-05:00[America/New_York]", flex.startTime().toString());
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.street.model._data.StreetModelForTest;

class FlexibleTransitLegBuilderTest implements PlanTestConstants {
class FlexibleTransitLegTest implements PlanTestConstants {

private static final FlexTripEdge EDGE = new FlexTripEdge(
StreetModelForTest.intersectionVertex(1, 1),
Expand Down Expand Up @@ -48,7 +48,7 @@ void listsAreInitialized() {
.withFlexTripEdge(EDGE)
.build();
assertNotNull(leg.fareProducts());
assertNotNull(leg.getTransitAlerts());
assertNotNull(leg.listTransitAlerts());
}

@Test
Expand All @@ -64,7 +64,7 @@ void everythingIsNonNull() {
}

@Test
void copy() {
void copyOf() {
var leg = new FlexibleTransitLegBuilder()
.withStartTime(START_TIME)
.withEndTime(END_TIME)
Expand All @@ -73,12 +73,12 @@ void copy() {
.withAlerts(Set.of(ALERT))
.build();

var copy = leg.copy().build();
var copy = leg.copyOf().build();

assertEquals(copy.flexTripEdge(), EDGE);
assertEquals(copy.getStartTime(), START_TIME);
assertEquals(copy.getEndTime(), END_TIME);
assertEquals(copy.getTransitAlerts(), Set.of(ALERT));
assertEquals(copy.startTime(), START_TIME);
assertEquals(copy.endTime(), END_TIME);
assertEquals(copy.listTransitAlerts(), Set.of(ALERT));
assertEquals(copy.fareProducts(), List.of(FARE_PRODUCT_USE));
}

Expand All @@ -94,9 +94,9 @@ void timeShift() {

var shifted = leg.withTimeShift(TIME_SHIFT);

assertEquals(START_TIME.plus(TIME_SHIFT), shifted.getStartTime());
assertEquals(END_TIME.plus(TIME_SHIFT), shifted.getEndTime());
assertEquals(START_TIME.plus(TIME_SHIFT), shifted.startTime());
assertEquals(END_TIME.plus(TIME_SHIFT), shifted.endTime());
assertEquals(List.of(FARE_PRODUCT_USE), shifted.fareProducts());
assertEquals(Set.of(ALERT), shifted.getTransitAlerts());
assertEquals(Set.of(ALERT), shifted.listTransitAlerts());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ void flexTripInTransitMode() {
var itin = itineraries.get(0);
var leg = itin.legs().get(0);

assertEquals("cujv", leg.getFrom().stop.getId().getId());
assertEquals("yz85", leg.getTo().stop.getId().getId());
assertEquals("cujv", leg.from().stop.getId().getId());
assertEquals("yz85", leg.to().stop.getId().getId());

var intermediateStops = leg.getIntermediateStops();
var intermediateStops = leg.listIntermediateStops();
assertEquals(1, intermediateStops.size());
assertEquals("zone_1", intermediateStops.get(0).place.stop.getId().getId());

EncodedPolyline legGeometry = EncodedPolyline.encode(leg.getLegGeometry());
EncodedPolyline legGeometry = EncodedPolyline.encode(leg.legGeometry());
assertThatPolylinesAreEqual(
legGeometry.points(),
"kfsmEjojcOa@eBRKfBfHR|ALjBBhVArMG|OCrEGx@OhAKj@a@tAe@hA]l@MPgAnAgw@nr@cDxCm@t@c@t@c@x@_@~@]pAyAdIoAhG}@lE{AzHWhAtt@t~Aj@tAb@~AXdBHn@FlBC`CKnA_@nC{CjOa@dCOlAEz@E|BRtUCbCQ~CWjD??qBvXBl@kBvWOzAc@dDOx@sHv]aIG?q@@c@ZaB\\mA"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.opentripplanner.model.plan.Itinerary;
import org.opentripplanner.model.plan.Leg;
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.ScheduledTransitLeg;
import org.opentripplanner.model.plan.leg.ScheduledTransitLeg;
import org.opentripplanner.routing.alertpatch.EntitySelector;
import org.opentripplanner.routing.alertpatch.TimePeriod;
import org.opentripplanner.routing.alertpatch.TransitAlert;
Expand Down Expand Up @@ -75,14 +75,14 @@ void testPopulateLegsWithRealtime() {
var leg1ArrivalDelay = legs
.get(0)
.asScheduledTransitLeg()
.getTripPattern()
.tripPattern()
.getScheduledTimetable()
.getTripTimes()
.getFirst()
.getArrivalDelay(1);
assertEquals(123, leg1ArrivalDelay);
assertEquals(0, legs.get(0).getTransitAlerts().size());
assertEquals(1, legs.get(1).getTransitAlerts().size());
assertEquals(0, legs.get(0).listTransitAlerts().size());
assertEquals(1, legs.get(1).listTransitAlerts().size());
assertEquals(1, itinerariesWithRealtime.size());
}

Expand Down Expand Up @@ -125,7 +125,7 @@ void testPopulateLegsWithRealtimeKeepStaySeated() {

assertEquals(1, itineraries.size());

var constrained = itineraries.get(0).legs().get(1).getTransferFromPrevLeg();
var constrained = itineraries.get(0).legs().get(1).transferFromPrevLeg();
assertNotNull(constrained);
assertTrue(constrained.getTransferConstraint().isStaySeated());
}
Expand Down Expand Up @@ -157,7 +157,7 @@ private static List<TripPattern> itineraryPatterns(Itinerary itinerary) {
.stream()
.filter(Leg::isScheduledTransitLeg)
.map(Leg::asScheduledTransitLeg)
.map(ScheduledTransitLeg::getTripPattern)
.map(ScheduledTransitLeg::tripPattern)
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import org.opentripplanner.model.plan.Leg;
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.PlanTestConstants;
import org.opentripplanner.model.plan.ScheduledTransitLeg;
import org.opentripplanner.model.plan.StreetLeg;
import org.opentripplanner.model.plan.TestItineraryBuilder;
import org.opentripplanner.model.plan.leg.ScheduledTransitLeg;
import org.opentripplanner.model.plan.leg.StreetLeg;

class DecorateConsolidatedStopNamesTest {

Expand All @@ -39,17 +39,17 @@ void changeNames() {
.build();

var first = (ScheduledTransitLeg) itinerary.legs().getFirst();
var withFp = first.copy().withFareProducts(List.of(FARE_PRODUCT_USE)).build();
var withFp = first.copyOf().withFareProducts(List.of(FARE_PRODUCT_USE)).build();
var legs = new ArrayList<>(itinerary.legs());
legs.set(0, withFp);

itinerary = itinerary.copyOf().withLegs(ignore -> legs).build();
itinerary = itinerary.copyOf().withLegs(legs).build();

itinerary = filter.decorate(itinerary);

var updatedLeg = itinerary.legs().getFirst();
assertEquals(STOP_C.getName(), updatedLeg.getFrom().name);
assertEquals(STOP_D.getName(), updatedLeg.getTo().name);
assertEquals(STOP_C.getName(), updatedLeg.from().name);
assertEquals(STOP_D.getName(), updatedLeg.to().name);

// Check that the fares were carried over
assertEquals(List.of(FARE_PRODUCT_USE), updatedLeg.fareProducts());
Expand Down
Loading
Loading