fix(接口测试): 修复修改引用的case的前后置操作,场景未同步的缺陷

--bug=1028019 --user=王孝刚 【测试跟踪】github#25703,测试计划关联场景,场景中引用了case, case
修改,测试计划执行未同步更新 https://www.tapd.cn/55049933/s/1396141
This commit is contained in:
wxg0103 2023-07-21 15:03:54 +08:00 committed by fit2-zhao
parent 27b5cfc1cd
commit 785e8d75ce
1 changed files with 17 additions and 11 deletions

View File

@ -74,6 +74,7 @@ import java.io.File;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -455,10 +456,22 @@ public class ElementUtil {
} }
}); });
sourceList = sourceList.stream().collect(Collectors
.collectingAndThen( //对sourceList根据id去重并且保持原有顺序
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MsTestElement::getId))), sourceList = sourceList.stream()
ArrayList::new)); .collect(Collectors.toMap(MsTestElement::getId, Function.identity(), (oldValue, newValue) -> oldValue, LinkedHashMap::new))
.values()
.stream()
.collect(Collectors.toList());
//删除不需要的元素
for (int i = 0; i < sourceList.size(); i++) {
MsTestElement item = sourceList.get(i);
if (!StringUtils.equals(item.getLabel(), SCENARIO_REF)
&& targetHashTree.stream().noneMatch(target -> StringUtils.equals(target.getId(), item.getId()))) {
sourceList.remove(i);
}
}
element.getHashTree().clear(); element.getHashTree().clear();
element.getHashTree().addAll(sourceList); element.getHashTree().addAll(sourceList);
@ -508,13 +521,6 @@ public class ElementUtil {
} }
} }
// 添加少的步骤
if (MapUtils.isNotEmpty(updateMap)) {
updateMap.forEach((k, v) -> {
sources.add(v);
});
}
// 删除多余的步骤 // 删除多余的步骤
for (int i = 0; i < sources.size(); i++) { for (int i = 0; i < sources.size(); i++) {
JSONObject source = sources.get(i); JSONObject source = sources.get(i);