fix(接口自动化): 迁移的数据执行报错处理

This commit is contained in:
fit2-zhao 2021-01-21 15:42:07 +08:00
parent 76d8e84341
commit a64294e86e
2 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package io.metersphere.api.dto.scenario;
import io.metersphere.api.dto.scenario.request.BodyFile;
import io.metersphere.commons.json.JSONSchemaGenerator;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
@ -81,12 +82,16 @@ public class Body {
private HTTPFileArg[] httpFileArgs(String requestId) {
List<HTTPFileArg> list = new ArrayList<>();
this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
});
this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
});
if (CollectionUtils.isNotEmpty(this.getKvs())) {
this.getKvs().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
});
}
if (CollectionUtils.isNotEmpty(this.getBinary())) {
this.getBinary().stream().filter(KeyValue::isFile).filter(KeyValue::isEnable).forEach(keyValue -> {
setFileArg(list, keyValue.getFiles(), keyValue, requestId);
});
}
return list.toArray(new HTTPFileArg[0]);
}

View File

@ -114,6 +114,7 @@ public class HistoricalDataUpgradeService {
}
if (request1.getBody() != null && request1.getBody().isOldKV()) {
request1.getBody().setType(Body.FORM_DATA);
request1.getBody().setBinary(new ArrayList<>());
}
BeanUtils.copyBean(element, request1);
((MsHTTPSamplerProxy) element).setProtocol(RequestType.HTTP);