fix(测试用例): 修复一直在导出中问题

This commit is contained in:
WangXu10 2024-08-14 17:41:56 +08:00 committed by 刘瑞斌
parent 1021bb4c56
commit 4e91ace3ce
7 changed files with 12 additions and 9 deletions

View File

@ -71,7 +71,7 @@ public class FunctionalCaseCheckEventListener extends AnalysisEventListener<Map<
excelDataClass = clazz;
//当前项目模板的自定义字段
customFieldsMap = customFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldName, i -> i));
customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap();
customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId());
functionalCaseService = CommonBeanFactory.getBean(FunctionalCaseService.class);
}

View File

@ -95,7 +95,7 @@ public class FunctionalCaseImportEventListener extends AnalysisEventListener<Map
customFieldsMap = customFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldName, i -> i));
moduleTree = CommonBeanFactory.getBean(FunctionalCaseModuleService.class).getTree(request.getProjectId());
functionalCaseService = CommonBeanFactory.getBean(FunctionalCaseService.class);
customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap();
customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId());
lastPos = new AtomicLong(pos);
this.user = user;

View File

@ -7,7 +7,6 @@ import io.metersphere.sdk.util.CommonBeanFactory;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
import io.metersphere.system.utils.SessionUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
@ -25,9 +24,12 @@ public class CustomFieldMemberValidator extends AbstractCustomFieldValidator {
protected Map<String, String> userNameMap;
public CustomFieldMemberValidator() {
}
public CustomFieldMemberValidator(String projectId) {
this.isKVOption = true;
ProjectApplicationService projectApplicationService = CommonBeanFactory.getBean(ProjectApplicationService.class);
List<User> memberOption = projectApplicationService.getProjectUserList(SessionUtils.getCurrentProjectId());
List<User> memberOption = projectApplicationService.getProjectUserList(projectId);
userIdMap = memberOption.stream()
.collect(
Collectors.toMap(user -> user.getId().toLowerCase(), User::getId)

View File

@ -11,7 +11,8 @@ import java.util.HashMap;
public class CustomFieldValidatorFactory {
private static final HashMap<String, AbstractCustomFieldValidator> validatorMap = new HashMap<>();
public static HashMap<String, AbstractCustomFieldValidator> getValidatorMap() {
public static HashMap<String, AbstractCustomFieldValidator> getValidatorMap(String projectId) {
validatorMap.put(CustomFieldType.SELECT.name(), new CustomFieldSelectValidator());
validatorMap.put(CustomFieldType.SELECT.name(), new CustomFieldSelectValidator());
validatorMap.put(CustomFieldType.RADIO.name(), new CustomFieldSelectValidator());
@ -27,7 +28,7 @@ public class CustomFieldValidatorFactory {
validatorMap.put(CustomFieldType.DATE.name(), new CustomFieldDateValidator());
validatorMap.put(CustomFieldType.DATETIME.name(), new CustomFieldDateTimeValidator());
validatorMap.put(CustomFieldType.MEMBER.name(), new CustomFieldMemberValidator());
validatorMap.put(CustomFieldType.MEMBER.name(), new CustomFieldMemberValidator(projectId));
validatorMap.put(CustomFieldType.MULTIPLE_MEMBER.name(), new CustomFieldMultipleMemberValidator());
validatorMap.put(CustomFieldType.INT.name(), new CustomFieldIntegerValidator());

View File

@ -755,7 +755,7 @@ public class FunctionalCaseFileService {
if (CollectionUtils.isEmpty(request.getCustomFields())) {
return;
}
HashMap<String, AbstractCustomFieldValidator> customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap();
HashMap<String, AbstractCustomFieldValidator> customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId());
Map<String, TemplateCustomFieldDTO> customFieldsMap = templateCustomFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldId, i -> i));
Map<String, String> caseFieldvalueMap = functionalCaseCustomFields.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getFieldId, FunctionalCaseCustomField::getValue));
Map<String, Object> map = new HashMap<>();

View File

@ -72,7 +72,7 @@ public class XMindCaseParser {
customFieldsMap = customFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldName, i -> i));
functionalCaseService = CommonBeanFactory.getBean(FunctionalCaseService.class);
moduleTree = CommonBeanFactory.getBean(FunctionalCaseModuleService.class).getTree(request.getProjectId());
customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap();
customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId());
lastPos = new AtomicLong(pos);
this.user = user;
process = new DetailUtil();

View File

@ -518,7 +518,7 @@ public class XmindExportUtil {
//自定义字段
Map<String, String> customColumnsMap = request.getCustomFields().stream().collect(Collectors.toMap(FunctionalCaseHeader::getId, FunctionalCaseHeader::getName));
Map<String, TemplateCustomFieldDTO> temCustomFieldsMap = templateCustomFields.stream().collect(Collectors.toMap(TemplateCustomFieldDTO::getFieldId, i -> i));
HashMap<String, AbstractCustomFieldValidator> customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap();
HashMap<String, AbstractCustomFieldValidator> customFieldValidatorMap = CustomFieldValidatorFactory.getValidatorMap(request.getProjectId());
customColumnsMap.forEach((k, v) -> {
if (customFieldMap.containsKey(k) && temCustomFieldsMap.containsKey(k)) {