use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class NoticeAssignmentMapperTest method mapNoticeAssignment.
@Test
public void mapNoticeAssignment() {
NoticeAssignment noticeAssignment = new NoticeAssignment();
noticeAssignment.setNoticedObjectRef(new VersionOfObjectRefStructure().withRef(ROUTE_ID));
noticeAssignment.setNotice(NOTICE);
Route route = new Route();
route.setId(MappingSupport.ID_FACTORY.createId(ROUTE_ID));
EntityById<FeedScopedId, Route> routesById = new EntityById<>();
routesById.add(route);
NoticeAssignmentMapper noticeAssignmentMapper = new NoticeAssignmentMapper(MappingSupport.ID_FACTORY, new HierarchicalMultimap<>(), new HierarchicalMapById<>(), routesById, new EntityById<>(), new HashMap<>());
Multimap<TransitEntity<?>, org.opentripplanner.model.Notice> noticesByElement = noticeAssignmentMapper.map(noticeAssignment);
org.opentripplanner.model.Notice notice2 = noticesByElement.get(route).iterator().next();
assertEquals(NOTICE_ID, notice2.getId().getId());
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class NoticeAssignmentMapperTest method mapNoticeAssignmentOnStopPoint.
@Test
public void mapNoticeAssignmentOnStopPoint() {
HierarchicalMultimap<String, TimetabledPassingTime> passingTimeByStopPointId = new HierarchicalMultimap<>();
HierarchicalMapById<Notice> noticesById = new HierarchicalMapById<>();
passingTimeByStopPointId.add(STOP_POINT_ID, new TimetabledPassingTime().withId(TIMETABLED_PASSING_TIME1));
passingTimeByStopPointId.add(STOP_POINT_ID, new TimetabledPassingTime().withId(TIMETABLED_PASSING_TIME2));
Trip trip = new Trip();
trip.setId(new FeedScopedId("T", "1"));
StopTime stopTime1 = createStopTime(1, trip);
StopTime stopTime2 = createStopTime(2, trip);
Map<String, StopTime> stopTimesById = new HashMap<>();
stopTimesById.put(TIMETABLED_PASSING_TIME1, stopTime1);
stopTimesById.put(TIMETABLED_PASSING_TIME2, stopTime2);
noticesById.add(NOTICE);
NoticeAssignment noticeAssignment = new NoticeAssignment().withNoticedObjectRef(new VersionOfObjectRefStructure().withRef(STOP_POINT_ID)).withNoticeRef(new NoticeRefStructure().withRef(NOTICE_ID));
NoticeAssignmentMapper noticeAssignmentMapper = new NoticeAssignmentMapper(MappingSupport.ID_FACTORY, passingTimeByStopPointId, noticesById, new EntityById<>(), new EntityById<>(), stopTimesById);
Multimap<TransitEntity<?>, org.opentripplanner.model.Notice> noticesByElement = noticeAssignmentMapper.map(noticeAssignment);
org.opentripplanner.model.Notice notice2a = noticesByElement.get(stopTime1.getId()).stream().findFirst().orElseThrow(IllegalStateException::new);
org.opentripplanner.model.Notice notice2b = noticesByElement.get(stopTime2.getId()).stream().findFirst().orElseThrow(IllegalStateException::new);
assertEquals(NOTICE_ID, notice2a.getId().getId());
assertEquals(NOTICE_ID, notice2b.getId().getId());
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class OtpTransitServiceBuilderLimitPeriodTest method createTrip.
private Trip createTrip(String id, FeedScopedId serviceId) {
Trip trip = new Trip();
trip.setId(new FeedScopedId(FEED_ID, id));
trip.setServiceId(serviceId);
trip.setDirectionId("1");
trip.setRoute(route);
return trip;
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class OtpTransitServiceBuilderLimitPeriodTest method createTripPattern.
private TripPattern createTripPattern(Collection<Trip> trips) {
TripPattern p = new TripPattern(route, STOP_PATTERN);
p.setId(new FeedScopedId(FEED_ID, trips.stream().map(t -> t.getId().getId()).collect(Collectors.joining(":"))));
p.name = "Pattern";
for (Trip trip : trips) {
p.add(new TripTimes(trip, STOP_TIMES, DEDUPLICATOR));
}
return p;
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class OtpTransitServiceBuilderLimitPeriodTest method testLimitPeriod.
@Test
public void testLimitPeriod() {
// Assert the test is set up as expected
assertEquals(2, subject.getCalendars().size());
assertEquals(2, subject.getCalendarDates().size());
assertEquals(4, subject.getTripsById().size());
assertEquals(3, subject.getTripPatterns().get(STOP_PATTERN).size());
assertEquals(2, patternInT1.getTrips().size());
assertEquals(2, patternInT1.scheduledTimetable.tripTimes.size());
assertEquals(1, patternInT2.getTrips().size());
assertEquals(1, patternInT2.scheduledTimetable.tripTimes.size());
// Limit service to last half of month
subject.limitServiceDays(new ServiceDateInterval(D2, D3));
// Verify calendar
List<ServiceCalendar> calendars = subject.getCalendars();
assertEquals(calendars.toString(), 1, calendars.size());
assertEquals(calendars.toString(), SERVICE_C_IN, calendars.get(0).getServiceId());
// Verify calendar dates
List<ServiceCalendarDate> dates = subject.getCalendarDates();
assertEquals(dates.toString(), 1, dates.size());
assertEquals(dates.toString(), SERVICE_D_IN, dates.get(0).getServiceId());
// Verify trips
EntityById<FeedScopedId, Trip> trips = subject.getTripsById();
assertEquals(trips.toString(), 2, trips.size());
assertTrue(trips.toString(), trips.containsKey(tripCSIn.getId()));
assertTrue(trips.toString(), trips.containsKey(tripCSDIn.getId()));
// Verify patterns
Collection<TripPattern> patterns = subject.getTripPatterns().get(STOP_PATTERN);
assertEquals(2, patterns.size());
assertTrue(patterns.toString(), patterns.contains(patternInT1));
assertTrue(patterns.toString(), patterns.contains(patternInT2));
// Verify trips in pattern (one trip is removed from patternInT1)
assertEquals(1, patternInT1.getTrips().size());
assertEquals(tripCSIn, patternInT1.getTrips().get(0));
// Verify trips in pattern is unchanged (one trip)
assertEquals(1, patternInT2.getTrips().size());
// Verify scheduledTimetable trips (one trip is removed from patternInT1)
assertEquals(1, patternInT1.scheduledTimetable.tripTimes.size());
assertEquals(tripCSIn, patternInT1.scheduledTimetable.tripTimes.get(0).trip);
// Verify scheduledTimetable trips in pattern is unchanged (one trip)
assertEquals(1, patternInT2.scheduledTimetable.tripTimes.size());
}
Aggregations