From 92f32acd847ea1700590bc669750f23ef499840e Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 13:39:44 +0800
Subject: [PATCH] 清理旧测试结构并贯通最终业务数据链路

---
 ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java |   59 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestLiveServiceImplTest.java b/ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
similarity index 83%
rename from ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestLiveServiceImplTest.java
rename to ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
index dcc55fe..34dc6f4 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestLiveServiceImplTest.java
+++ b/ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
@@ -1,4 +1,4 @@
-package com.ruoyi.system.service.impl;
+package com.battery.business.service.impl;
 
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -19,18 +19,20 @@
 import org.junit.jupiter.api.Test;
 import org.springframework.web.context.request.async.AsyncRequestNotUsableException;
 import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
-import com.battery.device.simulator.BtsDevelopmentSimulator;
-import com.battery.device.discovery.DeviceDiscoveryCandidateStore;
-import com.battery.device.model.ChannelIdentity;
-import com.battery.device.model.DeviceWorkStatus;
-import com.battery.device.model.RealtimeSnapshot;
-import com.ruoyi.system.domain.TTest;
-import com.ruoyi.system.domain.TTestBattery;
-import com.ruoyi.system.domain.TTestChannelBinding;
-import com.ruoyi.system.domain.TTestWarningException;
-import com.ruoyi.system.mapper.TTestMapper;
-import com.ruoyi.system.service.ITTestService;
-import com.ruoyi.system.service.ITestLiveService.LiveState;
+import com.battery.device.api.TestDataObservationAdapter;
+import com.battery.business.web.TestLiveStream;
+import com.battery.business.service.ITestLiveService;
+import com.battery.device.api.discovery.DeviceDiscoveryCandidateStore;
+import com.battery.device.api.model.ChannelIdentity;
+import com.battery.device.api.model.DeviceWorkStatus;
+import com.battery.device.api.model.RealtimeSnapshot;
+import com.battery.business.domain.TTest;
+import com.battery.business.domain.TTestBattery;
+import com.battery.business.domain.TTestChannelBinding;
+import com.battery.business.domain.TTestWarningException;
+import com.battery.business.mapper.TTestMapper;
+import com.battery.business.service.ITTestService;
+import com.battery.business.service.ITestLiveService.LiveState;
 
 /** 实时流客户端断连时应结束连接而不触发全局异常处理。 */
 class TTestLiveServiceImplTest
@@ -152,7 +154,7 @@
             DeviceWorkStatus workStatus, TTestMapper mapper)
     {
         DeviceDiscoveryCandidateStore candidates = mock(DeviceDiscoveryCandidateStore.class);
-        BtsDevelopmentSimulator simulator = mock(BtsDevelopmentSimulator.class);
+        TestDataObservationAdapter simulator = mock(TestDataObservationAdapter.class);
         ITTestService tests = mock(ITTestService.class);
         when(tests.selectTestById(10L)).thenReturn(test);
         ChannelIdentity identity = new ChannelIdentity("dev-sim", 1, 1, 0, 1);
@@ -167,9 +169,9 @@
                 List.of(channel), now, now.plusSeconds(60));
         when(candidates.snapshot(any(Instant.class))).thenReturn(
                 new DeviceDiscoveryCandidateStore.CandidateSnapshot(List.of(cabinet), List.of()));
-        var plan = new BtsDevelopmentSimulator.BtsTestSnapshot(1, 1, 1, List.of());
-        when(simulator.btsTest(anyInt(), anyInt())).thenReturn(plan);
-        when(simulator.btsTest(anyInt(), anyInt(), anyInt())).thenReturn(plan);
+        var plan = new TestDataObservationAdapter.TestPlan(1, 1, 1, List.of());
+        when(simulator.testPlan(any(ChannelIdentity.class))).thenReturn(plan);
+
         return new CurrentLiveService(tests, candidates, simulator, mapper);
     }
 
@@ -177,7 +179,7 @@
     void initialWriteFailureShouldCompleteStreamWithoutErrorDispatch()
     {
         RecordingEmitter emitter = new RecordingEmitter(0);
-        TTestLiveServiceImpl service = new TestableLiveService(emitter);
+        TestLiveStream service = new TestableLiveService(emitter);
 
         try
         {
@@ -185,7 +187,7 @@
         }
         finally
         {
-            service.shutdown();
+            service.close();
         }
 
         assertTrue(emitter.completed);
@@ -196,7 +198,7 @@
     void scheduledWriteFailureShouldCompleteStreamWithoutErrorDispatch()
     {
         RecordingEmitter emitter = new RecordingEmitter(6);
-        TTestLiveServiceImpl service = new TestableLiveService(emitter);
+        TestLiveStream service = new TestableLiveService(emitter);
 
         try
         {
@@ -205,20 +207,19 @@
         }
         finally
         {
-            service.shutdown();
+            service.close();
         }
 
         assertFalse(emitter.completedWithError);
     }
 
-    private static final class TestableLiveService extends TTestLiveServiceImpl
+    private static final class TestableLiveService extends TestLiveStream
     {
         private final RecordingEmitter emitter;
 
         private TestableLiveService(RecordingEmitter emitter)
         {
-            super(mock(ITTestService.class), mock(DeviceDiscoveryCandidateStore.class),
-                    mock(BtsDevelopmentSimulator.class));
+            super(testLive());
             this.emitter = emitter;
         }
 
@@ -228,17 +229,17 @@
             return emitter;
         }
 
-        @Override
-        public LiveState current(Long testId)
-        {
-            return new LiveState(testId, "RUNNING", "RECEIVING", Instant.now(), List.of(), List.of());
+        private static ITestLiveService testLive() {
+            ITestLiveService live = mock(ITestLiveService.class);
+            when(live.current(any())).thenReturn(new LiveState(4L, "RUNNING", "RECEIVING", Instant.now(), List.of(), List.of()));
+            return live;
         }
     }
 
     private static final class CurrentLiveService extends TTestLiveServiceImpl
     {
         private CurrentLiveService(ITTestService tests, DeviceDiscoveryCandidateStore candidates,
-                BtsDevelopmentSimulator simulator, TTestMapper mapper)
+                TestDataObservationAdapter simulator, TTestMapper mapper)
         {
             super(tests, candidates, simulator, mapper);
         }

--
Gitblit v1.7.1