yeg
2026-09-02 96144b97e1761db230c0dc61a837ec55d76210df
ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
@@ -383,7 +383,6 @@
        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
        when(testMapper.collectorOnline(8L)).thenReturn(true);
        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
        assertEquals(1, testService.startReception(10L, 7L, "operator"));
@@ -406,7 +405,6 @@
        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
        when(testMapper.collectorOnline(8L)).thenReturn(true);
        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
        assertEquals(1, testService.startReception(10L, 7L, "operator"));
@@ -430,7 +428,6 @@
        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
        when(testMapper.collectorOnline(8L)).thenReturn(true);
        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
        assertEquals(1, testService.startReception(10L, 7L, "operator"));
@@ -438,22 +435,41 @@
    }
    @Test
    void startReceptionShouldRejectOfflineSourceWithoutWritingAnything()
    void startReceptionShouldAllowOfflineSourcesWithoutBlockingReception()
    {
        TTest current = validTest();
        current.setTestId(10L);
        current.setReceptionStatus("NOT_STARTED");
        current.getBatteries().get(0).getBinding().setBindingId(30L);
        when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current);
        TDetectionChannel channel = new TDetectionChannel();
        channel.setChannelId(100L);
        channel.setOnlineStatus("OFFLINE");
        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
        ServiceException exception = assertThrows(ServiceException.class,
                () -> testService.startReception(10L, 7L, "operator"));
        assertEquals(1, testService.startReception(10L, 7L, "operator"));
    }
        assertEquals("检测柜通道 100 当前离线或不可观测", exception.getMessage());
        verify(testMapper, never()).updateReceptionStarted(any(), any(), anyBoolean(), any());
    @Test
    void startReceptionShouldAllowOfflineCollectorWithoutBlockingReception()
    {
        TTest current = validTest();
        current.setTestId(10L);
        current.setReceptionStatus("NOT_STARTED");
        current.getBatteries().get(0).getBinding().setBindingId(30L);
        when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current);
        TDetectionChannel channel = new TDetectionChannel();
        channel.setChannelId(100L);
        channel.setOnlineStatus("ONLINE");
        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
        assertEquals(1, testService.startReception(10L, 7L, "operator"));
    }
    @Test
@@ -471,7 +487,6 @@
        channel.setLastSeenAtUtc(Instant.parse("2026-08-29T12:00:00Z"));
        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
        when(testMapper.collectorOnline(8L)).thenReturn(true);
        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
        ServiceException exception = assertThrows(ServiceException.class,