refactor(接口测试): 批量执行场景支持跨项目选环境
--bug=1028821 --user=赵勇 【接口测试】场景详情含跨项目复制和引用场景、case、api-未选择当前项目和更多项目环境-场景列表批量执行-只显示当前项目 https://www.tapd.cn/55049933/s/1404474 Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
4a71b5d3c4
commit
040a3d264f
|
@ -2350,9 +2350,8 @@ public class ApiScenarioService {
|
||||||
public Map<String, List<String>> getProjectEnvMap(RunScenarioRequest request) {
|
public Map<String, List<String>> getProjectEnvMap(RunScenarioRequest request) {
|
||||||
ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extApiScenarioMapper.selectIdsByQuery(query));
|
ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extApiScenarioMapper.selectIdsByQuery(query));
|
||||||
|
|
||||||
List<String> ids = request.getIds();
|
|
||||||
ApiScenarioExample example = new ApiScenarioExample();
|
ApiScenarioExample example = new ApiScenarioExample();
|
||||||
example.createCriteria().andIdIn(ids);
|
example.createCriteria().andIdIn(request.getIds());
|
||||||
List<ApiScenarioWithBLOBs> apiScenarios = apiScenarioMapper.selectByExampleWithBLOBs(example);
|
List<ApiScenarioWithBLOBs> apiScenarios = apiScenarioMapper.selectByExampleWithBLOBs(example);
|
||||||
Map<String, List<String>> projectEnvMap = new HashMap<>();
|
Map<String, List<String>> projectEnvMap = new HashMap<>();
|
||||||
apiScenarios.forEach(item -> {
|
apiScenarios.forEach(item -> {
|
||||||
|
@ -2360,8 +2359,7 @@ public class ApiScenarioService {
|
||||||
JSONObject jsonObject = JSONUtil.parseObject(item.getEnvironmentJson());
|
JSONObject jsonObject = JSONUtil.parseObject(item.getEnvironmentJson());
|
||||||
Map<String, Object> projectIdEnvMap = jsonObject.toMap();
|
Map<String, Object> projectIdEnvMap = jsonObject.toMap();
|
||||||
if (MapUtils.isNotEmpty(projectIdEnvMap)) {
|
if (MapUtils.isNotEmpty(projectIdEnvMap)) {
|
||||||
Set<String> projectIds = projectIdEnvMap.keySet();
|
projectIdEnvMap.keySet().forEach(t -> {
|
||||||
projectIds.forEach(t -> {
|
|
||||||
List<String> envIds = projectEnvMap.get(t);
|
List<String> envIds = projectEnvMap.get(t);
|
||||||
if (CollectionUtils.isNotEmpty(envIds)) {
|
if (CollectionUtils.isNotEmpty(envIds)) {
|
||||||
if (!envIds.contains(projectIdEnvMap.get(t).toString())) {
|
if (!envIds.contains(projectIdEnvMap.get(t).toString())) {
|
||||||
|
@ -2376,6 +2374,13 @@ public class ApiScenarioService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 未选择环境的项目
|
||||||
|
List<String> scenarioProjectIds = ElementUtil.getProjectIds(item.getScenarioDefinition());
|
||||||
|
scenarioProjectIds.forEach(id -> {
|
||||||
|
if (!projectEnvMap.containsKey(id)) {
|
||||||
|
projectEnvMap.put(id, new ArrayList<>());
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return projectEnvMap;
|
return projectEnvMap;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue