fix: 功能用例导入模块带空格导入失败

--bug=1009895 --user=陈建星 用附件的excel导入用例,提示node id为空,看了页面没有node id https://www.tapd.cn/55049933/s/1100397
This commit is contained in:
chenjianxing 2022-01-28 13:46:51 +08:00 committed by 刘瑞斌
parent 3a0e887eec
commit e8389648d0
3 changed files with 13 additions and 2 deletions

View File

@ -170,7 +170,7 @@ public class NodeTreeService<T extends TreeNodeDTO> {
path.append("/" + nodeName); path.append("/" + nodeName);
String pid = null; String pid;
//创建过不创建 //创建过不创建
if (pathMap.get(path.toString()) != null) { if (pathMap.get(path.toString()) != null) {
pid = pathMap.get(path.toString()); pid = pathMap.get(path.toString());

View File

@ -405,7 +405,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
List<String> nodeNameList = new ArrayList<>(Arrays.asList(item.split("/"))); List<String> nodeNameList = new ArrayList<>(Arrays.asList(item.split("/")));
Iterator<String> itemIterator = nodeNameList.iterator(); Iterator<String> itemIterator = nodeNameList.iterator();
Boolean hasNode = false; Boolean hasNode = false;
String rootNodeName = null; String rootNodeName;
if (nodeNameList.size() <= 1) { if (nodeNameList.size() <= 1) {
throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + item); throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + item);

View File

@ -937,6 +937,17 @@ public class TestCaseService {
testCase.setCreateUser(SessionUtils.getUserId()); testCase.setCreateUser(SessionUtils.getUserId());
testCase.setCreateTime(System.currentTimeMillis()); testCase.setCreateTime(System.currentTimeMillis());
testCase.setUpdateTime(System.currentTimeMillis()); testCase.setUpdateTime(System.currentTimeMillis());
if (StringUtils.isNotBlank(testCase.getNodePath())) {
String[] modules = testCase.getNodePath().split("/");
StringBuilder path = new StringBuilder();
for (String module : modules) {
if (StringUtils.isNotBlank(module)) {
path.append("/");
path.append(module.trim());
}
}
testCase.setNodePath(path.toString());
}
testCase.setNodeId(nodePathMap.get(testCase.getNodePath())); testCase.setNodeId(nodePathMap.get(testCase.getNodePath()));
testCase.setNum(num); testCase.setNum(num);
if (project.getCustomNum() && StringUtils.isBlank(testCase.getCustomNum())) { if (project.getCustomNum() && StringUtils.isBlank(testCase.getCustomNum())) {