fix (接口自动化): 修复SQL请求引用步骤执行问题

--bug=1007360 --user=赵勇 【github #6716】[BUG]sql类型的后置内容修改,在场景直接引用接口的情况下是正确的,当引用了这个sql用例的场景被再次引用时,对sql用例的后置脚本修改显示是修改后的,但是执行的时候还是执行的之前的脚本内容 https://www.tapd.cn/55049933/s/1057910
This commit is contained in:
fit2-zhao 2021-10-22 17:39:49 +08:00 committed by fit2-zhao
parent 6b4d42ee23
commit a7e6aa4c9d
4 changed files with 7 additions and 8 deletions

View File

@ -90,6 +90,7 @@ public class MsDubboSampler extends MsTestElement {
}
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
this.setRefElement();
hashTree = this.getHashTree();
}
final HashTree testPlanTree = tree.add(dubboSample(config));

View File

@ -9,8 +9,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.metersphere.api.dto.definition.request.ElementUtil;
import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
import io.metersphere.api.dto.scenario.DatabaseConfig;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
@ -86,6 +84,7 @@ public class MsJDBCSampler extends MsTestElement {
}
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
this.setRefElement();
hashTree = this.getHashTree();
}
if (config.getConfig() == null) {
// 单独接口执行
@ -123,9 +122,9 @@ public class MsJDBCSampler extends MsTestElement {
this.dataSource = null;
// 取当前环境下默认的一个数据源
if (config.isEffective(this.getProjectId())) {
if(config.getConfig().get(this.getProjectId()) != null){
if (config.getConfig().get(this.getProjectId()) != null) {
envConfig = config.getConfig().get(this.getProjectId());
if(CollectionUtils.isNotEmpty(envConfig.getDatabaseConfigs())){
if (CollectionUtils.isNotEmpty(envConfig.getDatabaseConfigs())) {
this.dataSource = envConfig.getDatabaseConfigs().get(0);
}
}

View File

@ -11,7 +11,6 @@ import io.metersphere.api.dto.automation.EsbDataStruct;
import io.metersphere.api.dto.automation.TcpTreeTableDataStruct;
import io.metersphere.api.dto.definition.request.ElementUtil;
import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
@ -122,6 +121,7 @@ public class MsTCPSampler extends MsTestElement {
}
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {
this.setRefElement();
hashTree = this.getHashTree();
}
if (config.getConfig() == null) {
// 单独接口执行

View File

@ -355,7 +355,7 @@ public class ApiAutomationService {
scenario.setVersion(version + 1);
}
deleteUpdateBodyFile(scenario);
deleteUpdateBodyFile(scenario,beforeScenario);
List<ApiMethodUrlDTO> useUrl = this.parseUrl(scenario);
scenario.setUseUrl(JSONArray.toJSONString(useUrl));
apiScenarioMapper.updateByPrimaryKeySelective(scenario);
@ -376,8 +376,7 @@ public class ApiAutomationService {
*
* @param scenario
*/
public void deleteUpdateBodyFile(ApiScenarioWithBLOBs scenario) {
ApiScenarioWithBLOBs oldScenario = apiScenarioMapper.selectByPrimaryKey(scenario.getId());
public void deleteUpdateBodyFile(ApiScenarioWithBLOBs scenario,ApiScenarioWithBLOBs oldScenario) {
Set<String> newRequestIds = getRequestIds(scenario.getScenarioDefinition());
MsTestElement msTestElement = parseScenarioDefinition(oldScenario.getScenarioDefinition());
List<MsHTTPSamplerProxy> oldRequests = MsHTTPSamplerProxy.findHttpSampleFromHashTree(msTestElement);