Merge branch 'v1.3'

This commit is contained in:
chenjianxing 2020-10-12 16:07:26 +08:00
commit f138d0271b
11 changed files with 31 additions and 23 deletions

View File

@ -16,16 +16,19 @@ public class KeyValue {
private boolean enable;
public KeyValue() {
this.enable = true;
}
public KeyValue(String name, String value) {
this.name = name;
this.value = value;
this.enable = true;
}
public KeyValue(String name, String value, String description) {
this.name = name;
this.value = value;
this.enable = true;
this.description = description;
}
}

View File

@ -137,8 +137,10 @@ public class Swagger2Parser extends ApiImportAbstractParser {
Model model = definitions.get(simpleRef);
HashSet<String> refSet = new HashSet<>();
refSet.add(simpleRef);
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions, refSet);
body.setRaw(bodyParameters.toJSONString());
if (model != null ) {
JSONObject bodyParameters = getBodyJSONObjectParameters(model.getProperties(), definitions, refSet);
body.setRaw(bodyParameters.toJSONString());
}
} else if (schema instanceof ArrayModel) {
ArrayModel arrayModel = (ArrayModel) bodyParameter.getSchema();
Property items = arrayModel.getItems();

View File

@ -29,12 +29,7 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
*/
protected static final int BATCH_COUNT = 2000;
protected Class<T> clazz;
public EasyExcelListener() {
Type type = getClass().getGenericSuperclass();
this.clazz = (Class<T>) ((ParameterizedType) type).getActualTypeArguments()[0];
}
protected Class clazz;
/**
* 每条数据解析都会调用

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.excel.domain.TestCaseExcelData;
import io.metersphere.i18n.Translator;
import io.metersphere.track.service.TestCaseService;
@ -25,8 +26,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
Set<String> userIds;
public TestCaseDataListener(TestCaseService testCaseService, String projectId, Set<String> testCaseNames, Set<String> userIds) {
this.testCaseService = testCaseService;
public TestCaseDataListener(Class clazz, String projectId, Set<String> testCaseNames, Set<String> userIds) {
this.clazz = clazz;
this.testCaseService = (TestCaseService) CommonBeanFactory.getBean("testCaseService");
this.projectId = projectId;
this.testCaseNames = testCaseNames;
this.userIds = userIds;

View File

@ -41,7 +41,9 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
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.util.*;
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());
try {
EasyExcelListener easyExcelListener = new TestCaseDataListener(this, projectId, testCaseNames, userIds);
EasyExcelFactory.read(multipartFile.getInputStream(), new TestCaseExcelDataFactory().getExcelDataByLocal(), easyExcelListener).sheet().doRead();
Class clazz = new TestCaseExcelDataFactory().getExcelDataByLocal();
EasyExcelListener easyExcelListener = new TestCaseDataListener(clazz, projectId, testCaseNames, userIds);
EasyExcelFactory.read(multipartFile.getInputStream(), clazz, easyExcelListener).sheet().doRead();
errList = easyExcelListener.getErrList();
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
@ -492,7 +495,7 @@ public class TestCaseService {
if (t.getTestId() != null && t.getTestId().equals("other")) {
data.setRemark(t.getOtherTestName());
} else {
data.setRemark(t.getApiName());
data.setRemark("[" + t.getApiName() + "]" + "\n" + t.getRemark());
}
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) {

@ -1 +1 @@
Subproject commit c2dacf960cdb1ed35664bdd3432120b1203b73d8
Subproject commit cf6b06526324326a563d933e07118fac014a63b4

View File

@ -103,7 +103,7 @@
},
},
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}));
}
}

View File

@ -99,6 +99,8 @@ export default {
clone(row) {
let scenarios = [];
row.selected.forEach(options => {
// IDID
options.id = undefined;
scenarios.push(new Scenario(options));
})
this.$emit('select', scenarios);

View File

@ -168,7 +168,7 @@
}
},
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'}));
}
}

View File

@ -1249,21 +1249,22 @@ class JMXGenerator {
if (request.controller.isValid() && request.controller.enable) {
if (request.controller instanceof IfController) {
let name = request.controller.label();
let variable = request.controller.variable;
let variable = "\"" + request.controller.variable + "\"";
let operator = request.controller.operator;
let value = request.controller.value;
let value = "\"" + request.controller.value + "\"";
if (operator === "=~" || operator === "!~") {
value = "\".*" + value + ".*\"";
value = "\".*" + request.controller.value + ".*\"";
}
if (operator === "is empty") {
variable = "empty(\"" + variable + "\")";
variable = "empty(" + variable + ")";
operator = "";
value = "";
}
if (operator === "is not empty") {
variable = "!empty(\"" + variable + "\")";
variable = "!empty(" + variable + ")";
operator = "";
value = "";
}

@ -1 +1 @@
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1