refactor(测试计划): 优化规划保存功能
This commit is contained in:
parent
1d00eb397f
commit
382526854a
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
|
@ -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<TestPlanAllocationTypeDTO> typeNodes;
|
|
||||||
|
|
||||||
@Schema(description = "规划节点(功能集-第三级)")
|
|
||||||
private List<TestPlanCollectionInitDTO> collectionNodes;
|
|
||||||
|
|
||||||
@Schema(description = "规划配置")
|
|
||||||
private TestPlanAllocation config;
|
|
||||||
}
|
|
|
@ -75,7 +75,4 @@ public class TestPlanCreateRequest {
|
||||||
|
|
||||||
@Schema(description = "查询用例的条件")
|
@Schema(description = "查询用例的条件")
|
||||||
private BaseAssociateCaseRequest baseAssociateCaseRequest;
|
private BaseAssociateCaseRequest baseAssociateCaseRequest;
|
||||||
|
|
||||||
@Schema(description = "测试规划请求参数")
|
|
||||||
private TestPlanAllocationCreateRequest allocationRequest;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,4 @@ public class TestPlanUpdateRequest {
|
||||||
|
|
||||||
@Schema(description = "测试计划组Id")
|
@Schema(description = "测试计划组Id")
|
||||||
private String testPlanGroupId = TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID;
|
private String testPlanGroupId = TestPlanConstants.TEST_PLAN_DEFAULT_GROUP_ID;
|
||||||
|
|
||||||
@Schema(description = "测试规划请求参数")
|
|
||||||
private TestPlanAllocationCreateRequest allocationRequest;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,6 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
*/
|
*/
|
||||||
public TestPlan add(TestPlanCreateRequest testPlanCreateRequest, String operator, String requestUrl, String requestMethod) {
|
public TestPlan add(TestPlanCreateRequest testPlanCreateRequest, String operator, String requestUrl, String requestMethod) {
|
||||||
TestPlan testPlan = savePlanDTO(testPlanCreateRequest, operator);
|
TestPlan testPlan = savePlanDTO(testPlanCreateRequest, operator);
|
||||||
// 保存规划节点及配置
|
|
||||||
saveAllocation(testPlanCreateRequest.getAllocationRequest(), operator, testPlan.getId());
|
|
||||||
testPlanLogService.saveAddLog(testPlan, operator, requestUrl, requestMethod);
|
testPlanLogService.saveAddLog(testPlan, operator, requestUrl, requestMethod);
|
||||||
return testPlan;
|
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<String, String> allocationTypeMap = new HashMap<>();
|
|
||||||
List<TestPlanAllocationType> addAllocationTypes = new ArrayList<>();
|
|
||||||
List<TestPlanAllocationType> 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<TestPlanCollection> addCollections = new ArrayList<>();
|
|
||||||
List<TestPlanCollection> 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());
|
testPlanConfig.setPassThreshold(request.getPassThreshold());
|
||||||
testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig);
|
testPlanConfigMapper.updateByPrimaryKeySelective(testPlanConfig);
|
||||||
}
|
}
|
||||||
// 保存规划节点及配置
|
|
||||||
saveAllocation(request.getAllocationRequest(), userId, testPlan.getId());
|
|
||||||
testPlanLogService.saveUpdateLog(testPlan, testPlanMapper.selectByPrimaryKey(request.getId()), testPlan.getProjectId(), userId, requestUrl, requestMethod);
|
testPlanLogService.saveUpdateLog(testPlan, testPlanMapper.selectByPrimaryKey(request.getId()), testPlan.getProjectId(), userId, requestUrl, requestMethod);
|
||||||
return testPlan;
|
return testPlan;
|
||||||
}
|
}
|
||||||
|
@ -775,11 +694,4 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
testPlanLogService.saveMoveLog(testPlanMapper.selectByPrimaryKey(request.getMoveId()), request.getMoveId(), logInsertModule);
|
testPlanLogService.saveMoveLog(testPlanMapper.selectByPrimaryKey(request.getMoveId()), request.getMoveId(), logInsertModule);
|
||||||
return new TestPlanOperationResponse(1);
|
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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,12 @@ import io.metersphere.api.domain.ApiTestCase;
|
||||||
import io.metersphere.functional.domain.FunctionalCase;
|
import io.metersphere.functional.domain.FunctionalCase;
|
||||||
import io.metersphere.plan.constants.TestPlanResourceConfig;
|
import io.metersphere.plan.constants.TestPlanResourceConfig;
|
||||||
import io.metersphere.plan.domain.*;
|
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.request.*;
|
||||||
import io.metersphere.plan.dto.response.TestPlanOperationResponse;
|
import io.metersphere.plan.dto.response.TestPlanOperationResponse;
|
||||||
import io.metersphere.plan.dto.response.TestPlanResponse;
|
import io.metersphere.plan.dto.response.TestPlanResponse;
|
||||||
import io.metersphere.plan.enums.ExecuteMethod;
|
import io.metersphere.plan.mapper.ExtTestPlanMapper;
|
||||||
import io.metersphere.plan.mapper.*;
|
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||||
|
import io.metersphere.plan.mapper.TestPlanReportMapper;
|
||||||
import io.metersphere.plan.service.*;
|
import io.metersphere.plan.service.*;
|
||||||
import io.metersphere.plan.utils.TestPlanTestUtils;
|
import io.metersphere.plan.utils.TestPlanTestUtils;
|
||||||
import io.metersphere.project.domain.Project;
|
import io.metersphere.project.domain.Project;
|
||||||
|
@ -90,12 +89,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
private CommonProjectService commonProjectService;
|
private CommonProjectService commonProjectService;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanTestService testPlanTestService;
|
private TestPlanTestService testPlanTestService;
|
||||||
@Resource
|
|
||||||
private TestPlanAllocationTypeMapper testPlanAllocationTypeMapper;
|
|
||||||
@Resource
|
|
||||||
private TestPlanCollectionMapper testPlanCollectionMapper;
|
|
||||||
@Resource
|
|
||||||
private TestPlanAllocationMapper testPlanAllocationMapper;
|
|
||||||
|
|
||||||
private static final List<CheckLogModel> LOG_CHECK_LIST = new ArrayList<>();
|
private static final List<CheckLogModel> LOG_CHECK_LIST = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -535,7 +528,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest();
|
BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest();
|
||||||
request.setBaseAssociateCaseRequest(associateCaseRequest);
|
request.setBaseAssociateCaseRequest(associateCaseRequest);
|
||||||
request.setAllocationRequest(buildAllocationParam());
|
|
||||||
for (int i = 0; i < 999; i++) {
|
for (int i = 0; i < 999; i++) {
|
||||||
String moduleId;
|
String moduleId;
|
||||||
if (i < 50) {
|
if (i < 50) {
|
||||||
|
@ -647,7 +639,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
itemRequest.setGroupId(groupTestPlanId7);
|
itemRequest.setGroupId(groupTestPlanId7);
|
||||||
itemRequest.setName("testPlan_group7_" + i);
|
itemRequest.setName("testPlan_group7_" + i);
|
||||||
itemRequest.setBaseAssociateCaseRequest(associateCaseRequest);
|
itemRequest.setBaseAssociateCaseRequest(associateCaseRequest);
|
||||||
itemRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
//测试项目没有开启测试计划模块时能否使用
|
//测试项目没有开启测试计划模块时能否使用
|
||||||
testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "testPlan");
|
testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "testPlan");
|
||||||
|
@ -1025,7 +1016,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
//修改名称
|
//修改名称
|
||||||
TestPlanUpdateRequest updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
TestPlanUpdateRequest updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setName(IDGenerator.nextStr());
|
updateRequest.setName(IDGenerator.nextStr());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
|
|
||||||
//测试项目没有开启测试计划模块时能否使用
|
//测试项目没有开启测试计划模块时能否使用
|
||||||
testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "testPlan");
|
testPlanTestService.removeProjectModule(project, PROJECT_MODULE, "testPlan");
|
||||||
|
@ -1044,7 +1034,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
//修改回来
|
//修改回来
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setName(testPlan.getName());
|
updateRequest.setName(testPlan.getName());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
returnStr = mvcResult.getResponse().getContentAsString();
|
returnStr = mvcResult.getResponse().getContentAsString();
|
||||||
holder = JSON.parseObject(returnStr, ResultHolder.class);
|
holder = JSON.parseObject(returnStr, ResultHolder.class);
|
||||||
|
@ -1063,7 +1052,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
|
BaseTreeNode a2Node = TestPlanTestUtils.getNodeByName(preliminaryTreeNodes, "a2");
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setModuleId(a2Node.getId());
|
updateRequest.setModuleId(a2Node.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
returnStr = mvcResult.getResponse().getContentAsString();
|
returnStr = mvcResult.getResponse().getContentAsString();
|
||||||
holder = JSON.parseObject(returnStr, ResultHolder.class);
|
holder = JSON.parseObject(returnStr, ResultHolder.class);
|
||||||
|
@ -1072,7 +1060,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
|
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
|
||||||
//修改回来
|
//修改回来
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setModuleId(testPlan.getModuleId());
|
updateRequest.setModuleId(testPlan.getModuleId());
|
||||||
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
returnStr = mvcResult.getResponse().getContentAsString();
|
returnStr = mvcResult.getResponse().getContentAsString();
|
||||||
|
@ -1083,7 +1070,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
//修改标签
|
//修改标签
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setTags(new LinkedHashSet<>(Arrays.asList("tag1", "tag2", "tag3", "tag3")));
|
updateRequest.setTags(new LinkedHashSet<>(Arrays.asList("tag1", "tag2", "tag3", "tag3")));
|
||||||
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
returnStr = mvcResult.getResponse().getContentAsString();
|
returnStr = mvcResult.getResponse().getContentAsString();
|
||||||
|
@ -1095,7 +1081,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
//修改计划开始结束时间
|
//修改计划开始结束时间
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setPlannedStartTime(System.currentTimeMillis());
|
updateRequest.setPlannedStartTime(System.currentTimeMillis());
|
||||||
updateRequest.setPlannedEndTime(updateRequest.getPlannedStartTime() - 10000);
|
updateRequest.setPlannedEndTime(updateRequest.getPlannedStartTime() - 10000);
|
||||||
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
|
@ -1108,7 +1093,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
//修改描述
|
//修改描述
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setDescription("This is desc");
|
updateRequest.setDescription("This is desc");
|
||||||
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
mvcResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
returnStr = mvcResult.getResponse().getContentAsString();
|
returnStr = mvcResult.getResponse().getContentAsString();
|
||||||
|
@ -1120,7 +1104,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
//修改配置项
|
//修改配置项
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setAutomaticStatusUpdate(true);
|
updateRequest.setAutomaticStatusUpdate(true);
|
||||||
updateRequest.setRepeatCase(true);
|
updateRequest.setRepeatCase(true);
|
||||||
updateRequest.setPassThreshold(43.12);
|
updateRequest.setPassThreshold(43.12);
|
||||||
|
@ -1132,7 +1115,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
|
testPlanTestService.checkTestPlanUpdateResult(testPlan, testPlanConfig, updateRequest);
|
||||||
|
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setAutomaticStatusUpdate(false);
|
updateRequest.setAutomaticStatusUpdate(false);
|
||||||
updateRequest.setRepeatCase(false);
|
updateRequest.setRepeatCase(false);
|
||||||
updateRequest.setPassThreshold(56.47);
|
updateRequest.setPassThreshold(56.47);
|
||||||
|
@ -1147,19 +1129,16 @@ public class TestPlanTests extends BaseTest {
|
||||||
|
|
||||||
//修改a2节点下的数据(91,92)的所属测试计划组
|
//修改a2节点下的数据(91,92)的所属测试计划组
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlanTestService.selectTestPlanByName("testPlan_91").getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlanTestService.selectTestPlanByName("testPlan_91").getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setTestPlanGroupId(groupTestPlanId7);
|
updateRequest.setTestPlanGroupId(groupTestPlanId7);
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
a2NodeCount--;
|
a2NodeCount--;
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(testPlanTestService.selectTestPlanByName("testPlan_92").getId());
|
updateRequest = testPlanTestService.generateUpdateRequest(testPlanTestService.selectTestPlanByName("testPlan_92").getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setTestPlanGroupId(groupTestPlanId7);
|
updateRequest.setTestPlanGroupId(groupTestPlanId7);
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
a2NodeCount--;
|
a2NodeCount--;
|
||||||
|
|
||||||
//修改测试计划组信息
|
//修改测试计划组信息
|
||||||
updateRequest = testPlanTestService.generateUpdateRequest(groupTestPlanId7);
|
updateRequest = testPlanTestService.generateUpdateRequest(groupTestPlanId7);
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
updateRequest.setName(IDGenerator.nextStr());
|
updateRequest.setName(IDGenerator.nextStr());
|
||||||
updateRequest.setDescription("This is desc");
|
updateRequest.setDescription("This is desc");
|
||||||
updateRequest.setTags(new LinkedHashSet<>(Arrays.asList("tag1", "tag2", "tag3", "tag3")));
|
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 = testPlanTestService.generateUpdateRequest(testPlan.getId());
|
||||||
updateRequest.setAllocationRequest(buildAllocationParam());
|
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_UPDATE, updateRequest);
|
||||||
|
|
||||||
//因为有条数据被移动了测试计划组里,所以检查一下moduleCount.
|
//因为有条数据被移动了测试计划组里,所以检查一下moduleCount.
|
||||||
|
@ -1972,7 +1950,6 @@ public class TestPlanTests extends BaseTest {
|
||||||
TestPlanCreateRequest request = new TestPlanCreateRequest();
|
TestPlanCreateRequest request = new TestPlanCreateRequest();
|
||||||
request.setProjectId(project.getId());
|
request.setProjectId(project.getId());
|
||||||
request.setTestPlanning(false);
|
request.setTestPlanning(false);
|
||||||
request.setAllocationRequest(buildAllocationParam());
|
|
||||||
BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest();
|
BaseAssociateCaseRequest associateCaseRequest = new BaseAssociateCaseRequest();
|
||||||
associateCaseRequest.setFunctionalSelectIds(Arrays.asList("wx_fc_1", "wx_fc_2"));
|
associateCaseRequest.setFunctionalSelectIds(Arrays.asList("wx_fc_1", "wx_fc_2"));
|
||||||
request.setBaseAssociateCaseRequest(associateCaseRequest);
|
request.setBaseAssociateCaseRequest(associateCaseRequest);
|
||||||
|
@ -2137,90 +2114,4 @@ public class TestPlanTests extends BaseTest {
|
||||||
request.setSelectIds(Arrays.asList("wx_test_plan_id_1"));
|
request.setSelectIds(Arrays.asList("wx_test_plan_id_1"));
|
||||||
this.requestPostWithOk(URL_TEST_PLAN_BATCH_EDIT, request);
|
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<TestPlanAllocationType> testPlanAllocationTypes = testPlanAllocationTypeMapper.selectByExample(allocationTypeExample);
|
|
||||||
List<TestPlanAllocationTypeDTO> 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<TestPlanCollection> collections = testPlanCollectionMapper.selectByExample(collectionExample);
|
|
||||||
List<TestPlanCollectionInitDTO> 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue