| | |
| | | // 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); |
| | | |
| | | // Mock XPUClient |
| | | MqttPublishDto res = new MqttPublishDto(); |
| | | res.setCode(200); |
| | | xpuClient = Mockito.mock(XPUClient.class); |
| | | Mockito.when(xpuClient.publish(Mockito.any(MqttPublishVo.class))) |
| | | .thenReturn(new MqttPublishDto()); |
| | | .thenReturn(res); |
| | | |
| | | // Inject mocks |
| | | Field vmpField = XPUUtil.class.getDeclaredField("vmpOpenServiceClient"); |
| | |
| | | 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 |
| | |
| | | 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()); |
| | | Assertions.assertTrue(capturedVo.getPayload().contains("\"cmd\": 10005"), "Payload should contain cmd CLOUD_CREATE_ORDER (10003), but was: " + capturedVo.getPayload()); |
| | | } |
| | | |
| | | @Test |
| | |
| | | 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()); |
| | | } |
| | |
| | | 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 |
| | |
| | | navigationDataBuilder.setContent(content); |
| | | navigationDataBuilder.setTimestamp(System.currentTimeMillis()); |
| | | |
| | | String xpuId = "1234567890ABCDEFGHIJKL"; |
| | | String xpuId = "c47b405bee79000f282a36e800000000"; |
| | | Long sequence = 3L; |
| | | |
| | | xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence); |
| | |
| | | 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()); |
| | | } |