Use deterministic default timestamp and add --current-timestamp option for JSON generation - #1038
Conversation
|
Thanks a lot for addressing this @gjavakhadze! LGTM. |
|
Thanks for the implementation. I think we should slightly reconsider the intended behavior for this issue. From my perspective, there are two main scenarios we should support:
With that model, the default behavior solves #813 directly, while users who need more dynamic sample data can still opt in explicitly. I’m also not sure we need a generic
|
|
@sekikn Thanks for your involvement and contribution in this project, my initial solution was kind of influenced from your referenced comment. @e-filchenko-bosh Thanks for your great insights,
Totaly agree here, will do the required changes for this. Do you have an idea what can we set for default timestamp value when
Previous behavior was current timestamp always, never random, so |
|
Thanks for the clarification. For the default timestamp value, I do not have a strong preference. The important part is that it is fixed and stable across runs. It could be today’s date, the Unix epoch, or something visually simple like Regarding the custom We can keep Currently this kind of value can easily lose information if it is parsed and converted through My preference would still be to keep the API smaller for this issue: |
|
@e-filchenko-bosh @gjavakhadze
Does this mean that we regard the current timestamp as a random value? If so, I'd like to distinguish between "non-deterministic" and "random" values here, because the current timestamp is non-deterministic but highly biased. I'm proposing another PR that adds a new option to give random values precedence over example values, so another option would be to include this "random" (not just "non-deterministic") behavior in that PR. |
|
Thanks @sekikn, that distinction makes sense to me. I agree that I also checked #1035, and my understanding is that it currently adds So I think #1035 is probably the right place to introduce truly random timestamp generation, but it would need an explicit implementation for timestamp/date/time types, e.g. generating values from a defined range. For #1038 I would keep the scope limited to:
Then truly random timestamp behavior can be handled separately in #1035 or a follow-up PR. |
# Conflicts: # core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/json/JsonPayloadGenerationConfig.java # documentation/developer-guide/modules/tooling-guide/pages/samm-cli.adoc # tools/esmf-aspect-model-maven-plugin/src/main/java/org/eclipse/esmf/aspectmodel/GenerateJsonPayload.java # tools/samm-cli/src/main/java/org/eclipse/esmf/aspect/to/AspectToJsonCommand.java
Description
Makes JSON payload timestamp generation deterministic by default:
exampleValueis defined in the model, date and time properties are generated using a fixed default timestamp (start of the Unix epoch:1970-01-01T00:00:00.000Z). Thisensures stable output across runs for automated tests and golden files.
--current-timestampflag (CLI, Maven plugin, and API config) to generate dynamic timestamps usingLocalDateTime.now().exampleValuedefined in the Aspect Model always takes precedence over generated default values.Default deterministic generation:
Opt-in current timestamp:
Fixes #813
Type of change
Checklist: