mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 12:39:12 +08:00
feat(测试用例): 修复功能用例xmind导入报错问题
--bug=1048527 --user=王旭 [功能用例]github#33991功能用例导出为xmind再导入会报错 “Index 1 out of bounds for length 1” https://www.tapd.cn/55049933/s/1607845
This commit is contained in:
parent
47f4b2c594
commit
c8f871dbc0
@ -132,7 +132,7 @@ public class XMindCaseParser {
|
|||||||
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 {
|
||||||
if (StringUtils.equalsIgnoreCase(parent.getPath().trim(), Translator.get("functional_case.module.default.name"))) {
|
if (StringUtils.equalsIgnoreCase(parent.getPath().trim(), Translator.get("functional_case.module.default.name"))) {
|
||||||
process.add(Translator.get("incorrect_format"), Translator.get("functional_case.module.default.name.add_error"));
|
process.add(Translator.get("incorrect_format"), Translator.get("functional_case.module.default.name.add_error"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String nodePath = parent.getPath().trim() + "/" + item.getTitle().trim();
|
String nodePath = parent.getPath().trim() + "/" + item.getTitle().trim();
|
||||||
@ -308,14 +308,14 @@ public class XMindCaseParser {
|
|||||||
private void formatTestCase(String title, String nodePath, List<Attached> attacheds) {
|
private void formatTestCase(String title, String nodePath, List<Attached> attacheds) {
|
||||||
FunctionalCaseExcelData testCase = new FunctionalCaseExcelData();
|
FunctionalCaseExcelData testCase = new FunctionalCaseExcelData();
|
||||||
String tc = title.replace(":", ":");
|
String tc = title.replace(":", ":");
|
||||||
String[] tcArrs = tc.split(":");
|
String[] tcArrs = tc.split(":", 2);
|
||||||
if (tcArrs.length <= 1) {
|
if (tcArrs.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;
|
||||||
}
|
}
|
||||||
// 用例名称
|
// 用例名称
|
||||||
String name = title.replace(tcArrs[0] + ":", StringUtils.EMPTY).replace(tcArrs[0] + ":", StringUtils.EMPTY);
|
String name = title.replace(tcArrs[0] + ":", StringUtils.EMPTY).replace(tcArrs[0] + ":", StringUtils.EMPTY);
|
||||||
if (name.length()>=255) {
|
if (name.length() >= 255) {
|
||||||
process.add(Translator.get("test_case_name") + Translator.get("length.too.large"), title);
|
process.add(Translator.get("test_case_name") + Translator.get("length.too.large"), title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -365,7 +365,7 @@ public class XMindCaseParser {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//自定义字段
|
//自定义字段
|
||||||
String[] customFiled = item.getTitle().split("(?:\\s*:|:)",2);
|
String[] customFiled = item.getTitle().split("(?:\\s*:|:)", 2);
|
||||||
Map<String, Object> stringObjectMap = testCase.getCustomData();
|
Map<String, Object> stringObjectMap = testCase.getCustomData();
|
||||||
if (customFiled.length > 1) {
|
if (customFiled.length > 1) {
|
||||||
TemplateCustomFieldDTO templateCustomFieldDTO = customFieldsMap.get(customFiled[0]);
|
TemplateCustomFieldDTO templateCustomFieldDTO = customFieldsMap.get(customFiled[0]);
|
||||||
@ -407,7 +407,7 @@ public class XMindCaseParser {
|
|||||||
*/
|
*/
|
||||||
private String getSteps(List<Attached> attacheds, String caseName) {
|
private String getSteps(List<Attached> attacheds, String caseName) {
|
||||||
List<FunctionalCaseStepDTO> functionalCaseStepDTOS = new ArrayList<>();
|
List<FunctionalCaseStepDTO> functionalCaseStepDTOS = new ArrayList<>();
|
||||||
if (attacheds!=null && !attacheds.isEmpty()) {
|
if (attacheds != null && !attacheds.isEmpty()) {
|
||||||
for (int i = 0; i < attacheds.size(); i++) {
|
for (int i = 0; i < attacheds.size(); i++) {
|
||||||
// 保持插入顺序,判断用例是否有相同的steps
|
// 保持插入顺序,判断用例是否有相同的steps
|
||||||
FunctionalCaseStepDTO functionalCaseStepDTO = new FunctionalCaseStepDTO();
|
FunctionalCaseStepDTO functionalCaseStepDTO = new FunctionalCaseStepDTO();
|
||||||
@ -415,8 +415,8 @@ public class XMindCaseParser {
|
|||||||
functionalCaseStepDTO.setNum(i + 1);
|
functionalCaseStepDTO.setNum(i + 1);
|
||||||
if (isAvailable(attacheds.get(i).getTitle(), STEP)) {
|
if (isAvailable(attacheds.get(i).getTitle(), STEP)) {
|
||||||
String stepDesc = attacheds.get(i).getTitle().replace(":", ":");
|
String stepDesc = attacheds.get(i).getTitle().replace(":", ":");
|
||||||
String[] stepDescArrs = stepDesc.split(":");
|
String[] stepDescArrs = stepDesc.split(":", 2);
|
||||||
functionalCaseStepDTO.setDesc(StringUtils.isNotBlank(stepDescArrs[1]) ? stepDescArrs[1] : StringUtils.EMPTY);
|
functionalCaseStepDTO.setDesc(stepDescArrs.length < 2 ? StringUtils.EMPTY : stepDescArrs[1]);
|
||||||
} else {
|
} else {
|
||||||
functionalCaseStepDTO.setDesc(StringUtils.EMPTY);
|
functionalCaseStepDTO.setDesc(StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
@ -429,8 +429,8 @@ public class XMindCaseParser {
|
|||||||
String title = attacheds.get(i).getChildren().getAttached().get(0).getTitle();
|
String title = attacheds.get(i).getChildren().getAttached().get(0).getTitle();
|
||||||
if (isAvailable(title, EXPECTED_RESULT)) {
|
if (isAvailable(title, EXPECTED_RESULT)) {
|
||||||
String stepDesc = title.replace(":", ":");
|
String stepDesc = title.replace(":", ":");
|
||||||
String[] stepDescArrs = stepDesc.split(":");
|
String[] stepDescArrs = stepDesc.split(":", 2);
|
||||||
functionalCaseStepDTO.setResult(StringUtils.isNotBlank(stepDescArrs[1]) ? stepDescArrs[1] : StringUtils.EMPTY);
|
functionalCaseStepDTO.setResult(stepDescArrs.length < 2 ? StringUtils.EMPTY : stepDescArrs[1]);
|
||||||
} else {
|
} else {
|
||||||
functionalCaseStepDTO.setResult(StringUtils.EMPTY);
|
functionalCaseStepDTO.setResult(StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
@ -452,6 +452,7 @@ public class XMindCaseParser {
|
|||||||
}
|
}
|
||||||
return JSON.toJSONString(functionalCaseStepDTOS);
|
return JSON.toJSONString(functionalCaseStepDTOS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取步骤数据
|
* 获取步骤数据
|
||||||
*/
|
*/
|
||||||
@ -460,7 +461,7 @@ public class XMindCaseParser {
|
|||||||
String title = attacheds.get(0).getTitle();
|
String title = attacheds.get(0).getTitle();
|
||||||
if (isAvailable(title, EXPECTED_RESULT)) {
|
if (isAvailable(title, EXPECTED_RESULT)) {
|
||||||
String stepDesc = title.replace(":", ":");
|
String stepDesc = title.replace(":", ":");
|
||||||
String[] stepDescArrs = stepDesc.split(":");
|
String[] stepDescArrs = stepDesc.split(":", 2);
|
||||||
return StringUtils.isNotBlank(stepDescArrs[1]) ? stepDescArrs[1] : StringUtils.EMPTY;
|
return StringUtils.isNotBlank(stepDescArrs[1]) ? stepDescArrs[1] : StringUtils.EMPTY;
|
||||||
} else {
|
} else {
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
|
Loading…
Reference in New Issue
Block a user