mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 21:19:52 +08:00
fix(测试跟踪): 测试跟踪中只有 功能用例时不展示Local资源池
--bug=1024554 --user=宋天阳 【测试跟踪】报告-查看-计划无接口测试用例-资源池显示为LOCAL https://www.tapd.cn/55049933/s/1352351
This commit is contained in:
parent
16eba5b19c
commit
60d60bb0be
@ -675,7 +675,7 @@ public class TestPlanReportService {
|
|||||||
try {
|
try {
|
||||||
returnDTO = testPlanService.buildTestPlanReportStruct(testPlan, testPlanReport, reportContent);
|
returnDTO = testPlanService.buildTestPlanReportStruct(testPlan, testPlanReport, reportContent);
|
||||||
//查找运行环境
|
//查找运行环境
|
||||||
this.initRunInfomation(returnDTO, testPlanReport);
|
this.initRunInformation(returnDTO, testPlanReport);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error("计算测试计划报告信息出错!", e);
|
LogUtil.error("计算测试计划报告信息出错!", e);
|
||||||
}
|
}
|
||||||
@ -1117,25 +1117,12 @@ public class TestPlanReportService {
|
|||||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||||
example.createCriteria().andIdIn(report.getResourcePools());
|
example.createCriteria().andIdIn(report.getResourcePools());
|
||||||
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
|
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
|
||||||
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
|
report.setResourcePool(getResourcePoolName(resourcePoolList, report.getResourcePools().contains("LOCAL")));
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initRunInfomation(TestPlanReportDataStruct testPlanReportDTO, TestPlanReport testPlanReport) {
|
public void initRunInformation(TestPlanReportDataStruct testPlanReportDTO, TestPlanReport testPlanReport) {
|
||||||
if (StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
|
if (StringUtils.isNotEmpty(testPlanReport.getRunInfo())) {
|
||||||
try {
|
try {
|
||||||
TestPlanReportRunInfoDTO runInfoDTO = JSON.parseObject(testPlanReport.getRunInfo(), TestPlanReportRunInfoDTO.class);
|
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) {
|
public void setEnvironmentToDTO(TestPlanReportDataStruct testPlanReportDTO, TestPlanReportRunInfoDTO runInfoDTO) {
|
||||||
if (ObjectUtils.allNotNull(testPlanReportDTO, runInfoDTO)) {
|
if (ObjectUtils.allNotNull(testPlanReportDTO, runInfoDTO)) {
|
||||||
//查找资源池
|
//查找资源池
|
||||||
@ -1153,19 +1157,9 @@ public class TestPlanReportService {
|
|||||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||||
example.createCriteria().andIdIn(runInfoDTO.getResourcePools());
|
example.createCriteria().andIdIn(runInfoDTO.getResourcePools());
|
||||||
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
|
List<TestResourcePool> resourcePoolList = testResourcePoolMapper.selectByExample(example);
|
||||||
if (CollectionUtils.isNotEmpty(resourcePoolList)) {
|
testPlanReportDTO.setResourcePool(getResourcePoolName(resourcePoolList, runInfoDTO.getResourcePools().contains("LOCAL")));
|
||||||
ArrayList<String> resourcePoolName = new ArrayList<>();
|
} else if (CollectionUtils.isNotEmpty(testPlanReportDTO.getApiAllCases()) || CollectionUtils.isNotEmpty(testPlanReportDTO.getScenarioAllCases())) {
|
||||||
resourcePoolList.forEach(item -> {
|
//存在接口或者场景的用例,资源池默认是local
|
||||||
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("LOCAL");
|
testPlanReportDTO.setResourcePool("LOCAL");
|
||||||
}
|
}
|
||||||
// 环境组/运行环境
|
// 环境组/运行环境
|
||||||
|
@ -136,13 +136,23 @@ public class TestPlanReportUtil {
|
|||||||
return null;
|
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) {
|
if (resourcePools == null) {
|
||||||
resourcePools = new ArrayList<>();
|
resourcePools = new ArrayList<>();
|
||||||
}
|
}
|
||||||
if (originResourcePools == null) {
|
if (reFormatOriginResourcePools == null) {
|
||||||
return resourcePools;
|
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<>();
|
List<String> returnList = new ArrayList<>();
|
||||||
returnList.addAll(resourcePools);
|
returnList.addAll(resourcePools);
|
||||||
returnList.addAll(originResourcePools);
|
returnList.addAll(originResourcePools);
|
||||||
|
Loading…
Reference in New Issue
Block a user