fix(测试计划): 设置自动化用例报告名进行字符串最大值压缩
This commit is contained in:
parent
02ca9cf611
commit
40d2421458
|
@ -184,7 +184,7 @@ CREATE TABLE IF NOT EXISTS test_plan_report_api_case(
|
||||||
`api_case_id` VARCHAR(50) NOT NULL COMMENT '接口用例ID' ,
|
`api_case_id` VARCHAR(50) NOT NULL COMMENT '接口用例ID' ,
|
||||||
`api_case_num` BIGINT NOT NULL COMMENT '接口用例业务ID' ,
|
`api_case_num` BIGINT NOT NULL COMMENT '接口用例业务ID' ,
|
||||||
`api_case_name` VARCHAR(255) NOT NULL COMMENT '接口用例名称' ,
|
`api_case_name` VARCHAR(255) NOT NULL COMMENT '接口用例名称' ,
|
||||||
`api_case_module` VARCHAR(255) COMMENT '接口用例所属模块' ,
|
`api_case_module` VARCHAR(500) COMMENT '接口用例所属模块',
|
||||||
`api_case_priority` VARCHAR(255) COMMENT '接口用例等级' ,
|
`api_case_priority` VARCHAR(255) COMMENT '接口用例等级' ,
|
||||||
`api_case_execute_user` VARCHAR(50) COMMENT '接口用例执行人' ,
|
`api_case_execute_user` VARCHAR(50) COMMENT '接口用例执行人' ,
|
||||||
`api_case_execute_result` VARCHAR(50) COMMENT '接口用例执行结果' ,
|
`api_case_execute_result` VARCHAR(50) COMMENT '接口用例执行结果' ,
|
||||||
|
@ -206,7 +206,7 @@ CREATE TABLE IF NOT EXISTS test_plan_report_api_scenario(
|
||||||
`api_scenario_id` VARCHAR(50) NOT NULL COMMENT '场景用例ID' ,
|
`api_scenario_id` VARCHAR(50) NOT NULL COMMENT '场景用例ID' ,
|
||||||
`api_scenario_num` BIGINT NOT NULL COMMENT '场景用例业务ID' ,
|
`api_scenario_num` BIGINT NOT NULL COMMENT '场景用例业务ID' ,
|
||||||
`api_scenario_name` VARCHAR(255) NOT NULL COMMENT '场景用例名称' ,
|
`api_scenario_name` VARCHAR(255) NOT NULL COMMENT '场景用例名称' ,
|
||||||
`api_scenario_module` VARCHAR(255) COMMENT '场景用例所属模块' ,
|
`api_scenario_module` VARCHAR(500) COMMENT '场景用例所属模块',
|
||||||
`api_scenario_priority` VARCHAR(255) COMMENT '场景用例等级' ,
|
`api_scenario_priority` VARCHAR(255) COMMENT '场景用例等级' ,
|
||||||
`api_scenario_execute_user` VARCHAR(50) COMMENT '场景用例执行人' ,
|
`api_scenario_execute_user` VARCHAR(50) COMMENT '场景用例执行人' ,
|
||||||
`api_scenario_execute_result` VARCHAR(50) COMMENT '场景用例执行结果' ,
|
`api_scenario_execute_result` VARCHAR(50) COMMENT '场景用例执行结果' ,
|
||||||
|
|
|
@ -116,4 +116,13 @@ public class ServiceUtils {
|
||||||
}
|
}
|
||||||
throw new MSException(MsHttpResultCode.VALIDATE_FAILED, tips.toString());
|
throw new MSException(MsHttpResultCode.VALIDATE_FAILED, tips.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String compressName(String name, int maxSize) {
|
||||||
|
String newName = name;
|
||||||
|
// 限制名称长度 (数据库里最大的长度是255,这里判断超过250时截取到200附近)
|
||||||
|
if (newName.length() > maxSize) {
|
||||||
|
newName = newName.substring(0, maxSize - 3) + "...";
|
||||||
|
}
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ public class TestPlanExecuteController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch")
|
@PostMapping("/batch")
|
||||||
@Operation(summary = "测试计划-开始自行")
|
@Operation(summary = "测试计划-批量执行")
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
||||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
@CheckOwner(resourceId = "#request.getExecuteIds()", resourceType = "test_plan")
|
||||||
@Log(type = OperationLogType.EXECUTE, expression = "#msClass.batchExecuteLog(#request)", msClass = TestPlanLogService.class)
|
@Log(type = OperationLogType.EXECUTE, expression = "#msClass.batchExecuteLog(#request)", msClass = TestPlanLogService.class)
|
||||||
public void startExecute(@Validated @RequestBody TestPlanBatchExecuteRequest request) {
|
public void startExecute(@Validated @RequestBody TestPlanBatchExecuteRequest request) {
|
||||||
testPlanManagementService.checkModuleIsOpen(request.getProjectId(), TestPlanResourceConfig.CHECK_TYPE_PROJECT, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
testPlanManagementService.checkModuleIsOpen(request.getProjectId(), TestPlanResourceConfig.CHECK_TYPE_PROJECT, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
||||||
|
|
|
@ -31,6 +31,7 @@ import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import io.metersphere.system.service.SimpleUserService;
|
import io.metersphere.system.service.SimpleUserService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
|
import io.metersphere.system.utils.ServiceUtils;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -385,6 +386,8 @@ public class TestPlanReportService {
|
||||||
reportApiCase.setTestPlanReportId(report.getId());
|
reportApiCase.setTestPlanReportId(report.getId());
|
||||||
reportApiCase.setApiCaseModule(moduleParam.getApiModuleMap().getOrDefault(reportApiCase.getApiCaseModule(),
|
reportApiCase.setApiCaseModule(moduleParam.getApiModuleMap().getOrDefault(reportApiCase.getApiCaseModule(),
|
||||||
ModuleTreeUtils.MODULE_PATH_PREFIX + reportApiCase.getApiCaseModule()));
|
ModuleTreeUtils.MODULE_PATH_PREFIX + reportApiCase.getApiCaseModule()));
|
||||||
|
//根据不超过数据库字段最大长度压缩模块名
|
||||||
|
reportApiCase.setApiCaseModule(ServiceUtils.compressName(reportApiCase.getApiCaseModule(), 450));
|
||||||
if (!genParam.getUseManual()) {
|
if (!genParam.getUseManual()) {
|
||||||
// 接口执行时才更新结果
|
// 接口执行时才更新结果
|
||||||
reportApiCase.setApiCaseExecuteResult(null);
|
reportApiCase.setApiCaseExecuteResult(null);
|
||||||
|
@ -405,6 +408,8 @@ public class TestPlanReportService {
|
||||||
reportApiScenario.setTestPlanReportId(report.getId());
|
reportApiScenario.setTestPlanReportId(report.getId());
|
||||||
reportApiScenario.setApiScenarioModule(moduleParam.getScenarioModuleMap().getOrDefault(reportApiScenario.getApiScenarioModule(),
|
reportApiScenario.setApiScenarioModule(moduleParam.getScenarioModuleMap().getOrDefault(reportApiScenario.getApiScenarioModule(),
|
||||||
ModuleTreeUtils.MODULE_PATH_PREFIX + reportApiScenario.getApiScenarioModule()));
|
ModuleTreeUtils.MODULE_PATH_PREFIX + reportApiScenario.getApiScenarioModule()));
|
||||||
|
//根据不超过数据库字段最大长度压缩模块名
|
||||||
|
reportApiScenario.setApiScenarioModule(ServiceUtils.compressName(reportApiScenario.getApiScenarioModule(), 450));
|
||||||
if (!genParam.getUseManual()) {
|
if (!genParam.getUseManual()) {
|
||||||
// 接口执行时才更新结果
|
// 接口执行时才更新结果
|
||||||
reportApiScenario.setApiScenarioExecuteResult(null);
|
reportApiScenario.setApiScenarioExecuteResult(null);
|
||||||
|
|
Loading…
Reference in New Issue