fix(接口测试): 修复http请求参数拼接丢失问题

This commit is contained in:
fit2-zhao 2022-05-20 23:16:42 +08:00 committed by f2c-ci-robot[bot]
parent 3f902545d7
commit 58da8ee42d
2 changed files with 27 additions and 29 deletions

View File

@ -188,7 +188,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
setSamplerPath(config, httpConfig, sampler);
// 请求体处理
if (this.body != null && !StringUtils.equalsAnyIgnoreCase(method, "GET")) {
if (this.body != null) {
List<KeyValue> bodyParams = this.body.getBodyParams(sampler, this.getId());
if (StringUtils.isNotEmpty(this.body.getType()) && "Form Data".equals(this.body.getType())) {
AtomicBoolean kvIsEmpty = new AtomicBoolean(true);
@ -512,11 +512,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
sampler.setProperty("HTTPSampler.path", envPath);
}
if (CollectionUtils.isNotEmpty(this.getArguments())) {
if (StringUtils.equalsIgnoreCase(this.getMethod(), "GET")) {
getQueryParameters(sampler);
} else {
sampler.setProperty("HTTPSampler.path", postQueryParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8")));
}
sampler.setProperty("HTTPSampler.path", postQueryParameters(URLDecoder.decode(URLEncoder.encode(envPath, "UTF-8"), "UTF-8")));
}
}
} catch (Exception e) {
@ -694,28 +690,28 @@ public class MsHTTPSamplerProxy extends MsTestElement {
list.stream().
filter(KeyValue::isValid).
filter(KeyValue::isEnable).forEach(keyValue -> {
try {
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
if (keyValue.getValue() == null) {
httpArgument.setValue("");
}
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
if (StringUtils.isNotBlank(keyValue.getContentType())) {
httpArgument.setContentType(keyValue.getContentType());
}
if (StringUtils.equalsIgnoreCase(this.method, "get")) {
if (StringUtils.isNotEmpty(httpArgument.getValue())) {
arguments.addArgument(httpArgument);
}
} else {
arguments.addArgument(httpArgument);
}
} catch (Exception e) {
}
try {
String value = StringUtils.isNotEmpty(keyValue.getValue()) && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) : keyValue.getValue();
HTTPArgument httpArgument = new HTTPArgument(keyValue.getName(), value);
if (keyValue.getValue() == null) {
httpArgument.setValue("");
}
);
httpArgument.setAlwaysEncoded(keyValue.isUrlEncode());
if (StringUtils.isNotBlank(keyValue.getContentType())) {
httpArgument.setContentType(keyValue.getContentType());
}
if (StringUtils.equalsIgnoreCase(this.method, "get")) {
if (StringUtils.isNotEmpty(httpArgument.getValue())) {
arguments.addArgument(httpArgument);
}
} else {
arguments.addArgument(httpArgument);
}
} catch (Exception e) {
}
}
);
return arguments;
}

View File

@ -46,15 +46,17 @@ public class KafkaListenerTask implements Runnable {
@Override
public void run() {
try {
LoggerUtil.info("进入KAFKA消费接收到执行结果开始存储" + records.size());
// 分三类存储
Map<String, List<ResultDTO>> assortMap = new LinkedHashMap<>();
List<ResultDTO> resultDTOS = new LinkedList<>();
records.forEach(record -> {
ResultDTO testResult = this.formatResult(record.value());
LoggerUtil.info("KAFKA消费结果处理" + testResult.getReportId() + "", testResult.getArbitraryData() != null ? testResult.getArbitraryData().get("TEST_END") : false);
if (testResult != null) {
if (testResult.getArbitraryData() != null && testResult.getArbitraryData().containsKey("TEST_END") && (Boolean) testResult.getArbitraryData().get("TEST_END")) {
if (testResult.getArbitraryData() != null && testResult.getArbitraryData().containsKey("TEST_END")
&& (Boolean) testResult.getArbitraryData().get("TEST_END")) {
resultDTOS.add(testResult);
}
// 携带结果