feat(接口自动化): 统一执行方式

This commit is contained in:
fit2-zhao 2020-12-11 18:10:18 +08:00
parent 4402fcd010
commit 2d381a14fb

View File

@ -242,12 +242,16 @@ public class ApiAutomationService {
JSONObject element = JSON.parseObject(item.getScenarioDefinition()); JSONObject element = JSON.parseObject(item.getScenarioDefinition());
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class); MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取 // 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"), if (StringUtils.isNotEmpty(element.getString("hashTree"))) {
new TypeReference<LinkedList<MsTestElement>>() {}); LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"), new TypeReference<LinkedList<MsTestElement>>() {});
new TypeReference<LinkedList<KeyValue>>() {}); scenario.setHashTree(elements);
scenario.setHashTree(elements); }
scenario.setVariables(variables); if (StringUtils.isNotEmpty(element.getString("variables"))) {
LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"),
new TypeReference<LinkedList<KeyValue>>() {});
scenario.setVariables(variables);
}
LinkedList<MsTestElement> scenarios = new LinkedList<>(); LinkedList<MsTestElement> scenarios = new LinkedList<>();
scenarios.add(scenario); scenarios.add(scenario);
group.setHashTree(scenarios); group.setHashTree(scenarios);