fix(接口测试): 场景步骤中上传文件,执行报错
This commit is contained in:
parent
f20eed30bf
commit
d407f9d352
|
@ -15,19 +15,24 @@ public class FileAssociationSourceUtil {
|
||||||
public static final String SOURCE_TYPE_FUNCTIONAL_CASE = "FUNCTIONAL_CASE";
|
public static final String SOURCE_TYPE_FUNCTIONAL_CASE = "FUNCTIONAL_CASE";
|
||||||
public static final String SOURCE_TYPE_API_DEBUG = "API_DEBUG";
|
public static final String SOURCE_TYPE_API_DEBUG = "API_DEBUG";
|
||||||
public static final String SOURCE_TYPE_API_SCENARIO= "API_SCENARIO";
|
public static final String SOURCE_TYPE_API_SCENARIO= "API_SCENARIO";
|
||||||
|
public static final String SOURCE_TYPE_API_SCENARIO_STEP = "API_SCENARIO_STEP";
|
||||||
public static final String SOURCE_TYPE_API_TEST_CASE = "API_TEST_CASE";
|
public static final String SOURCE_TYPE_API_TEST_CASE = "API_TEST_CASE";
|
||||||
public static final String SOURCE_TYPE_API_DEFINITION = "API_DEFINITION";
|
public static final String SOURCE_TYPE_API_DEFINITION = "API_DEFINITION";
|
||||||
public static final String SOURCE_TYPE_API_DEFINITION_MOCK = "API_DEFINITION_MOCK";
|
public static final String SOURCE_TYPE_API_DEFINITION_MOCK = "API_DEFINITION_MOCK";
|
||||||
public static final Map<String, String> QUERY_SQL = new HashMap<>();
|
public static final Map<String, String> QUERY_SQL = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
QUERY_SQL.put(SOURCE_TYPE_BUG, "SELECT id AS sourceId, num AS sourceNum, title AS sourceName FROM bug");
|
QUERY_SQL.put(SOURCE_TYPE_BUG, "SELECT id AS sourceId, id AS redirectId, num AS sourceNum, title AS sourceName FROM bug t");
|
||||||
QUERY_SQL.put(SOURCE_TYPE_FUNCTIONAL_CASE, "SELECT id AS sourceId, num AS sourceNum, name AS sourceName FROM functional_case");
|
QUERY_SQL.put(SOURCE_TYPE_FUNCTIONAL_CASE, "SELECT id AS sourceId, id AS redirectId, num AS sourceNum, name AS sourceName FROM functional_case t");
|
||||||
QUERY_SQL.put(SOURCE_TYPE_API_DEBUG, "SELECT id AS sourceId, id AS sourceNum, name AS sourceName FROM api_debug");
|
QUERY_SQL.put(SOURCE_TYPE_API_DEBUG, "SELECT id AS sourceId, id AS redirectId, id AS sourceNum, name AS sourceName FROM api_debug t");
|
||||||
QUERY_SQL.put(SOURCE_TYPE_API_SCENARIO, "SELECT id AS sourceId, num AS sourceNum, name AS sourceName FROM api_scenario");
|
QUERY_SQL.put(SOURCE_TYPE_API_SCENARIO, "SELECT id AS sourceId, id AS redirectId, num AS sourceNum, name AS sourceName FROM api_scenario t");
|
||||||
QUERY_SQL.put(SOURCE_TYPE_API_TEST_CASE, "SELECT id AS sourceId, num AS sourceNum, name AS sourceName FROM api_test_case");
|
QUERY_SQL.put(SOURCE_TYPE_API_SCENARIO_STEP, """
|
||||||
QUERY_SQL.put(SOURCE_TYPE_API_DEFINITION, "SELECT id AS sourceId, num AS sourceNum, name AS sourceName FROM api_definition");
|
SELECT t.id AS sourceId, scenario.id AS redirectId, scenario.num AS sourceNum, CONCAT(scenario.name, ' (', t.name, ')') AS sourceName
|
||||||
QUERY_SQL.put(SOURCE_TYPE_API_DEFINITION_MOCK, "SELECT id AS sourceId, expect_num AS sourceNum, name AS sourceName FROM api_definition_mock");
|
FROM api_scenario_step t JOIN api_scenario scenario ON t.scenario_id = scenario.id
|
||||||
|
""");
|
||||||
|
QUERY_SQL.put(SOURCE_TYPE_API_TEST_CASE, "SELECT id AS sourceId, id AS redirectId, num AS sourceNum, name AS sourceName FROM api_test_case t");
|
||||||
|
QUERY_SQL.put(SOURCE_TYPE_API_DEFINITION, "SELECT id AS sourceId, id AS redirectId, num AS sourceNum, name AS sourceName FROM api_definition t");
|
||||||
|
QUERY_SQL.put(SOURCE_TYPE_API_DEFINITION_MOCK, "SELECT id AS sourceId, id AS redirectId, expect_num AS sourceNum, name AS sourceName FROM api_definition_mock t");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void validate(String type) {
|
public static void validate(String type) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -19,12 +20,12 @@ public class ApiResourceRunRequest {
|
||||||
* 创建时先按ID创建目录,再把文件放入目录
|
* 创建时先按ID创建目录,再把文件放入目录
|
||||||
*/
|
*/
|
||||||
@Schema(description = "新上传的文件ID")
|
@Schema(description = "新上传的文件ID")
|
||||||
private List<String> uploadFileIds;
|
private List<String> uploadFileIds = new ArrayList<>(0);
|
||||||
/**
|
/**
|
||||||
* 新关联的文件ID
|
* 新关联的文件ID
|
||||||
*/
|
*/
|
||||||
@Schema(description = "关联文件ID")
|
@Schema(description = "关联文件ID")
|
||||||
private List<String> linkFileIds;
|
private List<String> linkFileIds = new ArrayList<>(0);
|
||||||
/**
|
/**
|
||||||
* 执行的资源ID列表
|
* 执行的资源ID列表
|
||||||
* 场景执行时,为关联的所有用例和场景列表
|
* 场景执行时,为关联的所有用例和场景列表
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.api.dto.scenario;
|
package io.metersphere.api.dto.scenario;
|
||||||
|
|
||||||
|
import io.metersphere.api.dto.ResourceAddFileParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
@ -7,6 +8,7 @@ import jakarta.validation.constraints.Size;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: jianxing
|
* @Author: jianxing
|
||||||
|
@ -31,19 +33,20 @@ public class ApiScenarioDebugRequest extends ApiScenarioParseParam {
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 新上传的文件ID
|
|
||||||
* 创建时先按ID创建目录,再把文件放入目录
|
|
||||||
*/
|
|
||||||
@Schema(description = "新上传的文件ID")
|
|
||||||
private List<String> uploadFileIds;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新关联的文件ID
|
|
||||||
*/
|
|
||||||
@Schema(description = "关联文件ID")
|
|
||||||
private List<String> linkFileIds;
|
|
||||||
|
|
||||||
@Schema(description = "是否是本地执行")
|
@Schema(description = "是否是本地执行")
|
||||||
private Boolean frontendDebug = false;
|
private Boolean frontendDebug = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 步骤文件操作相关参数
|
||||||
|
* key 为步骤ID
|
||||||
|
* 值为文件参数
|
||||||
|
*/
|
||||||
|
@Schema(description = "步骤文件操作相关参数")
|
||||||
|
private Map<String, ResourceAddFileParam> stepFileParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 步骤文件操作相关参数
|
||||||
|
*/
|
||||||
|
@Schema(description = "场景文件操作相关参数")
|
||||||
|
private ResourceAddFileParam fileParam;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class ApiFileAssociationUpdateService implements FileAssociationUpdateSer
|
||||||
CommonBeanFactory.getBean(ApiDefinitionService.class).handleFileAssociationUpgrade(originFileAssociation, newFileMetadata);
|
CommonBeanFactory.getBean(ApiDefinitionService.class).handleFileAssociationUpgrade(originFileAssociation, newFileMetadata);
|
||||||
case FileAssociationSourceUtil.SOURCE_TYPE_API_TEST_CASE ->
|
case FileAssociationSourceUtil.SOURCE_TYPE_API_TEST_CASE ->
|
||||||
CommonBeanFactory.getBean(ApiTestCaseService.class).handleFileAssociationUpgrade(originFileAssociation, newFileMetadata);
|
CommonBeanFactory.getBean(ApiTestCaseService.class).handleFileAssociationUpgrade(originFileAssociation, newFileMetadata);
|
||||||
case FileAssociationSourceUtil.SOURCE_TYPE_API_SCENARIO ->
|
case FileAssociationSourceUtil.SOURCE_TYPE_API_SCENARIO_STEP ->
|
||||||
CommonBeanFactory.getBean(ApiScenarioService.class).handleFileAssociationUpgrade(originFileAssociation, newFileMetadata);
|
CommonBeanFactory.getBean(ApiScenarioService.class).handleStepFileAssociationUpgrade(originFileAssociation, newFileMetadata);
|
||||||
default -> {
|
default -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,6 +490,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
stepFileParam.forEach((stepId, fileParam) -> {
|
stepFileParam.forEach((stepId, fileParam) -> {
|
||||||
// 处理步骤文件
|
// 处理步骤文件
|
||||||
ApiFileResourceUpdateRequest resourceUpdateRequest = getApiFileResourceUpdateRequest(stepId, scenario.getProjectId(), creator);
|
ApiFileResourceUpdateRequest resourceUpdateRequest = getApiFileResourceUpdateRequest(stepId, scenario.getProjectId(), creator);
|
||||||
|
resourceUpdateRequest.setFileAssociationSourceType(FileAssociationSourceUtil.SOURCE_TYPE_API_SCENARIO_STEP);
|
||||||
resourceUpdateRequest.setUploadFileIds(fileParam.getUploadFileIds());
|
resourceUpdateRequest.setUploadFileIds(fileParam.getUploadFileIds());
|
||||||
resourceUpdateRequest.setLinkFileIds(fileParam.getLinkFileIds());
|
resourceUpdateRequest.setLinkFileIds(fileParam.getLinkFileIds());
|
||||||
apiFileResourceService.addFileResource(resourceUpdateRequest);
|
apiFileResourceService.addFileResource(resourceUpdateRequest);
|
||||||
|
@ -692,15 +693,15 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
ApiScenario originScenario = apiScenarioMapper.selectByPrimaryKey(request.getId());
|
ApiScenario originScenario = apiScenarioMapper.selectByPrimaryKey(request.getId());
|
||||||
|
|
||||||
|
// 更新场景步骤
|
||||||
|
updateApiScenarioStep(request, originScenario, updater);
|
||||||
|
|
||||||
// 处理步骤文件
|
// 处理步骤文件
|
||||||
handleStepFiles(request, updater, originScenario);
|
handleStepFiles(request, updater, originScenario);
|
||||||
|
|
||||||
// 处理场景文件
|
// 处理场景文件
|
||||||
handleScenarioFiles(request, updater, originScenario);
|
handleScenarioFiles(request, updater, originScenario);
|
||||||
|
|
||||||
// 更新场景步骤
|
|
||||||
updateApiScenarioStep(request, originScenario, updater);
|
|
||||||
|
|
||||||
return scenario;
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,8 +729,9 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
stepFileParam.forEach((stepId, fileParam) -> {
|
stepFileParam.forEach((stepId, fileParam) -> {
|
||||||
// 处理步骤文件
|
// 处理步骤文件
|
||||||
ApiFileResourceUpdateRequest resourceUpdateRequest = getApiFileResourceUpdateRequest(stepId, scenario.getProjectId(), updater);
|
ApiFileResourceUpdateRequest resourceUpdateRequest = getApiFileResourceUpdateRequest(stepId, scenario.getProjectId(), updater);
|
||||||
|
resourceUpdateRequest.setFileAssociationSourceType(FileAssociationSourceUtil.SOURCE_TYPE_API_SCENARIO_STEP);
|
||||||
resourceUpdateRequest = BeanUtils.copyBean(resourceUpdateRequest, fileParam);
|
resourceUpdateRequest = BeanUtils.copyBean(resourceUpdateRequest, fileParam);
|
||||||
apiFileResourceService.addFileResource(resourceUpdateRequest);
|
apiFileResourceService.updateFileResource(resourceUpdateRequest);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -808,6 +810,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测循环依赖
|
* 检测循环依赖
|
||||||
|
*
|
||||||
* @param scenarioId
|
* @param scenarioId
|
||||||
* @param steps
|
* @param steps
|
||||||
*/
|
*/
|
||||||
|
@ -1299,6 +1302,8 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
ApiResourceRunRequest runRequest = getApiResourceRunRequest(msScenario, tmpParam);
|
ApiResourceRunRequest runRequest = getApiResourceRunRequest(msScenario, tmpParam);
|
||||||
|
|
||||||
|
runRequest = setFileParam(request, runRequest);
|
||||||
|
|
||||||
TaskRequestDTO taskRequest = getTaskRequest(request.getReportId(), request.getId(), request.getProjectId(),
|
TaskRequestDTO taskRequest = getTaskRequest(request.getReportId(), request.getId(), request.getProjectId(),
|
||||||
apiExecuteService.getDebugRunModule(request.getFrontendDebug()));
|
apiExecuteService.getDebugRunModule(request.getFrontendDebug()));
|
||||||
taskRequest.setSaveResult(false);
|
taskRequest.setSaveResult(false);
|
||||||
|
@ -1311,6 +1316,39 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
return apiExecuteService.execute(runRequest, taskRequest, parseConfig);
|
return apiExecuteService.execute(runRequest, taskRequest, parseConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行时设置临时文件的相关参数
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param runRequest
|
||||||
|
*/
|
||||||
|
private ApiResourceRunRequest setFileParam(ApiScenarioDebugRequest request, ApiResourceRunRequest runRequest) {
|
||||||
|
runRequest.getLinkFileIds().addAll(getLinkFileIds(request.getFileParam()));
|
||||||
|
runRequest.getUploadFileIds().addAll(getUploadFileIds(request.getFileParam()));
|
||||||
|
Map<String, ResourceAddFileParam> stepFileParam = request.getStepFileParam();
|
||||||
|
if (MapUtils.isNotEmpty(stepFileParam)) {
|
||||||
|
stepFileParam.values().forEach(fileParam -> {
|
||||||
|
runRequest.getLinkFileIds().addAll(getLinkFileIds(fileParam));
|
||||||
|
runRequest.getUploadFileIds().addAll(getUploadFileIds(fileParam));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return runRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getLinkFileIds(ResourceAddFileParam fileParam) {
|
||||||
|
if (fileParam != null && CollectionUtils.isNotEmpty(fileParam.getLinkFileIds())) {
|
||||||
|
return fileParam.getLinkFileIds();
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUploadFileIds(ResourceAddFileParam fileParam) {
|
||||||
|
if (fileParam != null && CollectionUtils.isNotEmpty(fileParam.getUploadFileIds())) {
|
||||||
|
return fileParam.getUploadFileIds();
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
public TaskRequestDTO run(String id, String reportId, String userId) {
|
public TaskRequestDTO run(String id, String reportId, String userId) {
|
||||||
ApiScenarioDetail apiScenarioDetail = getForRun(id);
|
ApiScenarioDetail apiScenarioDetail = getForRun(id);
|
||||||
|
|
||||||
|
@ -1319,7 +1357,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
ApiScenarioParseParam parseParam = getApiScenarioParseParam(apiScenarioDetail);
|
ApiScenarioParseParam parseParam = getApiScenarioParseParam(apiScenarioDetail);
|
||||||
|
|
||||||
return executeRun(apiScenarioDetail, msScenario, apiScenarioDetail.getSteps(), parseParam, reportId, userId);
|
return executeRun(apiScenarioDetail, msScenario, apiScenarioDetail.getSteps(), parseParam, new ApiResourceRunRequest(), reportId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiScenarioParseParam getApiScenarioParseParam(ApiScenarioDetail apiScenarioDetail) {
|
public ApiScenarioParseParam getApiScenarioParseParam(ApiScenarioDetail apiScenarioDetail) {
|
||||||
|
@ -1351,19 +1389,24 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
// 处理特殊的步骤详情
|
// 处理特殊的步骤详情
|
||||||
addSpecialStepDetails(request.getSteps(), request.getStepDetails());
|
addSpecialStepDetails(request.getSteps(), request.getStepDetails());
|
||||||
|
|
||||||
return executeRun(apiScenario, msScenario, request.getSteps(), request, request.getReportId(), userId);
|
ApiResourceRunRequest runRequest = new ApiResourceRunRequest();
|
||||||
|
runRequest = setFileParam(request, runRequest);
|
||||||
|
|
||||||
|
return executeRun(apiScenario, msScenario, request.getSteps(), request, runRequest, request.getReportId(), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskRequestDTO executeRun(ApiScenario apiScenario,
|
public TaskRequestDTO executeRun(ApiScenario apiScenario,
|
||||||
MsScenario msScenario,
|
MsScenario msScenario,
|
||||||
List<? extends ApiScenarioStepCommonDTO> steps,
|
List<? extends ApiScenarioStepCommonDTO> steps,
|
||||||
ApiScenarioParseParam parseParam,
|
ApiScenarioParseParam parseParam,
|
||||||
String reportId, String userId) {
|
ApiResourceRunRequest runRequest,
|
||||||
|
String reportId,
|
||||||
|
String userId) {
|
||||||
|
|
||||||
// 解析生成场景树,并保存临时变量
|
// 解析生成场景树,并保存临时变量
|
||||||
ApiScenarioParseTmpParam tmpParam = parse(msScenario, steps, parseParam);
|
ApiScenarioParseTmpParam tmpParam = parse(msScenario, steps, parseParam);
|
||||||
|
|
||||||
ApiResourceRunRequest runRequest = getApiResourceRunRequest(msScenario, tmpParam);
|
runRequest = setApiResourceRunRequestParam(msScenario, tmpParam, runRequest);
|
||||||
|
|
||||||
String poolId = apiExecuteService.getProjectApiResourcePoolId(apiScenario.getProjectId());
|
String poolId = apiExecuteService.getProjectApiResourcePoolId(apiScenario.getProjectId());
|
||||||
|
|
||||||
|
@ -1511,6 +1554,10 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
public ApiResourceRunRequest getApiResourceRunRequest(MsScenario msScenario, ApiScenarioParseTmpParam tmpParam) {
|
public ApiResourceRunRequest getApiResourceRunRequest(MsScenario msScenario, ApiScenarioParseTmpParam tmpParam) {
|
||||||
ApiResourceRunRequest runRequest = new ApiResourceRunRequest();
|
ApiResourceRunRequest runRequest = new ApiResourceRunRequest();
|
||||||
|
return setApiResourceRunRequestParam(msScenario, tmpParam, runRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiResourceRunRequest setApiResourceRunRequestParam(MsScenario msScenario, ApiScenarioParseTmpParam tmpParam, ApiResourceRunRequest runRequest) {
|
||||||
runRequest.setRefResourceIds(tmpParam.getRefResourceIds());
|
runRequest.setRefResourceIds(tmpParam.getRefResourceIds());
|
||||||
runRequest.setRefProjectIds(tmpParam.getRefProjectIds());
|
runRequest.setRefProjectIds(tmpParam.getRefProjectIds());
|
||||||
runRequest.setTestElement(msScenario);
|
runRequest.setTestElement(msScenario);
|
||||||
|
@ -1575,6 +1622,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 MsHTTPElement 中的 method 等信息
|
* 设置 MsHTTPElement 中的 method 等信息
|
||||||
|
*
|
||||||
* @param httpElements
|
* @param httpElements
|
||||||
* @param getDefinitionInfoFunc
|
* @param getDefinitionInfoFunc
|
||||||
*/
|
*/
|
||||||
|
@ -1889,6 +1937,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部分引用的步骤的详情
|
* 查询部分引用的步骤的详情
|
||||||
|
*
|
||||||
* @param steps
|
* @param steps
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -2775,15 +2824,14 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
return operationHistoryService.listWidthTable(request, SCENARIO_TABLE);
|
return operationHistoryService.listWidthTable(request, SCENARIO_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleFileAssociationUpgrade(FileAssociation originFileAssociation, FileMetadata newFileMetadata) {
|
public void handleStepFileAssociationUpgrade(FileAssociation originFileAssociation, FileMetadata newFileMetadata) {
|
||||||
// 查询有步骤详情的请求类型的步骤
|
|
||||||
List<String> stepIds = extApiScenarioStepMapper.getHasBlobRequestStepIds(originFileAssociation.getSourceId());
|
|
||||||
// 查询步骤详情
|
// 查询步骤详情
|
||||||
ApiScenarioStepBlobExample blobExample = new ApiScenarioStepBlobExample();
|
ApiScenarioStepBlob apiScenarioStepBlob = apiScenarioStepBlobMapper.selectByPrimaryKey(originFileAssociation.getSourceId());
|
||||||
blobExample.createCriteria().andIdIn(stepIds);
|
|
||||||
List<ApiScenarioStepBlob> apiScenarioStepBlobs = apiScenarioStepBlobMapper.selectByExampleWithBLOBs(blobExample);
|
if (apiScenarioStepBlob == null || apiScenarioStepBlob.getContent() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (ApiScenarioStepBlob apiScenarioStepBlob : apiScenarioStepBlobs) {
|
|
||||||
AbstractMsTestElement msTestElement = null;
|
AbstractMsTestElement msTestElement = null;
|
||||||
try {
|
try {
|
||||||
msTestElement = ApiDataUtils.parseObject(new String(apiScenarioStepBlob.getContent()), AbstractMsTestElement.class);
|
msTestElement = ApiDataUtils.parseObject(new String(apiScenarioStepBlob.getContent()), AbstractMsTestElement.class);
|
||||||
|
@ -2802,7 +2850,6 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String transfer(ApiTransferRequest request, String userId) {
|
public String transfer(ApiTransferRequest request, String userId) {
|
||||||
return apiFileResourceService.transfer(request, userId, ApiResourceType.API_SCENARIO.name());
|
return apiFileResourceService.transfer(request, userId, ApiResourceType.API_SCENARIO.name());
|
||||||
|
@ -2852,6 +2899,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取场景前置的总等待时间
|
* 获取场景前置的总等待时间
|
||||||
|
*
|
||||||
* @param scenarioConfig
|
* @param scenarioConfig
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -175,6 +175,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
private ApiScenarioReportService scenarioReportService;
|
private ApiScenarioReportService scenarioReportService;
|
||||||
|
|
||||||
private static String fileMetadataId;
|
private static String fileMetadataId;
|
||||||
|
private static String fileMetadataStepId;
|
||||||
private static String localFileId;
|
private static String localFileId;
|
||||||
private static ApiScenario addApiScenario;
|
private static ApiScenario addApiScenario;
|
||||||
private static List<ApiScenarioStepRequest> addApiScenarioSteps;
|
private static List<ApiScenarioStepRequest> addApiScenarioSteps;
|
||||||
|
@ -627,6 +628,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
msHttpElement.setBody(ApiDebugControllerTests.addBodyLinkFile(msHttpElement.getBody(), fileMetadataId));
|
msHttpElement.setBody(ApiDebugControllerTests.addBodyLinkFile(msHttpElement.getBody(), fileMetadataId));
|
||||||
steptDetailMap.put(steps.get(0).getId(), getMsHttpElementStr(msHttpElement));
|
steptDetailMap.put(steps.get(0).getId(), getMsHttpElementStr(msHttpElement));
|
||||||
steptDetailMap.put(steps.get(1).getId(), getMsHttpElementStr(msHttpElement));
|
steptDetailMap.put(steps.get(1).getId(), getMsHttpElementStr(msHttpElement));
|
||||||
|
fileMetadataStepId = steps.get(0).getId();
|
||||||
|
|
||||||
request.setSteps(steps);
|
request.setSteps(steps);
|
||||||
request.setStepDetails(steptDetailMap);
|
request.setStepDetails(steptDetailMap);
|
||||||
|
@ -682,15 +684,13 @@ public class ApiScenarioControllerTests extends BaseTest {
|
||||||
private List<ApiFile> getApiFiles(String fileId) {
|
private List<ApiFile> getApiFiles(String fileId) {
|
||||||
ApiScenarioStepBlobExample example = new ApiScenarioStepBlobExample();
|
ApiScenarioStepBlobExample example = new ApiScenarioStepBlobExample();
|
||||||
example.createCriteria().andScenarioIdEqualTo(addApiScenario.getId());
|
example.createCriteria().andScenarioIdEqualTo(addApiScenario.getId());
|
||||||
List<ApiScenarioStepBlob> apiScenarioStepBlobs = apiScenarioStepBlobMapper.selectByExampleWithBLOBs(example);
|
ApiScenarioStepBlob apiScenarioStepBlob = apiScenarioStepBlobMapper.selectByPrimaryKey(fileMetadataStepId);
|
||||||
List<ApiFile> apiFiles = new ArrayList<>();
|
List<ApiFile> apiFiles = new ArrayList<>();
|
||||||
for (ApiScenarioStepBlob apiScenarioStepBlob : apiScenarioStepBlobs) {
|
|
||||||
try {
|
try {
|
||||||
AbstractMsTestElement msTestElement = ApiDataUtils.parseObject(new String(apiScenarioStepBlob.getContent()), AbstractMsTestElement.class);
|
AbstractMsTestElement msTestElement = ApiDataUtils.parseObject(new String(apiScenarioStepBlob.getContent()), AbstractMsTestElement.class);
|
||||||
apiFiles.addAll(apiCommonService.getApiFilesByFileId(fileId, msTestElement));
|
apiFiles.addAll(apiCommonService.getApiFilesByFileId(fileId, msTestElement));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return apiFiles;
|
return apiFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,5 @@ public class FileAssociationSource {
|
||||||
private String sourceId;
|
private String sourceId;
|
||||||
private String sourceNum;
|
private String sourceNum;
|
||||||
private String sourceName;
|
private String sourceName;
|
||||||
|
private String redirectId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@ public class FileAssociationResponse {
|
||||||
@Schema(description = "资源Id")
|
@Schema(description = "资源Id")
|
||||||
private String sourceId;
|
private String sourceId;
|
||||||
|
|
||||||
|
@Schema(description = "前端跳转Id")
|
||||||
|
private String redirectId;
|
||||||
|
|
||||||
@Schema(description = "资源编号")
|
@Schema(description = "资源编号")
|
||||||
private String sourceNum;
|
private String sourceNum;
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
<select id="selectNameBySourceTableAndId"
|
<select id="selectNameBySourceTableAndId"
|
||||||
resultType="io.metersphere.project.dto.filemanagement.FileAssociationSource">
|
resultType="io.metersphere.project.dto.filemanagement.FileAssociationSource">
|
||||||
${querySql}
|
${querySql}
|
||||||
WHERE id = #{sourceId}
|
WHERE t.id = #{sourceId}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectAssociationSourceBySourceTableAndIdList"
|
<select id="selectAssociationSourceBySourceTableAndIdList"
|
||||||
resultType="io.metersphere.project.dto.filemanagement.FileAssociationSource">
|
resultType="io.metersphere.project.dto.filemanagement.FileAssociationSource">
|
||||||
${querySql}
|
${querySql}
|
||||||
WHERE id IN
|
WHERE t.id IN
|
||||||
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class FileAssociationService {
|
||||||
response.setFileId(item.getFileId());
|
response.setFileId(item.getFileId());
|
||||||
response.setSourceName(sourceIdNameMap.get(item.getSourceId()).getSourceName());
|
response.setSourceName(sourceIdNameMap.get(item.getSourceId()).getSourceName());
|
||||||
response.setSourceNum(sourceIdNameMap.get(item.getSourceId()).getSourceNum());
|
response.setSourceNum(sourceIdNameMap.get(item.getSourceId()).getSourceNum());
|
||||||
|
response.setRedirectId(sourceIdNameMap.get(item.getSourceId()).getRedirectId());
|
||||||
response.setSourceType(item.getSourceType());
|
response.setSourceType(item.getSourceType());
|
||||||
response.setFileVersion(fileIdMap.get(item.getFileId()).getFileVersion());
|
response.setFileVersion(fileIdMap.get(item.getFileId()).getFileVersion());
|
||||||
responseList.add(response);
|
responseList.add(response);
|
||||||
|
|
Loading…
Reference in New Issue