INNER CODE UNIT · Java

timeTravelTo

PlaytikaOSS/testcontainers-spring-boot · embedded-aerospike/src/main/java/com/playtika/testcontainer/aerospike/AerospikeTestOperations.java:33

    public void timeTravelTo(OffsetDateTime futureTime) {
        OffsetDateTime now = DateTimeUtils.now();
        if (futureTime.isBefore(now)) {
            throw new IllegalArgumentException("Time should be in future. Now is: " + now + " time is:" + futureTime);
        } else {
            timeTravel(futureTime);
        }
    }

    public void rollbackTime() {
        DateTimeUtils.setCurrentMillisSystem();
    }

    private void timeTravel(OffsetDateTime newNow) {
        DateTimeUtils.setCurrentMillisFixed(newNow.toInstant().toEpochMilli());
        expiredDocumentsCleaner.cleanExpiredDocumentsBefore(newNow.toInstant().toEpochMilli());
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…