use of org.opentripplanner.model.StopTime 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.StopTime in project OpenTripPlanner by opentripplanner.
the class OtpTransitServiceImplTest method testGetAllStopTimes.
@Test
public void testGetAllStopTimes() {
List<StopTime> stopTimes = new ArrayList<>();
for (Trip trip : subject.getAllTrips()) {
stopTimes.addAll(subject.getStopTimesForTrip(trip));
}
assertEquals(80, stopTimes.size());
assertEquals("StopTime(seq=1 stop=Z:A trip=agency:1.1 times=00:00:00-00:00:00)", first(stopTimes).toString());
}
use of org.opentripplanner.model.StopTime in project OpenTripPlanner by opentripplanner.
the class OtpTransitServiceBuilderLimitPeriodTest method createStopTime.
private static StopTime createStopTime(Stop stop, int time) {
StopTime st = new StopTime();
st.setStop(stop);
st.setDepartureTime(time);
st.setArrivalTime(time);
st.setPickupType(1);
st.setDropOffType(1);
return st;
}
use of org.opentripplanner.model.StopTime in project OpenTripPlanner by opentripplanner.
the class TripTimesTest method testApply.
@Test
public void testApply() {
Trip trip = new Trip();
trip.setId(tripId);
List<StopTime> stopTimes = new LinkedList<StopTime>();
StopTime stopTime0 = new StopTime();
StopTime stopTime1 = new StopTime();
StopTime stopTime2 = new StopTime();
Stop stop0 = Stop.stopForTest(stops[0].getId(), 0.0, 0.0);
Stop stop1 = Stop.stopForTest(stops[1].getId(), 0.0, 0.0);
Stop stop2 = Stop.stopForTest(stops[2].getId(), 0.0, 0.0);
stopTime0.setStop(stop0);
stopTime0.setDepartureTime(0);
stopTime0.setStopSequence(0);
stopTime1.setStop(stop1);
stopTime1.setArrivalTime(30);
stopTime1.setDepartureTime(60);
stopTime1.setStopSequence(1);
stopTime2.setStop(stop2);
stopTime2.setArrivalTime(90);
stopTime2.setStopSequence(2);
stopTimes.add(stopTime0);
stopTimes.add(stopTime1);
stopTimes.add(stopTime2);
TripTimes differingTripTimes = new TripTimes(trip, stopTimes, new Deduplicator());
TripTimes updatedTripTimesA = new TripTimes(differingTripTimes);
updatedTripTimesA.updateArrivalTime(1, 89);
updatedTripTimesA.updateDepartureTime(1, 98);
assertFalse(updatedTripTimesA.timesIncreasing());
}
use of org.opentripplanner.model.StopTime in project OpenTripPlanner by opentripplanner.
the class StopTimesMapperTest method testMapStopTimes.
@Test
public void testMapStopTimes() {
NetexTestDataSample sample = new NetexTestDataSample();
StopTimesMapper stopTimesMapper = new StopTimesMapper(MappingSupport.ID_FACTORY, sample.getStopsById(), sample.getDestinationDisplayById(), sample.getQuayIdByStopPointRef());
StopTimesMapper.MappedStopTimes result = stopTimesMapper.mapToStopTimes(sample.getJourneyPattern(), new Trip(), sample.getTimetabledPassingTimes());
List<StopTime> stopTimes = result.stopTimes;
assertEquals(4, stopTimes.size());
assertStop(stopTimes.get(0), "NSR:Quay:1", 18000, "Bergen");
assertStop(stopTimes.get(1), "NSR:Quay:2", 18240, "Bergen");
assertStop(stopTimes.get(2), "NSR:Quay:3", 18600, "Stavanger");
assertStop(stopTimes.get(3), "NSR:Quay:4", 18900, "Stavanger");
Map<String, StopTime> map = result.stopTimeByNetexId;
assertEquals(stopTimes.get(0), map.get("TTPT-1"));
assertEquals(stopTimes.get(1), map.get("TTPT-2"));
assertEquals(stopTimes.get(2), map.get("TTPT-3"));
assertEquals(stopTimes.get(3), map.get("TTPT-4"));
}
Aggregations