zhuml4
2026-03-06 e1df35dffc9f10e0691d3b9a9237e71fe1fa8b89
fix:xpu topic
2个文件已修改
28 ■■■■■ 已修改文件
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/util/XPUUtil.java
@@ -200,13 +200,13 @@
        if (!prefix.endsWith("/")) {
            prefix = prefix + "/";
        }
        String value = xpuId;
        if (xpuId.length() > 10) {
            int start = 10;
            int end = Math.min(24, xpuId.length());
            value = xpuId.substring(start, end);
        }
        return prefix + value + "00000000";
//        String value = xpuId;
//        if (xpuId.length() > 10) {
//            int start = 10;
//            int end = Math.min(24, xpuId.length());
//            value = xpuId.substring(start, end);
//        }
        return prefix + xpuId;
    }
}
xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java
@@ -29,7 +29,7 @@
        // Mock VmpOpenServiceClient
        vmpClient = Mockito.mock(VmpOpenServiceClient.class);
        Map<String, String> mapping = new HashMap<>();
        mapping.put(XPUUtil.XPU_ID_TYPE, "1234567890ABCDEFGHIJKL");
        mapping.put(XPUUtil.XPU_ID_TYPE, "c47b405bee79000f282a36e800000000");
        Mockito.when(vmpClient.getVehicleBindInfoByVin(Mockito.anyString(), Mockito.anyList()))
                .thenReturn(mapping);
        
@@ -57,7 +57,7 @@
        Method buildTopic = XPUUtil.class.getDeclaredMethod("buildTopicByVin", String.class);
        buildTopic.setAccessible(true);
        String result = (String) buildTopic.invoke(xpuUtil, "VIN123");
        Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", result);
        Assertions.assertEquals("Robotaxi/Msg/Xpu/c47b405bee79000f282a36e800000000", result);
    }
    @Test
@@ -94,7 +94,7 @@
        Mockito.verify(xpuClient).publish(captor.capture());
        MqttPublishVo capturedVo = captor.getValue();
        
        Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
        Assertions.assertEquals("Robotaxi/Msg/Xpu/c47b405bee79000f282a36e800000000", capturedVo.getTopic());
        // Note: Current implementation serializes enum as ordinal.
        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\": 10003"), "Payload should contain cmd CLOUD_CREATE_ORDER (10003), but was: " + capturedVo.getPayload());
    }
@@ -141,7 +141,7 @@
        Mockito.verify(xpuClient).publish(captor.capture());
        MqttPublishVo capturedVo = captor.getValue();
        
        Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
        Assertions.assertEquals("Robotaxi/Msg/Xpu/c47b405bee79000f282a36e800000000", capturedVo.getTopic());
        // Note: CLOUD_ORDER_OPERATION is 10001
        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\": 10001"), "Payload should contain cmd CLOUD_ORDER_OPERATION (10001), but was: " + capturedVo.getPayload());
    }
@@ -161,7 +161,7 @@
        Mockito.verify(xpuClient).publish(captor.capture());
        MqttPublishVo capturedVo = captor.getValue();
        
        Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
        Assertions.assertEquals("Robotaxi/Msg/Xpu/c47b405bee79000f282a36e800000000", capturedVo.getTopic());
        // Note: CLOUD_TASK_CONTROL (used in responseMessage method? check code)
        // In XPUUtil.java: headerBuilder.setCmd(RTCmdType.CLOUD_TASK_CONTROL.getValue());
        // CLOUD_TASK_CONTROL is 10002
@@ -178,7 +178,7 @@
        navigationDataBuilder.setContent(content);
        navigationDataBuilder.setTimestamp(System.currentTimeMillis());
        String xpuId = "1234567890ABCDEFGHIJKL";
        String xpuId = "c47b405bee79000f282a36e800000000";
        Long sequence = 3L;
        xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence);
@@ -187,7 +187,7 @@
        Mockito.verify(xpuClient).publish(captor.capture());
        MqttPublishVo capturedVo = captor.getValue();
        
        Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
        Assertions.assertEquals("Robotaxi/Msg/Xpu/c47b405bee79000f282a36e800000000", capturedVo.getTopic());
        // Note: CLOUD_NAVIGATION_RESPONSE is 10006
        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\": 10006"), "Payload should contain cmd CLOUD_NAVIGATION_RESPONSE (10006), but was: " + capturedVo.getPayload());
    }