From 382526854a524883355a4070e47a4f49fe31b06e Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 5 Jun 2024 17:25:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E8=A7=84=E5=88=92=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/dto/TestPlanAllocationTypeDTO.java | 24 ---- .../plan/dto/TestPlanCollectionInitDTO.java | 29 ----- .../TestPlanAllocationCreateRequest.java | 27 ---- .../dto/request/TestPlanCreateRequest.java | 3 - .../dto/request/TestPlanUpdateRequest.java | 3 - .../plan/service/TestPlanService.java | 88 -------------- .../plan/controller/TestPlanTests.java | 115 +----------------- 7 files changed, 3 insertions(+), 286 deletions(-) delete mode 100644 backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanAllocationTypeDTO.java delete mode 100644 backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanCollectionInitDTO.java delete mode 100644 backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanAllocationCreateRequest.java diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanAllocationTypeDTO.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanAllocationTypeDTO.java deleted file mode 100644 index 5dc64583ef..0000000000 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanAllocationTypeDTO.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.metersphere.plan.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -public class TestPlanAllocationTypeDTO { - - @Schema(description = "测试集类型ID") - private String id; - - @Schema(description = "测试集名称", requiredMode = Schema.RequiredMode.REQUIRED) - private String name; - - @Schema(description = "测试集类型", allowableValues = {"FUNCTIONAL", "API", "SCENARIO"}, requiredMode = Schema.RequiredMode.REQUIRED) - private String type; - - @Schema(description = "执行方式", allowableValues = {"SERIAL-串行", "PARALLEL-并行"}, requiredMode = Schema.RequiredMode.REQUIRED) - private String executeMethod; - - @Schema(description = "位置, 从1开始递增的整数即可", requiredMode = Schema.RequiredMode.REQUIRED) - private Long pos; - -} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanCollectionInitDTO.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanCollectionInitDTO.java deleted file mode 100644 index 4a2668110f..0000000000 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/TestPlanCollectionInitDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.metersphere.plan.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Data -public class TestPlanCollectionInitDTO { - - @Schema(description = "测试集节点ID") - private String id; - - @Schema(description = "所属测试集类型ID, 类型ID空时传递具体测试集类型名称即可", requiredMode = Schema.RequiredMode.REQUIRED) - private String testCollectionTypeId; - - @Schema(description = "测试集名称", requiredMode = Schema.RequiredMode.REQUIRED) - private String name; - - @Schema(description = "执行方式", allowableValues = {"SERIAL-串行", "PARALLEL-并行"}, requiredMode = Schema.RequiredMode.REQUIRED) - private String executeMethod; - - @Schema(description = "是否使用环境组", requiredMode = Schema.RequiredMode.REQUIRED) - private Boolean grouped; - - @Schema(description = "环境ID/环境组ID, 根据是否环境组来传递相应的值", requiredMode = Schema.RequiredMode.REQUIRED) - private String environmentId; - - @Schema(description = "位置, 从1开始递增的整数即可", requiredMode = Schema.RequiredMode.REQUIRED) - private Long pos; -} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanAllocationCreateRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanAllocationCreateRequest.java deleted file mode 100644 index c4186de404..0000000000 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanAllocationCreateRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.metersphere.plan.dto.request; - -import io.metersphere.plan.domain.TestPlanAllocation; -import io.metersphere.plan.dto.TestPlanAllocationTypeDTO; -import io.metersphere.plan.dto.TestPlanCollectionInitDTO; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.List; - -/** - * 规划创建请求参数-脑图使用 - */ -@Data -@EqualsAndHashCode(callSuper = false) -public class TestPlanAllocationCreateRequest { - - @Schema(description = "规划节点(分类/类型-第二级)") - private List typeNodes; - - @Schema(description = "规划节点(功能集-第三级)") - private List collectionNodes; - - @Schema(description = "规划配置") - private TestPlanAllocation config; -} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java index 0d38bc4f08..0f63eca208 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanCreateRequest.java @@ -75,7 +75,4 @@ public class TestPlanCreateRequest { @Schema(description = "查询用例的条件") private BaseAssociateCaseRequest baseAssociateCaseRequest; - - @Schema(description = "测试规划请求参数") - private TestPlanAllocationCreateRequest allocationRequest; } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanUpdateRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanUpdateRequest.java index 9bf7cd8b9e..8234970877 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanUpdateRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanUpdateRequest.java @@ -52,7 +52,4 @@ public class TestPlanUpdateRequest { @Schema(description = "测试计划组Id") private String testPlanGroupId = TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID; - - @Schema(description = "测试规划请求参数") - private TestPlanAllocationCreateRequest allocationRequest; } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java index 1fd1f6b8f5..a982468893 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -89,8 +89,6 @@ public class TestPlanService extends TestPlanBaseUtilsService { */ public TestPlan add(TestPlanCreateRequest testPlanCreateRequest, String operator, String requestUrl, String requestMethod) { TestPlan testPlan = savePlanDTO(testPlanCreateRequest, operator); - // 保存规划节点及配置 - saveAllocation(testPlanCreateRequest.getAllocationRequest(), operator, testPlan.getId()); testPlanLogService.saveAddLog(testPlan, operator, requestUrl, requestMethod); return testPlan; } @@ -147,83 +145,6 @@ public class TestPlanService extends TestPlanBaseUtilsService { } } - /** - * 保存规划 - * - * @param allocationRequest 规划的请求参数 - * @param currentUser 当前用户 - */ - private void saveAllocation(TestPlanAllocationCreateRequest allocationRequest, String currentUser, String planId) { - // 前置参数校验 - checkAllocationParam(allocationRequest); - - SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); - TestPlanAllocationTypeMapper allocationTypeBatchMapper = sqlSession.getMapper(TestPlanAllocationTypeMapper.class); - TestPlanCollectionMapper collectionBatchMapper = sqlSession.getMapper(TestPlanCollectionMapper.class); - // 处理测试集分类 - Map allocationTypeMap = new HashMap<>(); - List addAllocationTypes = new ArrayList<>(); - List updateAllocationTypes = new ArrayList<>(); - allocationRequest.getTypeNodes().forEach(allocationTypeDTO -> { - TestPlanAllocationType allocationType = new TestPlanAllocationType(); - BeanUtils.copyBean(allocationType, allocationTypeDTO); - allocationType.setTestPlanId(planId); - allocationType.setPos(allocationType.getPos() << 6); - if (allocationTypeDTO.getId() == null) { - allocationType.setId(IDGenerator.nextStr()); - allocationTypeMap.put(allocationType.getType(), allocationType.getId()); - addAllocationTypes.add(allocationType); - } else { - updateAllocationTypes.add(allocationType); - } - }); - // 处理测试集 - List addCollections = new ArrayList<>(); - List updateCollections = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(allocationRequest.getCollectionNodes())) { - allocationRequest.getCollectionNodes().forEach(collectionNode -> { - TestPlanCollection collection = new TestPlanCollection(); - BeanUtils.copyBean(collection, collectionNode); - collection.setTestPlanId(planId); - collection.setPos(collection.getPos() << 6); - if (collection.getId() == null) { - collection.setId(IDGenerator.nextStr()); - collection.setTestCollectionTypeId(allocationTypeMap.get(collection.getTestCollectionTypeId())); - collection.setCreateUser(currentUser); - collection.setCreateTime(System.currentTimeMillis()); - addCollections.add(collection); - } else { - updateCollections.add(collection); - } - }); - } - - // 入库 { 测试集分类, 测试集, 规划配置项 } - if (CollectionUtils.isNotEmpty(addAllocationTypes)) { - allocationTypeBatchMapper.batchInsert(addAllocationTypes); - } - if (CollectionUtils.isNotEmpty(updateAllocationTypes)) { - // 仅有三条记录 - updateAllocationTypes.forEach(allocationType -> allocationTypeBatchMapper.updateByPrimaryKey(allocationType)); - } - if (CollectionUtils.isNotEmpty(addCollections)) { - collectionBatchMapper.batchInsert(addCollections); - } - if (CollectionUtils.isNotEmpty(updateCollections)) { - updateCollections.forEach(collection -> collectionBatchMapper.updateByPrimaryKeySelective(collection)); - } - if (allocationRequest.getConfig().getId() == null) { - TestPlanAllocation allocationConfig = allocationRequest.getConfig(); - allocationConfig.setId(IDGenerator.nextStr()); - allocationConfig.setTestPlanId(planId); - testPlanAllocationMapper.insert(allocationConfig); - } else { - testPlanAllocationMapper.updateByPrimaryKeySelective(allocationRequest.getConfig()); - } - sqlSession.flushStatements(); - SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); - } - /** * 删除测试计划 */ @@ -399,8 +320,6 @@ public class TestPlanService extends TestPlanBaseUtilsService { testPlanConfig.setPassThreshold(request.getPassThreshold()); testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig); } - // 保存规划节点及配置 - saveAllocation(request.getAllocationRequest(), userId, testPlan.getId()); testPlanLogService.saveUpdateLog(testPlan, testPlanMapper.selectByPrimaryKey(request.getId()), testPlan.getProjectId(), userId, requestUrl, requestMethod); return testPlan; } @@ -775,11 +694,4 @@ public class TestPlanService extends TestPlanBaseUtilsService { testPlanLogService.saveMoveLog(testPlanMapper.selectByPrimaryKey(request.getMoveId()), request.getMoveId(), logInsertModule); return new TestPlanOperationResponse(1); } - - - private void checkAllocationParam(TestPlanAllocationCreateRequest request) { - if (CollectionUtils.size(request.getTypeNodes()) != 3) { - throw new MSException(Translator.get("test_plan_allocation_type_param_error")); - } - } } diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java index ac1d82b8a2..56ec697a22 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java @@ -5,13 +5,12 @@ import io.metersphere.api.domain.ApiTestCase; import io.metersphere.functional.domain.FunctionalCase; import io.metersphere.plan.constants.TestPlanResourceConfig; import io.metersphere.plan.domain.*; -import io.metersphere.plan.dto.TestPlanAllocationTypeDTO; -import io.metersphere.plan.dto.TestPlanCollectionInitDTO; import io.metersphere.plan.dto.request.*; import io.metersphere.plan.dto.response.TestPlanOperationResponse; import io.metersphere.plan.dto.response.TestPlanResponse; -import io.metersphere.plan.enums.ExecuteMethod; -import io.metersphere.plan.mapper.*; +import io.metersphere.plan.mapper.ExtTestPlanMapper; +import io.metersphere.plan.mapper.TestPlanMapper; +import io.metersphere.plan.mapper.TestPlanReportMapper; import io.metersphere.plan.service.*; import io.metersphere.plan.utils.TestPlanTestUtils; import io.metersphere.project.domain.Project; @@ -90,12 +89,6 @@ public class TestPlanTests extends BaseTest { private CommonProjectService commonProjectService; @Resource private TestPlanTestService testPlanTestService; - @Resource - private TestPlanAllocationTypeMapper testPlanAllocationTypeMapper; - @Resource - private TestPlanCollectionMapper testPlanCollectionMapper; - @Resource - private TestPlanAllocationMapper testPlanAllocationMapper; private static final List LOG_CHECK_LIST = new ArrayList<>(); @@ -535,7 +528,6 @@ public class TestPlanTests extends BaseTest { BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest(); request.setBaseAssociateCaseRequest(associateCaseRequest); - request.setAllocationRequest(buildAllocationParam()); for (int i = 0; i < 999; i++) { String moduleId; if (i < 50) { @@ -647,7 +639,6 @@ public class TestPlanTests extends BaseTest { itemRequest.setGroupId(groupTestPlanId7); itemRequest.setName("testPlan_group7_" + i); itemRequest.setBaseAssociateCaseRequest(associateCaseRequest); - itemRequest.setAllocationRequest(buildAllocationParam()); if (i == 0) { //测试项目没有开启测试计划模块时能否使用 testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "testPlan"); @@ -1025,7 +1016,6 @@ public class TestPlanTests extends BaseTest { //修改名称 TestPlanUpdateRequest updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); updateRequest.setName(IDGenerator.nextStr()); - updateRequest.setAllocationRequest(buildAllocationParam()); //测试项目没有开启测试计划模块时能否使用 testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "testPlan"); @@ -1044,7 +1034,6 @@ public class TestPlanTests extends BaseTest { //修改回来 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); updateRequest.setName(testPlan.getName()); - updateRequest.setAllocationRequest(buildAllocationParam()); mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest); returnStr = mvcResult.getResponse().getContentAsString(); holder = JSON.parseObject(returnStr, ResultHolder.class); @@ -1063,7 +1052,6 @@ public class TestPlanTests extends BaseTest { BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2"); updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); updateRequest.setModuleId(a2Node.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest); returnStr = mvcResult.getResponse().getContentAsString(); holder = JSON.parseObject(returnStr, ResultHolder.class); @@ -1072,7 +1060,6 @@ public class TestPlanTests extends BaseTest { testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest); //修改回来 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setModuleId(testPlan.getModuleId()); mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest); returnStr = mvcResult.getResponse().getContentAsString(); @@ -1083,7 +1070,6 @@ public class TestPlanTests extends BaseTest { //修改标签 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setTags(new LinkedHashSet<>(Arrays.asList("tag1", "tag2", "tag3", "tag3"))); mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest); returnStr = mvcResult.getResponse().getContentAsString(); @@ -1095,7 +1081,6 @@ public class TestPlanTests extends BaseTest { //修改计划开始结束时间 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setPlannedStartTime(System.currentTimeMillis()); updateRequest.setPlannedEndTime(updateRequest.getPlannedStartTime() - 10000); mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest); @@ -1108,7 +1093,6 @@ public class TestPlanTests extends BaseTest { //修改描述 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setDescription("This is desc"); mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest); returnStr = mvcResult.getResponse().getContentAsString(); @@ -1120,7 +1104,6 @@ public class TestPlanTests extends BaseTest { //修改配置项 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setAutomaticStatusUpdate(true); updateRequest.setRepeatCase(true); updateRequest.setPassThreshold(43.12); @@ -1132,7 +1115,6 @@ public class TestPlanTests extends BaseTest { testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest); updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setAutomaticStatusUpdate(false); updateRequest.setRepeatCase(false); updateRequest.setPassThreshold(56.47); @@ -1147,19 +1129,16 @@ public class TestPlanTests extends BaseTest { //修改a2节点下的数据(91,92)的所属测试计划组 updateRequest = testPlanTestService.generateUpdateRequest(testPlanTestService.selectTestPlanByName("testPlan_91").getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setTestPlanGroupId(groupTestPlanId7); this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest); a2NodeCount--; updateRequest = testPlanTestService.generateUpdateRequest(testPlanTestService.selectTestPlanByName("testPlan_92").getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setTestPlanGroupId(groupTestPlanId7); this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest); a2NodeCount--; //修改测试计划组信息 updateRequest = testPlanTestService.generateUpdateRequest(groupTestPlanId7); - updateRequest.setAllocationRequest(buildAllocationParam()); updateRequest.setName(IDGenerator.nextStr()); updateRequest.setDescription("This is desc"); updateRequest.setTags(new LinkedHashSet<>(Arrays.asList("tag1", "tag2", "tag3", "tag3"))); @@ -1169,7 +1148,6 @@ public class TestPlanTests extends BaseTest { //什么都不修改 updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId()); - updateRequest.setAllocationRequest(buildAllocationParam()); this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest); //因为有条数据被移动了测试计划组里,所以检查一下moduleCount. @@ -1972,7 +1950,6 @@ public class TestPlanTests extends BaseTest { TestPlanCreateRequest request = new TestPlanCreateRequest(); request.setProjectId(project.getId()); request.setTestPlanning(false); - request.setAllocationRequest(buildAllocationParam()); BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest(); associateCaseRequest.setFunctionalSelectIds(Arrays.asList("wx_fc_1", "wx_fc_2")); request.setBaseAssociateCaseRequest(associateCaseRequest); @@ -2137,90 +2114,4 @@ public class TestPlanTests extends BaseTest { request.setSelectIds(Arrays.asList("wx_test_plan_id_1")); this.requestPostWithOk(URL_TEST_PLAN_BATCH_EDIT, request); } - - @Test - @Order(308) - void testSaveAllocation() throws Exception { - TestPlanCreateRequest createRequest = new TestPlanCreateRequest(); - BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest(); - createRequest.setBaseAssociateCaseRequest(associateCaseRequest); - createRequest.setTestPlanning(true); - createRequest.setProjectId(project.getId()); - createRequest.setName("测试一下关联"); - createRequest.setPlannedEndTime(null); - createRequest.setPlannedStartTime(null); - createRequest.setRepeatCase(false); - createRequest.setAutomaticStatusUpdate(false); - createRequest.setPassThreshold(100); - createRequest.setDescription(null); - createRequest.setType(TestPlanConstants.TEST_PLAN_TYPE_PLAN); - createRequest.setAllocationRequest(buildAllocationParam()); - MvcResult mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_ADD, createRequest); - String sortData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); - ResultHolder sortHolder = JSON.parseObject(sortData, ResultHolder.class); - TestPlan testPlan = JSON.parseObject(JSON.toJSONString(sortHolder.getData()), TestPlan.class); - TestPlanAllocationCreateRequest updateRequest = buildAllocationUpdateParam(testPlan.getId()); - createRequest.setAllocationRequest(updateRequest); - this.requestPostWithOk(URL_POST_TEST_PLAN_ADD, createRequest); - TestPlanAllocationCreateRequest createRequest1 = buildAllocationParam(); - createRequest1.setCollectionNodes(null); - createRequest.setAllocationRequest(createRequest1); - this.requestPostWithOk(URL_POST_TEST_PLAN_ADD, createRequest); - } - - private TestPlanAllocationCreateRequest buildAllocationParam() { - TestPlanAllocationCreateRequest request = new TestPlanAllocationCreateRequest(); - TestPlanAllocationTypeDTO functionalType = new TestPlanAllocationTypeDTO(); - functionalType.setType(CaseType.FUNCTIONAL_CASE.getKey()); - functionalType.setName("功能用例"); - functionalType.setPos(1L); - functionalType.setExecuteMethod(ExecuteMethod.SERIAL.name()); - request.setTypeNodes(List.of(functionalType, functionalType, functionalType)); - TestPlanCollectionInitDTO collection = new TestPlanCollectionInitDTO(); - collection.setName("默认测试集"); - collection.setTestCollectionTypeId(CaseType.FUNCTIONAL_CASE.getKey()); - collection.setExecuteMethod(ExecuteMethod.PARALLEL.name()); - collection.setGrouped(false); - collection.setEnvironmentId(IDGenerator.nextStr()); - collection.setPos(1L); - request.setCollectionNodes(List.of(collection)); - TestPlanAllocation allocation = new TestPlanAllocation(); - allocation.setTestResourcePoolId(IDGenerator.nextStr()); - allocation.setRetryOnFail(true); - allocation.setRetryTimes(10); - allocation.setRetryInterval(1000); - allocation.setRetryType(CaseType.SCENARIO_CASE.getKey()); - allocation.setStopOnFail(false); - request.setConfig(allocation); - return request; - } - - private TestPlanAllocationCreateRequest buildAllocationUpdateParam(String planId) { - TestPlanAllocationCreateRequest updateParam = new TestPlanAllocationCreateRequest(); - TestPlanAllocationTypeExample allocationTypeExample = new TestPlanAllocationTypeExample(); - allocationTypeExample.createCriteria().andTestPlanIdEqualTo(planId); - List testPlanAllocationTypes = testPlanAllocationTypeMapper.selectByExample(allocationTypeExample); - List allocationTypeDTOS = new ArrayList<>(); - testPlanAllocationTypes.forEach(allocationType -> { - TestPlanAllocationTypeDTO allocationTypeDTO = new TestPlanAllocationTypeDTO(); - BeanUtils.copyBean(allocationTypeDTO, allocationType); - allocationTypeDTOS.add(allocationTypeDTO); - }); - TestPlanCollectionExample collectionExample = new TestPlanCollectionExample(); - collectionExample.createCriteria().andTestPlanIdEqualTo(planId); - List collections = testPlanCollectionMapper.selectByExample(collectionExample); - List collectionInitDTOS = new ArrayList<>(); - collections.forEach(collection -> { - TestPlanCollectionInitDTO collectionInitDTO = new TestPlanCollectionInitDTO(); - BeanUtils.copyBean(collectionInitDTO, collection); - collectionInitDTOS.add(collectionInitDTO); - }); - TestPlanAllocationExample example = new TestPlanAllocationExample(); - example.createCriteria().andTestPlanIdEqualTo(planId); - TestPlanAllocation allocation = testPlanAllocationMapper.selectByExample(example).get(0); - updateParam.setTypeNodes(allocationTypeDTOS); - updateParam.setCollectionNodes(collectionInitDTOS); - updateParam.setConfig(allocation); - return updateParam; - } }