fix(用例管理): 导入用例模块以/开始

--bug=1035904 --user=王旭 [用例管理]功能用例-导入的用例文件中模块名称开头没有“/”,校验成功,导入失败。 https://www.tapd.cn/55049933/s/1469768
This commit is contained in:
WangXu10 2024-03-05 20:39:40 +08:00 committed by 刘瑞斌
parent 49aebfe441
commit 05638aab20
4 changed files with 12 additions and 4 deletions

View File

@ -118,6 +118,7 @@ test_case_create_module_fail=Failed to create module
test_case_import_template_name=Test_case_templates
test_case_import_template_sheet=Template
module_not_null=The module must not be blank
module_starts_with=The module must start with '/'
user_not_exists=The user in this project is not exists
test_case_already_exists=The test case in this project is exists
parse_data_error=Parse data error

View File

@ -119,6 +119,7 @@ test_case_create_module_fail=创建模块失败
test_case_import_template_name=测试用例模版
test_case_import_template_sheet=模版
module_not_null=所属模块不能为空格
module_starts_with=所属模块必须以'/'开始
user_not_exists=该项目下无该用户
test_case_already_exists=该项目下已存在该测试用例
parse_data_error=解析数据出错

View File

@ -119,6 +119,7 @@ test_case_create_module_fail=創建模塊失敗
test_case_import_template_name=測試用例模版
test_case_import_template_sheet=模版
module_not_null=所屬模塊不能為空格
module_starts_with=所屬模塊必須以'/'開始
user_not_exists=該項目下無該用戶
test_case_already_exists=該項目下已存在該測試用例
parse_data_error=解析數據出錯

View File

@ -229,24 +229,24 @@ public class FunctionalCaseCheckEventListener extends AnalysisEventListener<Map<
}
}
private String getSteps(FunctionalCaseExcelData data,StringBuilder errMsg) {
private String getSteps(FunctionalCaseExcelData data, StringBuilder errMsg) {
List<Map<String, Object>> steps = new ArrayList<>();
if (CollectionUtils.isNotEmpty(data.getMergeTextDescription()) || CollectionUtils.isNotEmpty(data.getMergeExpectedResult())) {
// 如果是合并单元格则组合多条单元格的数据
for (int i = 0; i < data.getMergeTextDescription().size(); i++) {
List<Map<String, Object>> rowSteps = getSingleRowSteps(data.getMergeTextDescription().get(i), data.getMergeExpectedResult().get(i), steps.size(),errMsg);
List<Map<String, Object>> rowSteps = getSingleRowSteps(data.getMergeTextDescription().get(i), data.getMergeExpectedResult().get(i), steps.size(), errMsg);
steps.addAll(rowSteps);
}
} else {
// 如果不是合并单元格则直接解析单元格数据
steps.addAll(getSingleRowSteps(data.getTextDescription(), data.getExpectedResult(), steps.size(),errMsg));
steps.addAll(getSingleRowSteps(data.getTextDescription(), data.getExpectedResult(), steps.size(), errMsg));
}
return JSON.toJSONString(steps);
}
private List<Map<String, Object>> getSingleRowSteps(String cellDesc, String cellResult, Integer startStepIndex,StringBuilder errMsg) {
private List<Map<String, Object>> getSingleRowSteps(String cellDesc, String cellResult, Integer startStepIndex, StringBuilder errMsg) {
List<Map<String, Object>> steps = new ArrayList<>();
List<String> stepDescList = parseStepCell(cellDesc);
@ -387,6 +387,11 @@ public class FunctionalCaseCheckEventListener extends AnalysisEventListener<Map<
private void validateModule(FunctionalCaseExcelData data, StringBuilder errMsg) {
String module = data.getModule();
if (StringUtils.isNotEmpty(module)) {
if (!StringUtils.startsWith(module, "/")) {
errMsg.append(Translator.get("module_starts_with"))
.append(ERROR_MSG_SEPARATOR);
return;
}
String[] nodes = module.split("/");
//模块名不能为空
for (int i = 0; i < nodes.length; i++) {