refactor(core): centralize millisecond epoch seconds (#7150)

This commit is contained in:
Jimmy Liu Jia authored and GitHub committed 2026-10-31 20:02:40 -04:00
1 parent 0f94440442
commit 08d45041d5
41 files changed
+217 -136

No files matched your search

@@ -0,0 +1,28 @@
package io.github.hectorvent.floci.core.common;
import org.junit.jupiter.api.Test;
import java.time.Instant;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
class EpochSecondsTest {
@Test
void keepsMillisecondFractionAndDropsSubmillisecondPrecision() {
assertEquals(1_790_312_384.592, EpochSeconds.fromInstant(
Instant.ofEpochSecond(1_790_312_384L, 592_999_999L)));
}
@Test
void floorsNegativeSubmillisecondInstantToPreviousMillisecond() {
assertEquals(-0.001, EpochSeconds.fromInstant(Instant.ofEpochSecond(-1, 999_999_999)));
}
@Test
void retainsNullAndOverflowFailures() {
assertThrows(NullPointerException.class, () -> EpochSeconds.fromInstant(null));
assertThrows(ArithmeticException.class, () -> EpochSeconds.fromInstant(Instant.MAX));
}
}