|
|
@@ -296,6 +296,28 @@ class BusinessCockpitMapSnapshotAdapterTest {
|
|
|
.collect(java.util.stream.Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void redisTtlRoundsUpToTheSnapshotExpiryBoundary() {
|
|
|
+ RedisTemplate<Object, Object> sharedRedis = mock(RedisTemplate.class);
|
|
|
+ ValueOperations<Object, Object> values = mock(ValueOperations.class);
|
|
|
+ when(sharedRedis.opsForValue()).thenReturn(values);
|
|
|
+ when(values.get(any())).thenReturn(null);
|
|
|
+ when(values.setIfAbsent(any(), any(), anyLong(), eq(java.util.concurrent.TimeUnit.SECONDS)))
|
|
|
+ .thenReturn(Boolean.TRUE);
|
|
|
+ when(monitorPointService.list()).thenReturn(Collections.emptyList());
|
|
|
+ when(equipmentBaseService.list()).thenReturn(Collections.emptyList());
|
|
|
+ when(equipmentTypeService.list()).thenReturn(Collections.emptyList());
|
|
|
+ BusinessCockpitMapSnapshotAdapter fractionalClockAdapter = new BusinessCockpitMapSnapshotAdapter(
|
|
|
+ monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
|
|
|
+ Clock.fixed(Instant.parse("2026-09-02T02:00:00.900Z"), ZoneOffset.UTC), sharedRedis);
|
|
|
+
|
|
|
+ fractionalClockAdapter.load("2026-09-02T10:00:00+08:00");
|
|
|
+
|
|
|
+ verify(values).setIfAbsent(eq("cockpit:map-snapshot:2026-09-02T10:00:00+08:00"), any(), eq(600L),
|
|
|
+ eq(java.util.concurrent.TimeUnit.SECONDS));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Test
|
|
|
void expiredSnapshotAtIsRejectedInsteadOfLoadingCurrentRelations() {
|
|
|
when(monitorPointService.list()).thenReturn(Collections.emptyList());
|