Skip to content

feat: introduce CurrentDateTime#855

Merged
lionel-nj merged 21 commits intomasterfrom
dependency-injection
Apr 22, 2021
Merged

feat: introduce CurrentDateTime#855
lionel-nj merged 21 commits intomasterfrom
dependency-injection

Conversation

@lionel-nj
Copy link
Copy Markdown
Contributor

@lionel-nj lionel-nj commented Apr 15, 2021

Summary:

This PR introduces CurrentDateTime as a wrapper around ZonedDateTime to be used (in the future) in ValidationContext

Expected behavior:

No change in validation rule logic: same tests should pass.

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

@lionel-nj lionel-nj mentioned this pull request Apr 15, 2021
3 tasks
@lionel-nj lionel-nj self-assigned this Apr 15, 2021
@lionel-nj lionel-nj changed the title refactor: inject CurrentDateTime and GtfsFeedName [WIP] refactor: inject CurrentDateTime and GtfsFeedName Apr 15, 2021
@lionel-nj lionel-nj changed the title [WIP] refactor: inject CurrentDateTime and GtfsFeedName refactor: [WIP] inject CurrentDateTime and GtfsFeedName Apr 15, 2021
@lionel-nj lionel-nj changed the title refactor: [WIP] inject CurrentDateTime and GtfsFeedName refactor: [WIP] inject CurrentDateTime and CountryCode Apr 15, 2021
@lionel-nj lionel-nj changed the title refactor: [WIP] inject CurrentDateTime and CountryCode refactor: [WIP] Inject CurrentDateTime and CountryCode Apr 15, 2021
Copy link
Copy Markdown
Collaborator

@aababilov aababilov left a comment

Choose a reason for hiding this comment

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

Nice start! Do you mind to merge my #850 first?

lionel-nj added 2 commits April 22, 2021 15:20
# Conflicts:
#	core/src/main/java/org/mobilitydata/gtfsvalidator/parsing/RowParser.java
#	core/src/main/java/org/mobilitydata/gtfsvalidator/validator/ValidationContext.java
#	core/src/test/java/org/mobilitydata/gtfsvalidator/parsing/RowParserTest.java
#	main/src/main/java/org/mobilitydata/gtfsvalidator/cli/Main.java
#	main/src/test/java/org/mobilitydata/gtfsvalidator/table/GtfsLevelTableLoaderTest.java
#	main/src/test/java/org/mobilitydata/gtfsvalidator/validator/FeedExpirationDateValidatorTest.java
#	processor/src/main/java/org/mobilitydata/gtfsvalidator/processor/TableLoaderGenerator.java
- reintroduce ValidationContext
- encapsulate ZonedDateTime under CurrentDateTime
- update unit tests
- update javadocs
@lionel-nj
Copy link
Copy Markdown
Contributor Author

Thanks @aababilov, modified this PR as suggested.

@lionel-nj lionel-nj requested a review from aababilov April 22, 2021 20:13
@lionel-nj lionel-nj changed the title refactor: [WIP] Inject CurrentDateTime and CountryCode refactor: inject CurrentDateTime and CountryCode Apr 22, 2021
Copy link
Copy Markdown
Collaborator

@aababilov aababilov left a comment

Choose a reason for hiding this comment

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

LGTM! Please run

 google-java-format -i $(find . -name '*.java')  

@lionel-nj lionel-nj requested a review from aababilov April 22, 2021 20:39
Copy link
Copy Markdown
Collaborator

@aababilov aababilov left a comment

Choose a reason for hiding this comment

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

LGTM! Please merge and I will update my PR.

@lionel-nj lionel-nj requested a review from aababilov April 22, 2021 20:56
@aababilov
Copy link
Copy Markdown
Collaborator

Lionel, that will crash validator :) You have not modified dependency injection mechanism. Do you mind to leave that to me?

@aababilov
Copy link
Copy Markdown
Collaborator

Do you mind to merge #862 first?

@lionel-nj
Copy link
Copy Markdown
Contributor Author

Lionel, that will crash validator :) You have not modified dependency injection mechanism. Do you mind to leave that to me?

I knew I might I forgotten something. Yes, let's do that! I'll take note for the future 📝

@aababilov
Copy link
Copy Markdown
Collaborator

Here is a stacktrace for you. You need a feed with feed_info.txt to observe that.

SEVERE: Runtime exception when loading feed_info.txt
java.lang.IllegalArgumentException: argument type mismatch
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.mobilitydata.gtfsvalidator.validator.ValidatorLoader.createValidator(ValidatorLoader.java:236)
        at org.mobilitydata.gtfsvalidator.validator.ValidatorLoader.createSingleEntityValidators(ValidatorLoader.java:156)
        at org.mobilitydata.gtfsvalidator.table.GtfsFeedInfoTableLoader.load(GtfsFeedInfoTableLoader.java:95)
        at org.mobilitydata.gtfsvalidator.table.GtfsFeedLoader.lambda$loadAndValidate$0(GtfsFeedLoader.java:113)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)

@aababilov
Copy link
Copy Markdown
Collaborator

aababilov commented Apr 22, 2021

May I suggest the following:

Please submit CurrentDateTime.java , CurrentDateTimeTest.java and ValidationContext.java in this PR. I will write the next PR to make changes to dependency injection and modify the FeedExpirationDateValidator.

@lionel-nj
Copy link
Copy Markdown
Contributor Author

Here is a stacktrace for you. You need a feed with feed_info.txt to observe that.

Thank you very much, I ran it on a dataset that was not using feed_info.txt.

Please submit CurrentDateTime.java , CurrentDateTimeTest.java and ValidationContext.java in this PR.

On it!

@aababilov
Copy link
Copy Markdown
Collaborator

Thank you very much, I ran it on a dataset that was not using feed_info.txt.

I will add checks to ValidatorLoader for checking constructors for validator classes even if they are not instantiated. You see, right now if you don't have the feed_info.txt file, then the validators for it are not instantiated and you don't observe the failure.

@aababilov
Copy link
Copy Markdown
Collaborator

After you change the code in this PR, you can rename it to "Introduce CurrentDateTime".

@lionel-nj
Copy link
Copy Markdown
Contributor Author

lionel-nj commented Apr 22, 2021

Following your suggestion I only kept changes related to CurrentDateTime.java, CurrentDateTimeTest.java and ValidationContext.java - which unfortunately breaks the execution of GtfsLevelTableLoaderTest. Because of this I added the @Nullable to allow to temporary skip CurrentDateTime in ValidationContext builder.

@lionel-nj lionel-nj changed the title refactor: inject CurrentDateTime and CountryCode Introduce: CurrentDateTime Apr 22, 2021
@lionel-nj lionel-nj changed the title Introduce: CurrentDateTime feat: introduce CurrentDateTime Apr 22, 2021
Copy link
Copy Markdown
Collaborator

@aababilov aababilov left a comment

Choose a reason for hiding this comment

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

LGTM! Please merge it ;)

@lionel-nj lionel-nj marked this pull request as ready for review April 22, 2021 22:12
@lionel-nj lionel-nj merged commit d10efdc into master Apr 22, 2021
@lionel-nj lionel-nj deleted the dependency-injection branch April 22, 2021 22:13
@lionel-nj
Copy link
Copy Markdown
Contributor Author

Thanks @aababilov!

@aababilov
Copy link
Copy Markdown
Collaborator

Here you go: #866

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.

3 participants