fix(测试跟踪): 修复上次xmind 格式错误问题

This commit is contained in:
fit2-zhao 2021-02-09 17:22:15 +08:00
parent 94ead290cc
commit e0349f5a5f
2 changed files with 34 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.api.dto.SaveHistoricalDataUpgrade;
import io.metersphere.api.dto.automation.ScenarioStatus; import io.metersphere.api.dto.automation.ScenarioStatus;
import io.metersphere.api.dto.definition.request.MsScenario; import io.metersphere.api.dto.definition.request.MsScenario;
import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.MsTestElement;
import io.metersphere.api.dto.definition.request.assertions.MsAssertionDuration;
import io.metersphere.api.dto.definition.request.assertions.MsAssertions; import io.metersphere.api.dto.definition.request.assertions.MsAssertions;
import io.metersphere.api.dto.definition.request.controller.MsIfController; import io.metersphere.api.dto.definition.request.controller.MsIfController;
import io.metersphere.api.dto.definition.request.extract.MsExtract; import io.metersphere.api.dto.definition.request.extract.MsExtract;
@ -203,6 +204,23 @@ public class HistoricalDataUpgradeService {
if (StringUtils.isEmpty(msAssertions.getName())) { if (StringUtils.isEmpty(msAssertions.getName())) {
msAssertions.setName("Assertions"); msAssertions.setName("Assertions");
} }
// 给初始值
if (msAssertions.getDuration() == null) {
msAssertions.setDuration(new MsAssertionDuration());
}
if (CollectionUtils.isEmpty(msAssertions.getJsr223())) {
msAssertions.setJsr223(new LinkedList<>());
}
if (CollectionUtils.isEmpty(msAssertions.getXpath2())) {
msAssertions.setXpath2(new LinkedList<>());
}
if (CollectionUtils.isEmpty(msAssertions.getJsonPath())) {
msAssertions.setJsonPath(new LinkedList<>());
}
if (CollectionUtils.isEmpty(msAssertions.getRegex())) {
msAssertions.setRegex(new LinkedList<>());
}
msAssertions.setType("Assertions"); msAssertions.setType("Assertions");
msAssertions.setIndex(index + ""); msAssertions.setIndex(index + "");
msAssertions.setResourceId(UUID.randomUUID().toString()); msAssertions.setResourceId(UUID.randomUUID().toString());
@ -217,6 +235,16 @@ public class HistoricalDataUpgradeService {
if (StringUtils.isEmpty(extract.getName())) { if (StringUtils.isEmpty(extract.getName())) {
extract.setName("Extract"); extract.setName("Extract");
} }
// 默认给初始值
if (CollectionUtils.isEmpty(extract.getJson())) {
extract.setJson(new LinkedList<>());
}
if (CollectionUtils.isEmpty(extract.getXpath())) {
extract.setXpath(new LinkedList<>());
}
if (CollectionUtils.isEmpty(extract.getRegex())) {
extract.setRegex(new LinkedList<>());
}
extract.setType("Extract"); extract.setType("Extract");
extract.setIndex(index + ""); extract.setIndex(index + "");
extract.setHashTree(new LinkedList<>()); extract.setHashTree(new LinkedList<>());

View File

@ -277,12 +277,16 @@ public class XmindCaseParser {
String tc = title.replace("", ":"); String tc = title.replace("", ":");
String[] tcArr = tc.split(":"); String[] tcArr = tc.split(":");
if (tcArr.length != 2) { if (tcArr.length < 1) {
process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title); process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title);
return; return;
} }
// 用例名称 // 用例名称
testCase.setName(this.replace(tcArr[1], TC_REGEX)); StringBuffer name = new StringBuffer();
for (int i = 1; i < tcArr.length; i++) {
name.append(tcArr[i]);
}
testCase.setName(name.toString());
testCase.setNodePath(nodePath); testCase.setNodePath(nodePath);
// 用例等级和用例性质处理 // 用例等级和用例性质处理