package com.xiaopeng.map.service;
|
|
import com.xiaopeng.map.utils.XngpAreaRTreeFbsUtil;
|
import lombok.extern.slf4j.Slf4j;
|
import org.junit.jupiter.api.Assumptions;
|
import org.junit.jupiter.api.Test;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics;
|
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.test.context.ActiveProfiles;
|
|
import java.util.List;
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
/**
|
* AdcOssHandleService 集成测试,直接调用真实 OSS 服务。
|
* 运行前需配置环境变量:ALIYUN_OSS_ACCESS_KEY_ID、ALIYUN_OSS_ACCESS_KEY_SECRET、VIN_SALT1、VIN_SALT2
|
*/
|
@Slf4j
|
@SpringBootTest(classes = com.xiaopeng.map.MapApplication.class)
|
@ActiveProfiles("local")
|
@AutoConfigureMetrics
|
class AdcOssHandleServiceTest {
|
|
@Autowired(required = false)
|
private AdcOssHandleService adcOssHandleService;
|
|
@Autowired(required = false)
|
private RobotaxiOssService robotaxiOssService;
|
|
@Test
|
void uploadOddLayerFile() {
|
if (adcOssHandleService == null || robotaxiOssService == null) {
|
log.warn("OSS 未启用,测试跳过。请配置 ALIYUN_OSS_ACCESS_KEY_ID、ALIYUN_OSS_ACCESS_KEY_SECRET、VIN_SALT1、VIN_SALT2");
|
Assumptions.assumeTrue(false, "OSS 未启用,请配置环境变量");
|
}
|
// 构造测试坐标点:成都某区域多边形
|
String gcl = "104.06249_30.58322,104.06244_30.58049,104.06500_30.58100,104.06600_30.58400";
|
List<XngpAreaRTreeFbsUtil.LonLat> points = XngpAreaRTreeFbsUtil.parseGcl(gcl);
|
assertNotNull(points);
|
assertTrue(points.size() >= 3, "多边形至少需要 3 个点");
|
|
int areaId = 1;
|
String vin = "21312323333333312"; // 替换为实际测试 VIN
|
String areaCode = "510100";
|
|
String objectKey = adcOssHandleService.uploadOddLayerFile(points, areaId, vin, areaCode);
|
log.info("uploadOddLayerFile objectKey={}", objectKey);
|
|
assertNotNull(objectKey);
|
assertTrue(objectKey.contains("ROBOTAXI_ODD_layer") && objectKey.contains(areaCode),
|
"返回 objectKey 应包含路径前缀和区域编码");
|
|
// 获取下载临时链接(Presigned URL)
|
String downloadUrl = robotaxiOssService.generatePresignedDownloadUrl(objectKey, 3600);
|
log.info("generatePresignedDownloadUrl downloadUrl={}", downloadUrl);
|
assertNotNull(downloadUrl);
|
assertTrue(downloadUrl.contains("Expires") || downloadUrl.contains("Signature"),
|
"下载临时链接应包含签名参数(Expires 或 Signature)");
|
}
|
}
|