use of org.opentripplanner.model.calendar.ServiceDateInterval 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());
}
use of org.opentripplanner.model.calendar.ServiceDateInterval in project OpenTripPlanner by opentripplanner.
the class OtpTransitServiceBuilderLimitPeriodTest method createServiceCalendar.
private static ServiceCalendar createServiceCalendar(FeedScopedId serviceId, ServiceDate start, ServiceDate end) {
ServiceCalendar calendar = new ServiceCalendar();
calendar.setPeriod(new ServiceDateInterval(start, end));
calendar.setAllDays(1);
calendar.setServiceId(serviceId);
return calendar;
}
Aggregations