From ba78f764042ca15bf3f3be62e7a3fc699df56d67 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期六, 07 三月 2026 20:59:53 +0800
Subject: [PATCH] 提交管理后台新接口,修改XPU报文相关功能,增加测试小程序状态流转接口

---
 xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java |  148 ++++++++++++++++++++++++------------------------
 1 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java b/xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java
index e9f9fe0..72b2034 100644
--- a/xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java
+++ b/xp-robotaxi-automatic-pilot-boot/src/test/java/com/xiaopeng/automaticPilot/util/XPUUtilTest.java
@@ -4,12 +4,7 @@
 import com.xiaopeng.api.feignClient.automaticPilot.VmpOpenServiceClient;
 import com.xiaopeng.api.feignClient.automaticPilot.XPUClient;
 import com.xiaopeng.api.vo.automaticPilot.MqttPublishVo;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.GeoPoint;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.ResponseMessage;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.StatusCode;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudCreateOrder.*;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudOrderOperation.*;
-import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudPushNavigation.RestoreNavigationData;
+import com.xiaopeng.api.vo.automaticPilot.protobuf.*;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -18,7 +13,6 @@
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -70,125 +64,131 @@
     public void testCloudCreateOrder() {
         String orderId = "1881347710714060802";
 
-        RTTask task = new RTTask();
-        task.setTask_id("task-123");
-        task.setOrder_id(orderId);
-        task.setVin("VIN12345678900000");
-        task.setTask_type(TaskType.ROBOTAXI);
-        task.setStatus(TaskStatus.PENDING);
-        
-        NavigationWaypoint point = new NavigationWaypoint();
-        point.setType(WaypointType.START_POINT);
-        point.setAction(WaypointAction.PICK_UP);
-        point.setSequence(1);
-        GeoPoint geoPoint = new GeoPoint();
-        geoPoint.setLatitude(30.0);
-        geoPoint.setLongitude(120.0);
-        geoPoint.setPoi_name("Start Point");
-        point.setPoint(geoPoint);
-        
-        task.setPoints(Collections.singletonList(point));
+        RtTask.Builder taskBuilder = RtTask.newBuilder();
+        taskBuilder.setTaskId("task-123");
+        taskBuilder.setOrderId(orderId);
+        taskBuilder.setTaskType(OrderType.ORDER_TYPE_ROBOTAXI);
+
+        Waypoint.Builder pointBuilder = Waypoint.newBuilder();
+        pointBuilder.setPointType(PointType.START_POINT);
+        pointBuilder.setActionType(ActionType.PICK_UP);
+        pointBuilder.setSequence(1);
+
+        GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder();
+        geoPointBuilder.setLatitude(30.0);
+        geoPointBuilder.setLongitude(120.0);
+        // geoPointBuilder.setPoiName("Start Point"); // GeoPoint might not have poi_name
+        pointBuilder.setPoint(geoPointBuilder.build());
+
+        taskBuilder.addPoints(pointBuilder);
+
+        RtTaskList.Builder taskListBuilder = RtTaskList.newBuilder();
+        taskListBuilder.addTasks(taskBuilder.build());
 
         String vin = "VIN12345678900000";
         Long sequence = 1L;
 
-        xpuUtil.cloudCreateOrder(task, vin, sequence);
+        xpuUtil.cloudCreateOrder(taskListBuilder.build(), vin, sequence);
 
         ArgumentCaptor<MqttPublishVo> captor = ArgumentCaptor.forClass(MqttPublishVo.class);
         Mockito.verify(xpuClient).publish(captor.capture());
         MqttPublishVo capturedVo = captor.getValue();
         
         Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
-        // Note: Current implementation serializes enum as ordinal. CLOUD_CREATE_ORDER is ordinal 2.
-        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\":2"), "Payload should contain cmd CLOUD_CREATE_ORDER (ordinal 2), but was: " + capturedVo.getPayload());
+        // 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());
     }
 
     @Test
     public void testCloudOrderOperation() {
         String orderId = "1881347710714060802";
 
-        OrderOperation operation = new OrderOperation();
-        operation.setOrder_id(orderId);
-        operation.setTask_id("task-123");
-        operation.setOperation_type(OrderOperationType.CLOUD_CREATE_ORDER);
-        operation.setOrder_type(OrderType.ROBOTAXI);
-        
-        Waypoint waypoint = new Waypoint();
-        waypoint.setWaypoint_id("wp-1");
-        waypoint.setPoint_type(PointType.WAY_POINT);
-        waypoint.setAction_type(ActionType.WAIT);
-        waypoint.setSequence(2);
-        
-        GeoPoint geoPoint = new GeoPoint();
-        geoPoint.setLatitude(30.1);
-        geoPoint.setLongitude(120.1);
-        geoPoint.setPoi_name("Way Point");
-        waypoint.setPoint(geoPoint);
-        
-        operation.setWaypoints(Collections.singletonList(waypoint));
-        
-        TargetPoint targetPoint = new TargetPoint();
-        GeoPoint endGeoPoint = new GeoPoint();
-        endGeoPoint.setLatitude(30.2);
-        endGeoPoint.setLongitude(120.2);
-        endGeoPoint.setPoi_name("End Point");
-        targetPoint.setPoint(endGeoPoint);
-        operation.setTarget_point(targetPoint);
+        OrderOperation.Builder operationBuilder = OrderOperation.newBuilder();
+        operationBuilder.setOrderId(orderId);
+        operationBuilder.setTaskId("task-123");
+        operationBuilder.setOperationType(OrderOperationType.CLOUD_CREATE_ORDER);
+        operationBuilder.setOrderType(OrderType.ORDER_TYPE_ROBOTAXI);
+
+        Waypoint.Builder waypointBuilder = Waypoint.newBuilder();
+        waypointBuilder.setWaypointId("wp-1");
+        waypointBuilder.setPointType(PointType.WAY_POINT);
+        waypointBuilder.setActionType(ActionType.PICK_UP); // Use valid enum
+        waypointBuilder.setSequence(2);
+
+        GeoPoint.Builder geoPointBuilder = GeoPoint.newBuilder();
+        geoPointBuilder.setLatitude(30.1);
+        geoPointBuilder.setLongitude(120.1);
+        // geoPointBuilder.setPoiName("Way Point");
+        waypointBuilder.setPoint(geoPointBuilder.build());
+
+        operationBuilder.addWaypoints(waypointBuilder.build());
+
+        // TargetPoint targetPoint = new TargetPoint(); // OrderOperation uses Waypoint for target_point in proto?
+        // Check proto: Waypoint target_point = 6;
+        Waypoint.Builder targetPointBuilder = Waypoint.newBuilder();
+        GeoPoint.Builder endGeoPointBuilder = GeoPoint.newBuilder();
+        endGeoPointBuilder.setLatitude(30.2);
+        endGeoPointBuilder.setLongitude(120.2);
+        targetPointBuilder.setPoint(endGeoPointBuilder.build());
+        operationBuilder.setTargetPoint(targetPointBuilder.build());
 
         String vin = "VIN12345678900000";
         Long sequence = 2L;
 
-        xpuUtil.cloudOrderOperation(operation, vin, sequence);
+        xpuUtil.cloudOrderOperation(operationBuilder.build(), vin, sequence);
 
         ArgumentCaptor<MqttPublishVo> captor = ArgumentCaptor.forClass(MqttPublishVo.class);
         Mockito.verify(xpuClient).publish(captor.capture());
         MqttPublishVo capturedVo = captor.getValue();
         
         Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
-        // Note: CLOUD_ORDER_OPERATION is ordinal 0.
-        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\":0"), "Payload should contain cmd CLOUD_ORDER_OPERATION (ordinal 0), but was: " + capturedVo.getPayload());
+        // 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());
     }
 
     @Test
     public void testResponseMessage() {
-        ResponseMessage responseMessage = new ResponseMessage();
-        responseMessage.setRequest_seq(12345L);
-        responseMessage.setCode(StatusCode.OK);
-        responseMessage.setTimestamp(System.currentTimeMillis());
+        ResponseMessage.Builder responseMessageBuilder = ResponseMessage.newBuilder();
+        responseMessageBuilder.setRequestSeq(12345L);
+        responseMessageBuilder.setCode(StatusCode.OK);
+        responseMessageBuilder.setTimestamp(System.currentTimeMillis());
+
 
         String vin = "VIN12345678900000";
-
-        xpuUtil.responseMessage(responseMessage, vin);
+        xpuUtil.responseMessage(responseMessageBuilder.build(), vin);
 
         ArgumentCaptor<MqttPublishVo> captor = ArgumentCaptor.forClass(MqttPublishVo.class);
         Mockito.verify(xpuClient).publish(captor.capture());
         MqttPublishVo capturedVo = captor.getValue();
         
         Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
-        // Note: CLOUD_TASK_CONTROL is ordinal 1.
-        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\":1"), "Payload should contain cmd CLOUD_TASK_CONTROL (ordinal 1), but was: " + capturedVo.getPayload());
+        // 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
+        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\": 10002"), "Payload should contain cmd CLOUD_TASK_CONTROL (10002), but was: " + capturedVo.getPayload());
+
     }
 
     @Test
     public void testCloudPushNavigation() {
-        RestoreNavigationData navigationData = new RestoreNavigationData();
-        navigationData.setRequest_id("req-123");
-        navigationData.setRoute_id("5939fa259ad6479cbdf8871ceed96b72");
+        RestoreNavigationData.Builder navigationDataBuilder = RestoreNavigationData.newBuilder();
+        navigationDataBuilder.setRequestId("req-123");
+        navigationDataBuilder.setRouteId("5939fa259ad6479cbdf8871ceed96b72");
         String content = "{\"startPoint\":{\"location\":\"116.481028,39.989643\"},\"endPoint\":{\"location\":\"116.465302,40.004717\"},\"routeID\":\"xxxxxxxxxxxxx\",\"strategy\":17,\"type\":1,\"ferry\":0,\"disableEndDispatch\":1,\"viaInfo\":[{},{}],\"routeUserType\":2,\"bizScene\":2,\"plate\":\"京A12345\",\"vehicleType\":1}";
-        navigationData.setContent(content);
-        navigationData.setTimestamp(System.currentTimeMillis());
+        navigationDataBuilder.setContent(content);
+        navigationDataBuilder.setTimestamp(System.currentTimeMillis());
 
         String xpuId = "1234567890ABCDEFGHIJKL";
         Long sequence = 3L;
 
-        xpuUtil.cloudPushNavigation(navigationData, xpuId, sequence);
+        xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence);
 
         ArgumentCaptor<MqttPublishVo> captor = ArgumentCaptor.forClass(MqttPublishVo.class);
         Mockito.verify(xpuClient).publish(captor.capture());
         MqttPublishVo capturedVo = captor.getValue();
         
         Assertions.assertEquals("Robotaxi/Msg/Xpu/ABCDEFGHIJKL00000000", capturedVo.getTopic());
-        // Note: CLOUD_NAVIGATION_RESPONSE is ordinal 5.
-        Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\":5"), "Payload should contain cmd CLOUD_NAVIGATION_RESPONSE (ordinal 5), but was: " + capturedVo.getPayload());
+        // 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());
     }
 }

--
Gitblit v1.7.1