fix(用例管理): 修复用例导入默认等级问题

--bug=1045255 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001045255
--bug=1045204 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001045204
--bug=1045201 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001045201
This commit is contained in:
guoyuqi 2024-08-19 14:15:40 +08:00 committed by 刘瑞斌
parent 8fe7d869e8
commit f7c86b7f23
5 changed files with 41 additions and 52 deletions

View File

@ -310,6 +310,10 @@ public class FunctionalCaseCheckEventListener extends AnalysisEventListener<Map<
* @param errMsg * @param errMsg
*/ */
private void validateTags(FunctionalCaseExcelData data, StringBuilder errMsg) { private void validateTags(FunctionalCaseExcelData data, StringBuilder errMsg) {
if (StringUtils.isBlank(data.getTags())) {
data.setTags(StringUtils.EMPTY);
return;
}
List<String> tags = functionalCaseService.handleImportTags(data.getTags()); List<String> tags = functionalCaseService.handleImportTags(data.getTags());
if (tags.size() > TAGS_COUNT) { if (tags.size() > TAGS_COUNT) {
errMsg.append(Translator.get("tags_count")) errMsg.append(Translator.get("tags_count"))

View File

@ -1246,6 +1246,10 @@ public class FunctionalCaseService {
//需要保存的自定义字段 //需要保存的自定义字段
Map<String, Object> customData = functionalCaseExcelData.getCustomData(); Map<String, Object> customData = functionalCaseExcelData.getCustomData();
customFieldsMap.forEach((k, v) -> { customFieldsMap.forEach((k, v) -> {
//用例等级如果没有默认值则为P0
if (StringUtils.equalsIgnoreCase(v.getInternalFieldKey(), "functional_priority") && v.getDefaultValue()==null) {
v.setDefaultValue("P0");
}
Object value = customData.get(k); Object value = customData.get(k);
FunctionalCaseCustomField caseCustomField = new FunctionalCaseCustomField(); FunctionalCaseCustomField caseCustomField = new FunctionalCaseCustomField();
caseCustomField.setCaseId(caseId); caseCustomField.setCaseId(caseId);

View File

@ -173,7 +173,7 @@ public class XMindCaseParser {
private boolean validateTags(FunctionalCaseExcelData data) { private boolean validateTags(FunctionalCaseExcelData data) {
AtomicBoolean validate = new AtomicBoolean(true); AtomicBoolean validate = new AtomicBoolean(true);
if (StringUtils.isBlank(data.getTags())) { if (StringUtils.isBlank(data.getTags())) {
data.setTags(""); data.setTags(StringUtils.EMPTY);
return validate.get(); return validate.get();
} }
List<String> tags = functionalCaseService.handleImportTags(data.getTags()); List<String> tags = functionalCaseService.handleImportTags(data.getTags());
@ -286,6 +286,8 @@ public class XMindCaseParser {
//如果是覆盖那么有id的需要更新 //如果是覆盖那么有id的需要更新
functionalCaseExcelData.setNum(checkResult); functionalCaseExcelData.setNum(checkResult);
updateList.add(functionalCaseExcelData); updateList.add(functionalCaseExcelData);
} else {
list.add(functionalCaseExcelData);
} }
} else { } else {
list.add(functionalCaseExcelData); list.add(functionalCaseExcelData);

View File

@ -52,7 +52,7 @@ public class NoticeTemplateService {
Field[] allFields = FieldUtils.getAllFields(ApiReportMessageDTO.class); Field[] allFields = FieldUtils.getAllFields(ApiReportMessageDTO.class);
addOptionDto(messageTemplateFieldDTOList, allFields, null); addOptionDto(messageTemplateFieldDTOList, allFields, null);
} }
case NoticeConstants.TaskType.TEST_PLAN_TASK -> { case NoticeConstants.TaskType.TEST_PLAN_TASK, NoticeConstants.TaskType.JENKINS_TASK -> {
Field[] allFields = FieldUtils.getAllFields(TestPlanMessageDTO.class); Field[] allFields = FieldUtils.getAllFields(TestPlanMessageDTO.class);
addOptionDto(messageTemplateFieldDTOList, allFields, null); addOptionDto(messageTemplateFieldDTOList, allFields, null);
} }
@ -80,13 +80,6 @@ public class NoticeTemplateService {
Field[] allFields = FieldUtils.getAllFields(Schedule.class); Field[] allFields = FieldUtils.getAllFields(Schedule.class);
addOptionDto(messageTemplateFieldDTOList, allFields, "schedule_"); addOptionDto(messageTemplateFieldDTOList, allFields, "schedule_");
} }
case NoticeConstants.TaskType.JENKINS_TASK -> {
MessageTemplateFieldDTO messageTemplateFieldOperator = new MessageTemplateFieldDTO();
messageTemplateFieldOperator.setId("name");
messageTemplateFieldOperator.setFieldSource(NoticeConstants.FieldSource.CASE_FIELD);
messageTemplateFieldOperator.setName(Translator.get("message.jenkins_name"));
messageTemplateFieldDTOList.add(messageTemplateFieldOperator);
}
default -> messageTemplateFieldDTOList = new ArrayList<>(); default -> messageTemplateFieldDTOList = new ArrayList<>();
} }

View File

@ -140,7 +140,7 @@ public class MessageTemplateUtils {
case NoticeConstants.TaskType.API_DEFINITION_TASK -> FieldUtils.getAllFields(ApiDefinitionCaseDTO.class); case NoticeConstants.TaskType.API_DEFINITION_TASK -> FieldUtils.getAllFields(ApiDefinitionCaseDTO.class);
case NoticeConstants.TaskType.API_SCENARIO_TASK -> FieldUtils.getAllFields(ApiScenarioMessageDTO.class); case NoticeConstants.TaskType.API_SCENARIO_TASK -> FieldUtils.getAllFields(ApiScenarioMessageDTO.class);
case NoticeConstants.TaskType.API_REPORT_TASK -> FieldUtils.getAllFields(ApiReportMessageDTO.class); case NoticeConstants.TaskType.API_REPORT_TASK -> FieldUtils.getAllFields(ApiReportMessageDTO.class);
case NoticeConstants.TaskType.TEST_PLAN_TASK -> FieldUtils.getAllFields(TestPlanMessageDTO.class); case NoticeConstants.TaskType.TEST_PLAN_TASK, NoticeConstants.TaskType.JENKINS_TASK -> FieldUtils.getAllFields(TestPlanMessageDTO.class);
case NoticeConstants.TaskType.CASE_REVIEW_TASK -> FieldUtils.getAllFields(CaseReview.class); case NoticeConstants.TaskType.CASE_REVIEW_TASK -> FieldUtils.getAllFields(CaseReview.class);
case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> FieldUtils.getAllFields(FunctionalCaseMessageDTO.class); case NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK -> FieldUtils.getAllFields(FunctionalCaseMessageDTO.class);
case NoticeConstants.TaskType.BUG_TASK -> FieldUtils.getAllFields(BugMessageDTO.class); case NoticeConstants.TaskType.BUG_TASK -> FieldUtils.getAllFields(BugMessageDTO.class);
@ -194,12 +194,6 @@ public class MessageTemplateUtils {
} }
public static String getTranslateTemplate(String taskType, String template, Map<String, List<CustomField>> customFielddMap) { public static String getTranslateTemplate(String taskType, String template, Map<String, List<CustomField>> customFielddMap) {
if (StringUtils.equalsIgnoreCase(taskType, NoticeConstants.TaskType.JENKINS_TASK)) {
if (StringUtils.isNotBlank(template) && template.contains("${name}")) {
template = template.replace("${name}", "{{" + Translator.get("message.jenkins_name") + "}}");
}
return template;
} else {
Field[] domainTemplateFields = getDomainTemplateFields(taskType); Field[] domainTemplateFields = getDomainTemplateFields(taskType);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (StringUtils.isNotBlank(template) && template.contains("${OPERATOR}")) { if (StringUtils.isNotBlank(template) && template.contains("${OPERATOR}")) {
@ -215,7 +209,6 @@ public class MessageTemplateUtils {
addCustomFiled(taskType, customFielddMap, map); addCustomFiled(taskType, customFielddMap, map);
return getContent(template, map); return getContent(template, map);
} }
}
private static void addCustomFiled(String taskType, Map<String, List<CustomField>> customFielddMap, Map<String, Object> map) { private static void addCustomFiled(String taskType, Map<String, List<CustomField>> customFielddMap, Map<String, Object> map) {
for (TemplateScene value : TemplateScene.values()) { for (TemplateScene value : TemplateScene.values()) {
@ -238,7 +231,7 @@ public class MessageTemplateUtils {
putDescription(domainTemplateFields, map); putDescription(domainTemplateFields, map);
case NoticeConstants.TaskType.API_SCENARIO_TASK -> putDescription(domainTemplateFields, map); case NoticeConstants.TaskType.API_SCENARIO_TASK -> putDescription(domainTemplateFields, map);
case NoticeConstants.TaskType.API_REPORT_TASK -> putDescription(domainTemplateFields, map); case NoticeConstants.TaskType.API_REPORT_TASK -> putDescription(domainTemplateFields, map);
case NoticeConstants.TaskType.TEST_PLAN_TASK -> putDomainName(domainTemplateFields, map, "test_plan_"); case NoticeConstants.TaskType.TEST_PLAN_TASK, NoticeConstants.TaskType.JENKINS_TASK -> putDomainName(domainTemplateFields, map, "test_plan_");
case NoticeConstants.TaskType.CASE_REVIEW_TASK -> putDomainName(domainTemplateFields, map, "case_review_"); case NoticeConstants.TaskType.CASE_REVIEW_TASK -> putDomainName(domainTemplateFields, map, "case_review_");
case NoticeConstants.TaskType.BUG_TASK -> putDomainName(domainTemplateFields, map, "bug_"); case NoticeConstants.TaskType.BUG_TASK -> putDomainName(domainTemplateFields, map, "bug_");
case NoticeConstants.TaskType.SCHEDULE_TASK -> putDomainName(domainTemplateFields, map, "schedule_"); case NoticeConstants.TaskType.SCHEDULE_TASK -> putDomainName(domainTemplateFields, map, "schedule_");
@ -277,12 +270,6 @@ public class MessageTemplateUtils {
} }
public static String getTranslateSubject(String taskType, String subject, Map<String, List<CustomField>> customFielddMap) { public static String getTranslateSubject(String taskType, String subject, Map<String, List<CustomField>> customFielddMap) {
if (StringUtils.equalsIgnoreCase(taskType, NoticeConstants.TaskType.JENKINS_TASK)) {
if (StringUtils.isNotBlank(subject) && subject.contains("${name}")) {
subject = subject.replace("${name}", "{{" + Translator.get("message.jenkins_name") + "}}");
}
return subject;
} else {
Field[] domainTemplateFields = getDomainTemplateFields(taskType); Field[] domainTemplateFields = getDomainTemplateFields(taskType);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
if (StringUtils.isNotBlank(subject) && subject.contains("${OPERATOR}")) { if (StringUtils.isNotBlank(subject) && subject.contains("${OPERATOR}")) {
@ -298,7 +285,6 @@ public class MessageTemplateUtils {
addCustomFiled(taskType, customFielddMap, map); addCustomFiled(taskType, customFielddMap, map);
return getContent(subject, map); return getContent(subject, map);
} }
}
} }