fix(测试用例): 修复脑图空用例空模块相互转换问题以及测试计划脑图展示实际结果节点问题

--bug=1045780 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001045780
This commit is contained in:
guoyuqi 2024-09-02 11:56:33 +08:00 committed by Craftsman
parent c761ac7271
commit 41d723bee9
2 changed files with 39 additions and 29 deletions

View File

@ -79,6 +79,9 @@ public class FunctionalCaseMinderService {
@Resource
private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper;
@Resource
private FunctionalCaseTrashService functionalCaseTrashService;
@Resource
private FunctionalCaseService functionalCaseService;
@ -258,9 +261,11 @@ public class FunctionalCaseMinderService {
if (functionalCaseMindDTO.getContent() != null) {
contentText = new String(functionalCaseMindDTO.getContent(), StandardCharsets.UTF_8);
}
FunctionalMinderTreeDTO contentFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(StringUtils.isBlank(contentText) ? StringUtils.EMPTY : contentText, Translator.get("minder_extra_node.steps_actual_result"), (long) (i + 1));
if (StringUtils.isNotBlank(contentText)) {
FunctionalMinderTreeDTO contentFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(contentText, Translator.get("minder_extra_node.steps_actual_result"), (long) (i + 1));
children.add(contentFunctionalMinderTreeDTO);
}
}
return children;
}
@ -281,8 +286,8 @@ public class FunctionalCaseMinderService {
public void editFunctionalCaseBatch(FunctionalCaseMinderEditRequest request, String userId) {
//处理删除的模块和用例和空白节点
deleteResource(request, userId);
User user = userMapper.selectByPrimaryKey(userId);
deleteResource(request, user);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseModuleMapper moduleMapper = sqlSession.getMapper(FunctionalCaseModuleMapper.class);
MindAdditionalNodeMapper additionalNodeMapper = sqlSession.getMapper(MindAdditionalNodeMapper.class);
@ -291,6 +296,12 @@ public class FunctionalCaseMinderService {
//处理模块
Map<String, String> sourceIdAndInsertModuleIdMap = dealModule(request, userId, moduleMapper, functionalMinderUpdateDTO);
List<String> needToTurnModuleIds = sourceIdAndInsertModuleIdMap.keySet().stream().distinct().toList();
//删除用例
if (CollectionUtils.isNotEmpty(needToTurnModuleIds)) {
functionalCaseTrashService.deleteByIds(request.getProjectId(),needToTurnModuleIds,userId);
functionalCaseNoticeService.batchSendNotice(request.getProjectId(), needToTurnModuleIds, user, NoticeConstants.Event.DELETE);
}
//处理用例
Map<String, String> sourceIdAndInsertCaseIdMap = dealCase(request, userId, sqlSession, sourceIdAndInsertModuleIdMap, functionalMinderUpdateDTO);
List<String> needToTurnCaseIds = new ArrayList<>(sourceIdAndInsertCaseIdMap.keySet().stream().distinct().toList());
@ -1170,15 +1181,14 @@ public class FunctionalCaseMinderService {
return functionalCase;
}
private void deleteResource(FunctionalCaseMinderEditRequest request, String userId) {
private void deleteResource(FunctionalCaseMinderEditRequest request, User user) {
if (CollectionUtils.isNotEmpty(request.getDeleteResourceList())) {
User user = userMapper.selectByPrimaryKey(userId);
Map<String, List<MinderOptionDTO>> resourceMap = request.getDeleteResourceList().stream().collect(Collectors.groupingBy(MinderOptionDTO::getType));
List<MinderOptionDTO> caseOptionDTOS = resourceMap.get(Translator.get("minder_extra_node.case"));
List<String> caseIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(caseOptionDTOS)) {
caseIds = caseOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
functionalCaseService.handDeleteFunctionalCase(caseIds, false, userId, request.getProjectId());
functionalCaseService.handDeleteFunctionalCase(caseIds, false, user.getId(), request.getProjectId());
functionalCaseLogService.batchDeleteFunctionalCaseLogByIds(caseIds, "/functional/mind/case/edit");
}
@ -1191,7 +1201,7 @@ public class FunctionalCaseMinderService {
if (moduleIds.contains("root")) {
throw new MSException(Translator.get("functional_case.module.default.name.cut_error"));
}
List<FunctionalCase> functionalCases = functionalCaseModuleService.deleteModuleByIds(moduleIds, new ArrayList<>(), userId);
List<FunctionalCase> functionalCases = functionalCaseModuleService.deleteModuleByIds(moduleIds, new ArrayList<>(), user.getId());
functionalCaseModuleService.batchDelLog(functionalCases, request.getProjectId());
List<String> finalCaseIds = caseIds;
List<String> caseIdList = functionalCases.stream().map(FunctionalCase::getId).filter(id -> !finalCaseIds.contains(id)).toList();

View File

@ -209,7 +209,7 @@ public class FunctionalCaseTrashService {
}
}
private void deleteByIds(String projectId, List<String> deleteIds, String userId) {
public void deleteByIds(String projectId, List<String> deleteIds, String userId) {
deleteFunctionalCaseService.deleteFunctionalCaseResource(deleteIds, projectId);
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.CASE_IDS, deleteIds);