|
|
@@ -41,6 +41,7 @@ import static org.mockito.ArgumentMatchers.anyLong;
|
|
|
import static org.mockito.ArgumentMatchers.anyString;
|
|
|
import static org.mockito.ArgumentMatchers.eq;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
+import static org.mockito.Mockito.verify;
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
|
/**
|
|
|
@@ -215,11 +216,11 @@ class BusinessCockpitMapSnapshotAdapterTest {
|
|
|
Map<Object, Object> sharedValues = new ConcurrentHashMap<>();
|
|
|
when(sharedRedis.opsForValue()).thenReturn(values);
|
|
|
when(values.get(any())).thenAnswer(invocation -> sharedValues.get(invocation.getArgument(0)));
|
|
|
- when(values.setIfAbsent(any(), any(), anyLong(), eq(java.util.concurrent.TimeUnit.MINUTES)))
|
|
|
+ when(values.setIfAbsent(any(), any(), anyLong(), eq(java.util.concurrent.TimeUnit.SECONDS)))
|
|
|
.thenAnswer(invocation -> sharedValues.putIfAbsent(
|
|
|
invocation.getArgument(0), invocation.getArgument(1)) == null);
|
|
|
|
|
|
- String snapshotAt = "2026-09-02T10:00:00+08:00";
|
|
|
+ String snapshotAt = "2026-09-02T10:09:00+08:00";
|
|
|
MonitorPoint point = point("P-1", "POINT-1", "点位一", null, null);
|
|
|
EquipmentBase firstDevice = device("D-1", "DEVICE-1", "设备一", "11", null, null);
|
|
|
EquipmentBase changedDevice = device("D-2", "DEVICE-2", "设备二", "11", null, null);
|
|
|
@@ -233,6 +234,8 @@ class BusinessCockpitMapSnapshotAdapterTest {
|
|
|
Clock.fixed(Instant.parse("2026-09-02T02:00:00Z"), ZoneOffset.UTC), sharedRedis);
|
|
|
|
|
|
CockpitMapSnapshot first = firstAdapter.load(snapshotAt);
|
|
|
+ verify(values).setIfAbsent(eq("cockpit:map-snapshot:" + snapshotAt), any(), eq(19L * 60),
|
|
|
+ eq(java.util.concurrent.TimeUnit.SECONDS));
|
|
|
stubDevices(Collections.singletonList(changedDevice), Collections.singletonList(changedDevice));
|
|
|
BusinessCockpitMapSnapshotAdapter secondAdapter = new BusinessCockpitMapSnapshotAdapter(
|
|
|
monitorPointService, equipmentBaseService, equipmentTypeService, deviceFactResolver,
|