fix(接口测试): 新增场景步骤所属资源查询接口
--bug=1038780 --user=陈建星 【接口测试】场景-添加步骤-导入系统请求-导入后修改原请求的名称-hover图标查看导入系统请求名称-名称显示undefined https://www.tapd.cn/55049933/s/1491298
This commit is contained in:
parent
b1eabb9490
commit
4408222206
|
@ -14,7 +14,6 @@ import io.metersphere.api.service.ApiValidateService;
|
|||
import io.metersphere.api.service.scenario.ApiScenarioLogService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioNoticeService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioService;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.service.FileModuleService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.api.task.TaskRequestDTO;
|
||||
|
@ -142,11 +141,11 @@ public class ApiScenarioController {
|
|||
return apiScenarioService.getStepDetail(stepId);
|
||||
}
|
||||
|
||||
@GetMapping("/step/project-ifo/{projectId}")
|
||||
@Operation(summary = "接口测试-接口场景管理-获取步骤的所属项目信息")
|
||||
@GetMapping("/step/resource-info/{resourceId}")
|
||||
@Operation(summary = "接口测试-接口场景管理-获取步骤关联资源的信息")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_API_SCENARIO_READ)
|
||||
public Project getStepResourceProjectInfo(@PathVariable String projectId) {
|
||||
return apiScenarioService.getStepResourceProjectInfo(projectId);
|
||||
public ApiStepResourceInfo getStepResourceInfo(@PathVariable String resourceId, @RequestParam String resourceType) {
|
||||
return apiScenarioService.getStepResourceInfo(resourceId, resourceType);
|
||||
}
|
||||
|
||||
//需求补充:回收站里的相关操作都不需要发通知
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.api.dto.scenario;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiStepResourceInfo {
|
||||
@Schema(description = "资源ID")
|
||||
private String id;
|
||||
@Schema(description = "资源编号")
|
||||
private Long num;
|
||||
@Schema(description = "资源名称")
|
||||
private String name;
|
||||
@Schema(description = "所属项目ID")
|
||||
private String projectId;
|
||||
@Schema(description = "所属项目名称")
|
||||
private String projectName;
|
||||
}
|
|
@ -2738,14 +2738,41 @@ public class ApiScenarioService extends MoveNodeService {
|
|||
return extApiDefinitionMapper.getReference(request);
|
||||
}
|
||||
|
||||
public Project getStepResourceProjectInfo(String projectId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
if (project == null) {
|
||||
return null;
|
||||
public ApiStepResourceInfo getStepResourceInfo(String resourceId, String resourceType) {
|
||||
ApiResourceType apiResourceType = EnumValidator.validateEnum(ApiResourceType.class, resourceType);
|
||||
ApiStepResourceInfo apiStepResourceInfo = new ApiStepResourceInfo();
|
||||
apiStepResourceInfo.setId(resourceId);
|
||||
String projectId;
|
||||
|
||||
switch (apiResourceType) {
|
||||
case API_SCENARIO -> {
|
||||
ApiScenario apiScenario = apiScenarioMapper.selectByPrimaryKey(resourceId);
|
||||
apiStepResourceInfo.setId(apiScenario.getId());
|
||||
apiStepResourceInfo.setNum(apiScenario.getNum());
|
||||
apiStepResourceInfo.setName(apiScenario.getName());
|
||||
projectId = apiScenario.getProjectId();
|
||||
}
|
||||
case API -> {
|
||||
ApiDefinition apiDefinition = apiDefinitionMapper.selectByPrimaryKey(resourceId);
|
||||
apiStepResourceInfo.setId(apiDefinition.getId());
|
||||
apiStepResourceInfo.setNum(apiDefinition.getNum());
|
||||
apiStepResourceInfo.setName(apiDefinition.getName());
|
||||
projectId = apiDefinition.getProjectId();
|
||||
}
|
||||
case API_CASE -> {
|
||||
ApiTestCase apiTestCase = apiTestCaseMapper.selectByPrimaryKey(resourceId);
|
||||
apiStepResourceInfo.setId(apiTestCase.getId());
|
||||
apiStepResourceInfo.setNum(apiTestCase.getNum());
|
||||
apiStepResourceInfo.setName(apiTestCase.getName());
|
||||
projectId = apiTestCase.getProjectId();
|
||||
}
|
||||
default -> {
|
||||
return apiStepResourceInfo;
|
||||
}
|
||||
}
|
||||
Project projectInfo = new Project();
|
||||
projectInfo.setId(project.getId());
|
||||
projectInfo.setName(project.getName());
|
||||
return projectInfo;
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
apiStepResourceInfo.setProjectId(project.getId());
|
||||
apiStepResourceInfo.setProjectName(project.getName());
|
||||
return apiStepResourceInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import io.metersphere.api.utils.ApiDataUtils;
|
|||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||
import io.metersphere.project.api.assertion.MsResponseCodeAssertion;
|
||||
import io.metersphere.project.api.assertion.MsScriptAssertion;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.ProjectVersion;
|
||||
import io.metersphere.project.dto.environment.variables.CommonVariables;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileUploadRequest;
|
||||
|
@ -100,7 +99,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
protected static final String UPLOAD_TEMP_FILE = "upload/temp/file";
|
||||
protected static final String DELETE_TO_GC = "delete-to-gc/{0}";
|
||||
protected static final String STEP_GET = "step/get/{0}";
|
||||
protected static final String STEP_PROJECT_INFO = "step/project-ifo/{0}";
|
||||
protected static final String STEP_RESOURCE_INFO = "step/resource-info/{0}?resourceType={1}";
|
||||
protected static final String DEBUG = "debug";
|
||||
protected static final String RUN = "run/{0}";
|
||||
protected static final String RUN_REAL_TIME = "run/{0}?reportId={1}";
|
||||
|
@ -634,6 +633,8 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
// 测试关联的文件更新
|
||||
testHandleFileAssociationUpgrade();
|
||||
|
||||
addApiScenario = apiScenarioMapper.selectByPrimaryKey(addApiScenario.getId());
|
||||
|
||||
// @@重名校验异常
|
||||
request.setName(anOtherAddApiScenario.getName());
|
||||
assertErrorCode(this.requestPost(DEFAULT_UPDATE, request), API_SCENARIO_EXIST);
|
||||
|
@ -1218,17 +1219,30 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
|
||||
@Test
|
||||
@Order(7)
|
||||
public void getStepResourceProjectInfo() throws Exception {
|
||||
MvcResult mvcResult = this.requestGetAndReturn(STEP_PROJECT_INFO, DEFAULT_PROJECT_ID);
|
||||
Project project = getResultData(mvcResult, Project.class);
|
||||
Assertions.assertEquals(project.getName(), projectMapper.selectByPrimaryKey(project.getId()).getName());
|
||||
public void getStepResourceResourceInfo() throws Exception {
|
||||
|
||||
mvcResult = this.requestGetAndReturn(STEP_PROJECT_INFO, "tyuio");
|
||||
project = getResultData(mvcResult, Project.class);
|
||||
Assertions.assertNull(project);
|
||||
MvcResult mvcResult = this.requestGetAndReturn(STEP_RESOURCE_INFO, apiDefinition.getId(), ApiScenarioStepType.API.name());
|
||||
ApiStepResourceInfo apiStepResourceInfo = getResultData(mvcResult, ApiStepResourceInfo.class);
|
||||
Assertions.assertEquals(apiStepResourceInfo.getNum(), apiDefinition.getNum());
|
||||
Assertions.assertEquals(apiStepResourceInfo.getName(), apiDefinition.getName());
|
||||
Assertions.assertEquals(apiStepResourceInfo.getProjectName(), projectMapper.selectByPrimaryKey(apiDefinition.getProjectId()).getName());
|
||||
|
||||
mvcResult = this.requestGetAndReturn(STEP_RESOURCE_INFO, apiTestCase.getId(), ApiScenarioStepType.API_CASE.name());
|
||||
apiStepResourceInfo = getResultData(mvcResult, ApiStepResourceInfo.class);
|
||||
Assertions.assertEquals(apiStepResourceInfo.getNum(), apiTestCase.getNum());
|
||||
Assertions.assertEquals(apiStepResourceInfo.getName(), apiTestCase.getName());
|
||||
Assertions.assertEquals(apiStepResourceInfo.getProjectName(), projectMapper.selectByPrimaryKey(apiTestCase.getProjectId()).getName());
|
||||
|
||||
mvcResult = this.requestGetAndReturn(STEP_RESOURCE_INFO, addApiScenario.getId(), ApiScenarioStepType.API_SCENARIO.name());
|
||||
apiStepResourceInfo = getResultData(mvcResult, ApiStepResourceInfo.class);
|
||||
Assertions.assertEquals(apiStepResourceInfo.getNum(), addApiScenario.getNum());
|
||||
Assertions.assertEquals(apiStepResourceInfo.getName(), addApiScenario.getName());
|
||||
Assertions.assertEquals(apiStepResourceInfo.getProjectName(), projectMapper.selectByPrimaryKey(addApiScenario.getProjectId()).getName());
|
||||
|
||||
this.requestGetAndReturn(STEP_RESOURCE_INFO, addApiScenario.getId(), "AAA");
|
||||
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_READ, STEP_PROJECT_INFO, DEFAULT_PROJECT_ID);
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_API_SCENARIO_READ, STEP_RESOURCE_INFO, "aa", "bb");
|
||||
}
|
||||
|
||||
private void requestGetStepDetail(List<? extends ApiScenarioStepCommonDTO> steps) throws Exception {
|
||||
|
|
Loading…
Reference in New Issue