fix(接口测试): 修复场景引用其他设置未同步问题

--bug=1011443 --user=赵勇 【接口测试】场景引用case后,修改原始case的请求方式和其他设置,场景中的case不会更新 https://www.tapd.cn/55049933/s/1121879
This commit is contained in:
fit2-zhao 2022-03-21 13:39:32 +08:00 committed by fit2-zhao
parent d4a35c79eb
commit dedd7c30e4
2 changed files with 13 additions and 2 deletions

View File

@ -645,6 +645,18 @@ public class ElementUtil {
this.add("Extract");
}};
public static void copyBean(JSONObject target, JSONObject source) {
if (source == null || target == null) {
return;
}
for (String key : target.keySet()) {
if (source.containsKey(key) && !StringUtils.equalsIgnoreCase(key, "hashTree")) {
target.put(key, source.get(key));
}
}
}
public static List<MsTestElement> order(List<MsTestElement> elements) {
List<MsTestElement> elementList = new LinkedList<>();
if (CollectionUtils.isNotEmpty(elements)) {

View File

@ -13,7 +13,6 @@ import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.commons.utils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -182,7 +181,7 @@ public class MsHashTreeService {
JSONObject refElement = JSON.parseObject(apiTestCase.getRequest());
ElementUtil.dataFormatting(refElement);
JSONArray array = refElement.getJSONArray(HASH_TREE);
BeanUtils.copyBean(element, refElement);
ElementUtil.copyBean(element, refElement);
element.put(HEADERS, refElement.get(HEADERS));
element.put(REST, refElement.get(REST));
element.put(PATH, refElement.get(PATH));