Merge branch 'v1.7'

This commit is contained in:
Captain.B 2021-01-29 13:45:35 +08:00
commit fcf9c334a9
14 changed files with 73 additions and 56 deletions

View File

@ -256,25 +256,21 @@ public abstract class MsTestElement {
return getRootParent(element.getParent());
}
protected String getParentName(MsTestElement element, ParameterConfig config) {
if (element != null) {
MsTestElement parent = this.getRootParent(element);
if (parent != null) {
if (MsTestElementConstants.LoopController.name().equals(parent.getType())) {
MsLoopController loopController = (MsLoopController) parent;
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) {
return "While 循环-" + "${LoopCounterConfigXXX}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) {
return "ForEach 循环-" + "${LoopCounterConfigXXX}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) {
return "次数循环-" + "${LoopCounterConfigXXX}";
}
protected String getParentName(MsTestElement parent, ParameterConfig config) {
if (parent != null) {
if (MsTestElementConstants.LoopController.name().equals(parent.getType())) {
MsLoopController loopController = (MsLoopController) parent;
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) {
return "While 循环-" + "${LoopCounterConfigXXX}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) {
return "ForEach 循环-" + "${LoopCounterConfigXXX}";
}
if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) {
return "次数循环-" + "${LoopCounterConfigXXX}";
}
return parent.getName();
}
return element.getName();
return parent.getName();
} else if (config != null && StringUtils.isNotEmpty(config.getStep())) {
if (MsTestElementConstants.SCENARIO.name().equals(config.getStepType())) {
return config.getStep();

View File

@ -661,7 +661,10 @@ public class ApiDefinitionService {
public String getResourceId(SwaggerUrlRequest swaggerUrlRequest) {
SwaggerUrlProjectExample swaggerUrlProjectExample = new SwaggerUrlProjectExample();
SwaggerUrlProjectExample.Criteria criteria = swaggerUrlProjectExample.createCriteria();
criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()).andModuleIdEqualTo(swaggerUrlRequest.getModuleId());
criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl());
if (StringUtils.isNotBlank(swaggerUrlRequest.getModuleId())) {
criteria.andModuleIdEqualTo(swaggerUrlRequest.getModuleId());
}
List<SwaggerUrlProject> list = swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample);
String resourceId = "";
if (list.size() == 1) {

View File

@ -28,7 +28,6 @@ import io.metersphere.base.mapper.ApiTestMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -42,7 +41,6 @@ import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.net.URL;
import java.nio.channels.FileChannel;
import java.util.*;
@ -116,18 +114,6 @@ public class HistoricalDataUpgradeService {
if (request instanceof HttpRequest) {
element = new MsHTTPSamplerProxy();
HttpRequest request1 = (HttpRequest) request;
if (StringUtils.isEmpty(request1.getPath()) && StringUtils.isNotEmpty(request1.getUrl())) {
try {
URL urlObject = new URL(request1.getUrl());
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();
request1.setPath(envPath);
request1.setUrl(null);
} catch (Exception ex) {
LogUtil.error(ex.getMessage());
}
} else {
request1.setUrl(null);
}
if (request1.getBody() != null) {
request1.getBody().setBinary(new ArrayList<>());
if (request1.getBody().isOldKV()) {
@ -136,21 +122,21 @@ public class HistoricalDataUpgradeService {
if ("json".equals(request1.getBody().getFormat())) {
if ("Raw".equals(request1.getBody().getType())) {
request1.getBody().setType(Body.JSON);
}
if (CollectionUtils.isEmpty(request1.getHeaders())) {
List<KeyValue> headers = new LinkedList<>();
headers.add(new KeyValue("Content-Type", "application/json"));
request1.setHeaders(headers);
} else {
boolean isJsonType = false;
for (KeyValue keyValue : request1.getHeaders()) {
if ("Content-Type".equals(keyValue.getName())) {
isJsonType = true;
break;
if (CollectionUtils.isEmpty(request1.getHeaders())) {
List<KeyValue> headers = new LinkedList<>();
headers.add(new KeyValue("Content-Type", "application/json"));
request1.setHeaders(headers);
} else {
boolean isJsonType = false;
for (KeyValue keyValue : request1.getHeaders()) {
if ("Content-Type".equals(keyValue.getName())) {
isJsonType = true;
break;
}
}
if (!isJsonType) {
request1.getHeaders().set(request1.getHeaders().size() - 1, new KeyValue("Content-Type", "application/json"));
}
}
if (!isJsonType) {
request1.getHeaders().set(request1.getHeaders().size() - 1, new KeyValue("Content-Type", "application/json"));
}
}
}
@ -161,6 +147,13 @@ public class HistoricalDataUpgradeService {
BeanUtils.copyBean(element, request1);
((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP);
((MsHTTPSamplerProxy) element).setArguments(request1.getParameters());
if (StringUtils.isNotEmpty(request1.getPath()) && request1.isUseEnvironment()) {
((MsHTTPSamplerProxy) element).setPath(request1.getPath());
((MsHTTPSamplerProxy) element).setUrl(null);
} else {
((MsHTTPSamplerProxy) element).setPath(null);
((MsHTTPSamplerProxy) element).setUrl(request1.getUrl());
}
List<KeyValue> keyValues = new LinkedList<>();
keyValues.add(new KeyValue("", ""));
((MsHTTPSamplerProxy) element).setRest(keyValues);
@ -318,9 +311,6 @@ public class HistoricalDataUpgradeService {
}
private void createApiScenarioWithBLOBs(SaveHistoricalDataUpgrade saveHistoricalDataUpgrade, String id, String name, int total, String scenarioDefinition, ApiScenarioMapper mapper, int num) {
if (StringUtils.isEmpty(name)) {
name = "默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis());
}
ApiScenarioWithBLOBs scenario = getScenario(id, mapper);
if (scenario != null) {
scenario.setName(name);
@ -377,6 +367,11 @@ public class HistoricalDataUpgradeService {
if (CollectionUtils.isNotEmpty(scenarios)) {
// 批量处理
for (Scenario scenario : scenarios) {
if (StringUtils.isEmpty(scenario.getName())) {
scenario.setName("默认名称-" + DateUtils.getTimeStr(System.currentTimeMillis()));
}
scenario.setId(test.getId() + "=" + scenario.getId());
scenario.setName(test.getName() + "_" + scenario.getName());
MsScenario scenario1 = createScenario(scenario);
String scenarioDefinition = JSON.toJSONString(scenario1);
num++;

View File

@ -0,0 +1 @@
ALTER TABLE api_scenario MODIFY COLUMN id VARCHAR (120);

View File

@ -0,0 +1,6 @@
ALTER TABLE swagger_url_project
MODIFY COLUMN id VARCHAR(120);
ALTER TABLE swagger_url_project
MODIFY COLUMN project_id VARCHAR(120);
ALTER TABLE swagger_url_project
MODIFY COLUMN mode_id VARCHAR(120);

View File

@ -113,11 +113,11 @@ export default {
showEnvironmentSelect: true,
modeOptions: [{
id: 'fullCoverage',
name: '全量覆盖'
name: this.$t('commons.cover')
},
{
id: 'incrementalMerge',
name: '增量合并'
name: this.$t('commons.not_cover')
}],
protocol: "",
platforms: [
@ -152,8 +152,8 @@ export default {
formData: {
file: undefined,
swaggerUrl: '',
modeId: '',
moduleId: ''
modeId: this.$t('commons.not_cover'),
moduleId: '',
},
rules: {},
currentModule: {},

View File

@ -274,4 +274,7 @@ export default {
.el-row {
margin-bottom: 10px;
}
.el-button {
margin-left: 10px;
}
</style>

View File

@ -295,4 +295,8 @@ export default {
.el-row {
margin-bottom: 10px;
}
.el-button {
margin-left: 10px;
}
</style>

View File

@ -308,4 +308,7 @@ export default {
.el-row {
margin-bottom: 10px;
}
.el-button {
margin-left: 10px;
}
</style>

View File

@ -313,4 +313,7 @@ export default {
.el-row {
margin-bottom: 10px;
}
.el-button {
margin-left: 10px;
}
</style>

View File

@ -252,9 +252,6 @@ export default {
activated() {
this.initTableData();
},
created() {
this.list()
},
methods: {
create() {
this.dialogOrgAddVisible = true;

View File

@ -1,5 +1,7 @@
export default {
commons: {
cover:'Cover',
not_cover:'Not Cover',
import_mode: 'Import mode',
import_module: 'Import module',
please_fill_in_the_template: 'Please fill in the template',

View File

@ -1,5 +1,7 @@
export default {
commons: {
cover:'覆盖',
not_cover:'不覆盖',
import_mode: '导入模式',
import_module: '导入模块',
please_fill_in_the_template: '请填写模版内容',

View File

@ -1,5 +1,7 @@
export default {
commons: {
cover:'覆蓋',
not_cover:'不覆蓋',
import_mode: '導入模式',
import_module: '導入模塊',
please_fill_in_the_template: '請填寫模版內容',