Skip to content

Commit

Permalink
feat: update missing_trip_edge for flex feed (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
cka-y authored Sep 24, 2024
1 parent 242368d commit 9b83e21
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,43 @@ public void validate(NoticeContainer noticeContainer) {
List<GtfsStopTime> stopTimesForTrip = entry.getValue();
GtfsStopTime tripFirstStop = stopTimesForTrip.get(0);
GtfsStopTime tripLastStop = stopTimesForTrip.get(stopTimesForTrip.size() - 1);
if (!tripFirstStop.hasArrivalTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripFirstStop.csvRowNumber(),
tripFirstStop.stopSequence(),
tripId,
ARRIVAL_TIME_FIELD_NAME));
if (!tripFirstStop.hasStartPickupDropOffWindow()
&& !tripFirstStop.hasEndPickupDropOffWindow()) {
if (!tripFirstStop.hasArrivalTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripFirstStop.csvRowNumber(),
tripFirstStop.stopSequence(),
tripId,
ARRIVAL_TIME_FIELD_NAME));
}
if (!tripFirstStop.hasDepartureTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripFirstStop.csvRowNumber(),
tripFirstStop.stopSequence(),
tripId,
DEPARTURE_TIME_FIELD_NAME));
}
}
if (!tripFirstStop.hasDepartureTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripFirstStop.csvRowNumber(),
tripFirstStop.stopSequence(),
tripId,
DEPARTURE_TIME_FIELD_NAME));
}
if (!tripLastStop.hasArrivalTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripLastStop.csvRowNumber(),
tripLastStop.stopSequence(),
tripId,
ARRIVAL_TIME_FIELD_NAME));
}
if (!tripLastStop.hasDepartureTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripLastStop.csvRowNumber(),
tripLastStop.stopSequence(),
tripId,
DEPARTURE_TIME_FIELD_NAME));
if (!tripLastStop.hasStartPickupDropOffWindow()
&& !tripLastStop.hasEndPickupDropOffWindow()) {
if (!tripLastStop.hasArrivalTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripLastStop.csvRowNumber(),
tripLastStop.stopSequence(),
tripId,
ARRIVAL_TIME_FIELD_NAME));
}
if (!tripLastStop.hasDepartureTime()) {
noticeContainer.addValidationNotice(
new MissingTripEdgeNotice(
tripLastStop.csvRowNumber(),
tripLastStop.stopSequence(),
tripId,
DEPARTURE_TIME_FIELD_NAME));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ public static GtfsStopTime createStopTime(
.build();
}

public static GtfsStopTime createStopTimeWithPickupDropOffWindow(
int csvRowNumber,
String tripId,
GtfsTime arrivalTime,
GtfsTime departureTime,
int stopSequence,
GtfsTime startPickupDropOffWindow,
GtfsTime endPickupDropOffWindow) {
return new GtfsStopTime.Builder()
.setCsvRowNumber(csvRowNumber)
.setTripId(tripId)
.setArrivalTime(arrivalTime)
.setDepartureTime(departureTime)
.setStopSequence(stopSequence)
.setStopId("stop id")
.setStartPickupDropOffWindow(startPickupDropOffWindow)
.setEndPickupDropOffWindow(endPickupDropOffWindow)
.build();
}

public static GtfsTrip createTrip(int csvRowNumber, String tripId) {
return new GtfsTrip.Builder()
.setCsvRowNumber(csvRowNumber)
Expand Down Expand Up @@ -155,4 +175,28 @@ public void tripWithValidEdgesShouldNotGenerateNotice() {
4))))
.isEmpty();
}

@Test
public void tripWithPickupDropOffWindowShouldNotGenerateNotice() {
assertThat(
generateNotices(
ImmutableList.of(
createStopTimeWithPickupDropOffWindow(
2,
"trip id value",
null,
null,
1,
GtfsTime.fromSecondsSinceMidnight(1),
GtfsTime.fromSecondsSinceMidnight(2)),
createStopTimeWithPickupDropOffWindow(
3,
"trip id value 2",
null,
null,
1,
GtfsTime.fromSecondsSinceMidnight(1),
GtfsTime.fromSecondsSinceMidnight(2)))))
.isEmpty();
}
}

0 comments on commit 9b83e21

Please sign in to comment.