|
|
@@ -7,6 +7,7 @@ import com.zksy.base.service.EquipmentBaseService;
|
|
|
import com.zksy.base.service.EquipmentTypeService;
|
|
|
import com.zksy.base.service.MonitorPointService;
|
|
|
import com.zksy.cockpit.foundation.CockpitCoordinateValidator;
|
|
|
+import com.zksy.cockpit.foundation.CockpitReadException;
|
|
|
import com.zksy.cockpit.foundation.CockpitSnapshotExpiredException;
|
|
|
import com.zksy.cockpit.map.BusinessCockpitMapSnapshotAdapter;
|
|
|
import com.zksy.cockpit.map.CockpitMapSnapshot;
|
|
|
@@ -416,6 +417,37 @@ class BusinessCockpitMapSnapshotAdapterTest {
|
|
|
verifyNoInteractions(monitorPointService, equipmentBaseService, equipmentTypeService);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void redisGetFailureIsClassifiedAsReadFailure() {
|
|
|
+ RedisTemplate<Object, Object> sharedRedis = mock(RedisTemplate.class);
|
|
|
+ ValueOperations<Object, Object> values = mock(ValueOperations.class);
|
|
|
+ when(sharedRedis.opsForValue()).thenReturn(values);
|
|
|
+ when(values.get(any())).thenThrow(new IllegalStateException("redis unavailable"));
|
|
|
+ BusinessCockpitMapSnapshotAdapter sharedAdapter = new BusinessCockpitMapSnapshotAdapter(
|
|
|
+ monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
|
|
|
+ Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC), sharedRedis);
|
|
|
+
|
|
|
+ assertThrows(CockpitReadException.class, () -> sharedAdapter.load(null));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void redisSetFailureIsClassifiedAsReadFailure() {
|
|
|
+ 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)))
|
|
|
+ .thenThrow(new IllegalStateException("redis unavailable"));
|
|
|
+ when(monitorPointService.list()).thenReturn(Collections.emptyList());
|
|
|
+ when(equipmentBaseService.list()).thenReturn(Collections.emptyList());
|
|
|
+ when(equipmentTypeService.list()).thenReturn(Collections.emptyList());
|
|
|
+ BusinessCockpitMapSnapshotAdapter sharedAdapter = new BusinessCockpitMapSnapshotAdapter(
|
|
|
+ monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
|
|
|
+ Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC), sharedRedis);
|
|
|
+
|
|
|
+ assertThrows(CockpitReadException.class, () -> sharedAdapter.load(null));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void expiredSnapshotAtIsRejectedInsteadOfLoadingCurrentRelations() {
|
|
|
when(monitorPointService.list()).thenReturn(Collections.emptyList());
|