fix(功能用例): 修复用例脑图模块节点更新问题

This commit is contained in:
guoyuqi 2024-06-20 11:52:59 +08:00 committed by Craftsman
parent 9db8404d1c
commit 4ff44b27b7
3 changed files with 48 additions and 13 deletions

View File

@ -307,7 +307,12 @@ public class FunctionalCaseMinderService {
//处理用例 //处理用例
Map<String, String> sourceIdAndInsertCaseIdMap = dealCase(request, userId, sqlSession, sourceIdAndInsertModuleIdMap, functionalMinderUpdateDTO); Map<String, String> sourceIdAndInsertCaseIdMap = dealCase(request, userId, sqlSession, sourceIdAndInsertModuleIdMap, functionalMinderUpdateDTO);
List<String> needToTurnCaseIds = new ArrayList<>(sourceIdAndInsertCaseIdMap.keySet().stream().distinct().toList()); List<String> needToTurnCaseIds = new ArrayList<>(sourceIdAndInsertCaseIdMap.keySet().stream().distinct().toList());
//删除模块
if (CollectionUtils.isNotEmpty(needToTurnCaseIds)) {
FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andIdIn(needToTurnCaseIds);
moduleMapper.deleteByExample(functionalCaseModuleExample);
}
//删除已转为模块或用例的空白节点 //删除已转为模块或用例的空白节点
needToTurnCaseIds.addAll(needToTurnModuleIds); needToTurnCaseIds.addAll(needToTurnModuleIds);
if (CollectionUtils.isNotEmpty(needToTurnCaseIds)) { if (CollectionUtils.isNotEmpty(needToTurnCaseIds)) {
@ -337,7 +342,7 @@ public class FunctionalCaseMinderService {
if (CollectionUtils.isNotEmpty(targetIds)) { if (CollectionUtils.isNotEmpty(targetIds)) {
FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample(); FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andIdIn(targetIds); functionalCaseModuleExample.createCriteria().andIdIn(targetIds);
List<FunctionalCaseModule> targetModuleIds = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample); List<FunctionalCaseModule> targetModuleIds = moduleMapper.selectByExample(functionalCaseModuleExample);
Map<String, String> targetModuleMap = new HashMap<>(); Map<String, String> targetModuleMap = new HashMap<>();
List<String> targetModuleParentIds = new ArrayList<>(); List<String> targetModuleParentIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(targetModuleIds)) { if (CollectionUtils.isNotEmpty(targetModuleIds)) {
@ -348,7 +353,7 @@ public class FunctionalCaseMinderService {
if (CollectionUtils.isNotEmpty(targetModuleParentIds)) { if (CollectionUtils.isNotEmpty(targetModuleParentIds)) {
functionalCaseModuleExample = new FunctionalCaseModuleExample(); functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andParentIdIn(targetModuleParentIds); functionalCaseModuleExample.createCriteria().andParentIdIn(targetModuleParentIds);
allChildrenInDB = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample); allChildrenInDB = moduleMapper.selectByExample(functionalCaseModuleExample);
} }
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
@ -377,14 +382,14 @@ public class FunctionalCaseMinderService {
if (CollectionUtils.isNotEmpty(caseModuleIds)) { if (CollectionUtils.isNotEmpty(caseModuleIds)) {
functionalCaseModuleExample = new FunctionalCaseModuleExample(); functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andParentIdIn(caseModuleIds); functionalCaseModuleExample.createCriteria().andParentIdIn(caseModuleIds);
allChildrenByCaseInDB = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample); allChildrenByCaseInDB = moduleMapper.selectByExample(functionalCaseModuleExample);
} }
allChildrenInDB.addAll(allChildrenByCaseInDB); allChildrenInDB.addAll(allChildrenByCaseInDB);
MindAdditionalNodeExample mindAdditionalNodeExample = new MindAdditionalNodeExample(); MindAdditionalNodeExample mindAdditionalNodeExample = new MindAdditionalNodeExample();
mindAdditionalNodeExample.createCriteria().andIdIn(targetIds); mindAdditionalNodeExample.createCriteria().andIdIn(targetIds);
List<MindAdditionalNode> mindAdditionalNodes = mindAdditionalNodeMapper.selectByExample(mindAdditionalNodeExample); List<MindAdditionalNode> mindAdditionalNodes = additionalNodeMapper.selectByExample(mindAdditionalNodeExample);
Map<String, String> targetTextMap = new HashMap<>(); Map<String, String> targetTextMap = new HashMap<>();
List<String> targetTextParentIds = new ArrayList<>(); List<String> targetTextParentIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(mindAdditionalNodes)) { if (CollectionUtils.isNotEmpty(mindAdditionalNodes)) {
@ -401,7 +406,7 @@ public class FunctionalCaseMinderService {
if (CollectionUtils.isNotEmpty(targetTextParentNoRepeatIds)) { if (CollectionUtils.isNotEmpty(targetTextParentNoRepeatIds)) {
mindAdditionalNodeExample = new MindAdditionalNodeExample(); mindAdditionalNodeExample = new MindAdditionalNodeExample();
mindAdditionalNodeExample.createCriteria().andParentIdIn(targetTextParentNoRepeatIds); mindAdditionalNodeExample.createCriteria().andParentIdIn(targetTextParentNoRepeatIds);
allChildrenTextInDB = mindAdditionalNodeMapper.selectByExample(mindAdditionalNodeExample); allChildrenTextInDB = additionalNodeMapper.selectByExample(mindAdditionalNodeExample);
parentChildrenTextMap = allChildrenTextInDB.stream().collect(Collectors.groupingBy(MindAdditionalNode::getParentId)); parentChildrenTextMap = allChildrenTextInDB.stream().collect(Collectors.groupingBy(MindAdditionalNode::getParentId));
} }
@ -411,7 +416,7 @@ public class FunctionalCaseMinderService {
if (CollectionUtils.isNotEmpty(textModuleIds)) { if (CollectionUtils.isNotEmpty(textModuleIds)) {
functionalCaseModuleExample = new FunctionalCaseModuleExample(); functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andParentIdIn(textModuleIds); functionalCaseModuleExample.createCriteria().andParentIdIn(textModuleIds);
List<FunctionalCaseModule> allChildrenByTextInDB = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample); List<FunctionalCaseModule> allChildrenByTextInDB = moduleMapper.selectByExample(functionalCaseModuleExample);
allChildrenInDB.addAll(allChildrenByTextInDB); allChildrenInDB.addAll(allChildrenByTextInDB);
} }
List<String> textModuleFilterCaseIds = targetTextParentIds.stream().filter(t -> !targetCaseParentIdsNoRepeat.contains(t)).distinct().toList(); List<String> textModuleFilterCaseIds = targetTextParentIds.stream().filter(t -> !targetCaseParentIdsNoRepeat.contains(t)).distinct().toList();

View File

@ -197,6 +197,21 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
caseChangeRequests.add(caseChangeRequest); caseChangeRequests.add(caseChangeRequest);
request.setUpdateCaseList(caseChangeRequests); request.setUpdateCaseList(caseChangeRequests);
caseChangeRequest = new FunctionalCaseChangeRequest();
caseChangeRequest.setId("TEST_MINDER_MODULE_ID_GYQ_A");
caseChangeRequest.setName("模块转用例");
caseChangeRequest.setModuleId("TEST_MINDER_MODULE_ID_GYQ8");
caseChangeRequest.setTemplateId("100001");
caseChangeRequest.setMoveMode("BEFORE");
caseChangeRequest.setTargetId("TEST_FUNCTIONAL_MINDER_CASE_ID_2");
caseChangeRequest.setType("ADD");
caseChangeRequest.setPrerequisite("前置条件");
caseChangeRequest.setCaseEditType("TEXT");
customFields = new ArrayList<>();
caseChangeRequest.setCustomFields(customFields);
caseChangeRequests.add(caseChangeRequest);
request.setUpdateCaseList(caseChangeRequests);
List<FunctionalCaseModuleEditRequest> functionalCaseModuleEditRequests = new ArrayList<>(); List<FunctionalCaseModuleEditRequest> functionalCaseModuleEditRequests = new ArrayList<>();
FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest = new FunctionalCaseModuleEditRequest(); FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest = new FunctionalCaseModuleEditRequest();
functionalCaseModuleEditRequest.setId("uuuId"); functionalCaseModuleEditRequest.setId("uuuId");
@ -226,7 +241,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
mindAdditionalNodeRequest = new MindAdditionalNodeRequest(); mindAdditionalNodeRequest = new MindAdditionalNodeRequest();
mindAdditionalNodeRequest.setId("additional2"); mindAdditionalNodeRequest.setId("additional2");
mindAdditionalNodeRequest.setType("UPDATE"); mindAdditionalNodeRequest.setType("UPDATE");
mindAdditionalNodeRequest.setName("additional2"); mindAdditionalNodeRequest.setName("additional2更新");
mindAdditionalNodeRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ"); mindAdditionalNodeRequest.setParentId("TEST_MINDER_MODULE_ID_GYQ");
additionalNodeList.add(mindAdditionalNodeRequest); additionalNodeList.add(mindAdditionalNodeRequest);
request.setAdditionalNodeList(additionalNodeList); request.setAdditionalNodeList(additionalNodeList);
@ -255,12 +270,26 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
List<FunctionalCaseCustomField> functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(customFieldExample); List<FunctionalCaseCustomField> functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(customFieldExample);
Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.get(0).getValue(),"P0")); Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.get(0).getValue(),"P0"));
MindAdditionalNode mindAdditionalNode = mindAdditionalNodeMapper.selectByPrimaryKey("additional2"); FunctionalCaseModule functionalCaseModule = functionalCaseModuleMapper.selectByPrimaryKey("TEST_MINDER_MODULE_ID_GYQ7");
Assertions.assertTrue(StringUtils.equalsIgnoreCase(mindAdditionalNode.getParentId(),"TEST_MINDER_MODULE_ID_GYQ")); Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseModule.getName(),"移动7"));
FunctionalCaseModule functionalCaseModule1 = functionalCaseModuleMapper.selectByPrimaryKey("TEST_MINDER_MODULE_ID_GYQ_A");
Assertions.assertNull(functionalCaseModule1);
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
functionalCaseExample.createCriteria().andNameEqualTo("新增用例"); functionalCaseExample.createCriteria().andNameEqualTo("模块转用例");
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases)); Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases));
MindAdditionalNode mindAdditionalNode = mindAdditionalNodeMapper.selectByPrimaryKey("additional2");
Assertions.assertTrue(StringUtils.equalsIgnoreCase(mindAdditionalNode.getName(),"additional2更新"));
Assertions.assertTrue(StringUtils.equalsIgnoreCase(mindAdditionalNode.getParentId(),"TEST_MINDER_MODULE_ID_GYQ"));
functionalCaseExample = new FunctionalCaseExample();
functionalCaseExample.createCriteria().andNameEqualTo("新增用例");
functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases));
Assertions.assertTrue(functionalCases.get(0).getPos() > 0L); Assertions.assertTrue(functionalCases.get(0).getPos() > 0L);
Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases)); Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases));

View File

@ -45,8 +45,9 @@ VALUES
('TEST_MINDER_MODULE_ID_GYQ7', 'project-case-minder-test', '测试所属模块7', 'TEST_MINDER_MODULE_ID_GYQ', 0, 1669174143999, 1669174143999, 'admin', 'admin'), ('TEST_MINDER_MODULE_ID_GYQ7', 'project-case-minder-test', '测试所属模块7', 'TEST_MINDER_MODULE_ID_GYQ', 0, 1669174143999, 1669174143999, 'admin', 'admin'),
('TEST_MINDER_MODULE_ID_GYQ8', 'project-case-minder-test', '测试所属模块8', 'TEST_MINDER_MODULE_ID_GYQ', 0, 1669174143999, 1669174143999, 'admin', 'admin'), ('TEST_MINDER_MODULE_ID_GYQ8', 'project-case-minder-test', '测试所属模块8', 'TEST_MINDER_MODULE_ID_GYQ', 0, 1669174143999, 1669174143999, 'admin', 'admin'),
('TEST_MINDER_MODULE_ID_GYQ6', 'project-case-minder-test-xx', '测试所属模块1', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin'), ('TEST_MINDER_MODULE_ID_GYQ6', 'project-case-minder-test-xx', '测试所属模块1', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin'),
('TEST_MINDER_MODULE_ID_GYQ9', 'project-case-minder-test', '用来删除', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin'); ('TEST_MINDER_MODULE_ID_GYQ9', 'project-case-minder-test', '用来删除', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin'),
; ('TEST_MINDER_MODULE_ID_GYQ_A', 'project-case-minder-test', '模块转用例', 'TEST_MINDER_MODULE_ID_GYQ8', 0, 1669174143999, 1669174143999, 'admin', 'admin');
INSERT INTO test_plan(id, num, project_id, group_id, module_id, name, status, type, tags, create_time, create_user, update_time, update_user, planned_start_time, planned_end_time, actual_start_time, actual_end_time, description) INSERT INTO test_plan(id, num, project_id, group_id, module_id, name, status, type, tags, create_time, create_user, update_time, update_user, planned_start_time, planned_end_time, actual_start_time, actual_end_time, description)