diff --git a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidator.java b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidator.java index 6ba7588774..5641c7d586 100644 --- a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidator.java +++ b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidator.java @@ -56,37 +56,43 @@ public void validate(NoticeContainer noticeContainer) { List 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)); + } } } } diff --git a/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidatorTest.java b/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidatorTest.java index f913398150..e566db5fad 100644 --- a/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidatorTest.java +++ b/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidatorTest.java @@ -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) @@ -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(); + } }