refactor(用例管理): 修改脑图的枚举类型

This commit is contained in:
guoyuqi 2024-05-13 19:33:27 +08:00 committed by Craftsman
parent d594b278cc
commit 99567c9797
10 changed files with 146 additions and 110 deletions

View File

@ -93,6 +93,14 @@ minder_extra_node.group_id.length_range=项目ID长度必须在1-50之间
minder_extra_node.group_id.not_blank=项目ID不能为空
minder_extra_node.type.length_range=类型长度必须在1-30之间
minder_extra_node.type.not_blank=类型不能为空
minder_extra_node.case=用例
minder_extra_node.module=模块
minder_extra_node.prerequisite=前置条件
minder_extra_node.steps=步骤描述
minder_extra_node.steps_expected_result=预期结果
minder_extra_node.text_description=文本描述
minder_extra_node.text_expected_result=预期结果
minder_extra_node.description=备注信息
#moduleCaseReview
case_review.id.not_blank=ID不能为空
case_review.name.length_range=名称长度必须在1-200之间

View File

@ -129,6 +129,14 @@ minder_extra_node.group_id.length_range=The length of the group ID must be betwe
minder_extra_node.group_id.not_blank=Group ID cannot be empty
minder_extra_node.type.length_range=The length of the node type must be between 1 and 30
minder_extra_node.type.not_blank=Node type cannot be empty
minder_extra_node.case=Case
minder_extra_node.module=Module
minder_extra_node.prerequisite=Prerequisite
minder_extra_node.steps=Steps
minder_extra_node.steps_expected_result=ExpectedResult
minder_extra_node.text_description=TextDescription
minder_extra_node.text_expected_result=ExpectedResult
minder_extra_node.description=Description
#moduleCaseReview
case_review.id.not_blank=ID cannot be empty
case_review.name.length_range=The name length must be between 1 and 200

View File

@ -128,6 +128,14 @@ minder_extra_node.group_id.length_range=项目ID长度必须在1-50之间
minder_extra_node.group_id.not_blank=项目ID不能为空
minder_extra_node.type.length_range=类型长度必须在1-30之间
minder_extra_node.type.not_blank=类型不能为空
minder_extra_node.case=用例
minder_extra_node.module=模块
minder_extra_node.prerequisite=前置条件
minder_extra_node.steps=步骤描述
minder_extra_node.steps_expected_result=预期结果
minder_extra_node.text_description=文本描述
minder_extra_node.text_expected_result=预期结果
minder_extra_node.description=备注信息
#moduleCaseReview
case_review.id.not_blank=ID不能为空
case_review.name.length_range=名称长度必须在1-200之间

View File

@ -129,6 +129,14 @@ minder_extra_node.group_id.length_range=項目ID長度必須在1-50之間
minder_extra_node.group_id.not_blank=項目ID不能為空
minder_extra_node.type.length_range=類型長度必須在1-30之間
minder_extra_node.type.not_blank=類型不能為空
minder_extra_node.case=用例
minder_extra_node.module=模塊
minder_extra_node.prerequisite=前置條件
minder_extra_node.steps=步驟描述
minder_extra_node.steps_expected_result=預期結果
minder_extra_node.text_description=文字描述
minder_extra_node.text_expected_result=預期結果
minder_extra_node.description=備註資訊
#moduleCaseReview
case_review.id.not_blank=ID不能為空
case_review.name.length_range=名稱長度必須在1-200之間

View File

@ -28,7 +28,7 @@ public class FunctionalMinderTreeNodeDTO {
@Schema(description = "节点标签")
private List<String> resource;
@Schema(description = "节点标签")
@Schema(description = "节点状态")
private String expandState = "expand";
}

View File

@ -1,6 +1,5 @@
package io.metersphere.functional.request;
import io.metersphere.functional.constants.MinderLabel;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@ -26,7 +25,7 @@ public class FunctionalCaseMinderEditRequest{
private Long pos;
@Schema(description = "资源类型")
private MinderLabel type;
private String type;
@Schema(description = "用例等级(只更新用例的等级时传)")
private String priority;

View File

@ -4,7 +4,6 @@ import io.metersphere.bug.domain.Bug;
import io.metersphere.bug.domain.BugRelationCase;
import io.metersphere.bug.mapper.BugMapper;
import io.metersphere.bug.mapper.BugRelationCaseMapper;
import io.metersphere.functional.constants.MinderLabel;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
import io.metersphere.functional.dto.FunctionalCaseHistoryLogDTO;
@ -17,6 +16,7 @@ import io.metersphere.project.mapper.FileAssociationMapper;
import io.metersphere.sdk.constants.HttpMethodConstants;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.CustomField;
import io.metersphere.system.domain.CustomFieldExample;
import io.metersphere.system.log.constants.OperationLogModule;
@ -227,12 +227,12 @@ public class FunctionalCaseLogService {
String path = "/functional/mind/case/batch/delete/";
List<String> caseAllIds = new ArrayList<>();
Map<String, List<MinderOptionDTO>> resourceMap = resourceList.stream().collect(Collectors.groupingBy(MinderOptionDTO::getType));
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(MinderLabel.CASE.toString());
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.case"));
if (CollectionUtils.isNotEmpty(caseOptionDTOS)) {
List<String> caseIds = caseOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
caseAllIds.addAll(caseIds);
}
List<MinderOptionDTO> moduleOptionDTOS = resourceMap.get(MinderLabel.MODULE.toString());
List<MinderOptionDTO> moduleOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.module"));
if (CollectionUtils.isNotEmpty(moduleOptionDTOS)) {
List<String> moduleIds = moduleOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
List<FunctionalCase> functionalCaseByModuleIds = getFunctionalCaseByModuleIds(moduleIds, new ArrayList<>());
@ -244,7 +244,7 @@ public class FunctionalCaseLogService {
List<LogDTO>logDTOS = new ArrayList<>();
List<String>ids = new ArrayList<>();
for (String key : strings) {
if (StringUtils.equalsIgnoreCase(key, MinderLabel.CASE.toString()) || StringUtils.equalsIgnoreCase(key, MinderLabel.MODULE.toString())) {
if (StringUtils.equalsIgnoreCase(key, Translator.get("minder_extra_node.case")) || StringUtils.equalsIgnoreCase(key, Translator.get("minder_extra_node.module"))) {
List<LogDTO> logDTOS1 = batchDeleteFunctionalCaseLogByIds(caseAllIds, path);
logDTOS.addAll(logDTOS1);
} else {
@ -508,7 +508,7 @@ public class FunctionalCaseLogService {
}
public LogDTO updateMinderFunctionalCaseLog(FunctionalCaseMinderEditRequest request) {
if (request.getType() == MinderLabel.MODULE) {
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.module"))) {
return null;
}
FunctionalCaseHistoryLogDTO historyLogDTO = getOriginalValue(request.getId());

View File

@ -1,7 +1,6 @@
package io.metersphere.functional.service;
import io.metersphere.functional.constants.FunctionalCaseTypeConstants;
import io.metersphere.functional.constants.MinderLabel;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.*;
import io.metersphere.functional.mapper.*;
@ -111,7 +110,7 @@ public class FunctionalCaseMinderService {
rootData.setText(functionalCaseMindDTO.getName());
rootData.setPriority(functionalCaseMindDTO.getPriority());
rootData.setStatus(functionalCaseMindDTO.getReviewStatus());
rootData.setResource(List.of(MinderLabel.CASE.toString(), functionalCaseMindDTO.getPriority()));
rootData.setResource(List.of(Translator.get("minder_extra_node.case")));
List<FunctionalMinderTreeDTO> children = buildChildren(functionalCaseMindDTO);
root.setChildren(children);
root.setData(rootData);
@ -124,19 +123,19 @@ public class FunctionalCaseMinderService {
List<FunctionalMinderTreeDTO> children = new ArrayList<>();
if (functionalCaseMindDTO.getPrerequisite() != null) {
String prerequisiteText = new String(functionalCaseMindDTO.getPrerequisite(), StandardCharsets.UTF_8);
FunctionalMinderTreeDTO prerequisiteFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(prerequisiteText, MinderLabel.PREREQUISITE.toString(), 0L);
FunctionalMinderTreeDTO prerequisiteFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(prerequisiteText, Translator.get("minder_extra_node.prerequisite"), 0L);
children.add(prerequisiteFunctionalMinderTreeDTO);
}
if (StringUtils.equalsIgnoreCase(functionalCaseMindDTO.getCaseEditType(), FunctionalCaseTypeConstants.CaseEditType.TEXT.name()) && functionalCaseMindDTO.getTextDescription() != null) {
String textDescription = new String(functionalCaseMindDTO.getTextDescription(), StandardCharsets.UTF_8);
FunctionalMinderTreeDTO stepFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(textDescription, MinderLabel.TEXT_DESCRIPTION.toString(), 1L);
FunctionalMinderTreeDTO stepFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(textDescription, Translator.get("minder_extra_node.text_description"), 1L);
if (functionalCaseMindDTO.getExpectedResult() != null) {
String expectedResultText = new String(functionalCaseMindDTO.getExpectedResult(), StandardCharsets.UTF_8);
FunctionalMinderTreeDTO expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(expectedResultText, MinderLabel.TEXT_EXPECTED_RESULT.toString(), 1L);
FunctionalMinderTreeDTO expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(expectedResultText, Translator.get("minder_extra_node.text_expected_result"), 1L);
stepFunctionalMinderTreeDTO.getChildren().add(expectedResultFunctionalMinderTreeDTO);
} else {
FunctionalMinderTreeDTO expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO("", MinderLabel.TEXT_EXPECTED_RESULT.toString(), 1L);
FunctionalMinderTreeDTO expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO("", Translator.get("minder_extra_node.text_expected_result"), 1L);
stepFunctionalMinderTreeDTO.getChildren().add(expectedResultFunctionalMinderTreeDTO);
}
children.add(stepFunctionalMinderTreeDTO);
@ -148,13 +147,13 @@ public class FunctionalCaseMinderService {
List<FunctionalCaseStepDTO> functionalCaseStepDTOS = JSON.parseArray(stepText, FunctionalCaseStepDTO.class);
for (FunctionalCaseStepDTO functionalCaseStepDTO : functionalCaseStepDTOS) {
i = i + 1;
FunctionalMinderTreeDTO stepFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(functionalCaseStepDTO.getDesc(), MinderLabel.STEPS.toString(), Long.valueOf(functionalCaseStepDTO.getNum()));
FunctionalMinderTreeDTO stepFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(functionalCaseStepDTO.getDesc(), Translator.get("minder_extra_node.steps"), Long.valueOf(functionalCaseStepDTO.getNum()));
stepFunctionalMinderTreeDTO.getData().setId(functionalCaseStepDTO.getId());
FunctionalMinderTreeDTO expectedResultFunctionalMinderTreeDTO;
if (functionalCaseMindDTO.getExpectedResult() != null) {
expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(functionalCaseStepDTO.getResult(), MinderLabel.STEPS_EXPECTED_RESULT.toString(), Long.valueOf(functionalCaseStepDTO.getNum()));
expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(functionalCaseStepDTO.getResult(), Translator.get("minder_extra_node.steps_expected_result"), Long.valueOf(functionalCaseStepDTO.getNum()));
} else {
expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO("", MinderLabel.STEPS_EXPECTED_RESULT.toString(), Long.valueOf(functionalCaseStepDTO.getNum()));
expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO("", Translator.get("minder_extra_node.steps_expected_result"), Long.valueOf(functionalCaseStepDTO.getNum()));
}
stepFunctionalMinderTreeDTO.getChildren().add(expectedResultFunctionalMinderTreeDTO);
children.add(stepFunctionalMinderTreeDTO);
@ -164,7 +163,7 @@ public class FunctionalCaseMinderService {
if (functionalCaseMindDTO.getDescription() != null) {
String descriptionText = new String(functionalCaseMindDTO.getDescription(), StandardCharsets.UTF_8);
FunctionalMinderTreeDTO descriptionFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(descriptionText, MinderLabel.DESCRIPTION.toString(), (long) (i + 1));
FunctionalMinderTreeDTO descriptionFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(descriptionText, Translator.get("minder_extra_node.description"), (long) (i + 1));
children.add(descriptionFunctionalMinderTreeDTO);
}
return children;
@ -184,53 +183,55 @@ public class FunctionalCaseMinderService {
public void updateFunctionalCase(FunctionalCaseMinderEditRequest request, String userId) {
if (StringUtils.isNotBlank(request.getName())) {
switch (request.getType()) {
case CASE -> {
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setName(request.getName());
buildUpdateCaseParam(request.getId(), userId, functionalCase);
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
}
case MODULE -> {
FunctionalCaseModule functionalCaseModule = new FunctionalCaseModule();
functionalCaseModule.setName(request.getName());
buildUpdateCaseModuleParam(request.getId(), userId, functionalCaseModule);
functionalCaseModuleMapper.updateByPrimaryKeySelective(functionalCaseModule);
}
case PREREQUISITE -> {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setPrerequisite(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
case STEPS -> {
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey(request.getId());
updateSteps(request, functionalCaseBlob);
}
case STEPS_EXPECTED_RESULT -> {
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey(request.getId());
updateStepResult(request, functionalCaseBlob);
}
case TEXT_DESCRIPTION -> {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setTextDescription(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
case TEXT_EXPECTED_RESULT -> {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setExpectedResult(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
case DESCRIPTION -> {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setDescription(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
default -> {
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.case"))) {
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setName(request.getName());
buildUpdateCaseParam(request.getId(), userId, functionalCase);
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.module"))) {
FunctionalCaseModule functionalCaseModule = new FunctionalCaseModule();
functionalCaseModule.setName(request.getName());
buildUpdateCaseModuleParam(request.getId(), userId, functionalCaseModule);
functionalCaseModuleMapper.updateByPrimaryKeySelective(functionalCaseModule);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.prerequisite"))) {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setPrerequisite(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.steps"))) {
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey(request.getId());
updateSteps(request, functionalCaseBlob);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.steps_expected_result"))) {
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey(request.getId());
updateStepResult(request, functionalCaseBlob);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.text_description"))) {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setTextDescription(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.text_expected_result"))) {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setExpectedResult(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.steps_expected_result"))) {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setExpectedResult(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.description"))) {
FunctionalCaseBlob functionalCaseBlob = new FunctionalCaseBlob();
functionalCaseBlob.setId(request.getId());
functionalCaseBlob.setDescription(StringUtils.defaultIfBlank(request.getName(), StringUtils.EMPTY).getBytes(StandardCharsets.UTF_8));
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlob);
}
}
if (StringUtils.isNotBlank(request.getPriority())) {
@ -295,11 +296,11 @@ public class FunctionalCaseMinderService {
Map<String, List<MinderOptionDTO>> resourceMap = resourceList.stream().collect(Collectors.groupingBy(MinderOptionDTO::getType));
MinderTargetDTO caseMinderTargetDTO = request.getCaseMinderTargetDTO();
MinderTargetDTO moduleMinderTargetDTO = request.getModuleMinderTargetDTO();
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(MinderLabel.CASE.toString());
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.case"));
List<String> caseIds = new ArrayList<>();
caseIds = checkPermission(caseOptionDTOS, caseIds, FUNCTIONAL_CASE, userId);
List<String> moduleIds = new ArrayList<>();
List<MinderOptionDTO> moduleOptionDTOS = resourceMap.get(MinderLabel.MODULE.toString());
List<MinderOptionDTO> moduleOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.module"));
moduleIds = checkPermission(moduleOptionDTOS, moduleIds, FUNCTIONAL_CASE_MODULE, userId);
if (StringUtils.isNotBlank(request.getParentTargetId()) ) {
//移动到某节点下
@ -434,7 +435,7 @@ public class FunctionalCaseMinderService {
Map<String, List<MinderOptionDTO>> resourceMap = resourceList.stream().collect(Collectors.groupingBy(MinderOptionDTO::getType));
User user = userMapper.selectByPrimaryKey(userId);
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(MinderLabel.CASE.toString());
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.case"));
if (CollectionUtils.isNotEmpty(caseOptionDTOS)) {
List<String> caseIds = caseOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
if (!extCheckOwnerMapper.checkoutOwner(FUNCTIONAL_CASE, userId, caseIds)) {
@ -442,7 +443,7 @@ public class FunctionalCaseMinderService {
}
functionalCaseService.handDeleteFunctionalCase(caseIds, false, userId, projectId);
}
List<MinderOptionDTO> caseModuleOptionDTOS = resourceMap.get(MinderLabel.MODULE.toString());
List<MinderOptionDTO> caseModuleOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.module"));
if (CollectionUtils.isNotEmpty(caseModuleOptionDTOS)) {
List<String> moduleIds = caseModuleOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
if (!extCheckOwnerMapper.checkoutOwner(FUNCTIONAL_CASE_MODULE, userId, moduleIds)) {
@ -451,19 +452,19 @@ public class FunctionalCaseMinderService {
List<FunctionalCase> functionalCases = functionalCaseModuleService.deleteModuleByIds(moduleIds, new ArrayList<>(), userId);
functionalCaseModuleService.batchDelLog(functionalCases, projectId);
}
List<MinderOptionDTO> prerequisiteOptionDTOS = resourceMap.get(MinderLabel.PREREQUISITE.toString());
List<MinderOptionDTO> prerequisiteOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.prerequisite"));
updateBlob(userId, "prerequisite", prerequisiteOptionDTOS, projectId, user);
List<MinderOptionDTO> descriptionOptionDTOS = resourceMap.get(MinderLabel.DESCRIPTION.toString());
List<MinderOptionDTO> descriptionOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.description"));
updateBlob(userId, "description", descriptionOptionDTOS, projectId, user);
List<MinderOptionDTO> stepOptionDTOS = resourceMap.get(MinderLabel.STEPS.toString());
List<MinderOptionDTO> stepOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.steps"));
if (CollectionUtils.isNotEmpty(stepOptionDTOS)) {
List<MinderOptionDTO> stepResultOptionDTOS = resourceMap.get(MinderLabel.STEPS_EXPECTED_RESULT.toString());
List<MinderOptionDTO> stepResultOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.steps_expected_result"));
stepOptionDTOS.addAll(stepResultOptionDTOS);
updateBlob(userId, "steps", stepOptionDTOS, projectId, user);
}
List<MinderOptionDTO> textOptionDTOS = resourceMap.get(MinderLabel.TEXT_DESCRIPTION.toString());
List<MinderOptionDTO> textOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.text_description"));
updateBlob(userId, "text_description", textOptionDTOS, projectId, user);
List<MinderOptionDTO> resultOptionDTOS = resourceMap.get(MinderLabel.TEXT_EXPECTED_RESULT.toString());
List<MinderOptionDTO> resultOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.text_expected_result"));
updateBlob(userId, "expected_result", resultOptionDTOS, projectId, user);
}

View File

@ -1,6 +1,5 @@
package io.metersphere.functional.service;
import io.metersphere.functional.constants.MinderLabel;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.CaseCustomFieldDTO;
import io.metersphere.functional.dto.FunctionalCaseDTO;
@ -20,6 +19,7 @@ import io.metersphere.plan.mapper.TestPlanFunctionalCaseMapper;
import io.metersphere.plan.mapper.TestPlanMapper;
import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.CustomField;
import io.metersphere.system.domain.CustomFieldExample;
import io.metersphere.system.domain.User;
@ -147,10 +147,10 @@ public class FunctionalCaseNoticeService {
return optionDTOList;
}
public FunctionalCaseDTO getAddMainFunctionalCaseDTO(FunctionalCaseAddRequest request, List<CaseCustomFieldDTO> customFields){
public FunctionalCaseDTO getAddMainFunctionalCaseDTO(FunctionalCaseAddRequest request, List<CaseCustomFieldDTO> customFields) {
FunctionalCaseEditRequest editRequest = new FunctionalCaseEditRequest();
BeanUtils.copyBean(editRequest, request);
return getMainFunctionalCaseDTO(editRequest,customFields);
return getMainFunctionalCaseDTO(editRequest, customFields);
}
public FunctionalCaseDTO getMainFunctionalCaseDTO(FunctionalCaseEditRequest request, List<CaseCustomFieldDTO> customFields) {
@ -226,6 +226,7 @@ public class FunctionalCaseNoticeService {
setReviewName(id, functionalCaseDTO);
return functionalCaseDTO;
}
public Map<String, FunctionalCase> copyBaseCaseInfo(String projectId, List<String> ids) {
FunctionalCaseExample example = new FunctionalCaseExample();
example.createCriteria().andProjectIdEqualTo(projectId).andIdIn(ids);
@ -280,7 +281,7 @@ public class FunctionalCaseNoticeService {
functionalCaseDTO.setCreateUser(null);
functionalCaseDTO.setFields(optionDTOS.get());
List<CaseReviewFunctionalCase> caseReviewFunctionalCases1 = caseReviewMap.get(id);
List<String>reviewName = new ArrayList<>();
List<String> reviewName = new ArrayList<>();
if (CollectionUtils.isNotEmpty(caseReviewFunctionalCases1)) {
for (CaseReviewFunctionalCase caseReviewFunctionalCase : caseReviewFunctionalCases1) {
String s = finalReviewMap.get(caseReviewFunctionalCase.getReviewId());
@ -288,7 +289,7 @@ public class FunctionalCaseNoticeService {
}
}
List<TestPlanFunctionalCase> planFunctionalCases = casePlanMap.get(id);
List<String>planName = new ArrayList<>();
List<String> planName = new ArrayList<>();
if (CollectionUtils.isNotEmpty(planFunctionalCases)) {
for (TestPlanFunctionalCase planFunctionalCase : planFunctionalCases) {
String s = finalPlanMap.get(planFunctionalCase.getTestPlanId());
@ -308,9 +309,9 @@ public class FunctionalCaseNoticeService {
return dtoList;
}
public FunctionalCaseDTO getMainFunctionalCaseMinderDTO(FunctionalCaseMinderEditRequest request) {
public FunctionalCaseDTO getMainFunctionalCaseMinderDTO(FunctionalCaseMinderEditRequest request) {
FunctionalCaseDTO functionalCaseDTO = new FunctionalCaseDTO();
if (request.getType() == MinderLabel.MODULE) {
if (StringUtils.equalsIgnoreCase(request.getType(), Translator.get("minder_extra_node.module"))) {
return functionalCaseDTO;
}
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(request.getId());
@ -335,7 +336,7 @@ public class FunctionalCaseNoticeService {
continue;
}
optionDTO.setId(customField.getName());
if (StringUtils.equalsIgnoreCase(customField.getId(),field) && StringUtils.isNotBlank(request.getPriority())) {
if (StringUtils.equalsIgnoreCase(customField.getId(), field) && StringUtils.isNotBlank(request.getPriority())) {
optionDTO.setName(request.getPriority());
} else {
optionDTO.setName(customFieldDTO.getValue());

View File

@ -1,16 +1,19 @@
package io.metersphere.functional.controller;
import io.metersphere.functional.constants.MinderLabel;
import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
import io.metersphere.functional.dto.MinderOptionDTO;
import io.metersphere.functional.dto.MinderTargetDTO;
import io.metersphere.functional.mapper.*;
import io.metersphere.functional.mapper.FunctionalCaseBlobMapper;
import io.metersphere.functional.mapper.FunctionalCaseCustomFieldMapper;
import io.metersphere.functional.mapper.FunctionalCaseMapper;
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
import io.metersphere.functional.request.FunctionalCaseMindRequest;
import io.metersphere.functional.request.FunctionalCaseMinderEditRequest;
import io.metersphere.functional.request.FunctionalCaseMinderRemoveRequest;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.dto.sdk.enums.MoveTypeEnum;
@ -115,20 +118,20 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
request.setProjectId("project-case-minder-test");
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
request.setName("TEST_FUNCTIONAL_MINDER_CASE_ID_Change_Name");
request.setType(MinderLabel.CASE);
request.setType(Translator.get("minder_extra_node.case"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
Assertions.assertEquals(functionalCase.getName(), "TEST_FUNCTIONAL_MINDER_CASE_ID_Change_Name");
request.setName("TEST_MINDER_MODULE_ID_GYQ5_Change_Name");
request.setId("TEST_MINDER_MODULE_ID_GYQ5");
request.setType(MinderLabel.MODULE);
request.setType(Translator.get("minder_extra_node.module"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
FunctionalCaseModule functionalCaseModule = functionalCaseModuleMapper.selectByPrimaryKey("TEST_MINDER_MODULE_ID_GYQ5");
Assertions.assertEquals(functionalCaseModule.getName(), "TEST_MINDER_MODULE_ID_GYQ5_Change_Name");
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
request.setName("前置哈哈哈");
request.setType(MinderLabel.PREREQUISITE);
request.setType(Translator.get("minder_extra_node.prerequisite"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
FunctionalCaseBlob functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
Assertions.assertEquals(new String(functionalCaseBlob.getPrerequisite(), StandardCharsets.UTF_8), "前置哈哈哈");
@ -140,7 +143,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseBlobMapper.updateByPrimaryKeySelective(functionalCaseBlobInDB);
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
request.setName("步骤哈哈哈");
request.setType(MinderLabel.STEPS);
request.setType(Translator.get("minder_extra_node.steps"));
request.setPos(1L);
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
@ -153,7 +156,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
});
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
request.setName("步骤结果哈哈哈");
request.setType(MinderLabel.STEPS_EXPECTED_RESULT);
request.setType(Translator.get("minder_extra_node.steps_expected_result"));
request.setPos(1L);
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
@ -166,17 +169,17 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
});
request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
request.setName("文本哈哈哈");
request.setType(MinderLabel.TEXT_DESCRIPTION);
request.setType(Translator.get("minder_extra_node.text_description"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
Assertions.assertEquals(new String(functionalCaseBlob.getTextDescription(), StandardCharsets.UTF_8), "文本哈哈哈");request.setId("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
request.setName("预期哈哈哈");
request.setType(MinderLabel.TEXT_EXPECTED_RESULT);
request.setType(Translator.get("minder_extra_node.text_expected_result"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
Assertions.assertEquals(new String(functionalCaseBlob.getExpectedResult(), StandardCharsets.UTF_8), "预期哈哈哈");
request.setName("备注哈哈哈");
request.setType(MinderLabel.DESCRIPTION);
request.setType(Translator.get("minder_extra_node.description"));
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_UPDATE_NAME_URL, request);
functionalCaseBlob = functionalCaseBlobMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
Assertions.assertEquals(new String(functionalCaseBlob.getDescription(), StandardCharsets.UTF_8), "备注哈哈哈");
@ -200,16 +203,16 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
public void testDeleteCase() throws Exception{
List<MinderOptionDTO> resourceList = new ArrayList<>();
this.requestPost(FUNCTIONAL_CASE_BATCH_DELETE+"/project-case-minder-test", resourceList).andExpect(status().is5xxServerError());
MinderOptionDTO optionDTO = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ6", MinderLabel.MODULE.name(), 5000L);
MinderOptionDTO optionDTO = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ6", Translator.get("minder_extra_node.module"), 5000L);
resourceList.add(optionDTO);
this.requestPost(FUNCTIONAL_CASE_BATCH_DELETE+"/project-case-minder-test-xxx", resourceList).andExpect(status().is5xxServerError());
resourceList = new ArrayList<>();
optionDTO = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", MinderLabel.CASE.name(), 1000L);
optionDTO = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", Translator.get("minder_extra_node.case"), 1000L);
resourceList.add(optionDTO);
this.requestPost(FUNCTIONAL_CASE_BATCH_DELETE+"/project-case-minder-test-xxx", resourceList).andExpect(status().is5xxServerError());
resourceList = new ArrayList<>();
MinderOptionDTO optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_6", MinderLabel.CASE.name(), 600L);
MinderOptionDTO optionDTOModule = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ", MinderLabel.MODULE.name(), 1200L);
MinderOptionDTO optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_6", Translator.get("minder_extra_node.case"), 600L);
MinderOptionDTO optionDTOModule = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ", Translator.get("minder_extra_node.module"), 1200L);
resourceList.add(optionDTOModule);
resourceList.add(optionDTOCase);
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_DELETE+"/project-case-minder-test", resourceList);
@ -218,14 +221,14 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
FunctionalCase functionalCaseTwo = functionalCaseMapper.selectByPrimaryKey("TEST_FUNCTIONAL_MINDER_CASE_ID_6");
Assertions.assertTrue(functionalCaseTwo.getDeleted());
resourceList = new ArrayList<>();
optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.CASE.name(), 600L);
optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.case"), 600L);
resourceList.add(optionDTOCase);
MinderOptionDTO optionDTOPrerequisite = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.PREREQUISITE.toString(), 0L);
MinderOptionDTO optionDTODescription = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.DESCRIPTION.toString(), 3L);
MinderOptionDTO optionDTOStep = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.STEPS.toString(), 2L);
MinderOptionDTO optionDTOStepExpectedResult = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.STEPS_EXPECTED_RESULT.toString(), 2L);
MinderOptionDTO optionDTOText = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.TEXT_DESCRIPTION.toString(), 2L);
MinderOptionDTO optionDTOTextExpectedResult = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", MinderLabel.TEXT_EXPECTED_RESULT.toString(), 2L);
MinderOptionDTO optionDTOPrerequisite = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.prerequisite").toString(), 0L);
MinderOptionDTO optionDTODescription = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.description").toString(), 3L);
MinderOptionDTO optionDTOStep = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.steps").toString(), 2L);
MinderOptionDTO optionDTOStepExpectedResult = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.steps_expected_result").toString(), 2L);
MinderOptionDTO optionDTOText = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.text_description").toString(), 2L);
MinderOptionDTO optionDTOTextExpectedResult = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_3", Translator.get("minder_extra_node.text_expected_result").toString(), 2L);
resourceList.add(optionDTOPrerequisite);
resourceList.add(optionDTODescription);
resourceList.add(optionDTOStep);
@ -234,9 +237,9 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
resourceList.add(optionDTOTextExpectedResult);
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_DELETE+"/project-case-minder-test", resourceList);
resourceList = new ArrayList<>();
optionDTOText = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", MinderLabel.TEXT_DESCRIPTION.toString(), 2L);
optionDTOText = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", Translator.get("minder_extra_node.text_description").toString(), 2L);
resourceList.add(optionDTOText);
optionDTOTextExpectedResult = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", MinderLabel.TEXT_EXPECTED_RESULT.toString(), 2L);
optionDTOTextExpectedResult = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", Translator.get("minder_extra_node.text_expected_result").toString(), 2L);
resourceList.add(optionDTOTextExpectedResult);
this.requestPost(FUNCTIONAL_CASE_BATCH_DELETE+"/project-case-minder-test", resourceList).andExpect(status().is5xxServerError());
@ -258,9 +261,9 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseMinderRemoveRequest.setResourceList(new ArrayList<>());
this.requestPost(FUNCTIONAL_CASE_BATCH_MOVE, functionalCaseMinderRemoveRequest).andExpect(status().is5xxServerError());
List<MinderOptionDTO> resourceList = new ArrayList<>();
MinderOptionDTO optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_8", MinderLabel.CASE.name(), 600L);
MinderOptionDTO optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_8", Translator.get("minder_extra_node.case"), 600L);
resourceList.add(optionDTOCase);
MinderOptionDTO optionDTOModule = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ5", MinderLabel.MODULE.name(), 600L);
MinderOptionDTO optionDTOModule = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ5", Translator.get("minder_extra_node.module"), 600L);
resourceList.add(optionDTOModule);
functionalCaseMinderRemoveRequest.setResourceList(resourceList);
this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_BATCH_MOVE, functionalCaseMinderRemoveRequest);
@ -291,10 +294,10 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
functionalCaseMinderRemoveRequest.setParentTargetId("TEST_MINDER_MODULE_ID_GYQ6");
this.requestPost(FUNCTIONAL_CASE_BATCH_MOVE, functionalCaseMinderRemoveRequest).andExpect(status().is5xxServerError());
resourceList = new ArrayList<>();
optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", MinderLabel.CASE.name(), 600L);
optionDTOCase = new MinderOptionDTO("TEST_FUNCTIONAL_MINDER_CASE_ID_7", Translator.get("minder_extra_node.case"), 600L);
resourceList.add(optionDTOCase);
this.requestPost(FUNCTIONAL_CASE_BATCH_MOVE, functionalCaseMinderRemoveRequest).andExpect(status().is5xxServerError());
optionDTOModule = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ6", MinderLabel.MODULE.name(), 600L);
optionDTOModule = new MinderOptionDTO("TEST_MINDER_MODULE_ID_GYQ6", Translator.get("minder_extra_node.module"), 600L);
resourceList = new ArrayList<>();
resourceList.add(optionDTOModule);
functionalCaseMinderRemoveRequest.setResourceList(resourceList);