refactor(测试跟踪): 合并导入所有校验方法

This commit is contained in:
fit2-zhao 2020-09-29 17:00:58 +08:00
parent cb8fb36297
commit e4a7c2eb34
1 changed files with 5 additions and 10 deletions

View File

@ -82,7 +82,8 @@ public class XmindCaseParser {
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
process.append(Translator.get("module_not_null") + "; "); process.append(Translator.get("module_not_null") + "; ");
break; } else if (nodes[i].trim().length() > 30) {
process.append(nodes[i].trim() + "" + Translator.get("test_track.length_less_than") + "30 ;");
} }
} }
}); });
@ -95,7 +96,6 @@ public class XmindCaseParser {
item.setParent(parent); item.setParent(parent);
this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null); this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null);
} else { } else {
validLength(item.getTitle());
String nodePath = parent.getPath() + "/" + item.getTitle(); String nodePath = parent.getPath() + "/" + item.getTitle();
item.setPath(nodePath); item.setPath(nodePath);
item.setParent(parent); item.setParent(parent);
@ -222,13 +222,6 @@ public class XmindCaseParser {
compartDatas.add(compartData); compartDatas.add(compartData);
} }
private void validLength(String title) {
if (StringUtils.equals(title.trim(), ""))
process.append(Translator.get("module_not_null") + "; ");
if (title.length() > 30)
process.append(title + "" + Translator.get("test_track.length_less_than") + "30 ;");
}
// 验证合法性 // 验证合法性
private boolean validate(TestCaseWithBLOBs data) { private boolean validate(TestCaseWithBLOBs data) {
String nodePath = data.getNodePath(); String nodePath = data.getNodePath();
@ -244,6 +237,9 @@ public class XmindCaseParser {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
stringBuilder.append(Translator.get("module_not_null") + "; "); stringBuilder.append(Translator.get("module_not_null") + "; ");
break; break;
} else if (nodes[i].trim().length() > 30) {
stringBuilder.append(nodes[i].trim() + "" + Translator.get("test_track.length_less_than") + "30 ;");
break;
} }
} }
} }
@ -281,7 +277,6 @@ public class XmindCaseParser {
if (isAvailable(item.getTitle(), "(?:tc:|tc|tc)")) { // 用例 if (isAvailable(item.getTitle(), "(?:tc:|tc|tc)")) { // 用例
return replace(item.getTitle(), "(?:tc:|tc|tc)") + "" + Translator.get("test_case_create_module_fail"); return replace(item.getTitle(), "(?:tc:|tc|tc)") + "" + Translator.get("test_case_create_module_fail");
} else { } else {
validLength(item.getTitle());
item.setPath(item.getTitle()); item.setPath(item.getTitle());
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) { if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
recursion(processBuffer, item, 1, item.getChildren().getAttached()); recursion(processBuffer, item, 1, item.getChildren().getAttached());