Skip to content

Fix #14 Extends GTFS types support -- Add support for Time and Date types#76

Merged
9 commits merged intomasterfrom
gtfs-types
Mar 27, 2020
Merged

Fix #14 Extends GTFS types support -- Add support for Time and Date types#76
9 commits merged intomasterfrom
gtfs-types

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 20, 2020

Summary:

This PR extends support of GTFS types to time and date
It also refactors some classes to make them injectable and the associated tests by introducing mockito framework use

Expected behavior:

All GTFS files should be validated, here for MTBA
image

close #14

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Format the title like "Fix #<issue_number> - " (for example - "Fix Bug: Running using documented Docker documentation fails #1111 - Check for null value before using field")
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

Fabrice V added 5 commits March 16, 2020 14:54
-modified type in .proto file
-updated bindings with protoc output
-took the occasion to correct package name
-remove test files associated with removed types
-also some formatting
-use new types in aciipb spec schema
-add time GTFS type support
-make parser and validator classes injectable
  -rewrite tests with mockito framework
  -remove now useless test fake schema resource files
-convert date strings to LocalDate type
-extend test
-remove unsupported type notice
@ghost ghost requested review from barbeau and lionel-nj March 20, 2020 19:59
@ghost ghost self-assigned this Mar 20, 2020
…erage into gtfs-types

� Conflicts:
�	adapter/parser/src/main/java/org/mobilitydata/gtfsvalidator/parser/GtfsEntityParser.java
�	adapter/parser/src/test/java/org/mobilitydata/gtfsvalidator/parser/GtfsEntityParserTest.java
�	adapter/repository/in-memory-simple/src/main/java/org/mobilitydata/gtfsvalidator/db/InMemoryGtfsSpecRepository.java
-non nullability of constructors parameters
Copy link
Copy Markdown
Member

@barbeau barbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fabrice-V Looking good! A few comments in-line.

assertEquals(TEST_FILE_TST, notice.getFilename());
assertEquals("Invalid color:AZ-FTJ in field:int_hex_with_regex for entity with id:test_id",
notice.getDescription());
verify(mockTimeValidator, times(1)).isValid(ArgumentMatchers.eq("01:02:03"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time is tricky in GTFS - the spec says:

Time - Time in the HH:MM:SS format (H:MM:SS is also accepted). The time is measured from "noon minus 12h" of the service day (effectively midnight except for days on which daylight savings time changes occur). For times occurring after midnight, enter the time as a value greater than 24:00:00 in HH:MM:SS local time for the day on which the trip schedule begins.
Example: 14:30:00 for 2:30PM or 25:35:00 for 1:35AM on the next day.

There need to be a few more assertions here to make sure we're covering all the valid times.

I suggest verifying that the following are correctly parsed as legit times:

  • "22:15:09"
  • "25:05:55"
  • "5:15:35"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in those unit tests the isValid return value is mocked and the parameter check is just here to verify it is passed unchanged. That way we don't test the validator library code at the same time. Do you think we shall have integration tests as well?

assertEquals("E016", notice.getId());
assertEquals("Invalid time", notice.getTitle());
assertEquals(TEST_FILE_TST, notice.getFilename());
assertEquals("Invalid time:001:2:00003 in field:time_with_regex for entity with id:test_id",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - I'd suggest adding more times that should fail:

  • "05:5:35"
  • "05:05:5"
  • "05:60:00"
  • "05:00:60"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in those unit tests the isValid return value is mocked and the parameter check is just here to verify it is passed unchanged. That way we don't test the validator library code at the same time. Do you think we shall have integration tests as well?

@ghost ghost mentioned this pull request Mar 27, 2020
Fabrice V added 2 commits March 27, 2020 12:52
-removed locale as the GTFS specification provide a format independent from the locale
@ghost ghost merged commit 411aa5b into master Mar 27, 2020
@ghost ghost deleted the gtfs-types branch March 27, 2020 18:26
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQUEST] Extend validation of GTFS types

1 participant