refactor(功能用例): 脑图保存用例等级优化以及测试计划脑图分层级校验
This commit is contained in:
parent
afe2687fdb
commit
81484e4272
|
@ -37,6 +37,10 @@ public class FunctionalCaseChangeRequest implements Serializable {
|
|||
@NotBlank(message = "{functional_case.module_id.not_blank}")
|
||||
private String moduleId;
|
||||
|
||||
@Schema(description = "用例等级", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{functional_case.name.not_blank}")
|
||||
private int priority = 0;
|
||||
|
||||
@Schema(description = "移动方式(节点移动或新增时需要)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String moveMode;
|
||||
|
||||
|
|
|
@ -130,7 +130,6 @@ public class FunctionalCaseMinderService {
|
|||
private static final String FUNCTIONAL_CASE = "functional_case";
|
||||
private static final String FUNCTIONAL_CASE_MODULE = "functional_case_module";
|
||||
private static final String CHECK_OWNER_CASE = "check_owner_case";
|
||||
|
||||
/**
|
||||
* 功能用例-脑图用例列表查询
|
||||
*
|
||||
|
@ -276,6 +275,8 @@ public class FunctionalCaseMinderService {
|
|||
FunctionalMinderTreeNodeDTO rootData = new FunctionalMinderTreeNodeDTO();
|
||||
rootData.setText(text);
|
||||
rootData.setPos(pos);
|
||||
//最子节点默认收起
|
||||
rootData.setExpandState("collapse");
|
||||
rootData.setResource(List.of(resource));
|
||||
functionalMinderTreeDTO.setChildren(new ArrayList<>());
|
||||
functionalMinderTreeDTO.setData(rootData);
|
||||
|
@ -620,7 +621,12 @@ 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);
|
||||
//保存自定义字段
|
||||
|
@ -658,6 +664,12 @@ public class FunctionalCaseMinderService {
|
|||
FunctionalCaseBlob functionalCaseBlob = updateBlob(functionalCaseChangeRequest, caseId, caseBlobMapper);
|
||||
//更新自定义字段
|
||||
List<FunctionalCaseCustomField> functionalCaseCustomFields = updateCustomFields(functionalCaseChangeRequest, oldCaseCustomFieldMap, caseId, caseCustomFieldMapper);
|
||||
//更新用例等级
|
||||
FunctionalCaseCustomField customField = new FunctionalCaseCustomField();
|
||||
customField.setCaseId(caseId);
|
||||
customField.setFieldId(defaultCustomFieldValueMap.get("priorityFieldId").toString());
|
||||
customField.setValue("P"+functionalCaseChangeRequest.getPriority());
|
||||
caseCustomFieldMapper.updateByPrimaryKeySelective(customField);
|
||||
//日志
|
||||
FunctionalCaseHistoryLogDTO historyLogDTO = new FunctionalCaseHistoryLogDTO(functionalCase, functionalCaseBlob, oldCaseCustomFieldMap.get(caseId), new ArrayList<>(), new ArrayList<>());
|
||||
FunctionalCaseHistoryLogDTO old = new FunctionalCaseHistoryLogDTO(oldCaseMap.get(caseId), oldBlobMap.get(caseId), new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
|
||||
|
@ -692,16 +704,16 @@ public class FunctionalCaseMinderService {
|
|||
TemplateDTO defaultTemplateDTO = projectTemplateService.getDefaultTemplateDTO(request.getProjectId(), TemplateScene.FUNCTIONAL.toString());
|
||||
List<TemplateCustomFieldDTO> customFields = defaultTemplateDTO.getCustomFields();
|
||||
Map<String, Object> defaultValueMap = new HashMap<>();
|
||||
String priorityFieldId = null;
|
||||
for (TemplateCustomFieldDTO field : customFields) {
|
||||
if (StringUtils.equalsIgnoreCase(field.getFieldName(), "functional_priority")) {
|
||||
if (field.getDefaultValue() == null) {
|
||||
field.setDefaultValue("P0");
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(field.getFieldName(), Translator.get("custom_field.functional_priority"))) {
|
||||
priorityFieldId = field.getFieldId();
|
||||
}
|
||||
if (field.getDefaultValue() != null) {
|
||||
if (field.getDefaultValue() != null && !StringUtils.equalsIgnoreCase(field.getFieldName(), Translator.get("custom_field.functional_priority"))) {
|
||||
defaultValueMap.put(field.getFieldId(), field.getDefaultValue());
|
||||
}
|
||||
}
|
||||
defaultValueMap.put("priorityFieldId", priorityFieldId);
|
||||
return defaultValueMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -449,7 +449,7 @@ public class FunctionalCaseService {
|
|||
long testPlanExecuteComment = testPlanCaseExecuteHistoryMapper.countByExample(testPlanCaseExecuteHistoryExample);
|
||||
OptionDTO executeOption = new OptionDTO();
|
||||
executeOption.setId("executiveComment");
|
||||
executeOption.setName(String.valueOf(reviewComment));
|
||||
executeOption.setName(String.valueOf(testPlanExecuteComment));
|
||||
commentList.add(2,executeOption);
|
||||
functionalCaseDetailDTO.setCommentList(commentList);
|
||||
long commentCount = caseComment + reviewComment + testPlanExecuteComment;
|
||||
|
|
|
@ -165,6 +165,7 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
|||
caseChangeRequest.setName("新增用例");
|
||||
caseChangeRequest.setModuleId("TEST_MINDER_MODULE_ID_GYQ2");
|
||||
caseChangeRequest.setMoveMode("AFTER");
|
||||
caseChangeRequest.setPriority(2);
|
||||
caseChangeRequest.setTargetId("TEST_FUNCTIONAL_MINDER_CASE_ID_3");
|
||||
caseChangeRequest.setTemplateId("100001");
|
||||
caseChangeRequest.setType("ADD");
|
||||
|
@ -172,8 +173,8 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
|||
caseChangeRequest.setCaseEditType("TEXT");
|
||||
List<CaseCustomFieldDTO> customFields = new ArrayList<>();
|
||||
CaseCustomFieldDTO customFieldDTO = new CaseCustomFieldDTO();
|
||||
customFieldDTO.setFieldId("custom_field_minder_gyq_id_3");
|
||||
customFieldDTO.setValue("P0");
|
||||
customFieldDTO.setFieldId("custom_field_minder_gyq_id_4");
|
||||
customFieldDTO.setValue("a");
|
||||
customFields.add(customFieldDTO);
|
||||
caseChangeRequest.setCustomFields(customFields);
|
||||
caseChangeRequests.add(caseChangeRequest);
|
||||
|
@ -182,6 +183,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.setMoveMode("BEFORE");
|
||||
caseChangeRequest.setTargetId("TEST_FUNCTIONAL_MINDER_CASE_ID_2");
|
||||
caseChangeRequest.setType("UPDATE");
|
||||
|
@ -189,8 +191,8 @@ public class FunctionalCaseMinderControllerTest extends BaseTest {
|
|||
caseChangeRequest.setCaseEditType("TEXT");
|
||||
customFields = new ArrayList<>();
|
||||
customFieldDTO = new CaseCustomFieldDTO();
|
||||
customFieldDTO.setFieldId("custom_field_minder_gyq_id_3");
|
||||
customFieldDTO.setValue("P3");
|
||||
customFieldDTO.setFieldId("custom_field_minder_gyq_id_4");
|
||||
customFieldDTO.setValue("b");
|
||||
customFields.add(customFieldDTO);
|
||||
caseChangeRequest.setCustomFields(customFields);
|
||||
caseChangeRequests.add(caseChangeRequest);
|
||||
|
|
|
@ -30,6 +30,8 @@ INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST
|
|||
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_2', 'custom_field_minder_gyq_id_3', 'P3');
|
||||
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_5', 'custom_field_minder_gyq_id_3', 'P3');
|
||||
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_6', 'custom_field_minder_gyq_id_3', 'P2');
|
||||
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('TEST_FUNCTIONAL_MINDER_CASE_ID_6', 'custom_field_minder_gyq_id_4', 'a');
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -56,7 +58,8 @@ INSERT INTO test_plan_functional_case(id, test_plan_id, functional_case_id, crea
|
|||
|
||||
INSERT INTO custom_field (id, name, scene, type, remark, internal, scope_type, create_time, update_time, create_user, scope_id) VALUES
|
||||
('custom_field_minder_gyq_id_2', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001'),
|
||||
('custom_field_minder_gyq_id_3', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'PROJECT', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'project-case-minder-test');
|
||||
('custom_field_minder_gyq_id_3', 'functional_priority', 'FUNCTIONAL', 'SELECT', '', true, 'PROJECT', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'project-case-minder-test'),
|
||||
('custom_field_minder_gyq_id_4', 'fff', 'FUNCTIONAL', 'SELECT', '', true, 'PROJECT', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'project-case-minder-test');
|
||||
|
||||
|
||||
|
||||
|
@ -99,3 +102,4 @@ VALUES ('additional1', 'project-case-minder-test', 'additional1', 'TEST_MINDER_M
|
|||
|
||||
INSERT INTO template(id,name,remark,internal,update_time,create_time,create_user,scope_type,scope_id,enable_third_part, scene, ref_id)
|
||||
VALUES ('100001', 'functional_default', '', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'PROJECT', 'project-case-minder-test', 0, 'FUNCTIONAL', '100001');
|
||||
INSERT INTO template_custom_field(id, field_id, template_id, required, pos, api_field_id, default_value) VALUES ('template_custom_field_minder_gyq_id', 'custom_field_minder_gyq_id_3', '100001', b'1', 0, NULL, NULL);
|
|
@ -73,6 +73,10 @@ public class TestPlanCollectionMinderEditDTO implements Serializable {
|
|||
@NotNull(message = "{test_plan_collection.stop_on_fail.not_blank}")
|
||||
private Boolean stopOnFail;
|
||||
|
||||
@Schema(description = "叶子等级", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{test_plan_collection.num.not_blank}")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "关联关系的数据")
|
||||
private List<TestPlanCollectionAssociateDTO>associateDTOS;
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public class TestPlanCollectionMinderService {
|
|||
} else {
|
||||
typeTreeNodeDTO.setPriority(2);
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(CaseType.FUNCTIONAL_CASE.getKey(),testPlanCollection.getType())) {
|
||||
if (StringUtils.equalsIgnoreCase(CaseType.FUNCTIONAL_CASE.getKey(), testPlanCollection.getType())) {
|
||||
typeTreeNodeDTO.setPriority(null);
|
||||
}
|
||||
return typeTreeNodeDTO;
|
||||
|
@ -188,7 +188,7 @@ public class TestPlanCollectionMinderService {
|
|||
buildChild(countTreeNodeDTO, count + Translator.get("test_plan.mind.strip"), "test_plan.mind.case_count", countTreeDTO, endList);
|
||||
TestPlanCollectionMinderTreeDTO envTreeDTO = new TestPlanCollectionMinderTreeDTO();
|
||||
TestPlanCollectionMinderTreeNodeDTO envTreeNodeDTO = new TestPlanCollectionMinderTreeNodeDTO();
|
||||
buildChild(envTreeNodeDTO, StringUtils.equalsIgnoreCase(planCollection.getEnvironmentId(),ModuleConstants.ROOT_NODE_PARENT_ID) ? Translator.get("api_report_default_env") : planCollection.getEnvName(), "test_plan.mind.environment", envTreeDTO, endList);
|
||||
buildChild(envTreeNodeDTO, StringUtils.equalsIgnoreCase(planCollection.getEnvironmentId(), ModuleConstants.ROOT_NODE_PARENT_ID) ? Translator.get("api_report_default_env") : planCollection.getEnvName(), "test_plan.mind.environment", envTreeDTO, endList);
|
||||
TestPlanCollectionMinderTreeDTO poolTreeDTO = new TestPlanCollectionMinderTreeDTO();
|
||||
TestPlanCollectionMinderTreeNodeDTO poolTreeNodeDTO = new TestPlanCollectionMinderTreeNodeDTO();
|
||||
buildChild(poolTreeNodeDTO, planCollection.getPoolName(), "test_plan.mind.test_resource_pool", poolTreeDTO, endList);
|
||||
|
@ -215,7 +215,7 @@ public class TestPlanCollectionMinderService {
|
|||
buildChild(countTreeNodeDTO, count + Translator.get("test_plan.mind.strip"), "test_plan.mind.case_count", countTreeDTO, endList);
|
||||
TestPlanCollectionMinderTreeDTO envTreeDTO = new TestPlanCollectionMinderTreeDTO();
|
||||
TestPlanCollectionMinderTreeNodeDTO envTreeNodeDTO = new TestPlanCollectionMinderTreeNodeDTO();
|
||||
buildChild(envTreeNodeDTO, StringUtils.equalsIgnoreCase(planCollection.getEnvironmentId(),ModuleConstants.ROOT_NODE_PARENT_ID) ? Translator.get("api_report_default_env") : planCollection.getEnvName() , "test_plan.mind.environment", envTreeDTO, endList);
|
||||
buildChild(envTreeNodeDTO, StringUtils.equalsIgnoreCase(planCollection.getEnvironmentId(), ModuleConstants.ROOT_NODE_PARENT_ID) ? Translator.get("api_report_default_env") : planCollection.getEnvName(), "test_plan.mind.environment", envTreeDTO, endList);
|
||||
TestPlanCollectionMinderTreeDTO poolTreeDTO = new TestPlanCollectionMinderTreeDTO();
|
||||
TestPlanCollectionMinderTreeNodeDTO poolTreeNodeDTO = new TestPlanCollectionMinderTreeNodeDTO();
|
||||
buildChild(poolTreeNodeDTO, planCollection.getPoolName(), "test_plan.mind.test_resource_pool", poolTreeDTO, endList);
|
||||
|
@ -272,7 +272,7 @@ public class TestPlanCollectionMinderService {
|
|||
}
|
||||
|
||||
private static void checkNameRepeat(Map<String, List<String>> updateTypeNameMap, Map<String, List<String>> addTypeNameMap) {
|
||||
updateTypeNameMap.forEach((k, v)->{
|
||||
updateTypeNameMap.forEach((k, v) -> {
|
||||
List<String> nameList = addTypeNameMap.get(k);
|
||||
if (CollectionUtils.isNotEmpty(nameList)) {
|
||||
List<String> repeatList = v.stream().filter(nameList::contains).collect(Collectors.toList());
|
||||
|
@ -284,8 +284,8 @@ 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())).toList();
|
||||
Map<String, List<String>>typeNamesMap = new HashMap<>();
|
||||
List<TestPlanCollectionMinderEditDTO> updateList = request.getEditList().stream().filter(t -> StringUtils.isNotBlank(t.getId()) && t.getLevel() == 2).toList();
|
||||
Map<String, List<String>> typeNamesMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(updateList)) {
|
||||
//处理删除
|
||||
deleteCollection(updateList, request.getPlanId());
|
||||
|
@ -311,8 +311,8 @@ public class TestPlanCollectionMinderService {
|
|||
}
|
||||
|
||||
private Map<String, List<String>> dealAddList(TestPlanCollectionMinderEditRequest request, String userId, Map<String, List<BaseCollectionAssociateRequest>> associateMap, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
Map<String, List<String>>typeNamesMap = new HashMap<>();
|
||||
List<TestPlanCollectionMinderEditDTO> addList = request.getEditList().stream().filter(t -> StringUtils.isBlank(t.getId())).toList();
|
||||
Map<String, List<String>> typeNamesMap = new HashMap<>();
|
||||
List<TestPlanCollectionMinderEditDTO> addList = request.getEditList().stream().filter(t -> StringUtils.isBlank(t.getId()) && t.getLevel() == 2).toList();
|
||||
if (CollectionUtils.isNotEmpty(addList)) {
|
||||
for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : addList) {
|
||||
TestPlanCollection testPlanCollection = addCollection(request, userId, testPlanCollectionMinderEditDTO, parentMap, collectionMapper);
|
||||
|
@ -346,14 +346,6 @@ public class TestPlanCollectionMinderService {
|
|||
return testPlanCollections.stream().collect(Collectors.groupingBy(TestPlanCollection::getType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<String, List<TestPlanCollection>> getChildrenMap(TestPlanCollectionMinderEditRequest request) {
|
||||
TestPlanCollectionExample testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andParentIdNotEqualTo(ModuleConstants.ROOT_NODE_PARENT_ID);
|
||||
List<TestPlanCollection> testPlanCollections = testPlanCollectionMapper.selectByExample(testPlanCollectionExample);
|
||||
return testPlanCollections.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();
|
||||
|
|
|
@ -69,6 +69,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
|||
testPlanCollectionMinderEditDTO.setType("API");
|
||||
testPlanCollectionMinderEditDTO.setExtended(false);
|
||||
testPlanCollectionMinderEditDTO.setGrouped(false);
|
||||
testPlanCollectionMinderEditDTO.setLevel(2);
|
||||
testPlanCollectionMinderEditDTO.setEnvironmentId("gyq_123");
|
||||
testPlanCollectionMinderEditDTO.setTestResourcePoolId("gyq_123_pool");
|
||||
testPlanCollectionMinderEditDTO.setRetryOnFail(true);
|
||||
|
@ -94,6 +95,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
|||
testPlanCollectionMinderEditDTO.setId(null);
|
||||
testPlanCollectionMinderEditDTO.setText("新建名称");
|
||||
testPlanCollectionMinderEditDTO.setNum(500L);
|
||||
testPlanCollectionMinderEditDTO.setLevel(2);
|
||||
testPlanCollectionMinderEditDTO.setExecuteMethod("PARALLEL");
|
||||
testPlanCollectionMinderEditDTO.setType("API");
|
||||
testPlanCollectionMinderEditDTO.setExtended(false);
|
||||
|
@ -133,6 +135,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
|||
testPlanCollectionMinderEditDTO.setNum(500L);
|
||||
testPlanCollectionMinderEditDTO.setExecuteMethod("PARALLEL");
|
||||
testPlanCollectionMinderEditDTO.setType("API");
|
||||
testPlanCollectionMinderEditDTO.setLevel(2);
|
||||
testPlanCollectionMinderEditDTO.setExtended(false);
|
||||
testPlanCollectionMinderEditDTO.setGrouped(false);
|
||||
testPlanCollectionMinderEditDTO.setEnvironmentId("gyq_123");
|
||||
|
|
Loading…
Reference in New Issue