From 7259e265b9237286996b09da03038ea5a133e1e0 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 17:45:07 +0800
Subject: [PATCH] 收敛模拟器为设备事实与实时观测
---
ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java b/ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
index 34dc6f4..cfb1d94 100644
--- a/ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
+++ b/ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
@@ -38,6 +38,38 @@
class TTestLiveServiceImplTest
{
@Test
+ void nonReceivingConsoleReadsCollectorStatusWithoutRequestingMeasurements() throws Exception
+ {
+ try (var simulator = new com.battery.device.simulator.BtsDevelopmentSimulator(0))
+ {
+ TTest test = test("RECEIVING");
+ test.getBatteries().get(0).setCollectorId(7L);
+ var tests = mock(ITTestService.class);
+ when(tests.selectTestById(10L)).thenReturn(test);
+ var mapper = mock(TTestMapper.class);
+ when(mapper.selectCollectorCode(7L)).thenReturn("dev-sim-collector-1");
+ var candidates = new com.battery.device.api.discovery.InMemoryDeviceDiscoveryCandidateStore();
+ Instant now = Instant.now();
+ candidates.replaceCollectors("dev-sim", List.of(new DeviceDiscoveryCandidateStore.CollectorCandidate(
+ "dev-sim", "dev-sim-collector-1", "127.0.1.2", null, "模拟采集器", null, null,
+ 4, true, now, now.plusSeconds(30))));
+ var service = new TTestLiveServiceImpl(tests, candidates, simulator, mapper);
+ service.current(10L);
+ var received = simulator.snapshot().recentRequests();
+ assertTrue(received.stream().anyMatch(item -> item.command().equals("collector-realtime")));
+ for (String status : List.of("PAUSED", "ENDED", "NOT_STARTED"))
+ {
+ test.setReceptionStatus(status);
+ var source = service.current(10L).sources().stream()
+ .filter(item -> item.sourceType().equals("COLLECTOR")).findFirst().orElseThrow();
+ assertEquals("ONLINE", source.deviceStatus());
+ assertTrue(source.latestSnapshot().isEmpty());
+ assertEquals(received, simulator.snapshot().recentRequests());
+ }
+ }
+ }
+
+ @Test
void notStartedShouldNotExposePreTestDeviceSnapshot()
{
Instant now = Instant.parse("2026-09-02T06:00:00Z");
--
Gitblit v1.7.1