test(任务中心): 补充任务中心测试用例

This commit is contained in:
song-cc-rock 2024-10-22 14:17:02 +08:00 committed by Craftsman
parent d7939c3b6d
commit c1a59f4cc0
8 changed files with 30 additions and 11 deletions

View File

@ -344,6 +344,9 @@ public class ApiReportService {
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
example.createCriteria().andTaskResourceIdEqualTo(taskId);
List<ApiReportRelateTask> apiReportRelateTasks = apiReportRelateTaskMapper.selectByExample(example);
if (CollectionUtils.isEmpty(apiReportRelateTasks)) {
return new ArrayList<>();
}
String reportId = apiReportRelateTasks.getFirst().getReportId();
return getDetail(reportId, taskItem.getResourceId());
}

View File

@ -467,9 +467,11 @@ public class ApiScenarioReportService {
private ApiScenarioReportDTO getScenarioReportDetail(String taskId, String taskItemId) {
ExecTaskItem taskItem = execTaskItemMapper.selectByPrimaryKey(taskItemId);
ApiScenarioReportDTO apiScenarioReportDTO = scenarioReportDetail(taskId);
if (CollectionUtils.isNotEmpty(apiScenarioReportDTO.getChildren())) {
List<ApiScenarioReportStepDTO> list = apiScenarioReportDTO.getChildren().stream()
.filter(step -> StringUtils.equals(step.getStepId(), taskItem.getResourceId())).toList();
apiScenarioReportDTO.setChildren(list);
}
return apiScenarioReportDTO;
}

View File

@ -27,7 +27,6 @@ import io.metersphere.sdk.mapper.ShareInfoMapper;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.domain.ExecTask;
import io.metersphere.system.domain.TestResourcePool;
import io.metersphere.system.domain.TestResourcePoolExample;
import io.metersphere.system.mapper.TestResourcePoolMapper;
@ -516,5 +515,7 @@ public class ApiReportControllerTests extends BaseTest {
@Sql(scripts = {"/dml/init_task_item_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void getTaskReport() throws Exception {
this.requestGet(TASK_REPORT, "1");
this.requestGet(TASK_REPORT, "3");
this.requestGet(TASK_REPORT, "4");
}
}

View File

@ -561,6 +561,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
@Sql(scripts = {"/dml/init_scenario_task_item_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
public void getTaskStep() throws Exception {
this.requestGet(TASK_STEP, "scenario_1");
this.requestGet(TASK_STEP, "scenario_3");
}
@Test

View File

@ -1,14 +1,16 @@
INSERT INTO `exec_task`(`id`, `num`, `task_name`, `status`, `case_count`, `result`, `task_type`, `trigger_mode`, `project_id`, `organization_id`, `create_time`, `create_user`, `start_time`, `end_time`, `integrated`)
VALUES
('scenario_1', 11, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
('scenario_2', 22, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0');
('scenario_2', 22, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
('scenario_3', 22, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'1');
INSERT INTO `exec_task_item`(`id`, `task_id`, `resource_id`, `resource_name`, `task_origin`, `status`, `result`, `resource_pool_id`, `resource_pool_node`, `resource_type`, `project_id`, `organization_id`, `thread_id`, `start_time`, `end_time`, `executor`)
VALUES
('scenario_1', 'scenario_1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
('scenario_2', 'scenario_2', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin');
('scenario_2', 'scenario_2', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
('scenario_3', 'scenario_3', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin');
INSERT INTO `api_report_relate_task`(`task_resource_id`, `report_id`)

View File

@ -3,14 +3,18 @@ VALUES
('1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
('2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
('3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
('4', 4, '删除任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0');
('4', 4, '删除任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
('5', 5, '删除任务5', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'1'),
('6', 6, '删除任务6', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639, b'1');
INSERT INTO `exec_task_item`(`id`, `task_id`, `resource_id`, `resource_name`, `task_origin`, `status`, `result`, `resource_pool_id`, `resource_pool_node`, `resource_type`, `project_id`, `organization_id`, `thread_id`, `start_time`, `end_time`, `executor`)
VALUES
('1', '1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
('2', '2', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin');
('2', '2', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
('3', '5', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
('4', '6', '1', '2', '3', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin');
INSERT INTO `api_report_relate_task`(`task_resource_id`, `report_id`) VALUES ('1', 'test-report-id');
INSERT INTO `api_report_relate_task`(`task_resource_id`, `report_id`) VALUES ('1', 'test-report-id'), ('6', 'test-report-id');

View File

@ -87,6 +87,9 @@ public class ProjectApplicationController {
return configMap;
}
/**
* ==========任务中心开始==========
*/
@PostMapping("/update/task")
@Operation(summary = "任务中心-配置")
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_TASK_UPDATE)
@ -102,6 +105,9 @@ public class ProjectApplicationController {
List<String> types = Arrays.stream(ProjectApplicationType.TASK.values()).map(ProjectApplicationType.TASK::name).collect(Collectors.toList());
return projectApplicationService.get(request, types);
}
/**
* ==========任务中心结束==========
*/
@GetMapping("/api/user/{projectId}")
@Operation(summary = "接口测试-获取审核人")

View File

@ -193,8 +193,8 @@ public class BaseTaskHubService {
* @param tasks 任务集合
*/
private void setTaskReportId(List<TaskHubDTO> tasks) {
List<TaskHubDTO> reportTasks = tasks.stream().filter(task -> !StringUtils.equals(task.getTaskType(), ExecTaskType.API_SCENARIO_BATCH.name()) &&
!StringUtils.equals(task.getTaskType(), ExecTaskType.API_CASE_BATCH.name())).toList();
List<TaskHubDTO> reportTasks = tasks.stream().filter(task -> !StringUtils.equals(task.getTaskType(), ExecTaskType.API_SCENARIO_BATCH.name()) && !StringUtils.equals(task.getTaskType(), ExecTaskType.API_CASE_BATCH.name())
&& !StringUtils.equals(task.getTaskType(), ExecTaskType.TEST_PLAN_API_CASE_BATCH.name()) && !StringUtils.equals(task.getTaskType(), ExecTaskType.TEST_PLAN_API_SCENARIO_BATCH.name())).toList();
List<String> integratedTaskIds = reportTasks.stream().filter(task ->
StringUtils.equalsAny(task.getTaskType(), ExecTaskType.TEST_PLAN.name(), ExecTaskType.TEST_PLAN_GROUP.name()) || task.getIntegrated()).map(ExecTask::getId).toList();
List<String> noIntegratedTasks = reportTasks.stream().map(ExecTask::getId).filter(id -> !integratedTaskIds.contains(id)).toList();