test(任务中心): 补充任务中心测试用例
This commit is contained in:
parent
d7939c3b6d
commit
c1a59f4cc0
|
@ -344,6 +344,9 @@ public class ApiReportService {
|
||||||
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
|
ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
|
||||||
example.createCriteria().andTaskResourceIdEqualTo(taskId);
|
example.createCriteria().andTaskResourceIdEqualTo(taskId);
|
||||||
List<ApiReportRelateTask> apiReportRelateTasks = apiReportRelateTaskMapper.selectByExample(example);
|
List<ApiReportRelateTask> apiReportRelateTasks = apiReportRelateTaskMapper.selectByExample(example);
|
||||||
|
if (CollectionUtils.isEmpty(apiReportRelateTasks)) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
String reportId = apiReportRelateTasks.getFirst().getReportId();
|
String reportId = apiReportRelateTasks.getFirst().getReportId();
|
||||||
return getDetail(reportId, taskItem.getResourceId());
|
return getDetail(reportId, taskItem.getResourceId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -467,9 +467,11 @@ public class ApiScenarioReportService {
|
||||||
private ApiScenarioReportDTO getScenarioReportDetail(String taskId, String taskItemId) {
|
private ApiScenarioReportDTO getScenarioReportDetail(String taskId, String taskItemId) {
|
||||||
ExecTaskItem taskItem = execTaskItemMapper.selectByPrimaryKey(taskItemId);
|
ExecTaskItem taskItem = execTaskItemMapper.selectByPrimaryKey(taskItemId);
|
||||||
ApiScenarioReportDTO apiScenarioReportDTO = scenarioReportDetail(taskId);
|
ApiScenarioReportDTO apiScenarioReportDTO = scenarioReportDetail(taskId);
|
||||||
List<ApiScenarioReportStepDTO> list = apiScenarioReportDTO.getChildren().stream()
|
if (CollectionUtils.isNotEmpty(apiScenarioReportDTO.getChildren())) {
|
||||||
.filter(step -> StringUtils.equals(step.getStepId(), taskItem.getResourceId())).toList();
|
List<ApiScenarioReportStepDTO> list = apiScenarioReportDTO.getChildren().stream()
|
||||||
apiScenarioReportDTO.setChildren(list);
|
.filter(step -> StringUtils.equals(step.getStepId(), taskItem.getResourceId())).toList();
|
||||||
|
apiScenarioReportDTO.setChildren(list);
|
||||||
|
}
|
||||||
return apiScenarioReportDTO;
|
return apiScenarioReportDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import io.metersphere.sdk.mapper.ShareInfoMapper;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.domain.ExecTask;
|
|
||||||
import io.metersphere.system.domain.TestResourcePool;
|
import io.metersphere.system.domain.TestResourcePool;
|
||||||
import io.metersphere.system.domain.TestResourcePoolExample;
|
import io.metersphere.system.domain.TestResourcePoolExample;
|
||||||
import io.metersphere.system.mapper.TestResourcePoolMapper;
|
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))
|
@Sql(scripts = {"/dml/init_task_item_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||||
public void getTaskReport() throws Exception {
|
public void getTaskReport() throws Exception {
|
||||||
this.requestGet(TASK_REPORT, "1");
|
this.requestGet(TASK_REPORT, "1");
|
||||||
|
this.requestGet(TASK_REPORT, "3");
|
||||||
|
this.requestGet(TASK_REPORT, "4");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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))
|
@Sql(scripts = {"/dml/init_scenario_task_item_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||||
public void getTaskStep() throws Exception {
|
public void getTaskStep() throws Exception {
|
||||||
this.requestGet(TASK_STEP, "scenario_1");
|
this.requestGet(TASK_STEP, "scenario_1");
|
||||||
|
this.requestGet(TASK_STEP, "scenario_3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -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`)
|
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
|
VALUES
|
||||||
('scenario_1', 11, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
('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`)
|
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
|
VALUES
|
||||||
('scenario_1', 'scenario_1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
|
('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`)
|
INSERT INTO `api_report_relate_task`(`task_resource_id`, `report_id`)
|
||||||
|
|
|
@ -3,14 +3,18 @@ VALUES
|
||||||
('1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639, b'0'),
|
('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'),
|
('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'),
|
('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`)
|
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
|
VALUES
|
||||||
('1', '1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'),
|
('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');
|
||||||
|
|
|
@ -87,6 +87,9 @@ public class ProjectApplicationController {
|
||||||
return configMap;
|
return configMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ==========任务中心开始==========
|
||||||
|
*/
|
||||||
@PostMapping("/update/task")
|
@PostMapping("/update/task")
|
||||||
@Operation(summary = "任务中心-配置")
|
@Operation(summary = "任务中心-配置")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_TASK_UPDATE)
|
@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());
|
List<String> types = Arrays.stream(ProjectApplicationType.TASK.values()).map(ProjectApplicationType.TASK::name).collect(Collectors.toList());
|
||||||
return projectApplicationService.get(request, types);
|
return projectApplicationService.get(request, types);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* ==========任务中心结束==========
|
||||||
|
*/
|
||||||
|
|
||||||
@GetMapping("/api/user/{projectId}")
|
@GetMapping("/api/user/{projectId}")
|
||||||
@Operation(summary = "接口测试-获取审核人")
|
@Operation(summary = "接口测试-获取审核人")
|
||||||
|
|
|
@ -193,8 +193,8 @@ public class BaseTaskHubService {
|
||||||
* @param tasks 任务集合
|
* @param tasks 任务集合
|
||||||
*/
|
*/
|
||||||
private void setTaskReportId(List<TaskHubDTO> tasks) {
|
private void setTaskReportId(List<TaskHubDTO> tasks) {
|
||||||
List<TaskHubDTO> reportTasks = tasks.stream().filter(task -> !StringUtils.equals(task.getTaskType(), ExecTaskType.API_SCENARIO_BATCH.name()) &&
|
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.API_CASE_BATCH.name())).toList();
|
&& !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 ->
|
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();
|
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();
|
List<String> noIntegratedTasks = reportTasks.stream().map(ExecTask::getId).filter(id -> !integratedTaskIds.contains(id)).toList();
|
||||||
|
|
Loading…
Reference in New Issue