fix(测试跟踪): 功能用例兼容旧模板的责任人

--bug=1020164 --user=陈建星 【测试跟踪】测试用例-导入旧模版用例-导入后责任人为空 https://www.tapd.cn/55049933/s/1303172
This commit is contained in:
chenjianxing 2022-11-23 18:01:16 +08:00 committed by 刘瑞斌
parent 941a9966f8
commit a2e203d33f
1 changed files with 6 additions and 2 deletions

View File

@ -398,6 +398,10 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
Map<String, Object> customData = data.getCustomData(); Map<String, Object> customData = data.getCustomData();
for (String fieldName : customData.keySet()) { for (String fieldName : customData.keySet()) {
Object value = customData.get(fieldName); Object value = customData.get(fieldName);
String originFieldName = fieldName;
if (TestCaseImportFiled.MAINTAINER.getFiledLangMap().containsValue(fieldName.replace("(ID)", StringUtils.EMPTY))) {
fieldName = fieldName.replace("(ID)", StringUtils.EMPTY); // 兼容旧模板的 责任人(ID)
}
CustomFieldDao customField = customFieldsMap.get(fieldName); CustomFieldDao customField = customFieldsMap.get(fieldName);
if (customField == null) { if (customField == null) {
continue; continue;
@ -407,7 +411,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
customFieldValidator.validate(customField, value.toString()); customFieldValidator.validate(customField, value.toString());
if (customFieldValidator.isKVOption) { if (customFieldValidator.isKVOption) {
// 这里如果填的是选项值替换成选项ID保存 // 这里如果填的是选项值替换成选项ID保存
customData.put(fieldName, customFieldValidator.parse2Key(value.toString(), customField)); customData.put(originFieldName, customFieldValidator.parse2Key(value.toString(), customField));
} }
if (StringUtils.equalsAny(customField.getType(), CustomFieldType.TEXTAREA.getValue(), CustomFieldType.RICH_TEXT.getValue())) { if (StringUtils.equalsAny(customField.getType(), CustomFieldType.TEXTAREA.getValue(), CustomFieldType.RICH_TEXT.getValue())) {
data.getTextFieldSet().add(fieldName); data.getTextFieldSet().add(fieldName);
@ -420,7 +424,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.PRIORITY.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) { } else if (StringUtils.equals(fieldName, TestCaseImportFiled.PRIORITY.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
data.setPriority(customData.get(fieldName).toString()); data.setPriority(customData.get(fieldName).toString());
} else if (StringUtils.equals(fieldName, TestCaseImportFiled.MAINTAINER.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) { } else if (StringUtils.equals(fieldName, TestCaseImportFiled.MAINTAINER.getFiledLangMap().get(Locale.SIMPLIFIED_CHINESE))) {
data.setMaintainer(customData.get(fieldName).toString()); data.setMaintainer(customData.get(originFieldName).toString());
} }
} }
} }