I am currently working in a message-driven microservice project where we do not yet use axon, but will be in the future.
We have a lot of business constraints, that rely on time (waiting x days after a letter has been sent before the next action may happen, …). For testing complex use cases, over the years we came up with the concept of time traveling … so to ensure all relevant time based constraints elapsed, a typical integration test reads like: "go back in time (= set Instant.now) 2 weeks, sent out the letter, go back to “the future” (AKA= today) and evaluate the constraints are met and the next action can be triggered.
When we introduce axon eventsourcing into a world like this … any ideas how we can keep the time travel for testing?
We will have a “mixed” architecture (state based and event based storage), so switching to event-based only and just publish “time elapsed events” that fix the business constraint won’t work.
Can I reply events based on a custom order of events? Can I influence what “now” means for the event publisher? Would you be open to the concept of “CurrentTimeSupplier”, which defaults to “Instant.now()” but can be overwritten programmatically during tests? How do you deal with time based events?
Thanks for your thoughts and comments
Jan