fix(测试跟踪): 用例导出缺少责任人字段
This commit is contained in:
parent
5ff9bd0461
commit
c620f5e2dd
|
@ -1,28 +1,64 @@
|
||||||
package io.metersphere.excel.constants;
|
package io.metersphere.excel.constants;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
|
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
public enum TestCaseImportFiled {
|
public enum TestCaseImportFiled {
|
||||||
|
|
||||||
ID("ID", "ID", "ID"), NAME("用例名称", "用例名稱", "Name"), MODULE("所属模块", "所屬模塊", "Module"),
|
ID("ID", "ID", "ID", TestCaseExcelData::getCustomNum),
|
||||||
TAG("标签", "標簽", "Tag"), PREREQUISITE("前置条件", "前置條件", "Prerequisite"), REMARK("备注", "備註", "Remark"),
|
NAME("用例名称", "用例名稱", "Name", TestCaseExcelData::getName),
|
||||||
STEP_DESC("步骤描述", "步驟描述", "Step description"), STEP_RESULT("预期结果", "預期結果", "Step result"), STEP_MODEL("编辑模式", "編輯模式", "Edit Model"),
|
MODULE("所属模块", "所屬模塊", "Module", TestCaseExcelData::getNodePath),
|
||||||
STATUS("用例状态", "用例狀態", "Case status"), MAINTAINER("责任人", "責任人", "Maintainer"), PRIORITY("用例等级", "用例等級", "Priority");
|
TAG("标签", "標簽", "Tag", TestCaseImportFiled::parseTags),
|
||||||
|
PREREQUISITE("前置条件", "前置條件", "Prerequisite", TestCaseExcelData::getPrerequisite),
|
||||||
|
REMARK("备注", "備註", "Remark", TestCaseExcelData::getRemark),
|
||||||
|
STEP_DESC("步骤描述", "步驟描述", "Step description", TestCaseExcelData::getStepDesc),
|
||||||
|
STEP_RESULT("预期结果", "預期結果", "Step result", TestCaseExcelData::getStepResult),
|
||||||
|
STEP_MODEL("编辑模式", "編輯模式", "Edit Model", TestCaseExcelData::getStepModel),
|
||||||
|
STATUS("用例状态", "用例狀態", "Case status", TestCaseExcelData::getStatus),
|
||||||
|
MAINTAINER("责任人", "責任人", "Maintainer", TestCaseExcelData::getMaintainer),
|
||||||
|
PRIORITY("用例等级", "用例等級", "Priority", TestCaseExcelData::getPriority);
|
||||||
|
|
||||||
private Map<Locale, String> filedLangMap;
|
private Map<Locale, String> filedLangMap;
|
||||||
|
private Function<TestCaseExcelData, String> parseFunc;
|
||||||
|
|
||||||
public Map<Locale, String> getFiledLangMap() {
|
public Map<Locale, String> getFiledLangMap() {
|
||||||
return this.filedLangMap;
|
return this.filedLangMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCaseImportFiled(String zn, String chineseTw, String us) {
|
TestCaseImportFiled(String zn, String chineseTw, String us, Function<TestCaseExcelData, String> parseFunc) {
|
||||||
this.filedLangMap = new HashMap<>() {{
|
this.filedLangMap = new HashMap<>() {{
|
||||||
put(Locale.SIMPLIFIED_CHINESE, zn);
|
put(Locale.SIMPLIFIED_CHINESE, zn);
|
||||||
put(Locale.TRADITIONAL_CHINESE, chineseTw);
|
put(Locale.TRADITIONAL_CHINESE, chineseTw);
|
||||||
put(Locale.US, us);
|
put(Locale.US, us);
|
||||||
}};
|
}};
|
||||||
|
this.parseFunc = parseFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String parseExcelDataValue(TestCaseExcelData excelData) {
|
||||||
|
return parseFunc.apply(excelData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String parseTags(TestCaseExcelData excelData) {
|
||||||
|
String tags = "";
|
||||||
|
try {
|
||||||
|
if (excelData.getTags() != null) {
|
||||||
|
JSONArray arr = JSONArray.parseArray(excelData.getTags());
|
||||||
|
if (CollectionUtils.isNotEmpty(arr)) {
|
||||||
|
tags = StringUtils.joinWith(",", arr.toArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class TestCaseExcelData {
|
||||||
if (StringUtils.equalsAny(dto.getName(),
|
if (StringUtils.equalsAny(dto.getName(),
|
||||||
TestCaseImportFiled.PRIORITY.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE),
|
TestCaseImportFiled.PRIORITY.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE),
|
||||||
TestCaseImportFiled.STATUS.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE),
|
TestCaseImportFiled.STATUS.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE),
|
||||||
TestCaseImportFiled.MAINTAINER.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE).concat("(ID)"))) {
|
TestCaseImportFiled.MAINTAINER.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
heads.add(new ArrayList<>() {{
|
heads.add(new ArrayList<>() {{
|
||||||
|
|
|
@ -24,13 +24,13 @@ import io.metersphere.base.mapper.ext.ExtProjectVersionMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.controller.request.OrderRequest;
|
import io.metersphere.controller.request.OrderRequest;
|
||||||
import io.metersphere.controller.request.ProjectVersionRequest;
|
import io.metersphere.controller.request.ProjectVersionRequest;
|
||||||
import io.metersphere.controller.request.ResetOrderRequest;
|
import io.metersphere.controller.request.ResetOrderRequest;
|
||||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||||
import io.metersphere.dto.*;
|
import io.metersphere.dto.*;
|
||||||
|
import io.metersphere.excel.constants.TestCaseImportFiled;
|
||||||
import io.metersphere.excel.domain.*;
|
import io.metersphere.excel.domain.*;
|
||||||
import io.metersphere.excel.handler.FunctionCaseMergeWriteHandler;
|
import io.metersphere.excel.handler.FunctionCaseMergeWriteHandler;
|
||||||
import io.metersphere.excel.handler.FunctionCaseTemplateWriteHandler;
|
import io.metersphere.excel.handler.FunctionCaseTemplateWriteHandler;
|
||||||
|
@ -1422,46 +1422,24 @@ public class TestCaseService {
|
||||||
for (TestCaseExcelData model : data) {
|
for (TestCaseExcelData model : data) {
|
||||||
List<Object> fields = new ArrayList<>();
|
List<Object> fields = new ArrayList<>();
|
||||||
Map<String, String> customDataMaps = Optional.ofNullable(model.getCustomDatas()).orElse(new HashMap<>());
|
Map<String, String> customDataMaps = Optional.ofNullable(model.getCustomDatas()).orElse(new HashMap<>());
|
||||||
|
TestCaseImportFiled[] importFields = TestCaseImportFiled.values();
|
||||||
|
|
||||||
for (String head : headList) {
|
for (String head : headList) {
|
||||||
if (StringUtils.equalsAnyIgnoreCase(head, "ID")) {
|
boolean isSystemField = false;
|
||||||
fields.add(model.getCustomNum());
|
for (TestCaseImportFiled importFiled : importFields) {
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Name", "用例名稱", "用例名称")) {
|
if (importFiled.getFiledLangMap().values().contains(head)) {
|
||||||
fields.add(model.getName());
|
fields.add(importFiled.parseExcelDataValue(model));
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Module", "所屬模塊", "所属模块")) {
|
isSystemField = true;
|
||||||
fields.add(model.getNodePath());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Tag", "標簽", "标签")) {
|
|
||||||
String tags = "";
|
|
||||||
try {
|
|
||||||
if (model.getTags() != null) {
|
|
||||||
JSONArray arr = JSONArray.parseArray(model.getTags());
|
|
||||||
for (int i = 0; i < arr.size(); i++) {
|
|
||||||
tags += arr.getString(i) + ",";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
if (!isSystemField) {
|
||||||
|
String value = customDataMaps.get(head);
|
||||||
|
if (value == null) {
|
||||||
|
value = "";
|
||||||
}
|
}
|
||||||
fields.add(tags);
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Prerequisite", "前置條件", "前置条件")) {
|
|
||||||
fields.add(model.getPrerequisite());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Remark", "備註", "备注")) {
|
|
||||||
fields.add(model.getRemark());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Step description", "步驟描述", "步骤描述")) {
|
|
||||||
fields.add(model.getStepDesc());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Step result", "預期結果", "预期结果")) {
|
|
||||||
fields.add(model.getStepResult());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Edit Model", "編輯模式", "编辑模式")) {
|
|
||||||
fields.add(model.getStepModel());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Priority", "用例等級", "用例等级")) {
|
|
||||||
fields.add(model.getPriority());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Case status", "用例状态", "用例狀態")) {
|
|
||||||
fields.add(model.getStatus());
|
|
||||||
} else if (StringUtils.equalsAnyIgnoreCase(head, "Maintainer(ID)", "责任人(ID)", "維護人(ID)")) {
|
|
||||||
fields.add(model.getMaintainer());
|
|
||||||
} else {
|
|
||||||
String value = Optional.ofNullable(customDataMaps.get(head)).orElse("");
|
|
||||||
fields.add(value);
|
fields.add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
result.add(fields);
|
result.add(fields);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue