libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 00667074eaa9218dc9a2d7eaf102f2360c6a8505
parent 5c6a7255cbaa69eaa3dd15e01781156c32132a61
Author: MS <ms@taler.net>
Date:   Tue,  5 Jan 2021 20:39:13 +0100

Clock manipulation.

Trying to move clock in the future along a unit test.

Diffstat:
Mutil/src/test/kotlin/TimeTest.kt | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/util/src/test/kotlin/TimeTest.kt b/util/src/test/kotlin/TimeTest.kt @@ -1,11 +1,23 @@ import org.junit.Test -import tech.libeufin.util.parseDashedDate import java.time.* import java.time.format.DateTimeFormatter -import java.time.temporal.TemporalAccessor + +// https://stackoverflow.com/questions/32437550/whats-the-difference-between-instant-and-localdatetime class TimeTest { @Test + fun mock() { + // Using the system clock, thus not mocking at all. + val systemClock = Clock.system(ZoneId.systemDefault()) + val realNow = ZonedDateTime.now(systemClock) + println(realNow) + // Moving four hours later. + val offsetTime = Clock.offset(systemClock, Duration.ofHours(4)) + val offesetNow = ZonedDateTime.now(offsetTime) + println(offesetNow) + } + + @Test fun importMillis() { fun fromLong(millis: Long): LocalDateTime { return LocalDateTime.ofInstant(