mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-30 11:08:38 +08:00
fix(测试计划): 脑图保存根节点被删除问题
This commit is contained in:
parent
b5a292e4a3
commit
df335e5f89
@ -621,16 +621,16 @@ public class FunctionalCaseMinderService {
|
||||
FunctionalCase functionalCase = addCase(request, userId, functionalCaseChangeRequest, caseMapper, sourceIdAndInsertModuleIdMap);
|
||||
String caseId = functionalCase.getId();
|
||||
sourceIdAndInsertCaseIdMap.put(functionalCaseChangeRequest.getId(), caseId);
|
||||
//保存用例等级
|
||||
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||
customField.setCaseId(caseId);
|
||||
customField.setFieldId(defaultCustomFieldValueMap.get("priorityFieldId").toString());
|
||||
customField.setValue("P"+functionalCaseChangeRequest.getPriority());
|
||||
caseCustomFieldMapper.insertSelective(customField);
|
||||
//附属表
|
||||
FunctionalCaseBlob functionalCaseBlob = addCaseBlob(functionalCaseChangeRequest, caseId, caseBlobMapper);
|
||||
//保存自定义字段
|
||||
List<FunctionalCaseCustomField> functionalCaseCustomFields = addCustomFields(functionalCaseChangeRequest, caseId, caseCustomFieldMapper, defaultCustomFieldValueMap);
|
||||
//保存用例等级
|
||||
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||
customField.setCaseId(caseId);
|
||||
customField.setFieldId(defaultCustomFieldValueMap.get("priorityFieldId").toString());
|
||||
customField.setValue("P"+(functionalCaseChangeRequest.getPriority()-1));
|
||||
caseCustomFieldMapper.insertSelective(customField);
|
||||
//日志
|
||||
FunctionalCaseHistoryLogDTO historyLogDTO = new FunctionalCaseHistoryLogDTO(functionalCase, functionalCaseBlob, functionalCaseCustomFields, new ArrayList<>(), new ArrayList<>());
|
||||
LogDTO logDTO = addLog(request, userId, caseId, historyLogDTO, null);
|
||||
@ -668,7 +668,7 @@ public class FunctionalCaseMinderService {
|
||||
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||
customField.setCaseId(caseId);
|
||||
customField.setFieldId(defaultCustomFieldValueMap.get("priorityFieldId").toString());
|
||||
customField.setValue("P"+functionalCaseChangeRequest.getPriority());
|
||||
customField.setValue("P"+(functionalCaseChangeRequest.getPriority()-1));
|
||||
caseCustomFieldMapper.updateByPrimaryKeySelective(customField);
|
||||
//日志
|
||||
FunctionalCaseHistoryLogDTO historyLogDTO = new FunctionalCaseHistoryLogDTO(functionalCase, functionalCaseBlob, oldCaseCustomFieldMap.get(caseId), new ArrayList<>(), new ArrayList<>());
|
||||
@ -1060,7 +1060,7 @@ public class FunctionalCaseMinderService {
|
||||
List<String> list = customFields.stream().map(CaseCustomFieldDTO::getFieldId).toList();
|
||||
List<CaseCustomFieldDTO> customFieldDTOs = new ArrayList<>();
|
||||
defaultValueMap.forEach((k, v) -> {
|
||||
if (!list.contains(k)) {
|
||||
if (!list.contains(k) && !StringUtils.equalsIgnoreCase(k,"priorityFieldId")) {
|
||||
CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO();
|
||||
customFieldDTO.setFieldId(k);
|
||||
customFieldDTO.setValue(v.toString());
|
||||
|
@ -5,10 +5,7 @@ import io.metersphere.functional.dto.CaseCustomFieldDTO;
|
||||
import io.metersphere.functional.dto.FunctionalCaseStepDTO;
|
||||
import io.metersphere.functional.dto.FunctionalMinderTreeDTO;
|
||||
import io.metersphere.functional.dto.MinderOptionDTO;
|
||||
import io.metersphere.functional.mapper.FunctionalCaseBlobMapper;
|
||||
import io.metersphere.functional.mapper.FunctionalCaseMapper;
|
||||
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
|
||||
import io.metersphere.functional.mapper.MindAdditionalNodeMapper;
|
||||
import io.metersphere.functional.mapper.*;
|
||||
import io.metersphere.functional.request.*;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
@ -58,6 +55,8 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||
private FunctionalCaseModuleMapper functionalCaseModuleMapper;
|
||||
@Resource
|
||||
private MindAdditionalNodeMapper mindAdditionalNodeMapper;
|
||||
@Resource
|
||||
private FunctionalCaseCustomFieldMapper functionalCaseCustomFieldMapper;
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@ -165,7 +164,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||
caseChangeRequest.setName("新增用例");
|
||||
caseChangeRequest.setModuleId("TEST_MINDER_MODULE_ID_GYQ2");
|
||||
caseChangeRequest.setMoveMode("AFTER");
|
||||
caseChangeRequest.setPriority(2);
|
||||
caseChangeRequest.setPriority(3);
|
||||
caseChangeRequest.setTargetId("TEST_FUNCTIONAL_MINDER_CASE_ID_3");
|
||||
caseChangeRequest.setTemplateId("100001");
|
||||
caseChangeRequest.setType("ADD");
|
||||
@ -183,7 +182,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||
caseChangeRequest.setName("TEST_MINDER_MODULE_ID_GYQ_更新");
|
||||
caseChangeRequest.setModuleId("TEST_MINDER_MODULE_ID_GYQ");
|
||||
caseChangeRequest.setTemplateId("100001");
|
||||
caseChangeRequest.setPriority(2);
|
||||
caseChangeRequest.setPriority(3);
|
||||
caseChangeRequest.setMoveMode("BEFORE");
|
||||
caseChangeRequest.setTargetId("TEST_FUNCTIONAL_MINDER_CASE_ID_2");
|
||||
caseChangeRequest.setType("UPDATE");
|
||||
@ -251,6 +250,10 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
||||
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(functionalCases));
|
||||
Assertions.assertTrue(functionalCases.get(0).getPos() > 0L);
|
||||
FunctionalCaseCustomFieldExample customFieldExample = new FunctionalCaseCustomFieldExample();
|
||||
customFieldExample.createCriteria().andCaseIdEqualTo(functionalCases.get(0).getId()).andFieldIdEqualTo("custom_field_minder_gyq_id_3");
|
||||
List<FunctionalCaseCustomField> functionalCaseCustomFields = functionalCaseCustomFieldMapper.selectByExample(customFieldExample);
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(functionalCaseCustomFields.get(0).getValue(),"P2"));
|
||||
FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample();
|
||||
functionalCaseModuleExample.createCriteria().andNameEqualTo("新增9");
|
||||
List<FunctionalCaseModule> functionalCaseModules = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample);
|
||||
|
@ -284,13 +284,14 @@ public class TestPlanCollectionMinderService {
|
||||
}
|
||||
|
||||
private Map<String, List<String>> dealUpdateList(TestPlanCollectionMinderEditRequest request, String userId, Map<String, List<BaseCollectionAssociateRequest>> associateMap, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
List<TestPlanCollectionMinderEditDTO> updateList = request.getEditList().stream().filter(t -> StringUtils.isNotBlank(t.getId()) && t.getLevel() == 2).toList();
|
||||
List<TestPlanCollectionMinderEditDTO> updateList = request.getEditList().stream().filter(t -> StringUtils.isNotBlank(t.getId())).toList();
|
||||
Map<String, List<String>> typeNamesMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(updateList)) {
|
||||
//处理删除
|
||||
deleteCollection(updateList, request.getPlanId());
|
||||
//处理更新
|
||||
for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : updateList) {
|
||||
List<TestPlanCollectionMinderEditDTO> collect = updateList.stream().filter(t -> t.getLevel() == 2).toList();
|
||||
for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : collect) {
|
||||
TestPlanCollection testPlanCollection = updateCollection(request, userId, testPlanCollectionMinderEditDTO, parentMap, collectionMapper);
|
||||
checkChangeDataRepeat(typeNamesMap, testPlanCollection);
|
||||
setAssociateMap(testPlanCollectionMinderEditDTO, associateMap, testPlanCollection);
|
||||
@ -340,26 +341,35 @@ public class TestPlanCollectionMinderService {
|
||||
|
||||
@NotNull
|
||||
private Map<String, List<TestPlanCollection>> getParentMap(TestPlanCollectionMinderEditRequest request) {
|
||||
TestPlanCollectionExample testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andParentIdEqualTo(ModuleConstants.ROOT_NODE_PARENT_ID);
|
||||
List<TestPlanCollection> testPlanCollections = testPlanCollectionMapper.selectByExample(testPlanCollectionExample);
|
||||
return testPlanCollections.stream().collect(Collectors.groupingBy(TestPlanCollection::getType));
|
||||
List<TestPlanCollectionMinderEditDTO> list = request.getEditList().stream().filter(t -> StringUtils.isNotBlank(t.getId()) && t.getLevel() == 1).toList();
|
||||
List<TestPlanCollection>parentList = new ArrayList<>();
|
||||
for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : list) {
|
||||
TestPlanCollection testPlanCollection = new TestPlanCollection();
|
||||
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
|
||||
parentList.add(testPlanCollection);
|
||||
}
|
||||
return parentList.stream().collect(Collectors.groupingBy(TestPlanCollection::getType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static TestPlanCollection updateCollection(TestPlanCollectionMinderEditRequest request, String userId, TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
TestPlanCollection testPlanCollection = new TestPlanCollection();
|
||||
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
|
||||
testPlanCollection.setId(testPlanCollectionMinderEditDTO.getId());
|
||||
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
|
||||
testPlanCollection.setTestPlanId(request.getPlanId());
|
||||
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
|
||||
|
||||
TestPlanCollection parent = parentMap.get(testPlanCollectionMinderEditDTO.getType()).get(0);
|
||||
if (StringUtils.equalsIgnoreCase(parent.getId(), testPlanCollectionMinderEditDTO.getId())) {
|
||||
testPlanCollection.setParentId(parent.getParentId());
|
||||
} else {
|
||||
testPlanCollection.setParentId(parent.getId());
|
||||
}
|
||||
if (testPlanCollectionMinderEditDTO.getExtended()) {
|
||||
BeanUtils.copyBean(testPlanCollection, parent);
|
||||
} else {
|
||||
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
|
||||
}
|
||||
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
|
||||
testPlanCollection.setTestPlanId(request.getPlanId());
|
||||
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
|
||||
testPlanCollection.setId(testPlanCollectionMinderEditDTO.getId());
|
||||
testPlanCollection.setCreateUser(userId);
|
||||
testPlanCollection.setCreateTime(null);
|
||||
testPlanCollection.setPos(testPlanCollectionMinderEditDTO.getNum());
|
||||
@ -369,19 +379,24 @@ public class TestPlanCollectionMinderService {
|
||||
|
||||
@NotNull
|
||||
private static TestPlanCollection addCollection(TestPlanCollectionMinderEditRequest request, String userId, TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
TestPlanCollection testPlanCollection = new TestPlanCollection();
|
||||
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
|
||||
testPlanCollection.setId(IDGenerator.nextStr());
|
||||
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
|
||||
testPlanCollection.setTestPlanId(request.getPlanId());
|
||||
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
|
||||
List<TestPlanCollection> testPlanCollections = parentMap.get(testPlanCollectionMinderEditDTO.getType());
|
||||
TestPlanCollection parent = null;
|
||||
TestPlanCollection testPlanCollection = new TestPlanCollection();
|
||||
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
|
||||
if (CollectionUtils.isNotEmpty(testPlanCollections)) {
|
||||
TestPlanCollection parent = testPlanCollections.get(0);
|
||||
parent = testPlanCollections.get(0);
|
||||
testPlanCollection.setParentId(parent.getId());
|
||||
} else {
|
||||
testPlanCollection.setParentId(CommonConstants.DEFAULT_NULL_VALUE);
|
||||
}
|
||||
if (testPlanCollectionMinderEditDTO.getExtended() && parent!=null) {
|
||||
BeanUtils.copyBean(testPlanCollection, parent);
|
||||
} else {
|
||||
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
|
||||
}
|
||||
testPlanCollection.setId(IDGenerator.nextStr());
|
||||
testPlanCollection.setTestPlanId(request.getPlanId());
|
||||
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
|
||||
testPlanCollection.setCreateUser(userId);
|
||||
testPlanCollection.setCreateTime(System.currentTimeMillis());
|
||||
testPlanCollection.setPos(testPlanCollectionMinderEditDTO.getNum());
|
||||
|
@ -59,6 +59,60 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
void editMind() throws Exception {
|
||||
TestPlanCollectionMinderEditRequest request = new TestPlanCollectionMinderEditRequest();
|
||||
request.setPlanId("gyq_plan_1");
|
||||
List<TestPlanCollectionMinderEditDTO> parentList = new ArrayList<>();
|
||||
TestPlanCollectionMinderEditDTO funcParent = new TestPlanCollectionMinderEditDTO();
|
||||
funcParent.setId("gyq_wxxx_2");
|
||||
funcParent.setText("功能用例");
|
||||
funcParent.setNum(2L);
|
||||
funcParent.setExecuteMethod("PARALLEL");
|
||||
funcParent.setType("FUNCTIONAL");
|
||||
funcParent.setExtended(false);
|
||||
funcParent.setGrouped(false);
|
||||
funcParent.setLevel(1);
|
||||
funcParent.setEnvironmentId("gyq_123");
|
||||
funcParent.setTestResourcePoolId("gyq_123_pool");
|
||||
funcParent.setRetryOnFail(true);
|
||||
funcParent.setRetryType("SCENARIO");
|
||||
funcParent.setRetryTimes(5);
|
||||
funcParent.setRetryInterval(1000);
|
||||
funcParent.setStopOnFail(true);
|
||||
parentList.add(funcParent);
|
||||
TestPlanCollectionMinderEditDTO apiParent = new TestPlanCollectionMinderEditDTO();
|
||||
apiParent.setId("gyq_wxxx_1");
|
||||
apiParent.setText("接口用例");
|
||||
apiParent.setNum(1L);
|
||||
apiParent.setExecuteMethod("PARALLEL");
|
||||
apiParent.setType("API");
|
||||
apiParent.setExtended(false);
|
||||
apiParent.setGrouped(false);
|
||||
apiParent.setLevel(1);
|
||||
apiParent.setEnvironmentId("NONE");
|
||||
apiParent.setTestResourcePoolId("gyq_123_pool");
|
||||
apiParent.setRetryOnFail(true);
|
||||
apiParent.setRetryType("SCENARIO");
|
||||
apiParent.setRetryTimes(5);
|
||||
apiParent.setRetryInterval(1000);
|
||||
apiParent.setStopOnFail(true);
|
||||
parentList.add(apiParent);
|
||||
|
||||
TestPlanCollectionMinderEditDTO scenarioParent = new TestPlanCollectionMinderEditDTO();
|
||||
scenarioParent.setId("gyq_wxxx_3");
|
||||
scenarioParent.setText("场景用例");
|
||||
scenarioParent.setNum(3L);
|
||||
scenarioParent.setExecuteMethod("PARALLEL");
|
||||
scenarioParent.setType("SCENARIO");
|
||||
scenarioParent.setExtended(false);
|
||||
scenarioParent.setGrouped(false);
|
||||
scenarioParent.setLevel(1);
|
||||
scenarioParent.setEnvironmentId("NONE");
|
||||
scenarioParent.setTestResourcePoolId("gyq_123_pool");
|
||||
scenarioParent.setRetryOnFail(true);
|
||||
scenarioParent.setRetryType("SCENARIO");
|
||||
scenarioParent.setRetryTimes(6);
|
||||
scenarioParent.setRetryInterval(1000);
|
||||
scenarioParent.setStopOnFail(true);
|
||||
parentList.add(scenarioParent);
|
||||
|
||||
List<TestPlanCollectionMinderEditDTO> editList = new ArrayList<>();
|
||||
TestPlanCollectionMinderEditDTO deleteDTO = new TestPlanCollectionMinderEditDTO();
|
||||
TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO = new TestPlanCollectionMinderEditDTO();
|
||||
@ -67,7 +121,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
testPlanCollectionMinderEditDTO.setNum(500L);
|
||||
testPlanCollectionMinderEditDTO.setExecuteMethod("PARALLEL");
|
||||
testPlanCollectionMinderEditDTO.setType("API");
|
||||
testPlanCollectionMinderEditDTO.setExtended(false);
|
||||
testPlanCollectionMinderEditDTO.setExtended(true);
|
||||
testPlanCollectionMinderEditDTO.setGrouped(false);
|
||||
testPlanCollectionMinderEditDTO.setLevel(2);
|
||||
testPlanCollectionMinderEditDTO.setEnvironmentId("gyq_123");
|
||||
@ -85,12 +139,19 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
testPlanCollectionMinderEditDTO.setAssociateDTOS(associateDTOS);
|
||||
deleteDTO = testPlanCollectionMinderEditDTO;
|
||||
editList.add(testPlanCollectionMinderEditDTO);
|
||||
editList.addAll(parentList);
|
||||
request.setEditList(editList);
|
||||
this.requestPostWithOkAndReturn(EDIT_MIND, request);
|
||||
|
||||
TestPlanCollectionExample testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample.createCriteria().andTestPlanIdEqualTo("gyq_plan_1");
|
||||
List<TestPlanCollection> testPlanCollections1 = testPlanCollectionMapper.selectByExample(testPlanCollectionExample);
|
||||
Assertions.assertEquals(4, testPlanCollections1.size());
|
||||
TestPlanCollection testPlanCollection = testPlanCollectionMapper.selectByPrimaryKey("gyq_wxxx_4");
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(testPlanCollection.getName(),"更新名称"));
|
||||
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(testPlanCollection.getEnvironmentId(),"NONE"));
|
||||
editList = new ArrayList<>();
|
||||
editList.addAll(parentList);
|
||||
testPlanCollectionMinderEditDTO = new TestPlanCollectionMinderEditDTO();
|
||||
testPlanCollectionMinderEditDTO.setId(null);
|
||||
testPlanCollectionMinderEditDTO.setText("新建名称");
|
||||
@ -116,11 +177,11 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
editList.add(testPlanCollectionMinderEditDTO);
|
||||
request.setEditList(editList);
|
||||
this.requestPostWithOkAndReturn(EDIT_MIND, request);
|
||||
TestPlanCollectionExample testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample.createCriteria().andNameEqualTo("新建名称");
|
||||
List<TestPlanCollection> testPlanCollections = testPlanCollectionMapper.selectByExample(testPlanCollectionExample);
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(testPlanCollections));
|
||||
editList = new ArrayList<>();
|
||||
editList = new ArrayList<>(parentList);
|
||||
editList.add(deleteDTO);
|
||||
editList.add(deleteDTO);
|
||||
request.setEditList(editList);
|
||||
@ -145,7 +206,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
testPlanCollectionMinderEditDTO.setRetryTimes(5);
|
||||
testPlanCollectionMinderEditDTO.setRetryInterval(1000);
|
||||
testPlanCollectionMinderEditDTO.setStopOnFail(true);
|
||||
editList = new ArrayList<>();
|
||||
editList = new ArrayList<>(parentList);
|
||||
editList.add(testPlanCollectionMinderEditDTO);
|
||||
request.setEditList(editList);
|
||||
this.requestPostWithOkAndReturn(EDIT_MIND, request);
|
||||
|
Loading…
Reference in New Issue
Block a user