yeg
2026-09-05 f522c9ffa487e3710d691e8b98df8c4f0cfafd43
ruoyi-admin/src/test/java/com/battery/business/service/impl/TTestLiveServiceImplTest.java
@@ -38,6 +38,35 @@
class TTestLiveServiceImplTest
{
    @Test
    void consoleReadsConfiguredSimulatorPlanAtCurrentChannelPosition() throws Exception
    {
        try (var simulator = new com.battery.device.simulator.BtsDevelopmentSimulator(0)) {
            var test = test("RECEIVING");
            var binding = test.getBatteries().get(0).getBinding();
            binding.setDevtype(22); binding.setSubdevid(1);
            simulator.configureChannel(1, 1, new com.battery.device.simulator.BtsSimulatorStateStore.ChannelConfiguration(
                    BigDecimal.ONE, new BigDecimal("4.125"), BigDecimal.ONE, BigDecimal.ONE, 2, 2, 3, 120, 30,
                    List.of(new com.battery.device.simulator.BtsSimulatorStateStore.SimulatorPlanStep("充电", "cc", 60, 4.2),
                            new com.battery.device.simulator.BtsSimulatorStateStore.SimulatorPlanStep("放电", "dc", 90, 3.0))));
            simulator.updateChannel(1, 1, true, DeviceWorkStatus.WORKING);
            var tests = mock(ITTestService.class);
            when(tests.selectTestById(10L)).thenReturn(test);
            var service = new TTestLiveServiceImpl(tests,
                    new com.battery.device.api.discovery.InMemoryDeviceDiscoveryCandidateStore(), simulator);
            var plan = service.current(10L).testPlan();
            assertEquals(2, plan.currentCycleNo());
            assertEquals(2, plan.currentStepNo());
            assertEquals(3, plan.plannedCycleCount());
            assertEquals(List.of(1, 2), plan.rows().stream().map(row -> row.cyclePosition()).toList());
            assertEquals("放电", plan.rows().get(1).stepName());
            assertEquals(90d, plan.rows().get(1).durationSeconds());
            assertEquals("进行中", plan.rows().get(1).executionStatus());
            simulator.updateChannel(1, 1, false, DeviceWorkStatus.WORKING);
            org.junit.jupiter.api.Assertions.assertNull(service.current(10L).testPlan());
        }
    }
    @Test
    void offlineHintIsIndependentOfHistoricalHandlingStatusAndSurvivesRefresh()
    {
        TTest test = test("RECEIVING");