fix(接口测试): 修复har导入没有合并响应体的问题
--bug=1046761 --user=宋天阳 【接口测试】导入har接口和已存在接口响应体不同名-接口更新-响应体被覆盖了 https://www.tapd.cn/55049933/s/1581743
This commit is contained in:
parent
8c866e3b6c
commit
021966ae23
|
@ -100,12 +100,11 @@ public class HarParserApiDefinition extends HttpApiDefinitionImportAbstractParse
|
||||||
if (CollectionUtils.isEmpty(importApi.getResponse())) {
|
if (CollectionUtils.isEmpty(importApi.getResponse())) {
|
||||||
importApi.setResponse(savedApi.getResponse());
|
importApi.setResponse(savedApi.getResponse());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(savedApi.getResponse())) {
|
if (CollectionUtils.isEmpty(savedApi.getResponse())) {
|
||||||
importApi.getResponse().getFirst().setDefaultFlag(true);
|
importApi.getResponse().getFirst().setDefaultFlag(true);
|
||||||
} else {
|
} else {
|
||||||
List<HttpResponse> existenceResponseList = savedApi.getResponse();
|
List<HttpResponse> existenceResponseList = savedApi.getResponse();
|
||||||
for (HttpResponse importRsp : savedApi.getResponse()) {
|
for (HttpResponse importRsp : importApi.getResponse()) {
|
||||||
boolean isExistence = false;
|
boolean isExistence = false;
|
||||||
for (HttpResponse existenceRsp : existenceResponseList) {
|
for (HttpResponse existenceRsp : existenceResponseList) {
|
||||||
if (StringUtils.equals(importRsp.getName(), existenceRsp.getName())) {
|
if (StringUtils.equals(importRsp.getName(), existenceRsp.getName())) {
|
||||||
|
@ -120,6 +119,9 @@ public class HarParserApiDefinition extends HttpApiDefinitionImportAbstractParse
|
||||||
existenceResponseList.add(importRsp);
|
existenceResponseList.add(importRsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(existenceResponseList)) {
|
||||||
|
importApi.setResponse(existenceResponseList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class HTTPSamplerConverter extends AbstractMsElementConverter<HTTPSampler
|
||||||
source.getArguments().getArgumentsAsMap().forEach((k, v) -> samplerProxy.getBody().setRawBody(new RawBody() {{
|
source.getArguments().getArgumentsAsMap().forEach((k, v) -> samplerProxy.getBody().setRawBody(new RawBody() {{
|
||||||
this.setValue(v);
|
this.setValue(v);
|
||||||
}}));
|
}}));
|
||||||
} else if (StringUtils.isNotEmpty(bodyType) || ("POST".equalsIgnoreCase(source.getMethod()) && source.getArguments().getArgumentsAsMap().size() > 0)) {
|
} else if (StringUtils.isNotEmpty(bodyType) || (StringUtils.equalsAnyIgnoreCase(source.getMethod(), "POST", "PUT") && !source.getArguments().getArgumentsAsMap().isEmpty())) {
|
||||||
samplerProxy.getBody().setBodyType(Body.BodyType.WWW_FORM.name());
|
samplerProxy.getBody().setBodyType(Body.BodyType.WWW_FORM.name());
|
||||||
List<WWWFormKV> keyValues = new LinkedList<>();
|
List<WWWFormKV> keyValues = new LinkedList<>();
|
||||||
source.getArguments().getArguments().forEach(params -> {
|
source.getArguments().getArguments().forEach(params -> {
|
||||||
|
|
Loading…
Reference in New Issue