fix(测试跟踪): 启用自定义 ID 时脑图可重复导入相同 ID 的 bug 修复

--bug=1008968 --user=周骏弘 【功能用例】项目启用测试用例自定义id时,采用脑图导入可重复导入,id重复了。 https://www.tapd.cn/55049933/s/1097728
This commit is contained in:
junhong 2022-01-24 20:26:27 +08:00 committed by zhangdahai112
parent 25f1ac954e
commit bac7bbf85a
1 changed files with 15 additions and 0 deletions

View File

@ -254,6 +254,19 @@ public class XmindCaseParser {
} }
} }
// 判断新增
if (StringUtils.equals(importType, FunctionCaseImportEnum.Create.name())) {
String checkResult;
// 针对自定义 ID 的情况做重复判断
if (isUseCustomId) {
checkResult = testCaseService.checkCustomIdExist(data.getCustomNum(), projectId);
if (null != checkResult) { //该ID在当前项目中存在
process.add(Translator.get("custom_num_is_exist"), nodePath + "/" + compartData.getName());
return false;
}
}
}
if (validatePass) { if (validatePass) {
this.continueValidatedCase.add(data); this.continueValidatedCase.add(data);
} }
@ -267,6 +280,7 @@ public class XmindCaseParser {
for (Attached item : attacheds) { for (Attached item : attacheds) {
if (isAvailable(item.getTitle(), TC_REGEX)) { if (isAvailable(item.getTitle(), TC_REGEX)) {
item.setParent(parent); item.setParent(parent);
// 格式化一个用例
this.formatTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); this.formatTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null);
} else { } else {
String nodePath = parent.getPath().trim() + "/" + item.getTitle().trim(); String nodePath = parent.getPath().trim() + "/" + item.getTitle().trim();
@ -430,6 +444,7 @@ public class XmindCaseParser {
String nodePath = item.getTitle(); String nodePath = item.getTitle();
item.setPath(nodePath); item.setPath(nodePath);
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) { if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
// 递归处理案例数据
recursion(item, 1, item.getChildren().getAttached()); recursion(item, 1, item.getChildren().getAttached());
} else { } else {
if (!nodePath.startsWith("/")) { if (!nodePath.startsWith("/")) {