fix(测试跟踪):修复测试用例导入思维导图内容包含关键字问题

This commit is contained in:
fit2-zhao 2021-06-10 17:58:28 +08:00 committed by fit2-zhao
parent 3db84e2e28
commit 09726552cf
1 changed files with 20 additions and 20 deletions

View File

@ -68,7 +68,7 @@ public class XmindCaseParser {
private String importType; private String importType;
public XmindCaseParser(TestCaseService testCaseService, String userId, String projectId, Set<String> testCaseNames,boolean isUseCustomId,String importType) { public XmindCaseParser(TestCaseService testCaseService, String userId, String projectId, Set<String> testCaseNames, boolean isUseCustomId, String importType) {
this.testCaseService = testCaseService; this.testCaseService = testCaseService;
this.maintainer = userId; this.maintainer = userId;
this.projectId = projectId; this.projectId = projectId;
@ -84,11 +84,11 @@ public class XmindCaseParser {
this.importType = importType; this.importType = importType;
} }
private static final String TC_REGEX = "(?:tc:|tc|tc)"; private static final String TC_REGEX = "(?:tc:|tc)";
private static final String PC_REGEX = "(?:pc:|pc|pc)"; private static final String PC_REGEX = "(?:pc:|pc)";
private static final String RC_REGEX = "(?:rc:|rc|rc)"; private static final String RC_REGEX = "(?:rc:|rc)";
private static final String ID_REGEX = "(?:id:|id|id)"; private static final String ID_REGEX = "(?:id:|id)";
private static final String TAG_REGEX = "(?:tag:|tag|tag)"; private static final String TAG_REGEX = "(?:tag:|tag)";
public void clear() { public void clear() {
compartDatas.clear(); compartDatas.clear();
@ -99,18 +99,18 @@ public class XmindCaseParser {
} }
public List<TestCaseWithBLOBs> getTestCase() { public List<TestCaseWithBLOBs> getTestCase() {
if(StringUtils.equals(this.importType,FunctionCaseImportEnum.Create.name())){ if (StringUtils.equals(this.importType, FunctionCaseImportEnum.Create.name())) {
return this.testCases; return this.testCases;
}else { } else {
return new ArrayList<>(); return new ArrayList<>();
} }
} }
public List<TestCaseWithBLOBs> getUpdateTestCase() { public List<TestCaseWithBLOBs> getUpdateTestCase() {
if(StringUtils.equals(this.importType,FunctionCaseImportEnum.Update.name())){ if (StringUtils.equals(this.importType, FunctionCaseImportEnum.Update.name())) {
return this.updateTestCases; return this.updateTestCases;
}else { } else {
return new ArrayList<>(); return new ArrayList<>();
} }
} }
@ -233,13 +233,13 @@ public class XmindCaseParser {
//自定义ID判断 //自定义ID判断
if(StringUtils.isEmpty(data.getCustomNum())){ if (StringUtils.isEmpty(data.getCustomNum())) {
if(StringUtils.equals(this.importType, FunctionCaseImportEnum.Update.name())){ if (StringUtils.equals(this.importType, FunctionCaseImportEnum.Update.name())) {
validatePass = false; validatePass = false;
process.add(Translator.get("id_required"), nodePath + "/" + compartData.getName()); process.add(Translator.get("id_required"), nodePath + "/" + compartData.getName());
return false; return false;
}else{ } else {
if(isUseCustomId){ if (isUseCustomId) {
validatePass = false; validatePass = false;
process.add(Translator.get("custom_num_is_not_exist"), nodePath + "/" + compartData.getName()); process.add(Translator.get("custom_num_is_not_exist"), nodePath + "/" + compartData.getName());
return false; return false;
@ -248,7 +248,7 @@ public class XmindCaseParser {
} }
//判断更新 //判断更新
if(StringUtils.equals(this.importType,FunctionCaseImportEnum.Update.name())) { if (StringUtils.equals(this.importType, FunctionCaseImportEnum.Update.name())) {
String checkResult = null; String checkResult = null;
if (isUseCustomId) { if (isUseCustomId) {
checkResult = testCaseService.checkCustomIdExist(data.getCustomNum().toString(), projectId); checkResult = testCaseService.checkCustomIdExist(data.getCustomNum().toString(), projectId);
@ -257,13 +257,13 @@ public class XmindCaseParser {
} }
if (null != checkResult) { //该ID在当前项目中存在 if (null != checkResult) { //该ID在当前项目中存在
//如果前面所经过的校验都没报错 //如果前面所经过的校验都没报错
if(!isUseCustomId){ if (!isUseCustomId) {
data.setNum(Integer.parseInt(data.getCustomNum())); data.setNum(Integer.parseInt(data.getCustomNum()));
data.setCustomNum(null); data.setCustomNum(null);
} }
data.setId(checkResult); data.setId(checkResult);
updateTestCases.add(data); updateTestCases.add(data);
}else { } else {
process.add(Translator.get("custom_num_is_not_exist"), nodePath + "/" + compartData.getName()); process.add(Translator.get("custom_num_is_not_exist"), nodePath + "/" + compartData.getName());
validatePass = false; validatePass = false;
} }
@ -406,7 +406,7 @@ public class XmindCaseParser {
}); });
} }
testCase.setRemark(rc.toString()); testCase.setRemark(rc.toString());
if(isUseCustomId || StringUtils.equals(importType,FunctionCaseImportEnum.Update.name())){ if (isUseCustomId || StringUtils.equals(importType, FunctionCaseImportEnum.Update.name())) {
testCase.setCustomNum(customId.toString()); testCase.setCustomNum(customId.toString());
} }