refactor(接口测试): 优化场景报告步骤排序方法,以解决存在未执行步骤时报告步骤排序错乱的问题
--bug=1011633 --user=宋天阳 【测试跟踪】-测试报告中功能用例ID顺序和测试计划功能用例顺序不一致 https://www.tapd.cn/55049933/s/1126292
This commit is contained in:
parent
8e1302f23b
commit
7ff56b4d01
|
@ -383,25 +383,12 @@ public class ApiScenarioReportStructureService {
|
|||
if (dtoList.stream().filter(e -> e.getValue() != null).collect(Collectors.toList()).size() == dtoList.size()) {
|
||||
List<StepTreeDTO> unList = dtoList.stream().filter(e -> e.getValue() != null
|
||||
&& StringUtils.equalsIgnoreCase(e.getTotalStatus(), "unexecute")).collect(Collectors.toList());
|
||||
Map<String, Integer> map = unList.stream().collect(Collectors.toMap(StepTreeDTO::getResourceId, StepTreeDTO::getIndex));
|
||||
|
||||
List<StepTreeDTO> list = dtoList.stream()
|
||||
.sorted(
|
||||
(x, y) -> {
|
||||
// 如果开始时间是0,即未开始,则排后面
|
||||
if (x.getValue().getStartTime() == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return x.getValue().getStartTime() - y.getValue().getStartTime() > 0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
if (map.containsKey(list.get(index).getResourceId())) {
|
||||
Collections.swap(list, index, (map.get(list.get(index).getResourceId()) - 1));
|
||||
}
|
||||
List<StepTreeDTO> list = dtoList.stream().filter(e -> e.getValue().getStartTime() != 0).collect(Collectors.toList());
|
||||
list = list.stream().sorted(Comparator.comparing(x -> x.getValue().getStartTime())).collect(Collectors.toList());
|
||||
unList = unList.stream().sorted(Comparator.comparing(x -> x.getIndex())).collect(Collectors.toList());
|
||||
for (StepTreeDTO unListDTO : unList) {
|
||||
int index = unListDTO.getIndex();
|
||||
list.add(index - 1, unListDTO);
|
||||
}
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
list.get(index).setIndex((index + 1));
|
||||
|
|
Loading…
Reference in New Issue