Skip to content

Commit

Permalink
Fix TimetableSnapshot merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
vpaturet committed Jul 16, 2024
1 parent cd86c22 commit e0f60f5
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static org.opentripplanner.transit.model.basic.TransitMode.RAIL;
import static org.opentripplanner.transit.model.basic.TransitMode.TRAM;

import com.google.common.collect.ImmutableSetMultimap;
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.Set;
Expand All @@ -15,10 +15,13 @@
import org.opentripplanner.model.TimetableSnapshot;
import org.opentripplanner.transit.model._data.TransitModelForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
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.site.Station;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.timetable.RealTimeTripTimes;
import org.opentripplanner.transit.model.timetable.ScheduledTripTimes;

class DefaultTransitServiceTest {

Expand All @@ -36,6 +39,13 @@ class DefaultTransitServiceTest {
static TripPattern FERRY_PATTERN = TEST_MODEL.pattern(FERRY).build();
static TripPattern BUS_PATTERN = TEST_MODEL.pattern(BUS).build();

static StopPattern REAL_TIME_STOP_PATTERN = TransitModelForTest.stopPattern(STOP_A, STOP_B);
static TripPattern REAL_TIME_PATTERN = TEST_MODEL
.pattern(BUS)
.withStopPattern(REAL_TIME_STOP_PATTERN)
.withCreatedByRealtimeUpdater(true)
.build();

@BeforeAll
static void setup() {
var stopModel = TEST_MODEL
Expand All @@ -51,8 +61,16 @@ static void setup() {

transitModel.initTimetableSnapshotProvider(() -> {
TimetableSnapshot timetableSnapshot = new TimetableSnapshot();
timetableSnapshot.setPatternsForStop(ImmutableSetMultimap.of(STOP_B, BUS_PATTERN));
return timetableSnapshot;
RealTimeTripTimes tripTimes = RealTimeTripTimes.of(
ScheduledTripTimes
.of()
.withTrip(TransitModelForTest.trip("REAL_TIME_TRIP").build())
.withDepartureTimes(new int[] { 0, 1 })
.build()
);
timetableSnapshot.update(REAL_TIME_PATTERN, tripTimes, LocalDate.now());

return timetableSnapshot.commit();
});

service =
Expand Down Expand Up @@ -95,6 +113,6 @@ void getPatternForStopsWithoutRealTime() {
@Test
void getPatternForStopsWithRealTime() {
Collection<TripPattern> patternsForStop = service.getPatternsForStop(STOP_B, true);
assertEquals(Set.of(FERRY_PATTERN, RAIL_PATTERN, BUS_PATTERN), patternsForStop);
assertEquals(Set.of(FERRY_PATTERN, RAIL_PATTERN, REAL_TIME_PATTERN), patternsForStop);
}
}

0 comments on commit e0f60f5

Please sign in to comment.