refactor(测试用例): 导入模版优化#1002294

--story=1002294 --user=lyh 11.测试跟踪导入模板优化
https://www.tapd.cn/55049933/s/1032253
This commit is contained in:
shiziyuan9527 2021-08-04 17:34:19 +08:00 committed by 刘瑞斌
parent a898bcbc1f
commit ff607a2d48
10 changed files with 62 additions and 43 deletions

View File

@ -135,7 +135,11 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
continue;
}
List<String> list = new ArrayList<>();
if (StringUtils.equals(dto.getName(), "责任人")) {
list.add("责任人(ID)");
} else {
list.add(dto.getName());
}
returnList.add(list);
}
}

View File

@ -135,7 +135,11 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
continue;
}
List<String> list = new ArrayList<>();
if (StringUtils.equals(dto.getName(), "责任人")) {
list.add("維護人(ID)");
} else {
list.add(dto.getName());
}
returnList.add(list);
}
}

View File

@ -135,7 +135,11 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
continue;
}
List<String> list = new ArrayList<>();
if (StringUtils.equals(dto.getName(), "责任人")) {
list.add("Maintainer(ID)");
} else {
list.add(dto.getName());
}
returnList.add(list);
}
}

View File

@ -43,7 +43,7 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra
returnMap.put("ID",index);
}else if(StringUtils.equalsAnyIgnoreCase(head,"所属模块","所屬模塊","Module")){
returnMap.put("Module",index);
}else if(StringUtils.equalsAnyIgnoreCase(head,"责任人","維護人","Maintainer")){
}else if(StringUtils.equalsAnyIgnoreCase(head,"责任人(ID)","維護人(ID)","Maintainer(ID)")){
returnMap.put("Maintainer",index);
}else if(StringUtils.equalsAnyIgnoreCase(head,"用例等级","用例等級","Priority")){
returnMap.put("Priority",index);
@ -51,6 +51,8 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra
returnMap.put("Tag",index);
}else if(StringUtils.equalsAnyIgnoreCase(head,"用例状态","用例狀態","Case status")){
returnMap.put("Status",index);
} else if (StringUtils.equalsAnyIgnoreCase(head, "编辑模式", "編輯模式", "Edit Model")) {
returnMap.put("StepModel",index);
}
index ++;
}
@ -94,7 +96,7 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra
sheet.getRow(0).getCell(1).setCellComment(comment);
}else if(StringUtils.equalsAnyIgnoreCase(coloum,"Maintainer")){
Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, index, 0, (short) 3, 1));
comment.setString(new XSSFRichTextString(Translator.get("please_input_workspace_member")));
comment.setString(new XSSFRichTextString(Translator.get("please_input_project_member")));
sheet.getRow(0).getCell(1).setCellComment(comment);
}else if(StringUtils.equalsAnyIgnoreCase(coloum,"Priority")){
Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, index, 0, (short) 3, 1));
@ -122,6 +124,10 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra
comment.setString(new XSSFRichTextString(Translator.get("options") + JSONArray.toJSONString(list)));
sheet.getRow(0).getCell(1).setCellComment(comment);
}
} else if (StringUtils.equalsAnyIgnoreCase(coloum, "StepModel")) {
Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, index, 0, (short) 3, 1));
comment.setString(new XSSFRichTextString(Translator.get("step_model_tip")));
sheet.getRow(0).getCell(1).setCellComment(comment);
}
}
}

View File

@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.ListUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.*;
import io.metersphere.excel.domain.ExcelErrData;
import io.metersphere.excel.domain.TestCaseExcelData;
import io.metersphere.excel.utils.ExcelValidateHelper;
@ -19,8 +16,6 @@ import io.metersphere.track.service.TestCaseService;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -132,9 +127,13 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
}
}
//校验维护人
if (StringUtils.isBlank(data.getMaintainer())) {
data.setMaintainer(SessionUtils.getUserId());
} else {
if (!userIds.contains(data.getMaintainer())) {
stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; ");
}
}
/*
校验Excel中是否有ID
@ -259,11 +258,11 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){
if(StringUtils.equalsAny(data.getStatus(),"Underway","underway","进行中","進行中")){
caseStatusValue = "Underway";
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","prepare","未开始","未開始")){
caseStatusValue = "Prepare";
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","completed","已完成","已完成")){
caseStatusValue = "Completed";
}
if(StringUtils.isNotEmpty(caseStatusValue)){
@ -330,11 +329,11 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){
if(StringUtils.equalsAny(data.getStatus(),"Underway","underway","进行中","進行中")){
caseStatusValue = "Underway";
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","prepare","未开始","未開始")){
caseStatusValue = "Prepare";
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","completed","已完成","已完成")){
caseStatusValue = "Completed";
}
if(StringUtils.isNotEmpty(caseStatusValue)){

View File

@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.ListUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.*;
import io.metersphere.excel.domain.ExcelErrData;
import io.metersphere.excel.domain.TestCaseExcelData;
import io.metersphere.excel.utils.ExcelValidateHelper;
@ -19,8 +16,6 @@ import io.metersphere.track.service.TestCaseService;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -117,9 +112,13 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
//校验维护人
if (StringUtils.isBlank(data.getMaintainer())) {
data.setMaintainer(SessionUtils.getUserId());
} else {
if (!userIds.contains(data.getMaintainer())) {
stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; ");
}
}
/*
校验Excel中是否有ID

View File

@ -3,17 +3,13 @@ package io.metersphere.excel.listener;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.TestCase;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.ListUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.*;
import io.metersphere.dto.CustomFieldDao;
import io.metersphere.excel.annotation.NotRequired;
import io.metersphere.excel.domain.ExcelErrData;
@ -231,9 +227,13 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
}else if (StringUtils.equals(customName, "maintainer")) {
value = data.getMaintainer();
//校验维护人
if (StringUtils.isBlank(data.getMaintainer())) {
data.setMaintainer(SessionUtils.getUserId());
} else {
if (!userIds.contains(data.getMaintainer())) {
stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; ");
}
}
continue;
} else {
value = data.getCustomDatas().get(customName);
@ -404,11 +404,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if (StringUtils.equalsAny(data.getStatus(), "Underway", "进行中", "進行中")) {
if (StringUtils.equalsAny(data.getStatus(), "Underway","underway", "进行中", "進行中")) {
caseStatusValue = "Underway";
} else if (StringUtils.equalsAny(data.getStatus(), "Prepare", "未开始", "未開始")) {
} else if (StringUtils.equalsAny(data.getStatus(), "Prepare","prepare", "未开始", "未開始")) {
caseStatusValue = "Prepare";
} else if (StringUtils.equalsAny(data.getStatus(), "Completed", "已完成", "已完成")) {
} else if (StringUtils.equalsAny(data.getStatus(), "Completed", "completed","已完成", "已完成")) {
caseStatusValue = "Completed";
}
data.setStatus(caseStatusValue);
@ -454,11 +454,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if (StringUtils.equalsAny(data.getStatus(), "Underway", "进行中", "進行中")) {
if (StringUtils.equalsAny(data.getStatus(), "Underway","underway" ,"进行中", "進行中")) {
caseStatusValue = "Underway";
} else if (StringUtils.equalsAny(data.getStatus(), "Prepare", "未开始", "未開始")) {
} else if (StringUtils.equalsAny(data.getStatus(), "Prepare","prepare" ,"未开始", "未開始")) {
caseStatusValue = "Prepare";
} else if (StringUtils.equalsAny(data.getStatus(), "Completed", "已完成", "已完成")) {
} else if (StringUtils.equalsAny(data.getStatus(), "Completed", "completed","已完成", "已完成")) {
caseStatusValue = "Completed";
}
data.setStatus(caseStatusValue);

View File

@ -149,7 +149,7 @@ options_yes=Yes
options_no=No
required=Required
password_format_is_incorrect=Valid password: 8-30 digits, English upper and lower case letters + numbers + special characters (optional)
please_input_workspace_member=Please input workspace merber's number
please_input_project_member=Please input project merber's number
test_case_report_template_repeat=The workspace has the same name template
plan_name_already_exists=Test plan name already exists
test_case_already_exists_excel=There are duplicate test cases in the import file
@ -160,6 +160,7 @@ custom_num_is_exist=Use case custom ID already exists
custom_num_is_not_exist=Use case custom ID not exists
id_required=ID required
id_repeat_in_table=ID is repeat in table
step_model_tip=Step description fill in STEP, text description please fill in TEXT (not required)
#ldap
ldap_url_is_null=LDAP address is empty
ldap_dn_is_null=LDAP binding DN is empty

View File

@ -149,7 +149,7 @@ options_yes=是
options_no=
required=必填
password_format_is_incorrect=有效密码8-30位英文大小写字母+数字+特殊字符(可选)
please_input_workspace_member=请填写该工作空间的相关人员ID
please_input_project_member=请填写该项目下的相关人员ID
test_case_report_template_repeat=同一工作空间下不能存在同名模版
plan_name_already_exists=测试计划名称已存在
test_case_already_exists_excel=文件中存在多条相同用例
@ -160,6 +160,7 @@ custom_num_is_exist=用例自定义ID已存在
custom_num_is_not_exist=用例自定义ID不存在
id_required=ID必填
id_repeat_in_table=表格内ID重复
step_model_tip=步骤描述填写 STEP,文本描述请填写 TEXT (非必填)
#ldap
ldap_url_is_null=LDAP地址为空
ldap_dn_is_null=LDAP绑定DN为空

View File

@ -149,7 +149,7 @@ options_yes=是
options_no=
required=必填
password_format_is_incorrect=有效密碼8-30位英文大小寫字母+數字+特殊字符(可選)
please_input_workspace_member=請填寫該工作空間的相關人員ID
please_input_project_member=請填寫該項目的相關人員ID
test_case_report_template_repeat=同壹工作空間下不能存在同名模版
plan_name_already_exists=測試計劃名稱已存在
test_case_already_exists_excel=文件中存在多條相同用例
@ -160,6 +160,7 @@ custom_num_is_exist=用例自定義ID已存在
custom_num_is_not_exist=用例自定義ID不存在
id_required=ID必填
id_repeat_in_table=表格內ID重複
step_model_tip=步驟描述填寫 STEP,文本描述請填寫 TEXT (非必填)
#ldap
ldap_url_is_null=LDAP地址為空
ldap_dn_is_null=LDAP綁定DN為空