Add Clock Support for Deterministic Timestamps#4
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds configurable clock support to improve testability and deterministic timestamp behavior across the application. Key changes include:
- Introduction of ClockConfig and ClockProperties for centralized clock management.
- Modifications to PingMapper and related tests to use injected Clock instead of Instant.now().
- Updates to the README and application.yml to document and enable timezone configuration.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/dev/luismachadoreis/flighttracker/server/ping/application/dto/PingMapperTest.java | Updated tests to use a fixed Clock for deterministic timestamps. |
| src/test/java/dev/luismachadoreis/flighttracker/server/flightdata/infrastructure/pubsub/FlightDataSubscriberTest.java | Updated test to use fixed Clock for timestamp generation. |
| src/main/resources/application.yml | Added new clock configuration settings (timezone set to UTC by default). |
| src/main/java/dev/luismachadoreis/flighttracker/server/ping/application/dto/PingMapper.java | Modified to use injected Clock for creating timestamps. |
| src/main/java/dev/luismachadoreis/flighttracker/server/common/infrastructure/ClockProperties.java | Added a record for clock properties with default timezone assignment. |
| src/main/java/dev/luismachadoreis/flighttracker/server/common/infrastructure/ClockConfig.java | Provides a Clock bean based on the configured timezone. |
| README.md | Updated documentation to include clock configuration and simplified project structure. |
...ain/java/dev/luismachadoreis/flighttracker/server/common/infrastructure/ClockProperties.java
Outdated
Show resolved
Hide resolved
…infrastructure/ClockProperties.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
KKKK LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Add Clock Support for Deterministic Timestamps
Summary
This PR adds configurable clock support to improve testability and consistency of timestamp operations. It introduces a new clock configuration system that allows setting the timezone through application properties while maintaining UTC as the default.
Changes
ClockConfigandClockPropertiesfor configurable clock managementPingMapperto use injected clock instead ofInstant.now()application.ymlMotivation
Instant.now()Checklist