refactor(接口测试): 测试计划接口用例执行,资源池异常提示优化

--bug=1049011 --user=陈建星 【测试计划】计划详情-测试点资源池无效-场景列表-操作-执行场景用例失败 https://www.tapd.cn/55049933/s/1631376
This commit is contained in:
AgAngle 2024-12-16 17:57:13 +08:00 committed by Craftsman
parent e2b5f9a402
commit 98714c6cb2
4 changed files with 23 additions and 3 deletions

View File

@ -220,6 +220,24 @@ public class ApiExecuteService {
return null;
}
/**
* 测试计划资源发送执行任务
*
* @param taskRequest 执行参数
*/
public TaskRequestDTO executePlanResource(TaskRequestDTO taskRequest) {
try {
return execute(taskRequest);
} catch (MSException e) {
if (e.getErrorCode() == ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG) {
// 提示没有可用资源池
throw new MSException(ApiResultCode.TASK_ERROR_MESSAGE_INVALID_RESOURCE_POOL);
} else {
throw e;
}
}
}
/**
* 发送执行任务
*
@ -804,6 +822,7 @@ public class ApiExecuteService {
if (testResourcePool == null ||
// 资源池禁用
!testResourcePool.getEnable() ||
testResourcePool.getDeleted() ||
// 项目没有资源池权限
!commonProjectService.validateProjectResourcePool(testResourcePool, projectId)) {
throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG);

View File

@ -801,7 +801,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
taskInfo.setRealTime(true);
}
return apiExecuteService.execute(taskRequest);
return apiExecuteService.executePlanResource(taskRequest);
}
public void runRun(ExecTask execTask, ExecTaskItem execTaskItem, String userId) {

View File

@ -395,7 +395,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
apiScenarioRunService.initApiScenarioReport(taskItem.getId(), apiScenario, scenarioReport);
}
return apiExecuteService.execute(taskRequest);
return apiExecuteService.executePlanResource(taskRequest);
}
public void runRun(ExecTask execTask, ExecTaskItem execTaskItem, String userId) {

View File

@ -366,7 +366,8 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
public static void assertRun(MvcResult mvcResult) throws UnsupportedEncodingException {
Map resultData = JSON.parseMap(mvcResult.getResponse().getContentAsString());
Integer code = (Integer) resultData.get("code");
if (code != ApiResultCode.RESOURCE_POOL_EXECUTE_ERROR.getCode() && code != ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG.getCode()) {
if (code != ApiResultCode.RESOURCE_POOL_EXECUTE_ERROR.getCode() && code != ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG.getCode()
&& code != ApiResultCode.TASK_ERROR_MESSAGE_INVALID_RESOURCE_POOL.getCode()) {
Assertions.assertTrue(false);
}
}