fix(测试跟踪): 修复删除测试计划报告时后台会出现消息通知相关的报错

--bug=1026293 --user=宋天阳 【测试跟踪】github#24456,测试跟踪中的测试报告无法删除
https://www.tapd.cn/55049933/s/1374634
This commit is contained in:
song-tianyang 2023-05-23 17:20:57 +08:00 committed by fit2-zhao
parent 8f7097aed5
commit 31e2d936c1
2 changed files with 31 additions and 5 deletions

View File

@ -8,10 +8,7 @@ import io.metersphere.metadata.vo.FileRequest;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilder;
@ -127,6 +124,23 @@ public class JmxParseUtil {
}
private static boolean nodeIsScript(Node node) {
return StringUtils.containsAnyIgnoreCase(node.getNodeName(), "JSR223", "Processor");
if (StringUtils.containsAnyIgnoreCase(node.getNodeName(), "JSR223", "Processor")) {
//JSR223 或者 Processor判断里面是否有Script阶段 存在即为脚本
NodeList childNodes = node.getChildNodes();
for (int index = 0; index < childNodes.getLength(); index++) {
Node childNode = childNodes.item(index);
NamedNodeMap namedNodeMap = childNode.getAttributes();
if (namedNodeMap != null) {
for (int i = 0; i < namedNodeMap.getLength(); i++) {
Node nameNodeItem = namedNodeMap.item(i);
if (StringUtils.equalsIgnoreCase(nameNodeItem.getNodeValue(), "script")) {
return true;
}
}
}
}
}
return false;
}
}

View File

@ -133,6 +133,17 @@ public class TestPlanReportService {
private final String GROUP = "GROUP";
//这个方法是消息通知时获取报告内容的
public List<TestPlanReport> getReports(List<String> reportIdList) {
List<TestPlanReport> reportList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(reportIdList)) {
TestPlanReportExample example = new TestPlanReportExample();
example.createCriteria().andIdIn(reportIdList);
reportList = testPlanReportMapper.selectByExample(example);
}
return reportList;
}
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
if (StringUtils.isBlank(request.getProjectId())) {
return new ArrayList<>();
@ -683,6 +694,7 @@ public class TestPlanReportService {
runRequest.setTestPlanId(testPlanExecutionQueue.getTestPlanId());
runRequest.setReportId(testPlanExecutionQueue.getReportId());
runRequest.setTestPlanId(testPlan.getId());
runRequest.setTriggerMode(TriggerMode.BATCH.name());
try {
if (SessionUtils.getUser() == null) {
HttpHeaderUtils.runAsUser("admin");