You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library currently generates ZonedDateTime values across the entire Instant range with a random ZoneId. This works for general fixtures, but tests often need values constrained to specific or realistic time windows, or pinned to a specific time zone. Add a ZonedDateTimeStrategy that lets users choose from predefined generation windows or supply their own exact min/max bounds and optional zone, while keeping the existing full-range behavior as the default.
Scope
In scope:
Create a new ZonedDateTimeStrategy sealed interface in dev.appoutlet.some.config.
Add the following variants:
Default — current behavior, spanning the full Instant range.
NearPast — from 10 years before now until now.
NearFuture — from now until 10 years after now.
DistantPast — from Instant.MIN until now.
DistantFuture — from now until Instant.MAX.
Range(val min: Instant, val max: Instant, val zoneId: ZoneId? = null) — user-defined bounds, where min <= generated instant <= max. If zoneId is null, a random available JVM ZoneId is used.
Update JavaZonedDateTimeResolver to read the active ZonedDateTimeStrategy and generate values within the selected window.
Register ZonedDateTimeStrategy.default in SomeConfig.defaultStrategies().
Add unit tests covering each strategy variant and the strategy registration path.
Out of scope:
Strategies for other date/time types such as Instant, LocalDateTime, or Kotlin kotlinx.datetime types.
Zone ID customization for variants other than Range.
Acceptance criteria
GIVEN no explicit ZonedDateTimeStrategy is configured, WHEN a ZonedDateTime value is generated, THEN it behaves like today (random instant between Instant.MIN and Instant.MAX, random ZoneId).
GIVEN ZonedDateTimeStrategy.NearPast is configured, WHEN a ZonedDateTime value is generated, THEN its instant falls between 10 years before now and now.
GIVEN ZonedDateTimeStrategy.NearFuture is configured, WHEN a ZonedDateTime value is generated, THEN its instant falls between now and 10 years after now.
GIVEN ZonedDateTimeStrategy.DistantPast is configured, WHEN a ZonedDateTime value is generated, THEN its instant falls between Instant.MIN and now.
GIVEN ZonedDateTimeStrategy.DistantFuture is configured, WHEN a ZonedDateTime value is generated, THEN its instant falls between now and Instant.MAX.
GIVEN ZonedDateTimeStrategy.Range(min, max) is configured with min <= max, WHEN a ZonedDateTime value is generated, THEN its instant falls between min and max (inclusive) and its ZoneId is random.
GIVEN ZonedDateTimeStrategy.Range(min, max, zoneId) is configured, WHEN a ZonedDateTime value is generated, THEN its ZoneId equals the supplied zoneId.
GIVEN ZonedDateTimeStrategy.Range(min, max) is configured with min > max, THEN construction fails with a clear error.
GIVEN the strategy is registered via someSetup { strategy(ZonedDateTimeStrategy.Range(min, max, zoneId)) }, WHEN a ZonedDateTime value is generated, THEN the configured range and zone are respected.
Description
The library currently generates
ZonedDateTimevalues across the entireInstantrange with a randomZoneId. This works for general fixtures, but tests often need values constrained to specific or realistic time windows, or pinned to a specific time zone. Add aZonedDateTimeStrategythat lets users choose from predefined generation windows or supply their own exact min/max bounds and optional zone, while keeping the existing full-range behavior as the default.Scope
ZonedDateTimeStrategysealed interface indev.appoutlet.some.config.Default— current behavior, spanning the fullInstantrange.NearPast— from 10 years before now until now.NearFuture— from now until 10 years after now.DistantPast— fromInstant.MINuntil now.DistantFuture— from now untilInstant.MAX.Range(val min: Instant, val max: Instant, val zoneId: ZoneId? = null)— user-defined bounds, wheremin <= generated instant <= max. IfzoneIdisnull, a random available JVMZoneIdis used.JavaZonedDateTimeResolverto read the activeZonedDateTimeStrategyand generate values within the selected window.ZonedDateTimeStrategy.defaultinSomeConfig.defaultStrategies().Instant,LocalDateTime, or Kotlinkotlinx.datetimetypes.Range.Acceptance criteria
ZonedDateTimeStrategyis configured, WHEN aZonedDateTimevalue is generated, THEN it behaves like today (random instant betweenInstant.MINandInstant.MAX, randomZoneId).ZonedDateTimeStrategy.NearPastis configured, WHEN aZonedDateTimevalue is generated, THEN its instant falls between 10 years before now and now.ZonedDateTimeStrategy.NearFutureis configured, WHEN aZonedDateTimevalue is generated, THEN its instant falls between now and 10 years after now.ZonedDateTimeStrategy.DistantPastis configured, WHEN aZonedDateTimevalue is generated, THEN its instant falls betweenInstant.MINand now.ZonedDateTimeStrategy.DistantFutureis configured, WHEN aZonedDateTimevalue is generated, THEN its instant falls between now andInstant.MAX.ZonedDateTimeStrategy.Range(min, max)is configured withmin <= max, WHEN aZonedDateTimevalue is generated, THEN its instant falls betweenminandmax(inclusive) and itsZoneIdis random.ZonedDateTimeStrategy.Range(min, max, zoneId)is configured, WHEN aZonedDateTimevalue is generated, THEN itsZoneIdequals the suppliedzoneId.ZonedDateTimeStrategy.Range(min, max)is configured withmin > max, THEN construction fails with a clear error.someSetup { strategy(ZonedDateTimeStrategy.Range(min, max, zoneId)) }, WHEN aZonedDateTimevalue is generated, THEN the configured range and zone are respected.