yeg
2026-08-29 14ac9c2a2384f1e55b4c01eb7a104033b589d1e0
ruoyi-admin/src/test/java/com/ruoyi/web/controller/device/BtsDevelopmentSimulatorControllerTest.java
@@ -14,6 +14,7 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.server.ResponseStatusException;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.device.bts.BtsDevelopmentSimulator;
import com.ruoyi.device.discovery.DeviceDiscoveryCandidateStore.CabinetCandidate;
@@ -124,6 +125,47 @@
    }
    @Test
    void controllerPowersAllSimulatorDevicesWithoutResettingHistory() throws Exception
    {
        try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0))
        {
            BtsDevelopmentSimulatorController controller = controller(simulator);
            simulator.advanceCollectors(Instant.now());
            long historyCount = controller.state().collectors().get(0).historyRecordCount();
            var poweredOff = controller.setPower(
                    new BtsDevelopmentSimulatorController.SimulatorPowerCommand(false));
            assertTrue(poweredOff.devices().stream().noneMatch(device -> device.online()
                    || device.channels().stream().anyMatch(channel -> channel.online())));
            assertTrue(poweredOff.collectors().stream().noneMatch(collector -> collector.online()));
            assertEquals(historyCount, poweredOff.collectors().get(0).historyRecordCount());
            var poweredOn = controller.setPower(
                    new BtsDevelopmentSimulatorController.SimulatorPowerCommand(true));
            assertTrue(poweredOn.devices().stream().allMatch(device -> device.online()
                    && device.channels().stream().allMatch(channel -> channel.online()
                            && channel.workStatus() == DeviceWorkStatus.STOPPED)));
            assertTrue(poweredOn.collectors().stream().allMatch(collector -> collector.online()));
        }
    }
    @Test
    void simulatorPowerCommandRequiresExplicitState() throws Exception
    {
        try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0))
        {
            BtsDevelopmentSimulatorController controller = controller(simulator);
            ResponseStatusException exception = assertThrows(ResponseStatusException.class,
                    () -> controller.setPower(new BtsDevelopmentSimulatorController.SimulatorPowerCommand(null)));
            assertEquals(400, exception.getStatusCode().value());
            assertTrue(controller.state().collectors().get(0).online());
        }
    }
    @Test
    void virtualIpMustBeUniqueAcrossCabinetsAndCollectors() throws Exception
    {
        try (BtsDevelopmentSimulator simulator = new BtsDevelopmentSimulator(0))