Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
1c79468b00
|
@ -16,16 +16,19 @@ public class KeyValue {
|
||||||
private boolean enable;
|
private boolean enable;
|
||||||
|
|
||||||
public KeyValue() {
|
public KeyValue() {
|
||||||
|
this.enable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyValue(String name, String value) {
|
public KeyValue(String name, String value) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.enable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyValue(String name, String value, String description) {
|
public KeyValue(String name, String value, String description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.enable = true;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,8 +137,10 @@ public class Swagger2Parser extends ApiImportAbstractParser {
|
||||||
Model model = definitions.get(simpleRef);
|
Model model = definitions.get(simpleRef);
|
||||||
HashSet<String> refSet = new HashSet<>();
|
HashSet<String> refSet = new HashSet<>();
|
||||||
refSet.add(simpleRef);
|
refSet.add(simpleRef);
|
||||||
|
if (model != null ) {
|
||||||
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions, refSet);
|
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions, refSet);
|
||||||
body.setRaw(bodyParameters.toJSONString());
|
body.setRaw(bodyParameters.toJSONString());
|
||||||
|
}
|
||||||
} else if (schema instanceof ArrayModel) {
|
} else if (schema instanceof ArrayModel) {
|
||||||
ArrayModel arrayModel = (ArrayModel) bodyParameter.getSchema();
|
ArrayModel arrayModel = (ArrayModel) bodyParameter.getSchema();
|
||||||
Property items = arrayModel.getItems();
|
Property items = arrayModel.getItems();
|
||||||
|
|
|
@ -29,12 +29,7 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
|
||||||
*/
|
*/
|
||||||
protected static final int BATCH_COUNT = 2000;
|
protected static final int BATCH_COUNT = 2000;
|
||||||
|
|
||||||
protected Class<T> clazz;
|
protected Class clazz;
|
||||||
|
|
||||||
public EasyExcelListener() {
|
|
||||||
Type type = getClass().getGenericSuperclass();
|
|
||||||
this.clazz = (Class<T>) ((ParameterizedType) type).getActualTypeArguments()[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每条数据解析都会调用
|
* 每条数据解析都会调用
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||||
import io.metersphere.commons.constants.TestCaseConstants;
|
import io.metersphere.commons.constants.TestCaseConstants;
|
||||||
import io.metersphere.commons.utils.BeanUtils;
|
import io.metersphere.commons.utils.BeanUtils;
|
||||||
|
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.track.service.TestCaseService;
|
import io.metersphere.track.service.TestCaseService;
|
||||||
|
@ -25,8 +26,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
||||||
|
|
||||||
Set<String> userIds;
|
Set<String> userIds;
|
||||||
|
|
||||||
public TestCaseDataListener(TestCaseService testCaseService, String projectId, Set<String> testCaseNames, Set<String> userIds) {
|
public TestCaseDataListener(Class clazz, String projectId, Set<String> testCaseNames, Set<String> userIds) {
|
||||||
this.testCaseService = testCaseService;
|
this.clazz = clazz;
|
||||||
|
this.testCaseService = (TestCaseService) CommonBeanFactory.getBean("testCaseService");
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
this.testCaseNames = testCaseNames;
|
this.testCaseNames = testCaseNames;
|
||||||
this.userIds = userIds;
|
this.userIds = userIds;
|
||||||
|
|
|
@ -41,7 +41,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -317,8 +319,9 @@ public class TestCaseService {
|
||||||
Set<String> userIds = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getUserId).collect(Collectors.toSet());
|
Set<String> userIds = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getUserId).collect(Collectors.toSet());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EasyExcelListener easyExcelListener = new TestCaseDataListener(this, projectId, testCaseNames, userIds);
|
Class clazz = new TestCaseExcelDataFactory().getExcelDataByLocal();
|
||||||
EasyExcelFactory.read(multipartFile.getInputStream(), new TestCaseExcelDataFactory().getExcelDataByLocal(), easyExcelListener).sheet().doRead();
|
EasyExcelListener easyExcelListener = new TestCaseDataListener(clazz, projectId, testCaseNames, userIds);
|
||||||
|
EasyExcelFactory.read(multipartFile.getInputStream(), clazz, easyExcelListener).sheet().doRead();
|
||||||
errList = easyExcelListener.getErrList();
|
errList = easyExcelListener.getErrList();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e.getMessage(), e);
|
LogUtil.error(e.getMessage(), e);
|
||||||
|
@ -492,7 +495,7 @@ public class TestCaseService {
|
||||||
if (t.getTestId() != null && t.getTestId().equals("other")) {
|
if (t.getTestId() != null && t.getTestId().equals("other")) {
|
||||||
data.setRemark(t.getOtherTestName());
|
data.setRemark(t.getOtherTestName());
|
||||||
} else {
|
} else {
|
||||||
data.setRemark(t.getApiName());
|
data.setRemark("[" + t.getApiName() + "]" + "\n" + t.getRemark());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) {
|
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c2dacf960cdb1ed35664bdd3432120b1203b73d8
|
Subproject commit cf6b06526324326a563d933e07118fac014a63b4
|
|
@ -103,7 +103,7 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.items.length === 0) {
|
if (this.items.length === 0 || this.items[this.items.length - 1].name) {
|
||||||
this.items.push(new KeyValue({enable: true}));
|
this.items.push(new KeyValue({enable: true}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,8 @@ export default {
|
||||||
clone(row) {
|
clone(row) {
|
||||||
let scenarios = [];
|
let scenarios = [];
|
||||||
row.selected.forEach(options => {
|
row.selected.forEach(options => {
|
||||||
|
// 去掉ID,创建新的ID
|
||||||
|
options.id = undefined;
|
||||||
scenarios.push(new Scenario(options));
|
scenarios.push(new Scenario(options));
|
||||||
})
|
})
|
||||||
this.$emit('select', scenarios);
|
this.$emit('select', scenarios);
|
||||||
|
|
|
@ -168,7 +168,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.parameters.length === 0) {
|
if (this.parameters.length === 0 || this.parameters[this.parameters.length - 1].name) {
|
||||||
this.parameters.push(new KeyValue( {type: 'text', enable: true, uuid: this.uuid(), contentType: 'text/plain'}));
|
this.parameters.push(new KeyValue( {type: 'text', enable: true, uuid: this.uuid(), contentType: 'text/plain'}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1249,21 +1249,22 @@ class JMXGenerator {
|
||||||
if (request.controller.isValid() && request.controller.enable) {
|
if (request.controller.isValid() && request.controller.enable) {
|
||||||
if (request.controller instanceof IfController) {
|
if (request.controller instanceof IfController) {
|
||||||
let name = request.controller.label();
|
let name = request.controller.label();
|
||||||
let variable = request.controller.variable;
|
let variable = "\"" + request.controller.variable + "\"";
|
||||||
let operator = request.controller.operator;
|
let operator = request.controller.operator;
|
||||||
let value = request.controller.value;
|
let value = "\"" + request.controller.value + "\"";
|
||||||
|
|
||||||
if (operator === "=~" || operator === "!~") {
|
if (operator === "=~" || operator === "!~") {
|
||||||
value = "\".*" + value + ".*\"";
|
value = "\".*" + request.controller.value + ".*\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operator === "is empty") {
|
if (operator === "is empty") {
|
||||||
variable = "empty(\"" + variable + "\")";
|
variable = "empty(" + variable + ")";
|
||||||
operator = "";
|
operator = "";
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operator === "is not empty") {
|
if (operator === "is not empty") {
|
||||||
variable = "!empty(\"" + variable + "\")";
|
variable = "!empty(" + variable + ")";
|
||||||
operator = "";
|
operator = "";
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9
|
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1
|
Loading…
Reference in New Issue