fix(测试跟踪): 测试计划关联场景时环境设置问题
This commit is contained in:
parent
611aa96b81
commit
65a21d5719
|
@ -97,7 +97,7 @@ public class ApiAutomationController {
|
|||
}
|
||||
|
||||
@GetMapping("/getApiScenario/{id}")
|
||||
public ApiScenarioDTO getScenarioDefinition(@PathVariable String id) {
|
||||
public ApiScenarioWithBLOBs getScenarioDefinition(@PathVariable String id) {
|
||||
return apiAutomationService.getApiScenario(id);
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,11 @@ public class ApiAutomationController {
|
|||
return apiAutomationService.getApiScenarioEnv(request.getDefinition());
|
||||
}
|
||||
|
||||
@GetMapping("/getApiScenarioProjectId/{id}")
|
||||
public ScenarioEnv getApiScenarioProjectId(@PathVariable String id) {
|
||||
return apiAutomationService.getApiScenarioProjectId(id);
|
||||
}
|
||||
|
||||
@PostMapping("/getApiScenarios")
|
||||
public List<ApiScenarioWithBLOBs> getApiScenarios(@RequestBody List<String> ids) {
|
||||
return apiAutomationService.getApiScenarios(ids);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.jorphan.collections.HashTree;
|
|||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -134,7 +135,17 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
this.setProjectId(getParentProjectId());
|
||||
} else {
|
||||
// 1.8 之前 数据
|
||||
this.setProjectId("historyProjectID");
|
||||
if (config.getConfig() != null) {
|
||||
if (config.getConfig().containsKey("historyProjectID")) {
|
||||
this.setProjectId("historyProjectID");
|
||||
} else {
|
||||
// 测试计划执行
|
||||
Iterator<String> it = config.getConfig().keySet().iterator();
|
||||
if (it.hasNext()) {
|
||||
this.setProjectId(it.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加环境中的公共变量
|
||||
|
|
|
@ -361,15 +361,8 @@ public class ApiAutomationService {
|
|||
}
|
||||
}
|
||||
|
||||
public ApiScenarioDTO getApiScenario(String id) {
|
||||
ApiScenarioDTO apiScenarioDTO = new ApiScenarioDTO();
|
||||
ApiScenarioWithBLOBs scenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(id);
|
||||
if (scenarioWithBLOBs != null) {
|
||||
BeanUtils.copyBean(apiScenarioDTO, scenarioWithBLOBs);
|
||||
setApiScenarioProjectIds(apiScenarioDTO);
|
||||
return apiScenarioDTO;
|
||||
}
|
||||
return null;
|
||||
public ApiScenarioWithBLOBs getApiScenario(String id) {
|
||||
return apiScenarioMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public ScenarioEnv getApiScenarioEnv(String definition) {
|
||||
|
@ -408,7 +401,7 @@ public class ApiAutomationService {
|
|||
}
|
||||
} else if (StringUtils.equals(tr.getType(), "scenario")) {
|
||||
if (tr.isEnable()) {
|
||||
ApiScenarioDTO apiScenario = getApiScenario(tr.getId());
|
||||
ApiScenarioWithBLOBs apiScenario = getApiScenario(tr.getId());
|
||||
env.getProjectIds().add(apiScenario.getProjectId());
|
||||
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
||||
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
||||
|
@ -433,7 +426,9 @@ public class ApiAutomationService {
|
|||
if (!tr.isEnable()) {
|
||||
continue;
|
||||
}
|
||||
env.getProjectIds().add(tr.getProjectId());
|
||||
if (StringUtils.equals(tr.getType(), "scenario")) {
|
||||
env.getProjectIds().add(tr.getProjectId());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(tr.getHashTree())) {
|
||||
getHashTree(tr.getHashTree(), env);
|
||||
}
|
||||
|
@ -477,7 +472,7 @@ public class ApiAutomationService {
|
|||
}
|
||||
} else if (StringUtils.equals(tr.getType(), "scenario")) {
|
||||
if (tr.isEnable()) {
|
||||
ApiScenarioDTO apiScenario = getApiScenario(tr.getId());
|
||||
ApiScenarioWithBLOBs apiScenario = getApiScenario(tr.getId());
|
||||
env.getProjectIds().add(apiScenario.getProjectId());
|
||||
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
||||
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
||||
|
@ -502,7 +497,9 @@ public class ApiAutomationService {
|
|||
if (!tr.isEnable()) {
|
||||
continue;
|
||||
}
|
||||
env.getProjectIds().add(tr.getProjectId());
|
||||
if (StringUtils.equals(tr.getType(), "scenario")) {
|
||||
env.getProjectIds().add(tr.getProjectId());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(tr.getHashTree())) {
|
||||
getHashTree(tr.getHashTree(), env);
|
||||
}
|
||||
|
@ -1330,4 +1327,24 @@ public class ApiAutomationService {
|
|||
}catch (Exception e){
|
||||
}
|
||||
}
|
||||
|
||||
public ScenarioEnv getApiScenarioProjectId(String id) {
|
||||
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(id);
|
||||
ScenarioEnv scenarioEnv = new ScenarioEnv();
|
||||
if (scenario == null) {
|
||||
return scenarioEnv;
|
||||
}
|
||||
|
||||
String definition = scenario.getScenarioDefinition();
|
||||
if (StringUtils.isBlank(definition)) {
|
||||
return scenarioEnv;
|
||||
}
|
||||
|
||||
scenarioEnv = getApiScenarioEnv(definition);
|
||||
scenarioEnv.getProjectIds().remove(null);
|
||||
if (scenarioEnv.getProjectIds().isEmpty()) {
|
||||
scenarioEnv.getProjectIds().add(scenario.getProjectId());
|
||||
}
|
||||
return scenarioEnv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,8 +235,9 @@ export default {
|
|||
},
|
||||
setScenarioSelectRows(rows) {
|
||||
this.projectIds.clear();
|
||||
this.map.clear();
|
||||
rows.forEach(row => {
|
||||
this.result = this.$get('/api/automation/getApiScenario/' + row.id, res => {
|
||||
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + row.id, res => {
|
||||
let data = res.data;
|
||||
data.projectIds.forEach(d => this.projectIds.add(d));
|
||||
this.map.set(row.id, data.projectIds);
|
||||
|
|
|
@ -130,9 +130,10 @@
|
|||
this.$set(this.form, "value", "");
|
||||
if (val === 'projectEnv' && this.isScenario !== '') {
|
||||
this.projectIds.clear();
|
||||
this.map.clear();
|
||||
this.selectRows.forEach(row => {
|
||||
let id = this.isScenario === 'scenario' ? row.id : row.caseId;
|
||||
this.result = this.$get('/api/automation/getApiScenario/' + id, res => {
|
||||
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + id, res => {
|
||||
let data = res.data;
|
||||
data.projectIds.forEach(d => this.projectIds.add(d));
|
||||
this.map.set(row.id, data.projectIds);
|
||||
|
|
|
@ -168,8 +168,9 @@
|
|||
},
|
||||
initProjectIds() {
|
||||
this.projectIds.clear();
|
||||
this.map.clear();
|
||||
this.selectRows.forEach(row => {
|
||||
this.result = this.$get('/api/automation/getApiScenario/' + row.id, res => {
|
||||
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + row.id, res => {
|
||||
let data = res.data;
|
||||
data.projectIds.forEach(d => this.projectIds.add(d));
|
||||
this.map.set(row.id, data.projectIds);
|
||||
|
|
Loading…
Reference in New Issue