fix(接口定义): 修复场景引用case未及时同步其他设置信息的缺陷

--bug=1022544 --user=王孝刚
【接口测试】github#21594,swagger、postman、har格式导入的接口没有配置默认超时时间,导致修改case的超时时间后,场景中引用的case也不能同步修改超时时间
https://www.tapd.cn/55049933/s/1332339
This commit is contained in:
wxg0103 2023-02-07 14:14:07 +08:00 committed by wxg0103
parent 6808984da6
commit a6ce6765e9
1 changed files with 11 additions and 1 deletions

View File

@ -19,13 +19,13 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.ProjectConfig;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.service.definition.ApiTestCaseService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -83,6 +83,11 @@ public class MsHashTreeService {
public static final String SHOW_CUSTOM_NUM = "showCustomNum";
public static final String VERSION_ID = "versionId";
public static final String RESOURCE_ID = ElementConstants.RESOURCE_ID;
private static final String CONNECT_TIMEOUT = "connectTimeout";
private static final String RESPONSE_TIMEOUT = "responseTimeout";
private static final String FOLLOW_REDIRECTS = "followRedirects";
private static final String AUTO_REDIRECTS = "autoRedirects";
private static final String ALIAS = "alias";
public void setHashTree(JSONArray hashTree) {
// 将引用转成复制
@ -151,6 +156,11 @@ public class MsHashTreeService {
element.put(AUTH_MANAGER, refElement.opt(AUTH_MANAGER));
element.put(ARGUMENTS, refElement.opt(ARGUMENTS));
element.put(PROJECT_ID, apiTestCase.getProjectId());
element.put(CONNECT_TIMEOUT, refElement.opt(CONNECT_TIMEOUT));
element.put(RESPONSE_TIMEOUT, refElement.opt(RESPONSE_TIMEOUT));
element.put(FOLLOW_REDIRECTS, refElement.opt(FOLLOW_REDIRECTS));
element.put(AUTO_REDIRECTS, refElement.opt(AUTO_REDIRECTS));
element.put(ALIAS, refElement.opt(ALIAS));
if (array != null) {
JSONArray sourceHashTree = element.optJSONArray(HASH_TREE);
Map<String, List<JSONObject>> groupMap = ElementUtil.group(sourceHashTree);