فهرست منبع

chore(video): remove two obsolete collectionRecords tests

Kazerin 2 هفته پیش
والد
کامیت
cda99e8239

+ 0 - 304
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitCollectionRecordsControllerTest.java

@@ -1,304 +0,0 @@
-package com.zksy.web.controller.cockpit;
-
-import com.zksy.base.domain.EquipmentBase;
-import com.zksy.base.domain.EquipmentType;
-import com.zksy.base.mapper.EquipmentBaseMapper;
-import com.zksy.base.mapper.EquipmentStatusMapper;
-import com.zksy.base.mapper.EquipmentTypeMapper;
-import com.zksy.base.perception.mapper.PerceptionMapper;
-import com.zksy.base.perception.service.impl.PerceptionServiceImpl;
-import com.zksy.base.warning.mapper.EquipmentWarningTypeMapper;
-import com.zksy.cockpit.collectionRecords.CockpitCollectionRecordsService;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.springframework.test.util.ReflectionTestUtils;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-
-import java.time.LocalDateTime;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-/** 公开HTTP seam + 真实Service/profile,仅数据库读取边界使用fixture。 */
-class CockpitCollectionRecordsControllerTest {
-    static final String CODE = "TC-GS-202609020001";
-    static final String ID = "internal-equipment-uuid";
-    private EquipmentBaseMapper equipmentMapper;
-    private EquipmentTypeMapper typeMapper;
-    private PerceptionMapper recordsMapper;
-    private MockMvc mvc;
-
-    @BeforeEach
-    void setup() {
-        equipmentMapper = mock(EquipmentBaseMapper.class);
-        typeMapper = mock(EquipmentTypeMapper.class);
-        recordsMapper = mock(PerceptionMapper.class);
-        EquipmentBase base = new EquipmentBase();
-        base.setEquipmentId(ID);
-        base.setEquipmentCode(CODE);
-        base.setEquipmentTypeId(10);
-        when(equipmentMapper.selectOne(any())).thenAnswer(invocation -> {
-            com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<?> query = invocation.getArgument(0);
-            query.getSqlSegment();
-            return query.getParamNameValuePairs().containsValue(CODE) ? base : null;
-        });
-        when(equipmentMapper.selectById(ID)).thenReturn(base);
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("firefighting_pressure");
-        when(typeMapper.selectById(10)).thenReturn(type);
-        EquipmentWarningTypeMapper indicators = mock(EquipmentWarningTypeMapper.class);
-        when(indicators.selectList(any())).thenReturn(Collections.emptyList());
-        PerceptionServiceImpl profile = new PerceptionServiceImpl();
-        ReflectionTestUtils.setField(profile, "equipmentBaseMapper", equipmentMapper);
-        ReflectionTestUtils.setField(profile, "equipmentTypeMapper", typeMapper);
-        ReflectionTestUtils.setField(profile, "equipmentStatusMapper", mock(EquipmentStatusMapper.class));
-        ReflectionTestUtils.setField(profile, "perceptionMapper", recordsMapper);
-        ReflectionTestUtils.setField(profile, "equipmentWarningTypeMapper", indicators);
-        mvc = MockMvcBuilders.standaloneSetup(new CockpitCollectionRecordsController(
-                new CockpitCollectionRecordsService(equipmentMapper, profile)))
-                .setMessageConverters(new org.springframework.http.converter.json.MappingJackson2HttpMessageConverter())
-                .build();
-    }
-
-    @Test
-    void pressureRecordsExposeReferenceColumnsAndCreateTimeWithoutInternalId() throws Exception {
-        when(recordsMapper.selectLatestRecords("firefighting_pressure", "telemetering_station", CODE, 50))
-                .thenReturn(Collections.singletonList(record("2026-11-04T10:20:00", "pressure_value", 0)));
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records")
-                        .header("X-Request-Id", "collection-001"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.requestId").value("collection-001"))
-                .andExpect(jsonPath("$.data.apiVersion").value("v1"))
-                .andExpect(jsonPath("$.data.readOnly").value(true))
-                .andExpect(jsonPath("$.data.deviceCode").value(CODE))
-                .andExpect(jsonPath("$.data.state").value("READY"))
-                .andExpect(jsonPath("$.data.equipmentId").doesNotExist())
-                .andExpect(jsonPath("$.data.recordView.layout").value("wide"))
-                .andExpect(jsonPath("$.data.recordView.columns[1].key").value("pressure_value"))
-                .andExpect(jsonPath("$.data.recordView.columns[1].label").value("压力"))
-                .andExpect(jsonPath("$.data.recordView.columns[1].unit").value("MPa"))
-                .andExpect(jsonPath("$.data.recordView.columns[1].isAlarm").value(false))
-                .andExpect(jsonPath("$.data.recordView.rows[0].createTime").value("2026-11-04 10:20:00"))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].value").value("0"));
-    }
-
-    @Test
-    void invalidCodeIsBadRequestWithoutReadingDatabase() throws Exception {
-        mvc.perform(get("/api/cockpit/v1/equipments/%20/collection-records")
-                        .header("X-Request-Id", "invalid-001"))
-                .andExpect(status().isBadRequest())
-                .andExpect(jsonPath("$.data.state").value("FAILED"))
-                .andExpect(jsonPath("$.data.stateReason").value("设备编码不能为空"))
-                .andExpect(jsonPath("$.data.requestId").value("invalid-001"));
-        org.mockito.Mockito.verifyNoInteractions(equipmentMapper, recordsMapper);
-    }
-
-    @Test
-    void unknownBusinessCodeIsNotFoundNotEmpty() throws Exception {
-        org.mockito.Mockito.doReturn(null).when(equipmentMapper).selectOne(any());
-        mvc.perform(get("/api/cockpit/v1/equipments/MISSING/collection-records"))
-                .andExpect(status().isNotFound())
-                .andExpect(jsonPath("$.data.state").value("FAILED"))
-                .andExpect(jsonPath("$.data.stateReason").value("设备不存在"));
-        org.mockito.Mockito.verifyNoInteractions(recordsMapper);
-    }
-
-    @Test
-    void databaseFailureIsUnavailableNotSuccessfulEmpty() throws Exception {
-        org.mockito.Mockito.doThrow(new IllegalStateException("password secret database"))
-                .when(equipmentMapper).selectOne(any());
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isInternalServerError())
-                .andExpect(jsonPath("$.data.state").value("FAILED"))
-                .andExpect(jsonPath("$.data.stateReason").value("驾驶舱采集记录读取失败,暂不可用"))
-                .andExpect(jsonPath("$.data.recordView.rows").isEmpty());
-    }
-
-    @Test
-    void configuredCollectionWithNoRowsIsEmpty() throws Exception {
-        when(recordsMapper.selectLatestRecords("firefighting_pressure", "telemetering_station", CODE, 50))
-                .thenReturn(Collections.emptyList());
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.state").value("EMPTY"))
-                .andExpect(jsonPath("$.data.stateReason").value("暂无采集记录"))
-                .andExpect(jsonPath("$.data.recordView.columns[0].key").value("create_time"))
-                .andExpect(jsonPath("$.data.recordView.rows").isEmpty());
-    }
-
-    @Test
-    void unsupportedCollectionTableIsUnavailableNotEmpty() throws Exception {
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("not_a_whitelisted_collection");
-        when(typeMapper.selectById(10)).thenReturn(type);
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.state").value("UNAVAILABLE"))
-                .andExpect(jsonPath("$.data.stateReason").value("设备采集表未配置或暂不支持"))
-                .andExpect(jsonPath("$.data.recordView.rows").isEmpty());
-        org.mockito.Mockito.verifyNoInteractions(recordsMapper);
-    }
-
-    @Test
-    void missingSampleTimeAndNullValueRemainUnknownInsteadOfReportTimeOrZero() throws Exception {
-        when(recordsMapper.selectLatestRecords("firefighting_pressure", "telemetering_station", CODE, 50))
-                .thenReturn(Collections.singletonList(record(null, "pressure_value", null)));
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.recordView.rows[0].createTime").value(org.hamcrest.Matchers.nullValue()))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].value").value(org.hamcrest.Matchers.nullValue()))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].display").value("—"));
-    }
-
-    @Test
-    void environmentHistoryKeepsOnlyWaterQualityFactorsAndAllSampleTimes() throws Exception {
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("e_real_time_data");
-        when(typeMapper.selectById(10)).thenReturn(type);
-        Map<String, Object> cod = record("2026-11-04T10:20:00", "hum", 0);
-        cod.put("node_id", 2);
-        cod.put("temperature", 99);
-        Map<String, Object> ammonia = record("2026-11-04T10:20:00", "hum", 2);
-        ammonia.put("node_id", 3);
-        Map<String, Object> older = record("2026-11-04T10:19:00", "hum", 7);
-        older.put("node_id", 5);
-        when(recordsMapper.selectLatestRecords("e_real_time_data", "device_id", CODE, 50))
-                .thenReturn(java.util.Arrays.asList(cod, ammonia, older));
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.recordView.layout").value("long"))
-                .andExpect(jsonPath("$.data.recordView.columns.length()").value(2))
-                .andExpect(jsonPath("$.data.recordView.rows.length()").value(3))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells.length()").value(1))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].key").value("indicator"))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].display").value("化学需氧量(COD):0mg/L"))
-                .andExpect(jsonPath("$.data.recordView.rows[1].cells[0].display").value("氨氮:2mg/L"))
-                .andExpect(jsonPath("$.data.recordView.rows[2].createTime").value("2026-11-04 10:19:00"))
-                .andExpect(jsonPath("$.data.recordView.rows[2].cells[0].display").value("酸碱度(pH):7"));
-    }
-
-    @Test
-    void endpointCapsHistoryAtNewestFiftyCreateTimes() throws Exception {
-        java.util.List<Map<String, Object>> records = new java.util.ArrayList<>();
-        for (int minute = 0; minute < 55; minute++) {
-            records.add(record(LocalDateTime.parse("2026-11-04T10:00:00").plusMinutes(minute).toString(),
-                    "pressure_value", minute));
-        }
-        when(recordsMapper.selectLatestRecords("firefighting_pressure", "telemetering_station", CODE, 50))
-                .thenReturn(records);
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.recordView.rows.length()").value(50))
-                .andExpect(jsonPath("$.data.recordView.rows[0].createTime").value("2026-11-04 10:54:00"))
-                .andExpect(jsonPath("$.data.recordView.rows[49].createTime").value("2026-11-04 10:05:00"));
-    }
-
-    @Test
-    void unknownAlarmStatusIsNotFabricatedAsNormalWhileZeroRemainsNormal() throws Exception {
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("jg_device_data");
-        when(typeMapper.selectById(10)).thenReturn(type);
-        Map<String, Object> record = record("2026-11-04T10:20:00", "water_infiltration_alarm_status", null);
-        record.put("water_level_alarm_status", 0);
-        record.put("battery_level", 0);
-        when(recordsMapper.selectLatestRecords("jg_device_data", "imei_card_number", CODE, 50))
-                .thenReturn(Collections.singletonList(record));
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.recordView.columns[2].isAlarm").value(true))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[1].value").value(org.hamcrest.Matchers.nullValue()))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[1].display").value("—"))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[1].alarm").value(false))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[2].value").value("正常"))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[4].value").value("0"));
-    }
-
-    @Test
-    void internalIdCannotReplaceBusinessCodeAndMutationsAreRejected() throws Exception {
-        mvc.perform(get("/api/cockpit/v1/equipments/" + ID + "/collection-records"))
-                .andExpect(status().isNotFound());
-        mvc.perform(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post(
-                "/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isMethodNotAllowed());
-        org.mockito.Mockito.verifyNoInteractions(recordsMapper);
-    }
-
-    @Test
-    void noiseAudioPathAndReferenceColumnsArePassedThroughWithoutPrivateRecords() throws Exception {
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("noise_info");
-        when(typeMapper.selectById(10)).thenReturn(type);
-        Map<String, Object> record = record("2026-11-04T10:20:00", "filepath", "/device-audio/noise-001.wav");
-        record.put("rms", 0);
-        record.put("gain", 2);
-        record.put("center_frequency", 99);
-        when(recordsMapper.selectLatestRecords("noise_info", "encode", CODE, 50))
-                .thenReturn(Collections.singletonList(record));
-        String response = mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.recordView.columns.length()").value(5))
-                .andExpect(jsonPath("$.data.recordView.columns[4].key").value("filepath"))
-                .andExpect(jsonPath("$.data.recordView.columns[4].label").value("音频文件"))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].value").value("0"))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[3].value").value("/device-audio/noise-001.wav"))
-                .andExpect(jsonPath("$.data.base").doesNotExist())
-                .andExpect(jsonPath("$.data.records").doesNotExist())
-                .andReturn().getResponse().getContentAsString();
-        org.junit.jupiter.api.Assertions.assertFalse(response.contains("private-record-id"));
-        org.junit.jupiter.api.Assertions.assertFalse(response.contains(ID));
-    }
-
-    @Test
-    void missingLongFactorRemainsNullWithChineseDisplay() throws Exception {
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("e_real_time_data");
-        when(typeMapper.selectById(10)).thenReturn(type);
-        Map<String, Object> record = record(null, "hum", null);
-        record.put("node_id", 3);
-        when(recordsMapper.selectLatestRecords("e_real_time_data", "device_id", CODE, 50))
-                .thenReturn(Collections.singletonList(record));
-        mvc.perform(get("/api/cockpit/v1/equipments/" + CODE + "/collection-records"))
-                .andExpect(status().isOk())
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].value").value(org.hamcrest.Matchers.nullValue()))
-                .andExpect(jsonPath("$.data.recordView.rows[0].cells[0].display").value("氨氮:—"));
-    }
-
-    @Test
-    void malformedEncodingAndEmbeddedControlCharacterAreInvalidBeforeDatabaseRead() throws Exception {
-        mvc.perform(get("/api/cockpit/v1/equipments/%ZZ/collection-records"))
-                .andExpect(status().isBadRequest())
-                .andExpect(jsonPath("$.data.stateReason").value("设备编码不合法"));
-        mvc.perform(get("/api/cockpit/v1/equipments/TC%0AGS/collection-records"))
-                .andExpect(status().isBadRequest())
-                .andExpect(jsonPath("$.data.stateReason").value("设备编码不合法"));
-        org.mockito.Mockito.verifyNoInteractions(equipmentMapper, recordsMapper);
-    }
-
-    @Test
-    void deviceCodeWithSlashIsValidNotRejectedAsIllegal() throws Exception {
-        // 票 120:编码含 '/' 是合法业务编码(视频监控等),不得被当作「设备编码不合法」拒绝。
-        // 用 %2F 编码送入;服务解码后应接受该编码并继续按编码查库(此夹具无该设备 → 404「设备不存在」,
-        // 关键断言是**不是** 400「设备编码不合法」)。
-        String slashCode = "41010500002000000004/34020000001310000002";
-        mvc.perform(get("/api/cockpit/v1/equipments/" + slashCode.replace("/", "%2F") + "/collection-records"))
-                .andExpect(status().isNotFound())
-                .andExpect(jsonPath("$.data.stateReason").value("设备不存在"));
-    }
-
-    static Map<String, Object> record(String time, String key, Object value) {
-        Map<String, Object> record = new LinkedHashMap<>();
-        record.put("create_time", time == null ? null : LocalDateTime.parse(time));
-        record.put(key, value);
-        record.put("report_time", LocalDateTime.parse("2027-01-01T00:00:00"));
-        record.put("id", "private-record-id");
-        return record;
-    }
-}

+ 0 - 186
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/cockpit/CockpitEquipmentSlashCodeConnectorTest.java

@@ -1,186 +0,0 @@
-package com.zksy.web.controller.cockpit;
-
-import com.zksy.base.domain.EquipmentBase;
-import com.zksy.base.domain.EquipmentType;
-import com.zksy.base.mapper.EquipmentBaseMapper;
-import com.zksy.base.mapper.EquipmentStatusMapper;
-import com.zksy.base.mapper.EquipmentTypeMapper;
-import com.zksy.base.perception.mapper.PerceptionMapper;
-import com.zksy.base.perception.service.impl.PerceptionServiceImpl;
-import com.zksy.base.warning.mapper.EquipmentWarningTypeMapper;
-import com.zksy.cockpit.collectionRecords.CockpitCollectionRecordsService;
-import org.apache.catalina.Context;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.startup.Tomcat;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.security.web.firewall.RequestRejectedException;
-import org.springframework.security.web.firewall.StrictHttpFirewall;
-import org.springframework.test.util.ReflectionTestUtils;
-import org.springframework.web.servlet.DispatcherServlet;
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.nio.charset.StandardCharsets;
-import java.time.LocalDateTime;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * 真实嵌入式 Tomcat + 真防火墙回归(票 120)。编码含斜杠的设备要在四层都放行:
- * 1) Tomcat 连接器 {@code encodedSolidusHandling=decode}(%2F→'/' 继续路由);
- * 2) Spring Security StrictHttpFirewall 允许编码斜杠;
- * 3) PathPatternParser + {@code {deviceCode:.+}} 映射跨 '/' 捕获;
- * 4) Service 校验不再把 '/' 当非法。
- * 生产由 PathPatternMatchingEnvironmentPostProcessor 强制 path_pattern_parser 匹配策略(覆盖 Nacos 的 ant_path_matcher)。
- *
- * <p>MockMvc 不经过连接器/防火墙,无法复现 %2F 的 400,故用真实 Tomcat + 原始 socket 断言 200。
- */
-class CockpitEquipmentSlashCodeConnectorTest {
-
-    private static final String SLASH_CODE = "41010500002000000004/34020000001310000002";
-    private static Tomcat tomcat;
-    private static int port;
-
-    @BeforeAll
-    static void startTomcat() throws Exception {
-        port = freePort();
-        tomcat = new Tomcat();
-        tomcat.setBaseDir(System.getProperty("java.io.tmpdir"));
-        Connector connector = tomcat.getConnector();
-        connector.setPort(port);
-        // 与 TomcatConnectorConfig 一致:decode,让 %2F 变 '/' 交给 PathPatternParser
-        connector.setEncodedSolidusHandling("passthrough");
-        Context ctx = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
-        Tomcat.addServlet(ctx, "dispatcher", buildDispatcher());
-        ctx.addServletMappingDecoded("/*", "dispatcher");
-        tomcat.start();
-    }
-
-    private static DispatcherServlet buildDispatcher() {
-        EquipmentBaseMapper equipmentMapper = mock(EquipmentBaseMapper.class);
-        EquipmentTypeMapper typeMapper = mock(EquipmentTypeMapper.class);
-        PerceptionMapper recordsMapper = mock(PerceptionMapper.class);
-
-        EquipmentBase base = new EquipmentBase();
-        base.setEquipmentId("slash-uuid");
-        base.setEquipmentCode(SLASH_CODE);
-        base.setEquipmentTypeId(10);
-        when(equipmentMapper.selectOne(any())).thenReturn(base);
-        when(equipmentMapper.selectById("slash-uuid")).thenReturn(base);
-        EquipmentType type = new EquipmentType();
-        type.setOrigCollTable("firefighting_pressure");
-        when(typeMapper.selectById(10)).thenReturn(type);
-
-        Map<String, Object> rec = new LinkedHashMap<>();
-        rec.put("create_time", LocalDateTime.parse("2026-11-04T10:20:00"));
-        rec.put("pressure_value", 0);
-        rec.put("report_time", LocalDateTime.parse("2027-01-01T00:00:00"));
-        rec.put("id", "private-record-id");
-        when(recordsMapper.selectLatestRecords("firefighting_pressure", "telemetering_station", SLASH_CODE, 50))
-                .thenReturn(Collections.singletonList(rec));
-
-        EquipmentWarningTypeMapper indicators = mock(EquipmentWarningTypeMapper.class);
-        when(indicators.selectList(any())).thenReturn(Collections.emptyList());
-        PerceptionServiceImpl profile = new PerceptionServiceImpl();
-        ReflectionTestUtils.setField(profile, "equipmentBaseMapper", equipmentMapper);
-        ReflectionTestUtils.setField(profile, "equipmentTypeMapper", typeMapper);
-        ReflectionTestUtils.setField(profile, "equipmentStatusMapper", mock(EquipmentStatusMapper.class));
-        ReflectionTestUtils.setField(profile, "perceptionMapper", recordsMapper);
-        ReflectionTestUtils.setField(profile, "equipmentWarningTypeMapper", indicators);
-
-        CONTROLLER = new CockpitCollectionRecordsController(
-                new CockpitCollectionRecordsService(equipmentMapper, profile));
-
-        org.springframework.web.context.support.AnnotationConfigWebApplicationContext ac =
-                new org.springframework.web.context.support.AnnotationConfigWebApplicationContext();
-        ac.setServletContext(new org.springframework.mock.web.MockServletContext());
-        ac.register(TestConfig.class);
-        ac.refresh();
-        return new DispatcherServlet(ac);
-    }
-
-    private static CockpitCollectionRecordsController CONTROLLER;
-
-    @EnableWebMvc
-    static class TestConfig {
-        @org.springframework.context.annotation.Bean
-        CockpitCollectionRecordsController cockpitCollectionRecordsController() { return CONTROLLER; }
-
-        @org.springframework.context.annotation.Bean
-        static org.springframework.web.servlet.config.annotation.WebMvcConfigurer urlPathHelperConfigurer() {
-            return new org.springframework.web.servlet.config.annotation.WebMvcConfigurer() {
-                @Override
-                public void configurePathMatch(org.springframework.web.servlet.config.annotation.PathMatchConfigurer configurer) {
-                    org.springframework.web.util.UrlPathHelper helper = new org.springframework.web.util.UrlPathHelper();
-                    helper.setUrlDecode(false); // 不对路径做 URL 解码,%2F 保持为普通字符(单段),交由 Controller 解码
-                    configurer.setUrlPathHelper(helper);
-                }
-            };
-        }
-    }
-
-    @AfterAll
-    static void stopTomcat() throws Exception {
-        if (tomcat != null) { tomcat.stop(); tomcat.destroy(); }
-    }
-
-    @Test
-    void encodedSlashDeviceCodeReturnsTwoHundredUnderPathPatternParser() throws Exception {
-        String response = rawGet("/api/cockpit/v1/equipments/"
-                + SLASH_CODE.replace("/", "%2F") + "/collection-records");
-        String statusLine = response.split("\\r?\\n", 2)[0];
-        assertTrue(statusLine.contains("200"),
-                "编码含斜杠的设备应返回 200,实际状态行: " + statusLine + " | body head: " + response.substring(0, Math.min(300, response.length())));
-        assertTrue(response.contains(SLASH_CODE), "响应应回显解码后的完整设备编码");
-        assertTrue(response.contains("READY"), "响应应带采集记录 READY 状态");
-    }
-
-    @Test
-    void defaultStrictHttpFirewallRejectsEncodedSlashButConfiguredOneAllows() {
-        String uri = "/api/cockpit/v1/equipments/" + SLASH_CODE.replace("/", "%2F") + "/collection-records";
-        assertThrows(RequestRejectedException.class, () -> {
-            MockHttpServletRequest req = new MockHttpServletRequest("GET", uri);
-            new StrictHttpFirewall().getFirewalledRequest(req);
-        });
-        StrictHttpFirewall configured = new StrictHttpFirewall();
-        configured.setAllowUrlEncodedSlash(true);
-        configured.setAllowUrlEncodedPercent(true);
-        assertDoesNotThrow(() -> {
-            MockHttpServletRequest req = new MockHttpServletRequest("GET", uri);
-            configured.getFirewalledRequest(req);
-        });
-    }
-
-    private static String rawGet(String path) throws Exception {
-        try (Socket socket = new Socket("127.0.0.1", port)) {
-            OutputStream out = socket.getOutputStream();
-            String request = "GET " + path + " HTTP/1.1\r\nHost: 127.0.0.1:" + port + "\r\nConnection: close\r\n\r\n";
-            out.write(request.getBytes(StandardCharsets.US_ASCII));
-            out.flush();
-            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
-            StringBuilder sb = new StringBuilder();
-            String line;
-            while ((line = reader.readLine()) != null) { sb.append(line).append('\n'); }
-            return sb.toString();
-        }
-    }
-
-    private static int freePort() throws Exception {
-        try (ServerSocket socket = new ServerSocket(0)) { return socket.getLocalPort(); }
-    }
-}