Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TimetableSnapshot merge conflict #5972

Merged
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 @@ -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);
}
}
Loading