mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 12:09:13 +08:00
refactor(接口测试): 优化接口通知
This commit is contained in:
parent
6070b5bc9d
commit
e5471f9c17
@ -345,6 +345,7 @@ message.domain.case_update_time=用例更新时间
|
||||
message.domain.case_update_user=用例更新人
|
||||
message.domain.case_delete_time=用例删除时间
|
||||
message.domain.case_delete_user=用例删除人
|
||||
message.domain.mock_name=期望名称
|
||||
#场景字段
|
||||
message.domain.api_scenario_name=场景名称
|
||||
message.domain.api_scenario_level=场景级别
|
||||
@ -363,6 +364,28 @@ message.domain.api_scenario_deleteUser=删除人
|
||||
message.domain.api_scenario_createTime=创建时间
|
||||
message.domain.api_scenario_updateTime=更新时间
|
||||
message.domain.api_scenario_deleteTime=删除时间
|
||||
message.domain.api_scenario_priority=优先级
|
||||
message.domain.api_scenario_requestPassRate=请求通过率
|
||||
message.domain.api_scenario_environmentId=环境ID
|
||||
message.domain.scenario_report_url=报告地址
|
||||
message.domain.scenario_report_share_url=分享地址
|
||||
message.domain.scenario_report_name=报告名称
|
||||
message.domain.scenario_report_start_time=开始时间
|
||||
message.domain.scenario_report_end_time=结束时间
|
||||
message.domain.scenario_report_request_duration=请求总耗时
|
||||
message.domain.scenario_report_status=报告状态
|
||||
message.domain.scenario_report_environment=报告环境
|
||||
message.domain.scenario_report_error_count=失败数
|
||||
message.domain.scenario_report_fake_error_count=误报数
|
||||
message.domain.scenario_report_pending_count=未执行数
|
||||
message.domain.scenario_report_success_count=成功数
|
||||
message.domain.scenario_report_assertion_count=总断言数
|
||||
message.domain.scenario_report_assertion_success_count=断言成功数
|
||||
message.domain.scenario_report_request_error_rate=请求失败率
|
||||
message.domain.scenario_report_request_pending_rate=请求未执行率
|
||||
message.domain.scenario_report_request_fake_error_rate=请求误报率
|
||||
message.domain.scenario_report_request_pass_rate=请求通过率
|
||||
message.domain.scenario_report_assertion_pass_rate=断言通过率
|
||||
# 测试计划
|
||||
message.domain.test_plan_stage=测试阶段
|
||||
message.domain.test_plan_status=测试计划状态
|
||||
|
@ -381,6 +381,7 @@ message.domain.case_update_time=Case update time
|
||||
message.domain.case_update_user=Case update user
|
||||
message.domain.case_delete_time=Case delete time
|
||||
message.domain.case_delete_user=Case delete user
|
||||
message.domain.mock_name=Expect name
|
||||
#Scenario字段
|
||||
message.domain.api_scenario_name=Scenario name
|
||||
message.domain.api_scenario_level=Scenario level
|
||||
@ -399,6 +400,28 @@ message.domain.api_scenario_deleteUser=Delete user
|
||||
message.domain.api_scenario_createTime=Create time
|
||||
message.domain.api_scenario_updateTime=Update time
|
||||
message.domain.api_scenario_deleteTime=Delete time
|
||||
message.domain.api_scenario_priority=Priority
|
||||
message.domain.api_scenario_requestPassRate=Request pass rate
|
||||
message.domain.api_scenario_environmentId=Environment ID
|
||||
message.domain.scenario_report_url=Report URL
|
||||
message.domain.scenario_report_share_url=Share URL
|
||||
message.domain.scenario_report_name=Report name
|
||||
message.domain.scenario_report_start_time=Start time
|
||||
message.domain.scenario_report_end_time=End time
|
||||
message.domain.scenario_report_request_duration=Request duration
|
||||
message.domain.scenario_report_status=Report status
|
||||
message.domain.scenario_report_environment=Report environment
|
||||
message.domain.scenario_report_error_count=Error count
|
||||
message.domain.scenario_report_fake_error_count=Fake error count
|
||||
message.domain.scenario_report_pending_count=Pending count
|
||||
message.domain.scenario_report_success_count=Success count
|
||||
message.domain.scenario_report_assertion_count=Assertion count
|
||||
message.domain.scenario_report_assertion_success_count=Assertion success count
|
||||
message.domain.scenario_report_request_error_rate=Request error rate
|
||||
message.domain.scenario_report_request_pending_rate=Request pending rate
|
||||
message.domain.scenario_report_request_fake_error_rate=Request fake error rate
|
||||
message.domain.scenario_report_request_pass_rate=Request pass rate
|
||||
message.domain.scenario_report_assertion_pass_rate=Assertion pass rate
|
||||
# Test plan
|
||||
message.domain.test_plan_stage=Testing phase
|
||||
message.domain.test_plan_status=Test plan status
|
||||
|
@ -380,6 +380,7 @@ message.domain.case_update_time=用例更新时间
|
||||
message.domain.case_update_user=用例更新人
|
||||
message.domain.case_delete_time=用例删除时间
|
||||
message.domain.case_delete_user=用例删除人
|
||||
message.domain.mock_name=期望名称
|
||||
#场景字段
|
||||
message.domain.api_scenario_name=场景名称
|
||||
message.domain.api_scenario_level=场景级别
|
||||
@ -398,6 +399,28 @@ message.domain.api_scenario_deleteUser=删除人
|
||||
message.domain.api_scenario_createTime=创建时间
|
||||
message.domain.api_scenario_updateTime=更新时间
|
||||
message.domain.api_scenario_deleteTime=删除时间
|
||||
message.domain.api_scenario_priority=优先级
|
||||
message.domain.api_scenario_requestPassRate=请求通过率
|
||||
message.domain.api_scenario_environmentId=环境ID
|
||||
message.domain.scenario_report_url=报告地址
|
||||
message.domain.scenario_report_share_url=分享地址
|
||||
message.domain.scenario_report_name=报告名称
|
||||
message.domain.scenario_report_start_time=开始时间
|
||||
message.domain.scenario_report_end_time=结束时间
|
||||
message.domain.scenario_report_request_duration=请求总耗时
|
||||
message.domain.scenario_report_status=报告状态
|
||||
message.domain.scenario_report_environment=报告环境
|
||||
message.domain.scenario_report_error_count=失败数
|
||||
message.domain.scenario_report_fake_error_count=误报数
|
||||
message.domain.scenario_report_pending_count=未执行数
|
||||
message.domain.scenario_report_success_count=成功数
|
||||
message.domain.scenario_report_assertion_count=总断言数
|
||||
message.domain.scenario_report_assertion_success_count=断言成功数
|
||||
message.domain.scenario_report_request_error_rate=请求失败率
|
||||
message.domain.scenario_report_request_pending_rate=请求未执行率
|
||||
message.domain.scenario_report_request_fake_error_rate=请求误报率
|
||||
message.domain.scenario_report_request_pass_rate=请求通过率
|
||||
message.domain.scenario_report_assertion_pass_rate=断言通过率
|
||||
# 测试计划
|
||||
message.domain.test_plan_stage=测试阶段
|
||||
message.domain.test_plan_status=测试计划状态
|
||||
|
@ -381,6 +381,7 @@ message.domain.case_update_time=用例更新時間
|
||||
message.domain.case_update_user=用例更新人
|
||||
message.domain.case_delete_time=用例刪除時間
|
||||
message.domain.case_delete_user=用例刪除人
|
||||
message.domain.mock_name=期望名稱
|
||||
#場景字段
|
||||
message.domain.api_scenario_name=場景名稱
|
||||
message.domain.api_scenario_level=場景等級
|
||||
@ -399,6 +400,28 @@ message.domain.api_scenario_deleteUser=刪除人
|
||||
message.domain.api_scenario_createTime=創建時間
|
||||
message.domain.api_scenario_updateTime=更新時間
|
||||
message.domain.api_scenario_deleteTime=刪除時間
|
||||
message.domain.api_scenario_priority=優先級
|
||||
message.domain.api_scenario_requestPassRate=請求通過率
|
||||
message.domain.api_scenario_environmentId=環境ID
|
||||
message.domain.scenario_report_url=報告地址
|
||||
message.domain.scenario_report_share_url=分享地址
|
||||
message.domain.scenario_report_name=報告名稱
|
||||
message.domain.scenario_report_start_time=報告開始時間
|
||||
message.domain.scenario_report_end_time=報告結束時間
|
||||
message.domain.scenario_report_request_duration=請求持續時間
|
||||
message.domain.scenario_report_status=報告狀態
|
||||
message.domain.scenario_report_environment=報告環境
|
||||
message.domain.scenario_report_error_count=報告錯誤數
|
||||
message.domain.scenario_report_fake_error_count=報告誤報數
|
||||
message.domain.scenario_report_pending_count=報告待定數
|
||||
message.domain.scenario_report_success_count=報告成功數
|
||||
message.domain.scenario_report_assertion_count=報告斷言數
|
||||
message.domain.scenario_report_assertion_success_count=報告斷言成功數
|
||||
message.domain.scenario_report_request_error_rate=報告請求錯誤率
|
||||
message.domain.scenario_report_request_pending_rate=報告請求待定率
|
||||
message.domain.scenario_report_request_fake_error_rate=報告請求誤報率
|
||||
message.domain.scenario_report_request_pass_rate=報告請求通過率
|
||||
message.domain.scenario_report_assertion_pass_rate=報告斷言通過率
|
||||
# 測試計劃
|
||||
message.domain.test_plan_stage=測試階段
|
||||
message.domain.test_plan_status=測試計劃狀態
|
||||
|
@ -68,6 +68,7 @@ public class ApiDefinitionController {
|
||||
@Operation(summary = "接口测试-接口管理-批量更新接口定义")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_UPDATE)
|
||||
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_definition")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getBatchEditApiDTO(#request)", targetClass = ApiDefinitionNoticeService.class)
|
||||
public void batchUpdate(@Validated @RequestBody ApiDefinitionBatchUpdateRequest request) {
|
||||
apiDefinitionService.batchUpdate(request, SessionUtils.getUserId());
|
||||
}
|
||||
@ -85,6 +86,7 @@ public class ApiDefinitionController {
|
||||
@Operation(summary = "接口测试-接口管理-批量删除接口定义到回收站")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_DELETE)
|
||||
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_definition")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getBatchEditApiDTO(#request)", targetClass = ApiDefinitionNoticeService.class)
|
||||
public void batchDelete(@Validated @RequestBody ApiDefinitionBatchRequest request) {
|
||||
apiDefinitionService.batchDelete(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
@ -4,12 +4,18 @@ import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import io.metersphere.api.domain.ApiDefinitionMock;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionMockDTO;
|
||||
import io.metersphere.api.dto.definition.request.*;
|
||||
import io.metersphere.api.dto.definition.request.ApiDefinitionMockAddRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDefinitionMockPageRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDefinitionMockRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDefinitionMockUpdateRequest;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionMockLogService;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionMockNoticeService;
|
||||
import io.metersphere.api.service.definition.ApiDefinitionMockService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.notice.annotation.SendNotice;
|
||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
import io.metersphere.system.utils.PageUtils;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
@ -61,6 +67,7 @@ public class ApiDefinitionMockController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_MOCK_ADD)
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = ApiDefinitionMockLogService.class)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.MOCK_CREATE, target = "#targetClass.getApiMockDTO(#request)", targetClass = ApiDefinitionMockNoticeService.class)
|
||||
public ApiDefinitionMock add(@Validated @RequestBody ApiDefinitionMockAddRequest request) {
|
||||
return apiDefinitionMockService.create(request, SessionUtils.getUserId());
|
||||
}
|
||||
@ -70,6 +77,7 @@ public class ApiDefinitionMockController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_MOCK_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = ApiDefinitionMockLogService.class)
|
||||
@CheckOwner(resourceId = "#request.getId()", resourceType = "api_definition_mock")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.MOCK_UPDATE, target = "#targetClass.getApiMockDTO(#request)", targetClass = ApiDefinitionMockNoticeService.class)
|
||||
public ApiDefinitionMock update(@Validated @RequestBody ApiDefinitionMockUpdateRequest request) {
|
||||
return apiDefinitionMockService.update(request, SessionUtils.getUserId());
|
||||
}
|
||||
@ -88,6 +96,7 @@ public class ApiDefinitionMockController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_MOCK_DELETE)
|
||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.delLog(#request)", msClass = ApiDefinitionMockLogService.class)
|
||||
@CheckOwner(resourceId = "#request.getId()", resourceType = "api_definition_mock")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.MOCK_DELETE, target = "#targetClass.getApiMockDTO(#request.id)", targetClass = ApiDefinitionMockNoticeService.class)
|
||||
public void delete(@Validated @RequestBody ApiDefinitionMockRequest request) {
|
||||
apiDefinitionMockService.delete(request, SessionUtils.getUserId());
|
||||
}
|
||||
@ -109,5 +118,4 @@ public class ApiDefinitionMockController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ public class ApiTestCaseController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ApiTestCaseLogService.class)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_test_case")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_UPDATE, target = "#targetClass.getCaseDTO(#id)", targetClass = ApiTestCaseNoticeService.class)
|
||||
public void updatePriority(@PathVariable String id, @PathVariable String priority) {
|
||||
apiTestCaseService.updatePriority(id, priority, SessionUtils.getUserId());
|
||||
}
|
||||
@ -130,6 +131,7 @@ public class ApiTestCaseController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ApiTestCaseLogService.class)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_test_case")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_UPDATE, target = "#targetClass.getCaseDTO(#id)", targetClass = ApiTestCaseNoticeService.class)
|
||||
public void updateStatus(@PathVariable String id, @PathVariable String status) {
|
||||
apiTestCaseService.updateStatus(id, status, SessionUtils.getUserId());
|
||||
}
|
||||
@ -155,7 +157,7 @@ public class ApiTestCaseController {
|
||||
@Operation(summary = "接口测试-接口管理-接口用例-批量移动到回收站")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_DELETE)
|
||||
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_test_case")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_DELETE, target = "#targetClass.getBatchDeleteApiCaseDTO(#request)", targetClass = ApiTestCaseNoticeService.class)
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_DEFINITION_TASK, event = NoticeConstants.Event.CASE_DELETE, target = "#targetClass.getBatchEditApiCaseDTO(#request)", targetClass = ApiTestCaseNoticeService.class)
|
||||
public void deleteToGcByParam(@RequestBody ApiTestCaseBatchRequest request) {
|
||||
apiTestCaseService.batchMoveGc(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import io.metersphere.api.dto.scenario.ApiScenarioBatchCopyMoveRequest;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioBatchEditRequest;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioBatchRequest;
|
||||
import io.metersphere.api.service.ApiValidateService;
|
||||
import io.metersphere.api.service.definition.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
@ -49,7 +49,7 @@ public class ApiScenarioBatchOperationController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_DELETE)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_SCENARIO_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getBatchOptionScenarios(#request)", targetClass = ApiScenarioNoticeService.class)
|
||||
public ApiScenarioBatchOperationResponse deleteFromGC(@Validated @RequestBody ApiScenarioBatchRequest request) {
|
||||
public ApiScenarioBatchOperationResponse deleteFromGc(@Validated @RequestBody ApiScenarioBatchRequest request) {
|
||||
apiValidateService.validateApiMenuInProject(request.getProjectId(), ApiResource.PROJECT.name());
|
||||
return apiScenarioService.batchGCOperation(request, true, new LogInsertModule(SessionUtils.getUserId(), "/api/scenario/batch-operation/delete-gc", HttpMethodConstants.POST.name()));
|
||||
}
|
||||
@ -59,7 +59,7 @@ public class ApiScenarioBatchOperationController {
|
||||
@Operation(summary = "接口测试-接口场景批量操作-回收站列表-批量恢复")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_RECOVER)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public ApiScenarioBatchOperationResponse recoverFromGC(@Validated @RequestBody ApiScenarioBatchRequest request) {
|
||||
public ApiScenarioBatchOperationResponse recoverFromGc(@Validated @RequestBody ApiScenarioBatchRequest request) {
|
||||
apiValidateService.validateApiMenuInProject(request.getProjectId(), ApiResource.PROJECT.name());
|
||||
return apiScenarioService.batchGCOperation(request, false, new LogInsertModule(SessionUtils.getUserId(), "/api/scenario/batch-operation/recover-gc", HttpMethodConstants.POST.name()));
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import io.metersphere.api.constants.ApiResource;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.dto.scenario.*;
|
||||
import io.metersphere.api.service.ApiValidateService;
|
||||
import io.metersphere.api.service.definition.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioLogService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
@ -72,6 +72,7 @@ public class ApiScenarioController {
|
||||
@Operation(summary = "接口测试-接口场景管理-创建场景")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_ADD)
|
||||
@Log(type = OperationLogType.ADD, expression = "#msClass.addLog(#request)", msClass = ApiScenarioLogService.class)
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_SCENARIO_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getScenarioDTO(#request)", targetClass = ApiScenarioNoticeService.class)
|
||||
public ApiScenario add(@Validated @RequestBody ApiScenarioAddRequest request) {
|
||||
return apiScenarioService.add(request, SessionUtils.getUserId());
|
||||
}
|
||||
@ -88,6 +89,7 @@ public class ApiScenarioController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = ApiScenarioLogService.class)
|
||||
@CheckOwner(resourceId = "#request.getId()", resourceType = "api_scenario")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_SCENARIO_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getScenarioDTO(#request)", targetClass = ApiScenarioNoticeService.class)
|
||||
public ApiScenario update(@Validated @RequestBody ApiScenarioUpdateRequest request) {
|
||||
return apiScenarioService.update(request, SessionUtils.getUserId());
|
||||
}
|
||||
@ -106,6 +108,7 @@ public class ApiScenarioController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_DELETE)
|
||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = ApiScenarioLogService.class)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_scenario")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_SCENARIO_TASK, event = NoticeConstants.Event.DELETE, target = "#targetClass.getScenarioDTO(#id)", targetClass = ApiScenarioNoticeService.class)
|
||||
public void deleteToGc(@PathVariable String id) {
|
||||
apiScenarioService.deleteToGc(id);
|
||||
}
|
||||
@ -149,6 +152,7 @@ public class ApiScenarioController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ApiScenarioLogService.class)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_scenario")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_SCENARIO_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getScenarioDTO(#id)", targetClass = ApiScenarioNoticeService.class)
|
||||
public void updateStatus(@PathVariable String id, @PathVariable String status) {
|
||||
apiScenarioService.updateStatus(id, status, SessionUtils.getUserId());
|
||||
}
|
||||
@ -158,6 +162,7 @@ public class ApiScenarioController {
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ApiScenarioLogService.class)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "api_scenario")
|
||||
@SendNotice(taskType = NoticeConstants.TaskType.API_SCENARIO_TASK, event = NoticeConstants.Event.UPDATE, target = "#targetClass.getScenarioDTO(#id)", targetClass = ApiScenarioNoticeService.class)
|
||||
public void updatePriority(@PathVariable String id, @PathVariable String priority) {
|
||||
apiScenarioService.updatePriority(id, priority, SessionUtils.getUserId());
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package io.metersphere.api.mapper;
|
||||
|
||||
import io.metersphere.api.domain.ApiDefinition;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.api.domain.ApiDefinitionCustomField;
|
||||
import io.metersphere.api.dto.converter.ApiDefinitionImportDetail;
|
||||
import io.metersphere.api.dto.definition.*;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@ -51,4 +52,6 @@ public interface ExtApiDefinitionMapper {
|
||||
List<OptionDTO> selectVersionOptionByIds(@Param("apiIds") List<String> apiIds);
|
||||
|
||||
ApiDefinition selectApiDefinitionByVersion(@Param("refId") String refId, @Param("versionId") String versionId);
|
||||
|
||||
List<ApiDefinitionCustomField> getCustomFieldByCaseIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
@ -495,4 +495,10 @@
|
||||
from api_definition
|
||||
where api_definition.ref_id = #{refId} and api_definition.version_id = #{versionId}
|
||||
</select>
|
||||
<select id="getCustomFieldByCaseIds" resultType="io.metersphere.api.domain.ApiDefinitionCustomField">
|
||||
select api_id, field_id, `value` from api_definition_custom_field where api_id in
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -1,10 +1,12 @@
|
||||
package io.metersphere.api.service;
|
||||
|
||||
import io.metersphere.api.domain.ApiDefinition;
|
||||
import io.metersphere.api.domain.ApiReport;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioReport;
|
||||
import io.metersphere.api.domain.ApiTestCase;
|
||||
import io.metersphere.api.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.api.mapper.ApiReportMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
||||
import io.metersphere.api.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
@ -12,6 +14,7 @@ import io.metersphere.sdk.constants.ApiReportStatus;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.sdk.BaseSystemConfigDTO;
|
||||
@ -40,11 +43,14 @@ public class ApiReportSendNoticeService {
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||
@Resource
|
||||
private ApiReportMapper apiReportMapper;
|
||||
@Resource
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
private static final String API_SCENARIO = "API_SCENARIO";
|
||||
|
||||
public void sendNotice(ApiNoticeDTO noticeDTO) {
|
||||
String noticeType;
|
||||
@ -53,40 +59,47 @@ public class ApiReportSendNoticeService {
|
||||
assert systemParameterService != null;
|
||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||
BeanMap beanMap;
|
||||
switch (noticeDTO.getResourceType()) {
|
||||
case "API_SCENARIO":
|
||||
ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(noticeDTO.getResourceId());
|
||||
beanMap = new BeanMap(scenario);
|
||||
noticeType = NoticeConstants.TaskType.API_SCENARIO_TASK;
|
||||
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report/view/" + noticeDTO.getReportId();
|
||||
break;
|
||||
case "API":
|
||||
ApiDefinition definition = apiDefinitionMapper.selectByPrimaryKey(noticeDTO.getResourceId());
|
||||
beanMap = new BeanMap(definition);
|
||||
noticeType = NoticeConstants.TaskType.API_DEFINITION_TASK;
|
||||
|
||||
// TODO: 缺少生成分享链接
|
||||
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report/view/" + noticeDTO.getReportId();
|
||||
break;
|
||||
default:
|
||||
ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(noticeDTO.getResourceId());
|
||||
beanMap = new BeanMap(testCase);
|
||||
|
||||
// TODO 是否需要区分场景和用例
|
||||
noticeType = NoticeConstants.TaskType.API_DEFINITION_TASK;
|
||||
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report/view/" + noticeDTO.getReportId();
|
||||
break;
|
||||
}
|
||||
|
||||
String event;
|
||||
String status;
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ApiReportStatus.SUCCESS.name())) {
|
||||
event = NoticeConstants.Event.EXECUTE_SUCCESSFUL;
|
||||
status = "成功";
|
||||
ApiScenarioReport report = new ApiScenarioReport();
|
||||
if (API_SCENARIO.equals(noticeDTO.getResourceType())) {
|
||||
ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(noticeDTO.getResourceId());
|
||||
beanMap = new BeanMap(scenario);
|
||||
noticeType = NoticeConstants.TaskType.API_SCENARIO_TASK;
|
||||
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report/view/" + noticeDTO.getReportId();
|
||||
report = apiScenarioReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ApiReportStatus.SUCCESS.name())) {
|
||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_SUCCESSFUL;
|
||||
status = "成功";
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ApiReportStatus.FAKE_ERROR.name())) {
|
||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAKE_ERROR;
|
||||
status = "误报";
|
||||
} else {
|
||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAILED;
|
||||
status = "失败";
|
||||
}
|
||||
} else {
|
||||
event = NoticeConstants.Event.EXECUTE_FAILED;
|
||||
status = "失败";
|
||||
ApiTestCase testCase = apiTestCaseMapper.selectByPrimaryKey(noticeDTO.getResourceId());
|
||||
beanMap = new BeanMap(testCase);
|
||||
|
||||
// TODO 是否需要区分场景和用例
|
||||
noticeType = NoticeConstants.TaskType.API_DEFINITION_TASK;
|
||||
reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report/view/" + noticeDTO.getReportId();
|
||||
|
||||
ApiReport apiReport = apiReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
||||
BeanUtils.copyBean(report, apiReport);
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ApiReportStatus.SUCCESS.name())) {
|
||||
event = NoticeConstants.Event.CASE_EXECUTE_SUCCESSFUL;
|
||||
status = "成功";
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ApiReportStatus.FAKE_ERROR.name())) {
|
||||
event = NoticeConstants.Event.CASE_EXECUTE_FAKE_ERROR;
|
||||
status = "误报";
|
||||
} else {
|
||||
event = NoticeConstants.Event.CASE_EXECUTE_FAILED;
|
||||
status = "失败";
|
||||
}
|
||||
}
|
||||
|
||||
String userId = noticeDTO.getUserId();
|
||||
User user = userMapper.selectByPrimaryKey(userId);
|
||||
|
||||
@ -94,6 +107,25 @@ public class ApiReportSendNoticeService {
|
||||
paramMap.put("operator", user != null ? user.getName() : "");
|
||||
paramMap.put("status", noticeDTO.getReportStatus());
|
||||
|
||||
paramMap.put("reportName", report.getName());
|
||||
paramMap.put("startTime", report.getStartTime());
|
||||
paramMap.put("endTime", report.getEndTime());
|
||||
paramMap.put("requestDuration", report.getRequestDuration());
|
||||
paramMap.put("reportStatus", report.getStatus());
|
||||
paramMap.put("errorCount", report.getErrorCount());
|
||||
paramMap.put("fakeErrorCount", report.getFakeErrorCount());
|
||||
paramMap.put("pendingCount", report.getPendingCount());
|
||||
paramMap.put("successCount", report.getSuccessCount());
|
||||
paramMap.put("assertionCount", report.getAssertionCount());
|
||||
paramMap.put("assertionSuccessCount", report.getAssertionSuccessCount());
|
||||
paramMap.put("requestErrorRate", report.getRequestErrorRate());
|
||||
paramMap.put("requestPendingRate", report.getRequestPendingRate());
|
||||
paramMap.put("requestFakeErrorRate", report.getRequestFakeErrorRate());
|
||||
paramMap.put("requestPassRate", report.getRequestPassRate());
|
||||
paramMap.put("assertionPassRate", report.getAssertionPassRate());
|
||||
|
||||
// TODO 这里状态是否是国际化 还有分享链接需要补充
|
||||
|
||||
// TODO 暂时取一个环境处理
|
||||
if (StringUtils.isNotEmpty(noticeDTO.getEnvironmentId())) {
|
||||
Environment environment = environmentMapper.selectByPrimaryKey(noticeDTO.getEnvironmentId());
|
||||
|
@ -0,0 +1,49 @@
|
||||
package io.metersphere.api.service.definition;
|
||||
|
||||
import io.metersphere.api.domain.ApiDefinition;
|
||||
import io.metersphere.api.domain.ApiDefinitionMock;
|
||||
import io.metersphere.api.dto.definition.request.ApiDefinitionMockAddRequest;
|
||||
import io.metersphere.api.dto.definition.request.ApiDefinitionMockUpdateRequest;
|
||||
import io.metersphere.api.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.api.mapper.ApiDefinitionMockMapper;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ApiDefinitionMockNoticeService {
|
||||
|
||||
@Resource
|
||||
private ApiDefinitionMockMapper apiDefinitionMockMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
|
||||
|
||||
public ApiDefinitionCaseDTO getApiMockDTO(ApiDefinitionMockAddRequest request) {
|
||||
ApiDefinitionCaseDTO mockDTO = new ApiDefinitionCaseDTO();
|
||||
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(request.getApiDefinitionId());
|
||||
BeanUtils.copyBean(mockDTO, apiDefinition);
|
||||
mockDTO.setMockName(request.getName());
|
||||
return mockDTO;
|
||||
}
|
||||
|
||||
public ApiDefinitionCaseDTO getApiMockDTO(ApiDefinitionMockUpdateRequest request) {
|
||||
ApiDefinitionCaseDTO mockDTO = new ApiDefinitionCaseDTO();
|
||||
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(request.getApiDefinitionId());
|
||||
BeanUtils.copyBean(mockDTO, apiDefinition);
|
||||
mockDTO.setMockName(request.getName());
|
||||
return mockDTO;
|
||||
}
|
||||
|
||||
public ApiDefinitionCaseDTO getApiMockDTO(String id) {
|
||||
ApiDefinitionCaseDTO mockDTO = new ApiDefinitionCaseDTO();
|
||||
ApiDefinitionMock apiDefinitionMock = apiDefinitionMockMapper.selectByPrimaryKey(id);
|
||||
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(apiDefinitionMock.getApiDefinitionId());
|
||||
BeanUtils.copyBean(mockDTO, apiDefinition);
|
||||
mockDTO.setMockName(apiDefinitionMock.getName());
|
||||
return mockDTO;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,25 +1,43 @@
|
||||
package io.metersphere.api.service.definition;
|
||||
|
||||
import io.metersphere.api.domain.ApiDefinition;
|
||||
import io.metersphere.api.domain.ApiDefinitionCustomField;
|
||||
import io.metersphere.api.domain.ApiDefinitionExample;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionAddRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionBatchRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionUpdateRequest;
|
||||
import io.metersphere.api.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.api.mapper.ExtApiDefinitionMapper;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.SubListUtils;
|
||||
import io.metersphere.system.domain.CustomField;
|
||||
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
||||
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||
import io.metersphere.system.mapper.ExtOrganizationCustomFieldMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ApiDefinitionNoticeService {
|
||||
|
||||
|
||||
@Resource
|
||||
private CustomFieldMapper customFieldMapper;
|
||||
@Resource
|
||||
private ExtApiDefinitionMapper extApiDefinitionMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
private ExtOrganizationCustomFieldMapper extOrganizationCustomFieldMapper;
|
||||
|
||||
|
||||
public ApiDefinitionCaseDTO getApiDTO(ApiDefinitionAddRequest request) {
|
||||
ApiDefinitionCaseDTO caseDTO = new ApiDefinitionCaseDTO();
|
||||
@ -61,4 +79,57 @@ public class ApiDefinitionNoticeService {
|
||||
return caseDTO;
|
||||
}
|
||||
|
||||
public List<ApiDefinitionCaseDTO> getBatchEditApiDTO(ApiDefinitionBatchRequest request) {
|
||||
List<String> ids = this.doSelectIds(request, request.getProjectId(), request.getProtocol(), false);
|
||||
return handleBatchNotice(ids);
|
||||
}
|
||||
|
||||
private List<ApiDefinitionCaseDTO> handleBatchNotice(List<String> ids) {
|
||||
List<ApiDefinitionCaseDTO> dtoList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
SubListUtils.dealForSubList(ids, 100, (subList) -> {
|
||||
detailApiData(subList, dtoList);
|
||||
});
|
||||
}
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
private void detailApiData(List<String> ids, List<ApiDefinitionCaseDTO> dtoList) {
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<ApiDefinition> apiDefinitions = apiDefinitionMapper.selectByExample(example);
|
||||
Map<String, ApiDefinition> apiDefinitionMap = apiDefinitions.stream().collect(Collectors.toMap(ApiDefinition::getId, a -> a));
|
||||
List<ApiDefinitionCustomField> customFieldList = extApiDefinitionMapper.getCustomFieldByCaseIds(ids);
|
||||
Map<String, List<ApiDefinitionCustomField>> apiCustomFieldMap = customFieldList.stream().collect(Collectors.groupingBy(ApiDefinitionCustomField::getApiId));
|
||||
AtomicReference<List<OptionDTO>> optionDTOS = new AtomicReference<>(new ArrayList<>());
|
||||
ids.forEach(id -> {
|
||||
ApiDefinition api = apiDefinitionMap.get(id);
|
||||
List<ApiDefinitionCustomField> customFields = apiCustomFieldMap.get(id);
|
||||
if (CollectionUtils.isNotEmpty(customFields)) {
|
||||
List<String> fields = customFields.stream().map(apiDefinitionCustomField -> apiDefinitionCustomField.getFieldId()).toList();
|
||||
optionDTOS.set(extOrganizationCustomFieldMapper.getCustomFieldOptions(fields));
|
||||
}
|
||||
ApiDefinitionCaseDTO apiDefinitionCaseDTO = new ApiDefinitionCaseDTO();
|
||||
BeanUtils.copyBean(apiDefinitionCaseDTO, api);
|
||||
apiDefinitionCaseDTO.setFields(optionDTOS.get());
|
||||
dtoList.add(apiDefinitionCaseDTO);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public <T> List<String> doSelectIds(T dto, String projectId, String protocol, boolean deleted) {
|
||||
TableBatchProcessDTO request = (TableBatchProcessDTO) dto;
|
||||
if (request.isSelectAll()) {
|
||||
List<String> ids = extApiDefinitionMapper.getIds(request, projectId, protocol, deleted);
|
||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||
ids.removeAll(request.getExcludeIds());
|
||||
}
|
||||
ids.addAll(request.getSelectIds());
|
||||
return ids.stream().distinct().toList();
|
||||
} else {
|
||||
request.getSelectIds().removeAll(request.getExcludeIds());
|
||||
return request.getSelectIds();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.metersphere.api.service.definition;
|
||||
|
||||
import io.metersphere.api.domain.ApiTestCase;
|
||||
import io.metersphere.api.domain.ApiTestCaseExample;
|
||||
import io.metersphere.api.dto.definition.ApiCaseBatchEditRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseAddRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseBatchRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseUpdateRequest;
|
||||
@ -63,11 +62,6 @@ public class ApiTestCaseNoticeService {
|
||||
}
|
||||
|
||||
|
||||
public List<ApiDefinitionCaseDTO> getBatchDeleteApiCaseDTO(ApiTestCaseBatchRequest request) {
|
||||
List<String> ids = apiTestCaseService.doSelectIds(request, false);
|
||||
return handleBatchNotice(ids);
|
||||
}
|
||||
|
||||
private List<ApiDefinitionCaseDTO> handleBatchNotice(List<String> ids) {
|
||||
List<ApiDefinitionCaseDTO> dtoList = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
@ -88,7 +82,7 @@ public class ApiTestCaseNoticeService {
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
public List<ApiDefinitionCaseDTO> getBatchEditApiCaseDTO(ApiCaseBatchEditRequest request) {
|
||||
public List<ApiDefinitionCaseDTO> getBatchEditApiCaseDTO(ApiTestCaseBatchRequest request) {
|
||||
List<String> ids = apiTestCaseService.doSelectIds(request, false);
|
||||
return handleBatchNotice(ids);
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package io.metersphere.api.service.definition;
|
||||
package io.metersphere.api.service.scenario;
|
||||
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioExample;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioBatchRequest;
|
||||
import io.metersphere.api.dto.scenario.ApiScenarioScheduleConfigRequest;
|
||||
import io.metersphere.api.dto.scenario.*;
|
||||
import io.metersphere.api.job.ApiScenarioScheduleJob;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.SubListUtils;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.domain.ScheduleExample;
|
||||
@ -52,4 +51,24 @@ public class ApiScenarioNoticeService {
|
||||
return dtoList;
|
||||
}
|
||||
|
||||
public ApiScenarioDTO getScenarioDTO(ApiScenarioAddRequest request) {
|
||||
ApiScenarioDTO scenarioDTO = new ApiScenarioDTO();
|
||||
BeanUtils.copyBean(scenarioDTO, request);
|
||||
return scenarioDTO;
|
||||
}
|
||||
|
||||
public ApiScenarioDTO getScenarioDTO(ApiScenarioUpdateRequest request) {
|
||||
ApiScenarioDTO scenarioDTO = new ApiScenarioDTO();
|
||||
BeanUtils.copyBean(scenarioDTO, request);
|
||||
return scenarioDTO;
|
||||
}
|
||||
|
||||
public ApiScenarioDTO getScenarioDTO(String id) {
|
||||
ApiScenario apiScenario = apiScenarioMapper.selectByPrimaryKey(id);
|
||||
ApiScenarioDTO scenarioDTO = new ApiScenarioDTO();
|
||||
BeanUtils.copyBean(scenarioDTO, apiScenario);
|
||||
return scenarioDTO;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -181,7 +181,7 @@ public class ApiScenarioService {
|
||||
item.setModulePath(StringUtils.isNotBlank(moduleMap.get(item.getModuleId())) ? moduleMap.get(item.getModuleId()) : Translator.get("api_unplanned_scenario"));
|
||||
if (!item.getGrouped() && envMap.containsKey(item.getEnvironmentId())) {
|
||||
item.setEnvironmentName(envMap.get(item.getEnvironmentId()));
|
||||
} else if (item.getGrouped() && groupMap.containsKey(item.getId())) {
|
||||
} else if (item.getGrouped() && groupMap.containsKey(item.getEnvironmentId())) {
|
||||
item.setEnvironmentName(groupMap.get(item.getEnvironmentId()));
|
||||
}
|
||||
if (MapUtils.isNotEmpty(scheduleMap) && scheduleMap.containsKey(item.getId())) {
|
||||
|
@ -0,0 +1,188 @@
|
||||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.domain.ApiReport;
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.api.domain.ApiScenarioReport;
|
||||
import io.metersphere.api.domain.ApiTestCase;
|
||||
import io.metersphere.api.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.api.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.api.service.ApiReportSendNoticeService;
|
||||
import io.metersphere.api.service.definition.ApiReportService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||
import io.metersphere.sdk.constants.ApiReportStatus;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class ApiReportSendNoticeTests extends BaseTest {
|
||||
|
||||
|
||||
@Resource
|
||||
private ApiReportService apiReportService;
|
||||
@Resource
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private ApiTestCaseMapper apiTestCaseMapper;
|
||||
@Resource
|
||||
private ApiScenarioReportService apiScenarioReportService;
|
||||
@Resource
|
||||
private ApiReportSendNoticeService apiReportSendNoticeService;
|
||||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
|
||||
@Test
|
||||
@Order(0)
|
||||
public void sendNoticeTest() throws Exception {
|
||||
Environment environment = new Environment();
|
||||
environment.setId("api-environment-id");
|
||||
environment.setName("api-environment-name");
|
||||
environment.setProjectId(DEFAULT_PROJECT_ID);
|
||||
environment.setCreateUser("admin");
|
||||
environment.setUpdateUser("admin");
|
||||
environment.setUpdateTime(System.currentTimeMillis());
|
||||
environment.setCreateTime(System.currentTimeMillis());
|
||||
environment.setPos(1L);
|
||||
environmentMapper.insertSelective(environment);
|
||||
|
||||
ApiTestCase apiTestCase = new ApiTestCase();
|
||||
apiTestCase.setId("send-api-case-id");
|
||||
apiTestCase.setApiDefinitionId("api-definition-id");
|
||||
apiTestCase.setProjectId(DEFAULT_PROJECT_ID);
|
||||
apiTestCase.setName(StringUtils.join("接口用例", apiTestCase.getId()));
|
||||
apiTestCase.setPriority("P0");
|
||||
apiTestCase.setStatus("Underway");
|
||||
apiTestCase.setNum(1111L);
|
||||
apiTestCase.setPos(0L);
|
||||
apiTestCase.setCreateTime(System.currentTimeMillis());
|
||||
apiTestCase.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestCase.setCreateUser("admin");
|
||||
apiTestCase.setUpdateUser("admin");
|
||||
apiTestCase.setVersionId("1.0");
|
||||
apiTestCase.setDeleted(false);
|
||||
apiTestCaseMapper.insert(apiTestCase);
|
||||
|
||||
List<ApiReport> reports = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ApiReport apiReport = new ApiReport();
|
||||
apiReport.setId("send-api-case-report-id" + i);
|
||||
apiReport.setProjectId(DEFAULT_PROJECT_ID);
|
||||
apiReport.setName("api-report-name" + i);
|
||||
apiReport.setStartTime(System.currentTimeMillis());
|
||||
apiReport.setResourceId("send-api-resource-id" + i);
|
||||
apiReport.setCreateUser("admin");
|
||||
apiReport.setUpdateUser("admin");
|
||||
apiReport.setUpdateTime(System.currentTimeMillis());
|
||||
apiReport.setPoolId("api-pool-id");
|
||||
apiReport.setEnvironmentId("api-environment-id");
|
||||
apiReport.setRunMode("api-run-mode");
|
||||
if (i == 0) {
|
||||
apiReport.setStatus(ApiReportStatus.SUCCESS.name());
|
||||
} else if (i == 1) {
|
||||
apiReport.setStatus(ApiReportStatus.ERROR.name());
|
||||
} else {
|
||||
apiReport.setStatus(ApiReportStatus.FAKE_ERROR.name());
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
apiReport.setVersionId("api-version-id" + i);
|
||||
reports.add(apiReport);
|
||||
}
|
||||
apiReportService.insertApiReport(reports);
|
||||
ApiNoticeDTO noticeDTO = new ApiNoticeDTO();
|
||||
noticeDTO.setReportId("send-api-case-report-id0");
|
||||
noticeDTO.setReportStatus(ApiReportStatus.SUCCESS.name());
|
||||
noticeDTO.setResourceId("send-api-case-id");
|
||||
noticeDTO.setResourceType("API_CASE");
|
||||
noticeDTO.setUserId("admin");
|
||||
noticeDTO.setProjectId(DEFAULT_PROJECT_ID);
|
||||
noticeDTO.setEnvironmentId("api-environment-id");
|
||||
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ApiReportStatus.ERROR.name());
|
||||
noticeDTO.setReportId("send-api-case-report-id1");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ApiReportStatus.FAKE_ERROR.name());
|
||||
noticeDTO.setReportId("send-api-case-report-id2");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
|
||||
|
||||
ApiScenario apiScenario = new ApiScenario();
|
||||
apiScenario.setId("send-scenario-id");
|
||||
apiScenario.setProjectId(DEFAULT_PROJECT_ID);
|
||||
apiScenario.setName("api-scenario-name");
|
||||
apiScenario.setCreateUser("admin");
|
||||
apiScenario.setUpdateUser("admin");
|
||||
apiScenario.setPriority("P0");
|
||||
apiScenario.setStatus("Underway");
|
||||
apiScenario.setNum(1111L);
|
||||
apiScenario.setUpdateTime(System.currentTimeMillis());
|
||||
apiScenario.setCreateTime(System.currentTimeMillis());
|
||||
apiScenario.setPos(1L);
|
||||
apiTestCase.setVersionId("1.0");
|
||||
apiScenario.setDeleted(false);
|
||||
apiScenario.setVersionId("1.0");
|
||||
apiScenario.setRefId("api-ref-id");
|
||||
apiScenario.setModuleId("api-module-id");
|
||||
apiScenarioMapper.insertSelective(apiScenario);
|
||||
|
||||
List<ApiScenarioReport> scenarioReports = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ApiScenarioReport scenarioReport = new ApiScenarioReport();
|
||||
scenarioReport.setId("send-scenario-report-id" + i);
|
||||
scenarioReport.setProjectId(DEFAULT_PROJECT_ID);
|
||||
scenarioReport.setName("scenario-report-name" + i);
|
||||
scenarioReport.setStartTime(System.currentTimeMillis());
|
||||
scenarioReport.setScenarioId("send-scenario-id");
|
||||
scenarioReport.setCreateUser("admin");
|
||||
scenarioReport.setUpdateUser("admin");
|
||||
if (i == 0) {
|
||||
scenarioReport.setStatus(ApiReportStatus.SUCCESS.name());
|
||||
} else if (i == 1) {
|
||||
scenarioReport.setStatus(ApiReportStatus.ERROR.name());
|
||||
} else {
|
||||
scenarioReport.setStatus(ApiReportStatus.FAKE_ERROR.name());
|
||||
}
|
||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||
scenarioReport.setPoolId("api-pool-id" + i);
|
||||
scenarioReport.setEnvironmentId("api-environment-id");
|
||||
scenarioReport.setRunMode("api-run-mode" + i);
|
||||
scenarioReport.setTriggerMode("api-trigger-mode" + i);
|
||||
scenarioReport.setVersionId("api-version-id" + i);
|
||||
scenarioReports.add(scenarioReport);
|
||||
}
|
||||
apiScenarioReportService.insertApiScenarioReport(scenarioReports);
|
||||
|
||||
|
||||
noticeDTO = new ApiNoticeDTO();
|
||||
noticeDTO.setReportId("send-scenario-report-id0");
|
||||
noticeDTO.setReportStatus(ApiReportStatus.SUCCESS.name());
|
||||
noticeDTO.setResourceId("send-api-case-id");
|
||||
noticeDTO.setResourceType("API_SCENARIO");
|
||||
noticeDTO.setUserId("admin");
|
||||
noticeDTO.setProjectId(DEFAULT_PROJECT_ID);
|
||||
noticeDTO.setEnvironmentId("api-environment-id");
|
||||
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ApiReportStatus.ERROR.name());
|
||||
noticeDTO.setReportId("send-scenario-report-id1");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ApiReportStatus.FAKE_ERROR.name());
|
||||
noticeDTO.setReportId("send-scenario-report-id2");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
}
|
||||
}
|
@ -180,29 +180,30 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||
apiScenario.setUpdateTime(System.currentTimeMillis());
|
||||
apiScenario.setCreateUser("admin");
|
||||
apiScenario.setUpdateUser("admin");
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setId(IDGenerator.nextStr());
|
||||
schedule.setKey(apiScenario.getId());
|
||||
schedule.setProjectId(DEFAULT_PROJECT_ID);
|
||||
schedule.setResourceId(apiScenario.getId());
|
||||
schedule.setJob(ApiScenarioScheduleJob.class.getName());
|
||||
schedule.setResourceType(ScheduleResourceType.API_SCENARIO.name());
|
||||
schedule.setEnable(true);
|
||||
schedule.setName("定时任务");
|
||||
schedule.setCreateUser("admin");
|
||||
schedule.setUpdateTime(System.currentTimeMillis());
|
||||
schedule.setCreateTime(System.currentTimeMillis());
|
||||
schedule.setType(ScheduleType.CRON.name());
|
||||
if (i % 2 == 0) {
|
||||
apiScenario.setTags(new ArrayList<>(List.of("tag1", "tag2")));
|
||||
apiScenario.setGrouped(true);
|
||||
apiScenario.setEnvironmentId("scenario-environment-group-id");
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setId(IDGenerator.nextStr());
|
||||
schedule.setKey(apiScenario.getId());
|
||||
schedule.setProjectId(DEFAULT_PROJECT_ID);
|
||||
schedule.setResourceId(apiScenario.getId());
|
||||
schedule.setJob(ApiScenarioScheduleJob.class.getName());
|
||||
schedule.setResourceType(ScheduleResourceType.API_SCENARIO.name());
|
||||
schedule.setValue("0 0 0/1 * * ? ");
|
||||
schedule.setEnable(true);
|
||||
schedule.setName("定时任务");
|
||||
schedule.setCreateUser("admin");
|
||||
schedule.setUpdateTime(System.currentTimeMillis());
|
||||
schedule.setCreateTime(System.currentTimeMillis());
|
||||
schedule.setType(ScheduleType.CRON.name());
|
||||
scheduleMapper.insertSelective(schedule);
|
||||
} else {
|
||||
apiScenario.setGrouped(false);
|
||||
apiScenario.setEnvironmentId(environments.get(0).getId());
|
||||
schedule.setValue("1111");
|
||||
}
|
||||
scheduleMapper.insertSelective(schedule);
|
||||
apiScenarioMapper.insertSelective(apiScenario);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.metersphere.project.service;
|
||||
|
||||
import io.metersphere.api.domain.ApiScenario;
|
||||
import io.metersphere.functional.domain.CaseReview;
|
||||
import io.metersphere.load.domain.LoadTest;
|
||||
import io.metersphere.plan.domain.TestPlan;
|
||||
@ -13,6 +12,7 @@ import io.metersphere.system.domain.CustomFieldExample;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.dto.BugNoticeDTO;
|
||||
import io.metersphere.system.dto.sdk.ApiDefinitionCaseDTO;
|
||||
import io.metersphere.system.dto.sdk.ApiScenarioMessageDTO;
|
||||
import io.metersphere.system.dto.sdk.FunctionalCaseMessageDTO;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||
@ -49,8 +49,8 @@ public class NoticeTemplateService {
|
||||
//TODO:获取报告
|
||||
}
|
||||
case NoticeConstants.TaskType.API_SCENARIO_TASK -> {
|
||||
Field[] allFields = FieldUtils.getAllFields(ApiScenario.class);
|
||||
addOptionDto(messageTemplateFieldDTOList, allFields, "api_scenario_");
|
||||
Field[] allFields = FieldUtils.getAllFields(ApiScenarioMessageDTO.class);
|
||||
addOptionDto(messageTemplateFieldDTOList, allFields, null);
|
||||
//TODO:获取报告
|
||||
}
|
||||
case NoticeConstants.TaskType.TEST_PLAN_TASK -> {
|
||||
|
@ -85,4 +85,64 @@ public class ApiDefinitionCaseDTO {
|
||||
@Schema(description = "自定义字段的值")
|
||||
private List<OptionDTO> fields;
|
||||
|
||||
@Schema(description = "message.domain.mock_name")
|
||||
private String mockName;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_url")
|
||||
private String reportUrl;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_share_url")
|
||||
private String shareUrl;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_name")
|
||||
private String reportName;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_start_time")
|
||||
private Long startTime;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_end_time")
|
||||
private Long endTime;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_duration")
|
||||
private Long requestDuration;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_status")
|
||||
private String reportStatus;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_environment")
|
||||
private String environment;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_error_count")
|
||||
private Long errorCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_fake_error_count")
|
||||
private Long fakeErrorCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_pending_count")
|
||||
private Long pendingCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_success_count")
|
||||
private Long successCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_assertion_count")
|
||||
private Long assertionCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_assertion_success_count")
|
||||
private Long assertionSuccessCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_error_rate")
|
||||
private String requestErrorRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_pending_rate")
|
||||
private String requestPendingRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_fake_error_rate")
|
||||
private String requestFakeErrorRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_pass_rate")
|
||||
private String requestPassRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_assertion_pass_rate")
|
||||
private String assertionPassRate;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,114 @@
|
||||
package io.metersphere.system.dto.sdk;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ApiScenarioMessageDTO {
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_name")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_priority")
|
||||
private String priority;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_status")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_stepTotal")
|
||||
private Integer stepTotal;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_passRate")
|
||||
private String requestPassRate;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_lastReportStatus")
|
||||
private String lastReportStatus;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_description")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_tags")
|
||||
private java.util.List<String> tags;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_grouped")
|
||||
private Boolean grouped;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_createUser")
|
||||
private String createUser;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_createTime")
|
||||
private Long createTime;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_deleteTime")
|
||||
private Long deleteTime;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_deleteUser")
|
||||
private String deleteUser;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_updateUser")
|
||||
private String updateUser;
|
||||
|
||||
@Schema(description = "message.domain.api_scenario_updateTime")
|
||||
private Long updateTime;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_url")
|
||||
private String reportUrl;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_share_url")
|
||||
private String shareUrl;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_name")
|
||||
private String reportName;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_start_time")
|
||||
private Long startTime;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_end_time")
|
||||
private Long endTime;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_duration")
|
||||
private Long requestDuration;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_status")
|
||||
private String reportStatus;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_environment")
|
||||
private String environment;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_error_count")
|
||||
private Long errorCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_fake_error_count")
|
||||
private Long fakeErrorCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_pending_count")
|
||||
private Long pendingCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_success_count")
|
||||
private Long successCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_assertion_count")
|
||||
private Long assertionCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_assertion_success_count")
|
||||
private Long assertionSuccessCount;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_error_rate")
|
||||
private String requestErrorRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_pending_rate")
|
||||
private String requestPendingRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_fake_error_rate")
|
||||
private String requestFakeErrorRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_request_pass_rate")
|
||||
private String reportRequestPassRate;
|
||||
|
||||
@Schema(description = "message.domain.scenario_report_assertion_pass_rate")
|
||||
private String assertionPassRate;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user