fix(接口自动化): 修复jmx导入其他选项不能编辑问题

This commit is contained in:
fit2-zhao 2021-03-25 18:13:53 +08:00
parent c43a258780
commit d6a0feb4fa
2 changed files with 6 additions and 12 deletions

View File

@ -136,6 +136,8 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
try {
HTTPSamplerProxy source = (HTTPSamplerProxy) key;
BeanUtils.copyBean(samplerProxy, source);
samplerProxy.setRest(new ArrayList<KeyValue>(){{this.add(new KeyValue());}});
samplerProxy.setArguments(new ArrayList<KeyValue>(){{this.add(new KeyValue());}});
if (source != null && source.getHTTPFiles().length > 0) {
samplerProxy.getBody().initBinary();
samplerProxy.getBody().setType(Body.FORM_DATA);
@ -153,12 +155,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
keyValue.setFiles(files);
keyValues.add(keyValue);
}
if (source.getPostBodyRaw() && CollectionUtils.isNotEmpty(keyValues)) {
samplerProxy.getBody().setType(Body.RAW);
samplerProxy.getBody().setRaw(keyValues.get(0).getValue());
} else {
samplerProxy.getBody().setKvs(keyValues);
}
samplerProxy.getBody().setKvs(keyValues);
}
samplerProxy.setProtocol(RequestType.HTTP);
samplerProxy.setPort(source.getPort() + "");
@ -168,6 +165,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
source.getArguments().getArgumentsAsMap().forEach((k, v) -> {
samplerProxy.getBody().setRaw(v);
});
samplerProxy.getBody().initKvs();
} else {
List<KeyValue> keyValues = new LinkedList<>();
source.getArguments().getArgumentsAsMap().forEach((k, v) -> {

View File

@ -66,12 +66,8 @@ public class Body {
sampler.setDoMultipart(true);
}
} else {
if (!this.isJson()) {
sampler.setPostBodyRaw(true);
} else {
if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) {
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
}
if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) {
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
}
KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true);
sampler.setPostBodyRaw(true);