Conversation
-for Float and Integer types. Including range validation. -refactor String validation to expose only GTFS types to client code (id and text)
barbeau
left a comment
There was a problem hiding this comment.
Generally LGTM, although a few comments in-line.
src/main/java/org/mobilitydata/gtfsvalidator/util/GTFSTypeValidationUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/mobilitydata/gtfsvalidator/util/GTFSTypeValidationUtils.java
Show resolved
Hide resolved
-add potential source of Locale to use for parsing, to be fixed later
-occurrence prefix formatted with entity id as well as problematic value -tests have been changed to reflect that -rule title and postfix have been clarified
barbeau
left a comment
There was a problem hiding this comment.
LGTM, although a few comments inline.
| } | ||
|
|
||
| Float length = GTFSTypeValidationUtils.parseAndValidateFloat("length", | ||
| Float length = GTFSTypeValidationUtils.parseAndValidateFloat(pathwayId, |
There was a problem hiding this comment.
This might be dependent on how these error messages are surfaced in a UI or managed more generally in code, but I think you'll want to capture the ID field name here as well (in this case, pathway_id). It may not always be obvious which file you're validating.
So it may be hard to immediately decipher:
id: 1234 length is -0.001
..., while this is much easier to immediately understand:
pathway_id: 1234 length is -0.001
I think all IDs in GTFS end with _id now (?), although that's not a required naming convention and probably would be best not to assume it.
There was a problem hiding this comment.
Ok, I thought field names being quite unique would make it clear enough. I'll make the change.
| assertEquals(1, testList.size()); | ||
| error = testList.get(0); | ||
| assertEquals(fieldName, error.getPrefix()); | ||
| assertEquals("id: " + validatedEntityId + " " + fieldName + " is " + "-0.001", error.getPrefix()); |
There was a problem hiding this comment.
I'd suggest instead of concatenating the variables in the "expected" parameter, actually hard-coding the entire string with sample values that are very close to real ones. It makes it much easier to read what the expected output is and you're more likely to catch concatenation issues like missing spaces or commas.
So an expected value here could be:
pathway_id: 1234 length is -0.001
You could just test the entire concatenated prefix and suffix as well against one hard-coded string, to make sure the prefix and suffix concatenating correctly too.
IIRC the GTFS-rt validator tests the prefix but not prefix + suffix concatenation - that was on my TODO list but I never got to it. Concatenation errors in the messages (missing/extra spaces, commas, colons) was probably one of the most common issues I caught when writing most of the RT validator tests.
-testing against a full hard coded string as opposed to concatenating -capturing ID field name for occurrence prefix
Ok, opening an improvement issue for that. |
-required changes after merging PR #19 to master
-required changes after merging PR #19
* GTFS types validation. Using Apache commons -for Float and Integer types. Including range validation. -refactor String validation to expose only GTFS types to client code (id and text) * GTFS types validation. time -add validation code -specified format HH:MM:SS or H:MM:SS -add unit testing of method * GTFS types validation. time -add test to check for HHH:MM:SS rejection * GTFS types validation. time -required changes after merging PR #19 to master * GTFS types validation. time -add check for suspicious value leading to a warning -default set at >= 27:00:00
* GTFS types validation. Using Apache commons -for Float and Integer types. Including range validation. -refactor String validation to expose only GTFS types to client code (id and text) * Stops.txt -- GTFS types validation + protobuf conversion * GTFS types validation. time -add validation code -specified format HH:MM:SS or H:MM:SS -add unit testing of method * GTFS types validation. time -add test to check for HHH:MM:SS rejection * GTFS types validation. time -required changes after merging PR #19 to master * Stops.txt -- GTFS types validation + protobuf conversion -required changes after merging PR #19
Summary:
Having added Apache commons validators for URL validation, it seemed logical to do a refactor to use the FloatValidator and IntegerValidator. No change to test suite.
https://commons.apache.org/proper/commons-validator/
Relates to #14
Also included in this PR is a small refactor regarding String validation. validateString been made private and publicly exposed validateId and validateText have been made available. This way, client code directly call the method associated with the expected GTFS type for the considered CSV field.
Expected behavior:
Please make sure these boxes are checked before submitting your pull request - thanks!
gradle testto make sure you didn't break anything