fix(测试跟踪): 测试跟踪中只有 功能用例时不展示Local资源池

--bug=1024554 --user=宋天阳 【测试跟踪】报告-查看-计划无接口测试用例-资源池显示为LOCAL
https://www.tapd.cn/55049933/s/1352351
This commit is contained in:
song-tianyang 2023-03-17 17:01:22 +08:00 committed by 建国
parent 16eba5b19c
commit 60d60bb0be
2 changed files with 35 additions and 31 deletions

View File

@ -675,7 +675,7 @@ public class TestPlanReportService {
try {
returnDTO = testPlanService.buildTestPlanReportStruct(testPlan, testPlanReport, reportContent);
//查找运行环境
this.initRunInfomation(returnDTO, testPlanReport);
this.initRunInformation(returnDTO, testPlanReport);
} catch (Exception e) {
LogUtil.error("计算测试计划报告信息出错!", e);
}
@ -1117,25 +1117,12 @@ public class TestPlanReportService {
TestResourcePoolExample example = new TestResourcePoolExample();
example.createCriteria().andIdIn(report.getResourcePools());
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
ArrayList<String> resourcePoolName = new ArrayList<>();
resourcePoolList.forEach(item -> {
if (!resourcePoolName.contains(item.getName())) {
resourcePoolName.add(item.getName());
}
});
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
report.setResourcePool(resourcePoolNames);
} else {
report.setResourcePool("LOCAL");
}
} else {
report.setResourcePool("LOCAL");
report.setResourcePool(getResourcePoolName(resourcePoolList, report.getResourcePools().contains("LOCAL")));
}
return report;
}
public void initRunInfomation(TestPlanReportDataStruct testPlanReportDTO, TestPlanReport testPlanReport) {
public void initRunInformation(TestPlanReportDataStruct testPlanReportDTO, TestPlanReport testPlanReport) {
if (StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
try {
TestPlanReportRunInfoDTO runInfoDTO = JSON.parseObject(testPlanReport.getRunInfo(), TestPlanReportRunInfoDTO.class);
@ -1146,6 +1133,23 @@ public class TestPlanReportService {
}
}
private String getResourcePoolName(List<TestResourcePool> resourcePoolList, boolean hasLocal) {
ArrayList<String> resourcePoolName = new ArrayList<>();
if (hasLocal) {
resourcePoolName.add("LOCAL");
}
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
resourcePoolList.forEach(item -> {
if (!resourcePoolName.contains(item.getName())) {
resourcePoolName.add(item.getName());
}
});
}
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
return resourcePoolNames;
}
public void setEnvironmentToDTO(TestPlanReportDataStruct testPlanReportDTO, TestPlanReportRunInfoDTO runInfoDTO) {
if (ObjectUtils.allNotNull(testPlanReportDTO, runInfoDTO)) {
//查找资源池
@ -1153,19 +1157,9 @@ public class TestPlanReportService {
TestResourcePoolExample example = new TestResourcePoolExample();
example.createCriteria().andIdIn(runInfoDTO.getResourcePools());
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
ArrayList<String> resourcePoolName = new ArrayList<>();
resourcePoolList.forEach(item -> {
if (!resourcePoolName.contains(item.getName())) {
resourcePoolName.add(item.getName());
}
});
String resourcePoolNames = StringUtils.join(resourcePoolName.toArray(), StringUtils.SPACE);
testPlanReportDTO.setResourcePool(resourcePoolNames);
} else {
testPlanReportDTO.setResourcePool("LOCAL");
}
} else {
testPlanReportDTO.setResourcePool(getResourcePoolName(resourcePoolList, runInfoDTO.getResourcePools().contains("LOCAL")));
} else if (CollectionUtils.isNotEmpty(testPlanReportDTO.getApiAllCases()) || CollectionUtils.isNotEmpty(testPlanReportDTO.getScenarioAllCases())) {
//存在接口或者场景的用例资源池默认是local
testPlanReportDTO.setResourcePool("LOCAL");
}
// 环境组/运行环境

View File

@ -136,13 +136,23 @@ public class TestPlanReportUtil {
return null;
}
public static List<String> mergeResourcePools(List<String> resourcePools, List<String> originResourcePools) {
public static List<String> mergeResourcePools(List<String> resourcePools, List<String> reFormatOriginResourcePools) {
if (resourcePools == null) {
resourcePools = new ArrayList<>();
}
if (originResourcePools == null) {
if (reFormatOriginResourcePools == null) {
return resourcePools;
}
//检查originResourcePools是否含有null null代表local
List<String> originResourcePools = new ArrayList<>();
for (String resourcePool : reFormatOriginResourcePools) {
if (StringUtils.isEmpty(resourcePool)) {
resourcePool = "LOCAL";
}
if (!originResourcePools.contains(resourcePool)) {
originResourcePools.add(resourcePool);
}
}
List<String> returnList = new ArrayList<>();
returnList.addAll(resourcePools);
returnList.addAll(originResourcePools);