fix(测试用例): 导入的用例所属模块节点开始无/报错问题

--bug=1045195 --user=宋昌昌 【测试用例】excel导入用例-所属模块路径跟节点无/-导入报错 https://www.tapd.cn/55049933/s/1572218
This commit is contained in:
song-cc-rock 2024-09-02 15:14:51 +08:00 committed by Craftsman
parent 6c82da4de5
commit 93cee2b8b9
4 changed files with 11 additions and 7 deletions

View File

@ -45,7 +45,7 @@ public enum CaseType {
public static CaseType getType(String key) { public static CaseType getType(String key) {
for (CaseType caseType : CaseType.values()) { for (CaseType caseType : CaseType.values()) {
if (StringUtils.equals(caseType.getKey(), key)) { if (StringUtils.equalsIgnoreCase(caseType.getKey(), key)) {
return caseType; return caseType;
} }
} }

View File

@ -390,13 +390,11 @@ public class FunctionalCaseCheckEventListener extends AnalysisEventListener<Map<
* @param errMsg * @param errMsg
*/ */
private void validateModule(FunctionalCaseExcelData data, StringBuilder errMsg) { private void validateModule(FunctionalCaseExcelData data, StringBuilder errMsg) {
if (!StringUtils.startsWith(data.getModule(), "/")) {
data.setModule("/" + data.getModule());
}
String module = data.getModule(); String module = data.getModule();
if (StringUtils.isNotEmpty(module)) { if (StringUtils.isNotEmpty(module)) {
if (!StringUtils.startsWith(module, "/")) {
errMsg.append(Translator.get("module_starts_with"))
.append(ERROR_MSG_SEPARATOR);
return;
}
String[] nodes = module.split("/"); String[] nodes = module.split("/");
//模块名不能为空 //模块名不能为空
for (int i = 0; i < nodes.length; i++) { for (int i = 0; i < nodes.length; i++) {

View File

@ -500,6 +500,9 @@ public class FunctionalCaseImportEventListener extends AnalysisEventListener<Map
* @param errMsg * @param errMsg
*/ */
private void validateModule(FunctionalCaseExcelData data, StringBuilder errMsg) { private void validateModule(FunctionalCaseExcelData data, StringBuilder errMsg) {
if (!StringUtils.startsWith(data.getModule(), "/")) {
data.setModule("/" + data.getModule());
}
String module = data.getModule(); String module = data.getModule();
if (StringUtils.isNotEmpty(module)) { if (StringUtils.isNotEmpty(module)) {
String[] nodes = module.split("/"); String[] nodes = module.split("/");

View File

@ -248,12 +248,15 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
public List<TestPlanCasePageResponse> getFunctionalCasePage(TestPlanCaseRequest request, boolean deleted) { public List<TestPlanCasePageResponse> getFunctionalCasePage(TestPlanCaseRequest request, boolean deleted) {
filterCaseRequest(request); filterCaseRequest(request);
// 查询中不需要项目ID参数
String projectId = request.getProjectId();
request.setProjectId(null);
List<TestPlanCasePageResponse> functionalCaseLists = extTestPlanFunctionalCaseMapper.getCasePage(request, deleted, request.getSortString()); List<TestPlanCasePageResponse> functionalCaseLists = extTestPlanFunctionalCaseMapper.getCasePage(request, deleted, request.getSortString());
if (CollectionUtils.isEmpty(functionalCaseLists)) { if (CollectionUtils.isEmpty(functionalCaseLists)) {
return new ArrayList<>(); return new ArrayList<>();
} }
//处理自定义字段值 //处理自定义字段值
return handleCustomFields(functionalCaseLists, request.getProjectId()); return handleCustomFields(functionalCaseLists, projectId);
} }
private List<TestPlanCasePageResponse> handleCustomFields(List<TestPlanCasePageResponse> functionalCaseLists, String projectId) { private List<TestPlanCasePageResponse> handleCustomFields(List<TestPlanCasePageResponse> functionalCaseLists, String projectId) {