fix(接口测试): 批量执行任务名称国际化有误
--bug=1047824 --user=陈建星 【项目任务中心】用例执行任务/用例执行任务详情列表-任务名称国际化错误 https://www.tapd.cn/55049933/s/1595865
This commit is contained in:
parent
2f986c832d
commit
e913074e2b
|
@ -9,6 +9,7 @@ import io.metersphere.api.dto.ReferenceDTO;
|
||||||
import io.metersphere.api.dto.ReferenceRequest;
|
import io.metersphere.api.dto.ReferenceRequest;
|
||||||
import io.metersphere.api.dto.definition.*;
|
import io.metersphere.api.dto.definition.*;
|
||||||
import io.metersphere.api.dto.request.ApiTransferRequest;
|
import io.metersphere.api.dto.request.ApiTransferRequest;
|
||||||
|
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||||
import io.metersphere.api.service.ApiFileResourceService;
|
import io.metersphere.api.service.ApiFileResourceService;
|
||||||
import io.metersphere.api.service.definition.*;
|
import io.metersphere.api.service.definition.*;
|
||||||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||||
|
@ -36,6 +37,7 @@ import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -300,6 +302,7 @@ public class ApiTestCaseController {
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_EXECUTE)
|
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_CASE_EXECUTE)
|
||||||
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_test_case")
|
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "api_test_case")
|
||||||
public void batchRun(@Validated @RequestBody ApiTestCaseBatchRunRequest request) {
|
public void batchRun(@Validated @RequestBody ApiTestCaseBatchRunRequest request) {
|
||||||
|
ApiBatchRunBaseService.setLocale(LocaleContextHolder.getLocale());
|
||||||
apiTestCaseBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
apiTestCaseBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.api.dto.scenario.ApiScenarioBatchCopyMoveRequest;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioBatchEditRequest;
|
import io.metersphere.api.dto.scenario.ApiScenarioBatchEditRequest;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioBatchRequest;
|
import io.metersphere.api.dto.scenario.ApiScenarioBatchRequest;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioBatchRunRequest;
|
import io.metersphere.api.dto.scenario.ApiScenarioBatchRunRequest;
|
||||||
|
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||||
import io.metersphere.api.service.ApiValidateService;
|
import io.metersphere.api.service.ApiValidateService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioBatchRunService;
|
import io.metersphere.api.service.scenario.ApiScenarioBatchRunService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
||||||
|
@ -21,6 +22,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
@ -99,6 +101,7 @@ public class ApiScenarioBatchOperationController {
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_EXECUTE)
|
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_EXECUTE)
|
||||||
public void batchRun(@Validated @RequestBody ApiScenarioBatchRunRequest request) {
|
public void batchRun(@Validated @RequestBody ApiScenarioBatchRunRequest request) {
|
||||||
apiValidateService.validateApiMenuInProject(request.getProjectId(), ApiResource.PROJECT.name());
|
apiValidateService.validateApiMenuInProject(request.getProjectId(), ApiResource.PROJECT.name());
|
||||||
|
ApiBatchRunBaseService.setLocale(LocaleContextHolder.getLocale());
|
||||||
apiScenarioBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
apiScenarioBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@ -38,14 +39,14 @@ public class ApiBatchRunBaseService {
|
||||||
@Resource
|
@Resource
|
||||||
private ExecTaskMapper execTaskMapper;
|
private ExecTaskMapper execTaskMapper;
|
||||||
|
|
||||||
/**
|
private final static ThreadLocal<Locale> localeThreadLocal = new ThreadLocal<>();
|
||||||
* 初始化执行队列
|
|
||||||
*
|
public static void setLocale(Locale locale) {
|
||||||
* @param resourceIds
|
localeThreadLocal.set(locale);
|
||||||
* @return
|
}
|
||||||
*/
|
|
||||||
public ExecutionQueue initExecutionqueue(List<String> resourceIds, String resourceType, String userId) {
|
public static Locale getLocale() {
|
||||||
return initExecutionqueue(resourceIds, null, resourceType, null, userId);
|
return localeThreadLocal.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class ApiTestCaseBatchRunService {
|
||||||
if (runModeConfig.isIntegratedReport()) {
|
if (runModeConfig.isIntegratedReport()) {
|
||||||
execTask.setTaskName(runModeConfig.getCollectionReport().getReportName());
|
execTask.setTaskName(runModeConfig.getCollectionReport().getReportName());
|
||||||
} else {
|
} else {
|
||||||
execTask.setTaskName(Translator.get("api_batch_task_name"));
|
execTask.setTaskName(Translator.get("api_batch_task_name", ApiBatchRunBaseService.getLocale()));
|
||||||
}
|
}
|
||||||
execTask.setOrganizationId(project.getOrganizationId());
|
execTask.setOrganizationId(project.getOrganizationId());
|
||||||
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
||||||
|
|
|
@ -243,7 +243,7 @@ public class ApiScenarioBatchRunService {
|
||||||
if (runModeConfig.isIntegratedReport()) {
|
if (runModeConfig.isIntegratedReport()) {
|
||||||
execTask.setTaskName(runModeConfig.getCollectionReport().getReportName());
|
execTask.setTaskName(runModeConfig.getCollectionReport().getReportName());
|
||||||
} else {
|
} else {
|
||||||
execTask.setTaskName(Translator.get("api_scenario_batch_task_name"));
|
execTask.setTaskName(Translator.get("api_scenario_batch_task_name", ApiBatchRunBaseService.getLocale()));
|
||||||
}
|
}
|
||||||
execTask.setOrganizationId(project.getOrganizationId());
|
execTask.setOrganizationId(project.getOrganizationId());
|
||||||
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.api.dto.definition.ApiReportDTO;
|
import io.metersphere.api.dto.definition.ApiReportDTO;
|
||||||
import io.metersphere.api.dto.definition.ApiReportDetailDTO;
|
import io.metersphere.api.dto.definition.ApiReportDetailDTO;
|
||||||
|
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||||
import io.metersphere.api.service.definition.ApiReportService;
|
import io.metersphere.api.service.definition.ApiReportService;
|
||||||
import io.metersphere.bug.domain.Bug;
|
import io.metersphere.bug.domain.Bug;
|
||||||
import io.metersphere.bug.dto.request.BugEditRequest;
|
import io.metersphere.bug.dto.request.BugEditRequest;
|
||||||
|
@ -39,6 +40,7 @@ import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -148,6 +150,7 @@ public class TestPlanApiCaseController {
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
||||||
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "test_plan", relationType = "test_plan_api_case")
|
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "test_plan", relationType = "test_plan_api_case")
|
||||||
public void batchRun(@Validated @RequestBody TestPlanApiCaseBatchRunRequest request) {
|
public void batchRun(@Validated @RequestBody TestPlanApiCaseBatchRunRequest request) {
|
||||||
|
ApiBatchRunBaseService.setLocale(LocaleContextHolder.getLocale());
|
||||||
testPlanApiCaseBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
testPlanApiCaseBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
import io.metersphere.api.dto.scenario.ApiScenarioReportDTO;
|
||||||
import io.metersphere.api.dto.scenario.ApiScenarioReportDetailDTO;
|
import io.metersphere.api.dto.scenario.ApiScenarioReportDetailDTO;
|
||||||
|
import io.metersphere.api.service.ApiBatchRunBaseService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.bug.domain.Bug;
|
import io.metersphere.bug.domain.Bug;
|
||||||
import io.metersphere.bug.dto.request.BugEditRequest;
|
import io.metersphere.bug.dto.request.BugEditRequest;
|
||||||
|
@ -36,6 +37,7 @@ import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
@ -98,6 +100,7 @@ public class TestPlanApiScenarioController {
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
|
||||||
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "test_plan", relationType = "test_plan_api_scenario")
|
@CheckOwner(resourceId = "#request.getSelectIds()", resourceType = "test_plan", relationType = "test_plan_api_scenario")
|
||||||
public void batchRun(@Validated @RequestBody TestPlanApiScenarioBatchRunRequest request) {
|
public void batchRun(@Validated @RequestBody TestPlanApiScenarioBatchRunRequest request) {
|
||||||
|
ApiBatchRunBaseService.setLocale(LocaleContextHolder.getLocale());
|
||||||
testPlanApiScenarioBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
testPlanApiScenarioBatchRunService.asyncBatchRun(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class TestPlanApiCaseBatchRunService {
|
||||||
private ExecTask initExecTask(int caseSize, Project project, String userId) {
|
private ExecTask initExecTask(int caseSize, Project project, String userId) {
|
||||||
ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId);
|
ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId);
|
||||||
execTask.setCaseCount(Long.valueOf(caseSize));
|
execTask.setCaseCount(Long.valueOf(caseSize));
|
||||||
execTask.setTaskName(Translator.get("api_batch_task_name"));
|
execTask.setTaskName(Translator.get("api_batch_task_name", ApiBatchRunBaseService.getLocale()));
|
||||||
execTask.setOrganizationId(project.getOrganizationId());
|
execTask.setOrganizationId(project.getOrganizationId());
|
||||||
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
||||||
execTask.setTaskType(ExecTaskType.TEST_PLAN_API_CASE_BATCH.name());
|
execTask.setTaskType(ExecTaskType.TEST_PLAN_API_CASE_BATCH.name());
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class TestPlanApiScenarioBatchRunService {
|
||||||
private ExecTask initExecTask(int caseSize, Project project, String userId) {
|
private ExecTask initExecTask(int caseSize, Project project, String userId) {
|
||||||
ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId);
|
ExecTask execTask = apiCommonService.newExecTask(project.getId(), userId);
|
||||||
execTask.setCaseCount(Long.valueOf(caseSize));
|
execTask.setCaseCount(Long.valueOf(caseSize));
|
||||||
execTask.setTaskName(Translator.get("api_scenario_batch_task_name"));
|
execTask.setTaskName(Translator.get("api_scenario_batch_task_name", ApiBatchRunBaseService.getLocale()));
|
||||||
execTask.setOrganizationId(project.getOrganizationId());
|
execTask.setOrganizationId(project.getOrganizationId());
|
||||||
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
execTask.setTriggerMode(TaskTriggerMode.BATCH.name());
|
||||||
execTask.setTaskType(ExecTaskType.TEST_PLAN_API_SCENARIO_BATCH.name());
|
execTask.setTaskType(ExecTaskType.TEST_PLAN_API_SCENARIO_BATCH.name());
|
||||||
|
|
Loading…
Reference in New Issue