refactor(接口自动化): 兼容历史数据
This commit is contained in:
parent
3e985afc4b
commit
64fd20803b
|
@ -2,6 +2,7 @@ package io.metersphere.api.service;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -102,8 +103,13 @@ public class ApiAutomationService {
|
|||
Map<String, String> map = d.getEnvironmentMap();
|
||||
List<String> idList = new ArrayList<>();
|
||||
if (map != null) {
|
||||
Set<String> set = d.getEnvironmentMap().keySet();
|
||||
idList = new ArrayList<>(set);
|
||||
if (map.isEmpty()) {
|
||||
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
|
||||
idList.addAll(new HashSet<>(ids));
|
||||
} else {
|
||||
Set<String> set = d.getEnvironmentMap().keySet();
|
||||
idList = new ArrayList<>(set);
|
||||
}
|
||||
} else {
|
||||
// 兼容历史数据,无EnvironmentMap直接赋值场景所属项目
|
||||
idList.add(data.getProjectId());
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.track.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONPath;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioDTO;
|
||||
import io.metersphere.api.dto.automation.ApiScenarioRequest;
|
||||
import io.metersphere.api.dto.automation.RunScenarioRequest;
|
||||
|
@ -56,8 +57,13 @@ public class TestPlanScenarioCaseService {
|
|||
Map<String, String> map = d.getEnvironmentMap();
|
||||
List<String> idList = new ArrayList<>();
|
||||
if (map != null) {
|
||||
Set<String> set = d.getEnvironmentMap().keySet();
|
||||
idList = new ArrayList<>(set);
|
||||
if (map.isEmpty()) {
|
||||
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
|
||||
idList.addAll(new HashSet<>(ids));
|
||||
} else {
|
||||
Set<String> set = d.getEnvironmentMap().keySet();
|
||||
idList = new ArrayList<>(set);
|
||||
}
|
||||
} else {
|
||||
// 兼容历史数据,无EnvironmentMap直接赋值场景所属项目
|
||||
idList.add(data.getProjectId());
|
||||
|
|
Loading…
Reference in New Issue