diff --git a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java index 580b8d470f..56b3fc682b 100644 --- a/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java +++ b/backend/src/main/java/io/metersphere/api/service/HistoricalDataUpgradeService.java @@ -7,6 +7,7 @@ import io.metersphere.api.dto.SaveHistoricalDataUpgrade; import io.metersphere.api.dto.automation.ScenarioStatus; import io.metersphere.api.dto.definition.request.MsScenario; 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.controller.MsIfController; import io.metersphere.api.dto.definition.request.extract.MsExtract; @@ -203,6 +204,23 @@ public class HistoricalDataUpgradeService { if (StringUtils.isEmpty(msAssertions.getName())) { 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.setIndex(index + ""); msAssertions.setResourceId(UUID.randomUUID().toString()); @@ -217,6 +235,16 @@ public class HistoricalDataUpgradeService { if (StringUtils.isEmpty(extract.getName())) { 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.setIndex(index + ""); extract.setHashTree(new LinkedList<>()); diff --git a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java index 1dab92a9f8..a2e5645e8c 100644 --- a/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java +++ b/backend/src/main/java/io/metersphere/xmind/XmindCaseParser.java @@ -277,12 +277,16 @@ public class XmindCaseParser { String tc = title.replace(":", ":"); String[] tcArr = tc.split(":"); - if (tcArr.length != 2) { + if (tcArr.length < 1) { process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title); 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); // 用例等级和用例性质处理