fix 测试用例导入
This commit is contained in:
parent
7dba9bea5f
commit
3634544ae2
|
@ -23,7 +23,6 @@ public class TestCaseExcelData {
|
||||||
@Pattern(regexp = "^(?!.*//).*$", message = "格式不正确")
|
@Pattern(regexp = "^(?!.*//).*$", message = "格式不正确")
|
||||||
private String nodePath;
|
private String nodePath;
|
||||||
|
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@ExcelProperty("用例类型")
|
@ExcelProperty("用例类型")
|
||||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "必须为functional、performance、api")
|
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "必须为functional、performance、api")
|
||||||
|
|
|
@ -41,6 +41,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
||||||
if ( nodePath.split("/").length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
|
if ( nodePath.split("/").length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
|
||||||
stringBuilder.append("节点最多为" + TestCaseConstants.MAX_NODE_DEPTH + "层;");
|
stringBuilder.append("节点最多为" + TestCaseConstants.MAX_NODE_DEPTH + "层;");
|
||||||
}
|
}
|
||||||
|
if ( nodePath.trim().contains(" ")) {
|
||||||
|
stringBuilder.append("所属模块不能包含空格");
|
||||||
|
}
|
||||||
if (!userNames.contains(data.getMaintainer())) {
|
if (!userNames.contains(data.getMaintainer())) {
|
||||||
stringBuilder.append("该工作空间下无该用户:" + data.getMaintainer() + ";");
|
stringBuilder.append("该工作空间下无该用户:" + data.getMaintainer() + ";");
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,6 +228,7 @@ public class TestCaseNodeService {
|
||||||
pathIterator.remove();
|
pathIterator.remove();
|
||||||
|
|
||||||
rootNodeName = pathIterator.next().trim();
|
rootNodeName = pathIterator.next().trim();
|
||||||
|
//原来没有,新建的树nodeTrees也不包含
|
||||||
for (TestCaseNodeDTO nodeTree : nodeTrees) {
|
for (TestCaseNodeDTO nodeTree : nodeTrees) {
|
||||||
if (StringUtils.equals(rootNodeName, nodeTree.getName())) {
|
if (StringUtils.equals(rootNodeName, nodeTree.getName())) {
|
||||||
hasNode = true;
|
hasNode = true;
|
||||||
|
@ -237,6 +238,7 @@ public class TestCaseNodeService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!hasNode) {
|
if (!hasNode) {
|
||||||
createNodeByPath(pathIterator, rootNodeName, null, projectId, 1, "", pathMap);
|
createNodeByPath(pathIterator, rootNodeName, null, projectId, 1, "", pathMap);
|
||||||
}
|
}
|
||||||
|
@ -297,20 +299,34 @@ public class TestCaseNodeService {
|
||||||
|
|
||||||
StringBuilder path = new StringBuilder(rootPath);
|
StringBuilder path = new StringBuilder(rootPath);
|
||||||
|
|
||||||
Integer pid = insertTestCaseNode(nodeName, pNode == null ? null : pNode.getId(), projectId, level);
|
|
||||||
path.append("/" + nodeName);
|
path.append("/" + nodeName);
|
||||||
pathMap.put(path.toString(), pid);
|
|
||||||
|
Integer pid = null;
|
||||||
|
//创建过不创建
|
||||||
|
if (pathMap.get(path.toString()) != null) {
|
||||||
|
pid = pathMap.get(path.toString());
|
||||||
|
level++;
|
||||||
|
} else {
|
||||||
|
pid = insertTestCaseNode(nodeName, pNode == null ? null : pNode.getId(), projectId, level);
|
||||||
|
pathMap.put(path.toString(), pid);
|
||||||
|
}
|
||||||
|
|
||||||
while (pathIterator.hasNext()) {
|
while (pathIterator.hasNext()) {
|
||||||
String nextNodeName = pathIterator.next();
|
String nextNodeName = pathIterator.next();
|
||||||
path.append("/" + nextNodeName);
|
path.append("/" + nextNodeName);
|
||||||
pid = insertTestCaseNode(nextNodeName, pid, projectId, ++level);
|
if (pathMap.get(path.toString()) != null) {
|
||||||
pathMap.put(path.toString(), pid);
|
pid = pathMap.get(path.toString());
|
||||||
|
level++;
|
||||||
|
} else {
|
||||||
|
pid = insertTestCaseNode(nextNodeName, pid, projectId, level);
|
||||||
|
pathMap.put(path.toString(), pid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer insertTestCaseNode(String nodName, Integer pId, String projectId, Integer level) {
|
private Integer insertTestCaseNode(String nodeName, Integer pId, String projectId, Integer level) {
|
||||||
TestCaseNode testCaseNode = new TestCaseNode();
|
TestCaseNode testCaseNode = new TestCaseNode();
|
||||||
testCaseNode.setName(nodName.trim());
|
testCaseNode.setName(nodeName.trim());
|
||||||
testCaseNode.setpId(pId);
|
testCaseNode.setpId(pId);
|
||||||
testCaseNode.setProjectId(projectId);
|
testCaseNode.setProjectId(projectId);
|
||||||
testCaseNode.setCreateTime(System.currentTimeMillis());
|
testCaseNode.setCreateTime(System.currentTimeMillis());
|
||||||
|
|
Loading…
Reference in New Issue