class ConstantNowProjectListener<Time : Temporal> : ConstantNowListener<Time>, ProjectListener
Simulate the value of now() while executing the project
This listener will simulate the value returned by the static method now as a helper to code that is sensitive
to now. After the execution of the project, the default behavior will be returned.
Supported classes are all classes in the java.time package that supports now, such as LocalDate.now() and
LocalDateTime.now(). Less used classes such as JapaneseDate.now() or Year.now() are also supported.
To simulate the value, this listener uses Mockk to modify the value returned from the static now function
ATTENTION: This code is very sensitive to race conditions. as the static method is global to the whole JVM instance,
if you're mocking now while running in parallel, the results may be inconsistent.
<init> |
Simulate the value of now() while executing the project ConstantNowProjectListener(now: Time) |
afterProject |
fun afterProject(): Unit |
beforeProject |
fun beforeProject(): Unit |