Merge remote-tracking branch 'origin/v1.8' into v1.8

This commit is contained in:
Captain.B 2021-03-30 19:14:07 +08:00
commit 75fb21ca4b
6 changed files with 43 additions and 43 deletions

View File

@ -163,7 +163,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
sampler.setProtocol(urlObject.getProtocol()); sampler.setProtocol(urlObject.getProtocol());
sampler.setPath(urlObject.getPath()); sampler.setPath(urlObject.getPath());
} else { } else {
String configStr = config.getConfig().get(this.getProjectId()).getHttpConfig().getSocket();
sampler.setDomain(configStr);
if (config.getConfig().get(this.getProjectId()).getHttpConfig().getPort() > 0) {
sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain()); sampler.setDomain(config.getConfig().get(this.getProjectId()).getHttpConfig().getDomain());
}
sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort()); sampler.setPort(config.getConfig().get(this.getProjectId()).getHttpConfig().getPort());
sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol()); sampler.setProtocol(config.getConfig().get(this.getProjectId()).getHttpConfig().getProtocol());
sampler.setPath(this.getPath()); sampler.setPath(this.getPath());

View File

@ -241,7 +241,7 @@ public class ApiAutomationService {
} else { } else {
scenario.setUserId(request.getUserId()); scenario.setUserId(request.getUserId());
} }
if (StringUtils.isEmpty(request.getApiScenarioModuleId()) || StringUtils.isEmpty(request.getModulePath()) || "default-module".equals(request.getApiScenarioModuleId())) { if (StringUtils.isEmpty(request.getApiScenarioModuleId()) || "default-module".equals(request.getApiScenarioModuleId())) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample(); ApiScenarioModuleExample example = new ApiScenarioModuleExample();
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andNameEqualTo("默认模块");
List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example); List<ApiScenarioModule> modules = apiScenarioModuleMapper.selectByExample(example);

View File

@ -264,15 +264,7 @@ public class ApiDefinitionService {
test.setEnvironmentId(request.getEnvironmentId()); test.setEnvironmentId(request.getEnvironmentId());
test.setUserId(request.getUserId()); test.setUserId(request.getUserId());
test.setTags(request.getTags()); test.setTags(request.getTags());
if (StringUtils.isEmpty(request.getModulePath()) || StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) { this.setModule(test);
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
test.setModuleId(modules.get(0).getId());
test.setModulePath(modules.get(0).getName());
}
}
apiDefinitionMapper.updateByPrimaryKeySelective(test); apiDefinitionMapper.updateByPrimaryKeySelective(test);
return test; return test;
} }
@ -297,7 +289,7 @@ public class ApiDefinitionService {
test.setStatus(APITestStatus.Underway.name()); test.setStatus(APITestStatus.Underway.name());
test.setModulePath(request.getModulePath()); test.setModulePath(request.getModulePath());
test.setModuleId(request.getModuleId()); test.setModuleId(request.getModuleId());
if (StringUtils.isEmpty(request.getModulePath()) || StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) { if (StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) {
ApiModuleExample example = new ApiModuleExample(); ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example); List<ApiModule> modules = apiModuleMapper.selectByExample(example);
@ -591,6 +583,17 @@ public class ApiDefinitionService {
return apiTestCaseMapper.selectByPrimaryKey(apiCaseId); return apiTestCaseMapper.selectByPrimaryKey(apiCaseId);
} }
private void setModule(ApiDefinitionWithBLOBs item) {
if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
item.setModulePath(modules.get(0).getName());
}
}
}
public ApiDefinitionImport apiTestImport(MultipartFile file, ApiTestImportRequest request) { public ApiDefinitionImport apiTestImport(MultipartFile file, ApiTestImportRequest request) {
ApiImportParser apiImportParser = ApiDefinitionImportParserFactory.getApiImportParser(request.getPlatform()); ApiImportParser apiImportParser = ApiDefinitionImportParserFactory.getApiImportParser(request.getPlatform());
@ -616,15 +619,7 @@ public class ApiDefinitionService {
} }
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
ApiDefinitionWithBLOBs item = data.get(i); ApiDefinitionWithBLOBs item = data.get(i);
if (StringUtils.isEmpty(item.getModuleId()) || StringUtils.isEmpty(item.getModulePath()) || "default-module".equals(item.getModuleId())) { this.setModule(item);
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
item.setModulePath(modules.get(0).getName());
}
}
if (item.getName().length() > 255) { if (item.getName().length() > 255) {
item.setName(item.getName().substring(0, 255)); item.setName(item.getName().substring(0, 255));
} }

View File

@ -93,7 +93,7 @@ public class TestCaseService {
TestCaseTestMapper testCaseTestMapper; TestCaseTestMapper testCaseTestMapper;
private void setNode(TestCaseWithBLOBs testCase){ private void setNode(TestCaseWithBLOBs testCase){
if (StringUtils.isEmpty(testCase.getNodeId()) || StringUtils.isEmpty(testCase.getNodePath()) || "default-module".equals(testCase.getNodeId())) { if (StringUtils.isEmpty(testCase.getNodeId()) || "default-module".equals(testCase.getNodeId())) {
TestCaseNodeExample example = new TestCaseNodeExample(); TestCaseNodeExample example = new TestCaseNodeExample();
example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("默认模块"); example.createCriteria().andProjectIdEqualTo(testCase.getProjectId()).andNameEqualTo("默认模块");
List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(example); List<TestCaseNode> nodes = testCaseNodeMapper.selectByExample(example);

View File

@ -134,6 +134,7 @@ export default {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
this.api.request.name = this.api.id; this.api.request.name = this.api.id;
this.api.request.url = undefined;
this.api.request.useEnvironment = this.api.environmentId; this.api.request.useEnvironment = this.api.environmentId;
this.api.protocol = this.currentProtocol; this.api.protocol = this.currentProtocol;
this.runData = []; this.runData = [];

@ -1 +1 @@
Subproject commit afb50f22464b832e4f458f3f7947e6d8f982707e Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd