From 7ab0e426264707fb85ee38d0a9a73caf41899635 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 29 八月 2026 13:11:40 +0800
Subject: [PATCH] 实现采集器独立实时与历史采样模拟
---
ruoyi-admin/src/test/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorControllerTest.java | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/ruoyi-admin/src/test/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorControllerTest.java b/ruoyi-admin/src/test/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorControllerTest.java
index 518fba3..720b47c 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorControllerTest.java
+++ b/ruoyi-admin/src/test/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorControllerTest.java
@@ -6,6 +6,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.lang.reflect.Method;
+import java.math.BigDecimal;
import java.net.InetAddress;
import java.time.Instant;
import java.util.List;
@@ -95,6 +96,34 @@
}
@Test
+ void controllerExposesCollectorRealtimeAndPagedHistory() throws Exception
+ {
+ try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0))
+ {
+ BtsDevelopmentSimulatorController controller = controller(simulator);
+ controller.configureCollectorSampling(1,
+ new BtsDevelopmentSimulatorController.CollectorSamplingCommand(
+ 100, List.of(), null, null, false));
+ controller.configureCollectorChannel(1, "S-01",
+ new BtsDevelopmentSimulatorController.CollectorChannelCommand(List.of(
+ new BtsDevelopmentSimulatorController.CollectorMetricCommand(
+ "temperature", new BigDecimal("27.2"), "℃"),
+ new BtsDevelopmentSimulatorController.CollectorMetricCommand(
+ "custom_voltage", new BigDecimal("1.234"), "V"))));
+ simulator.advanceCollectors(Instant.parse("2026-08-29T01:00:00Z"));
+
+ var realtime = controller.collectorRealtime(1);
+ var firstPage = controller.collectorHistory(1, 0, 2);
+
+ assertTrue(realtime.online());
+ assertTrue(realtime.measurements().stream().anyMatch(item -> item.metricCode().equals("custom_voltage")));
+ assertEquals(2, firstPage.records().size());
+ assertTrue(firstPage.hasMore());
+ assertEquals(2, firstPage.nextOffset());
+ }
+ }
+
+ @Test
void virtualIpMustBeUniqueAcrossCabinetsAndCollectors() throws Exception
{
try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0))
--
Gitblit v1.7.1