use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class TestSpecificTransfer method testSpecificTransfer.
/**
* Test different specific transfers
*/
public void testSpecificTransfer() {
// Setup from trip with route
Route fromRoute = new Route();
fromRoute.setId(new FeedScopedId("A1", "R1"));
Trip fromTrip = new Trip();
fromTrip.setId(new FeedScopedId("A1", "T1"));
fromTrip.setRoute(fromRoute);
// Setup to trip with route
Route toRoute = new Route();
toRoute.setId(new FeedScopedId("A1", "R2"));
Trip toTrip = new Trip();
toTrip.setId(new FeedScopedId("A1", "T2"));
toTrip.setRoute(toRoute);
// Create full SpecificTransfer
SpecificTransfer s1 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), fromTrip.getId(), toTrip.getId(), 1);
assertTrue(s1.matches(fromTrip, toTrip));
assertTrue(s1.getSpecificity() == SpecificTransfer.MAX_SPECIFICITY);
assertTrue(s1.transferTime == 1);
// Create empty SpecificTransfer
SpecificTransfer s2 = new SpecificTransfer((FeedScopedId) null, null, null, null, 2);
assertTrue(s2.matches(fromTrip, toTrip));
assertTrue(s2.getSpecificity() == SpecificTransfer.MIN_SPECIFICITY);
assertTrue(s2.transferTime == 2);
// Create SpecificTransfer one trip missing
SpecificTransfer s3 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), null, toTrip.getId(), 3);
assertTrue(s3.matches(fromTrip, toTrip));
assertTrue(s3.getSpecificity() == 3);
assertTrue(s3.transferTime == 3);
// Create SpecificTransfer one trip different
SpecificTransfer s4 = new SpecificTransfer(fromRoute.getId(), toRoute.getId(), new FeedScopedId("A1", "T3"), toTrip.getId(), 4);
assertFalse(s4.matches(fromTrip, toTrip));
assertTrue(s4.getSpecificity() == SpecificTransfer.MAX_SPECIFICITY);
assertTrue(s4.transferTime == 4);
// Create SpecificTransfer one trip and route missing
SpecificTransfer s5 = new SpecificTransfer(null, toRoute.getId(), null, toTrip.getId(), 5);
assertTrue(s5.matches(fromTrip, toTrip));
assertTrue(s5.getSpecificity() == 2);
assertTrue(s5.transferTime == 5);
// Create SpecificTransfer one trip only
SpecificTransfer s6 = new SpecificTransfer(null, null, null, toTrip.getId(), 6);
assertTrue(s6.matches(fromTrip, toTrip));
assertTrue(s6.getSpecificity() == 2);
assertTrue(s6.transferTime == 6);
// Create SpecificTransfer one route only
SpecificTransfer s7 = new SpecificTransfer(fromRoute.getId(), null, null, null, 7);
assertTrue(s7.matches(fromTrip, toTrip));
assertTrue(s7.getSpecificity() == 1);
assertTrue(s7.transferTime == 7);
}
use of org.opentripplanner.model.Trip in project OpenTripPlanner by opentripplanner.
the class ToStringBuilderTest method addTransitEntity.
@Test
public void addTransitEntity() {
Trip trip = new Trip();
trip.setId(new FeedScopedId("F", "1"));
assertEquals("ToStringBuilderTest{tripId: F:1}", subject().addEntityId("tripId", trip).toString());
}
use of org.opentripplanner.model.Trip 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.Trip 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.Trip 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;
}
Aggregations