From 9e2504441b620dcd5bf3f17cb14ec15c1b335288 Mon Sep 17 00:00:00 2001 From: Jingsi Lu Date: Wed, 9 Oct 2024 08:12:27 -0400 Subject: [PATCH] feat: 1795 timepoint clarification (#1867) * removed @Recommended Column and modified MissingTimepointValue validation rule * fixed broken test * reformatted code * renamed test method * formatted code --- .../mobilitydata/gtfsvalidator/table/GtfsStopTimeSchema.java | 2 -- .../gtfsvalidator/validator/TimepointTimeValidator.java | 2 +- .../gtfsvalidator/validator/TimepointTimeValidatorTest.java | 5 +++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/main/src/main/java/org/mobilitydata/gtfsvalidator/table/GtfsStopTimeSchema.java b/main/src/main/java/org/mobilitydata/gtfsvalidator/table/GtfsStopTimeSchema.java index 80561fe0ee..93a48fa614 100644 --- a/main/src/main/java/org/mobilitydata/gtfsvalidator/table/GtfsStopTimeSchema.java +++ b/main/src/main/java/org/mobilitydata/gtfsvalidator/table/GtfsStopTimeSchema.java @@ -29,7 +29,6 @@ import org.mobilitydata.gtfsvalidator.annotation.Index; import org.mobilitydata.gtfsvalidator.annotation.NonNegative; import org.mobilitydata.gtfsvalidator.annotation.PrimaryKey; -import org.mobilitydata.gtfsvalidator.annotation.RecommendedColumn; import org.mobilitydata.gtfsvalidator.annotation.Required; import org.mobilitydata.gtfsvalidator.type.GtfsTime; @@ -91,7 +90,6 @@ public interface GtfsStopTimeSchema extends GtfsEntity { double shapeDistTraveled(); @DefaultValue("1") - @RecommendedColumn GtfsStopTimeTimepoint timepoint(); @FieldType(FieldTypeEnum.ID) diff --git a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidator.java b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidator.java index 972a35d8f0..bcca748636 100644 --- a/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidator.java +++ b/main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidator.java @@ -60,7 +60,7 @@ public void validate(NoticeContainer noticeContainer) { return; } for (GtfsStopTime stopTime : stopTimes.getEntities()) { - if (!stopTime.hasTimepoint()) { + if ((stopTime.hasArrivalTime() || stopTime.hasDepartureTime()) && !stopTime.hasTimepoint()) { noticeContainer.addValidationNotice(new MissingTimepointValueNotice(stopTime)); } if (isTimepoint(stopTime)) { diff --git a/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidatorTest.java b/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidatorTest.java index 8d3c3455fa..dcdab56f47 100644 --- a/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidatorTest.java +++ b/main/src/test/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidatorTest.java @@ -201,7 +201,8 @@ public void nonTimepoint_timesProvided_shouldNotGenerateNotice() { } @Test - public void emptyTimepoint_noTimesProvided_shouldGenerateNotice() { + public void + emptyTimepoint_noArrivalTime_noDepartureTime_noTimePointProvided_shouldNotGenerateNotice() { // setting .setTimepoint(null) is used to define a missing value // (even if the timepoint value is included in header) List stopTimes = new ArrayList<>(); @@ -216,7 +217,7 @@ public void emptyTimepoint_noTimesProvided_shouldGenerateNotice() { .setTimepoint((Integer) null) .build()); assertThat(generateNotices(createHeaderWithTimepointColumn(), stopTimes)) - .containsExactly(new MissingTimepointValueNotice(stopTimes.get(0))); + .doesNotContain(new MissingTimepointValueNotice(stopTimes.get(0))); } @Test