From acfb83068486766f63284b479d30f78e3ec17dca Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 02:24:48 +0800
Subject: [PATCH] 完成测试生命周期与接收边界

---
 ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TestDataReceptionServiceImplTest.java |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TestDataReceptionServiceImplTest.java b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TestDataReceptionServiceImplTest.java
index 5ad0e30..5a14a85 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TestDataReceptionServiceImplTest.java
+++ b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TestDataReceptionServiceImplTest.java
@@ -75,12 +75,39 @@
     }
 
     @Test
+    void ordinaryEditsDoNotMoveReceptionBoundary()
+    {
+        TTestMapper mapper = mock(TTestMapper.class);
+        ITTestService tests = mock(ITTestService.class);
+        BtsDevelopmentSimulator simulator = mock(BtsDevelopmentSimulator.class);
+        TTest test = test(Date.from(Instant.parse("2026-09-02T04:00:00Z")));
+        test.setUpdateTime(Date.from(Instant.parse("2026-09-02T04:00:10Z")));
+        when(mapper.selectReceivingTestIds()).thenReturn(List.of(1L));
+        when(mapper.selectTestByIdForUpdate(1L)).thenReturn(test);
+        when(tests.selectTestById(1L)).thenReturn(test);
+        when(simulator.btsRecords(1, 1)).thenReturn(List.of(
+                record(1L, "2026-09-02T04:00:05Z"), record(2L, "2026-09-02T04:00:11Z")));
+        when(mapper.selectBtsSampleContentHash(any(), anyString(), any())).thenReturn(null);
+        when(mapper.insertBtsSample(any(), any(), any(), anyString(), any(), any(Date.class), anyString(),
+                any(Date.class), anyInt(), anyInt(), anyString(), anyString(), isNull(), any(BigDecimal.class),
+                any(BigDecimal.class), any(BigDecimal.class), any(BigDecimal.class), any(byte[].class))).thenReturn(1);
+
+        new TestDataReceptionServiceImpl(mapper, tests, simulator).captureDevelopmentCabinetRecords();
+
+        verify(mapper, times(2)).insertBtsSample(eq(1L), eq(2L), eq(3L), anyString(), any(), any(Date.class),
+                anyString(), any(Date.class), anyInt(), anyInt(), anyString(), anyString(), isNull(),
+                any(BigDecimal.class), any(BigDecimal.class), any(BigDecimal.class), any(BigDecimal.class),
+                any(byte[].class));
+    }
+
+    @Test
     void capturesOnlyMappedCollectorRealtimeMeasurementsAfterReceptionStart()
     {
         TTestMapper mapper = mock(TTestMapper.class);
         ITTestService tests = mock(ITTestService.class);
         BtsDevelopmentSimulator simulator = mock(BtsDevelopmentSimulator.class);
         TTest test = test(Date.from(Instant.parse("2026-09-02T04:00:00Z")));
+        test.setReceptionBoundaryAtUtc(Date.from(Instant.parse("2026-09-02T04:00:01.500Z")));
         test.getBatteries().get(0).setCollectorId(9L);
         TTestCollectorChannel mapping = new TTestCollectorChannel();
         mapping.setMeasurementCode("temperature"); mapping.setChannelCode("S-01");
@@ -94,8 +121,11 @@
         CollectorRealtimeMeasurement ignored = new CollectorRealtimeMeasurement("dev-sim", "collector-9", "S-02",
                 3L, matched.deviceTime(), matched.deviceTimeRaw(), matched.serverReceivedAt(), "temperature",
                 new BigDecimal("25.2"), "℃");
+        CollectorRealtimeMeasurement beforeBoundary = new CollectorRealtimeMeasurement("dev-sim", "collector-9", "S-01",
+                2L, Instant.parse("2026-09-02T04:00:00Z"), "2026-09-02 12:00:00.000",
+                Instant.parse("2026-09-02T04:00:01Z"), "temperature", new BigDecimal("24.9"), "℃");
         when(simulator.collectorRealtime(9)).thenReturn(new CollectorRealtimeSnapshot("collector-9", true, 1000,
-                List.of(matched, ignored)));
+                List.of(matched, ignored, beforeBoundary)));
         when(mapper.selectCollectorSampleContentHash(any(), anyString(), any(), anyString())).thenReturn(null);
         when(mapper.insertCollectorSample(any(), any(), any(), anyString(), anyString(), any(), any(Date.class), anyString(),
                 any(Date.class), anyString(), any(BigDecimal.class), anyString(), any(byte[].class))).thenReturn(1);
@@ -142,6 +172,7 @@
         battery.setBinding(binding);
         TTest test = new TTest();
         test.setTestId(1L);
+        test.setTestStatus("RUNNING");
         test.setReceptionStatus("RECEIVING");
         test.setStartedAtUtc(startedAt);
         test.setBatteries(List.of(battery));
@@ -150,7 +181,8 @@
 
     private static BtsHistoryRecord record(long sequenceId, String deviceTime)
     {
-        return new BtsHistoryRecord(sequenceId, Instant.parse(deviceTime), 1d, 2d, 3d, 4d,
-                1, 1, "恒流充电", "cc");
+        Instant parsed = Instant.parse(deviceTime);
+        return new BtsHistoryRecord(sequenceId, parsed, 1d, 2d, 3d, 4d,
+                1, 1, "恒流充电", "cc", parsed);
     }
 }

--
Gitblit v1.7.1