Skip to content

Commit

Permalink
feat: 1795 timepoint clarification (#1867)
Browse files Browse the repository at this point in the history
* removed @recommended Column and modified MissingTimepointValue validation rule

* fixed broken test

* reformatted code

* renamed test method

* formatted code
  • Loading branch information
qcdyx authored Oct 9, 2024
1 parent 0f19e74 commit 9e25044
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -91,7 +90,6 @@ public interface GtfsStopTimeSchema extends GtfsEntity {
double shapeDistTraveled();

@DefaultValue("1")
@RecommendedColumn
GtfsStopTimeTimepoint timepoint();

@FieldType(FieldTypeEnum.ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GtfsStopTime> stopTimes = new ArrayList<>();
Expand All @@ -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
Expand Down

0 comments on commit 9e25044

Please sign in to comment.