fix(测试跟踪): 功能用例导出多选成员为空
--bug=1016183 --user=陈建星 【测试跟踪】功能用例包含自定义字段,字段类型是多选成员,导出后该字段内容是空 {#_orginal_url#}
This commit is contained in:
parent
3604de7210
commit
70873d5c9b
|
@ -1551,8 +1551,9 @@ public class TestCaseService {
|
|||
List<TestCaseExcelData> list = new ArrayList<>();
|
||||
Map<String, Map<String, String>> customSelectValueMap = new HashMap<>();
|
||||
Map<String, String> customNameMap = new HashMap<>();
|
||||
String projectId = testCaseList.get(0).getProjectId();
|
||||
TestCaseTemplateService testCaseTemplateService = CommonBeanFactory.getBean(TestCaseTemplateService.class);
|
||||
TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(testCaseList.get(0).getProjectId());
|
||||
TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(projectId);
|
||||
|
||||
List<CustomFieldDao> customFieldList;
|
||||
if (testCaseTemplate == null) {
|
||||
|
@ -1562,7 +1563,11 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
Set<String> textFields = new HashSet<>();
|
||||
buildExportCustomFieldMap(customSelectValueMap, customNameMap, customFieldList, textFields);
|
||||
Map<String, String> userMap = userService.getProjectMemberOption(projectId)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(User::getId, User::getName));
|
||||
|
||||
buildExportCustomFieldMap(userMap, customSelectValueMap, customNameMap, customFieldList, textFields);
|
||||
|
||||
for (int rowIndex = 0; rowIndex < testCaseList.size(); rowIndex++) {
|
||||
TestCaseDTO t = testCaseList.get(rowIndex);
|
||||
|
@ -1572,6 +1577,7 @@ public class TestCaseService {
|
|||
|
||||
setExportSystemField(t, customNameMap, customSelectValueMap);
|
||||
BeanUtils.copyBean(data, t);
|
||||
data.setMaintainer(userMap.get(data.getMaintainer()));
|
||||
buildExportCustomNum(isUseCustomId, t, data);
|
||||
buildExportStep(t, stepDescList, stepResultList, data);
|
||||
buildExportCustomField(customSelectValueMap, customNameMap, t, data, textFields);
|
||||
|
@ -1715,8 +1721,8 @@ public class TestCaseService {
|
|||
}
|
||||
}
|
||||
|
||||
private void buildExportCustomFieldMap(Map<String, Map<String, String>> customSelectValueMap, Map<String, String> customNameMap,
|
||||
List<CustomFieldDao> customFieldList, Set<String> textFields) {
|
||||
private void buildExportCustomFieldMap(Map<String, String> userMap, Map<String, Map<String, String>> customSelectValueMap,
|
||||
Map<String, String> customNameMap, List<CustomFieldDao> customFieldList, Set<String> textFields) {
|
||||
for (CustomFieldDao dto : customFieldList) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (CustomFieldType.getHasOptionValueSet().contains(dto.getType())) {
|
||||
|
@ -1744,7 +1750,11 @@ public class TestCaseService {
|
|||
if (StringUtils.equalsAny(dto.getType(), CustomFieldType.TEXTAREA.getValue(), CustomFieldType.RICH_TEXT.getValue())) {
|
||||
textFields.add(dto.getId());
|
||||
}
|
||||
customSelectValueMap.put(dto.getId(), map);
|
||||
if (StringUtils.equalsAny(dto.getType(), CustomFieldType.MULTIPLE_MEMBER.getValue(), CustomFieldType.MEMBER.getValue())) {
|
||||
customSelectValueMap.put(dto.getId(), userMap);
|
||||
} else {
|
||||
customSelectValueMap.put(dto.getId(), map);
|
||||
}
|
||||
customNameMap.put(dto.getId(), dto.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator {
|
|||
this.isKVOption = true;
|
||||
UserService userService = CommonBeanFactory.getBean(UserService.class);
|
||||
List<User> memberOption = userService.getProjectMemberOption(SessionUtils.getCurrentProjectId());
|
||||
userIdMap = memberOption.stream().collect(Collectors.toMap(User::getId, User::getName));
|
||||
userNameMap = memberOption.stream().collect(Collectors.toMap(User::getName, User::getId));
|
||||
userIdMap = memberOption.stream().collect(Collectors.toMap(user -> user.getId().toLowerCase(), user -> user.getName().toLowerCase()));
|
||||
userNameMap = memberOption.stream().collect(Collectors.toMap(user -> user.getName().toLowerCase(), user -> user.getId().toLowerCase()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,8 +41,8 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator {
|
|||
|
||||
@Override
|
||||
public Object parse2Key(String keyOrValue, CustomFieldDao customField) {
|
||||
if (userNameMap.containsKey(keyOrValue)) {
|
||||
return userNameMap.get(keyOrValue);
|
||||
if (userNameMap.containsKey(keyOrValue.toLowerCase())) {
|
||||
return userNameMap.get(keyOrValue.toLowerCase());
|
||||
}
|
||||
return keyOrValue;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.metersphere.track.validate;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.metersphere.commons.exception.CustomFieldValidateException;
|
||||
import io.metersphere.dto.CustomFieldDao;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
@ -34,7 +33,7 @@ public class CustomFieldMultipleMemberValidator extends CustomFieldMemberValidat
|
|||
List<String> keyOrValues = parse2Array(keyOrValuesStr);
|
||||
|
||||
for (int i = 0; i < keyOrValues.size(); i++) {
|
||||
String item = keyOrValues.get(i);
|
||||
String item = keyOrValues.get(i).toLowerCase();
|
||||
if (userNameMap.containsKey(item)) {
|
||||
keyOrValues.set(i, userNameMap.get(item));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue