refactor(接口测试): 优化mock匹配请求头
This commit is contained in:
parent
6d9f017a90
commit
17f41bffcc
|
@ -37,7 +37,7 @@ public class MockMatchRule implements Serializable {
|
|||
if (matchRule == null) {
|
||||
return true;
|
||||
}
|
||||
return matchRule.match(matchParam);
|
||||
return matchRule.match(matchParam, StringUtils.equals("header", matchType));
|
||||
}
|
||||
|
||||
public boolean requestParamMatch(HttpRequestParam httpRequestParam) {
|
||||
|
@ -74,11 +74,11 @@ public class MockMatchRule implements Serializable {
|
|||
formDataBodyRule.getMatchRules().add(keyValueInfo);
|
||||
});
|
||||
}
|
||||
return formDataBodyRule.match(httpRequestParam.getBodyParamsObj());
|
||||
return formDataBodyRule.match(httpRequestParam.getBodyParamsObj(), false);
|
||||
case RAW:
|
||||
return StringUtils.contains(body.getRawBody().getValue(), httpRequestParam.getRaw());
|
||||
case WWW_FORM:
|
||||
return body.getWwwFormBody().match(httpRequestParam.getBodyParamsObj());
|
||||
return body.getWwwFormBody().match(httpRequestParam.getBodyParamsObj(), false);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ public class keyValueMatchRule {
|
|||
@Schema(description = "匹配规则")
|
||||
private List<KeyValueInfo> matchRules;
|
||||
|
||||
public boolean match(Map<String, String> matchParam) {
|
||||
if ((MapUtils.isEmpty(matchParam) && CollectionUtils.isNotEmpty(matchRules)) ||
|
||||
(CollectionUtils.isEmpty(matchRules) && MapUtils.isNotEmpty(matchParam))) {
|
||||
public boolean match(Map<String, String> matchParam, boolean isHeader) {
|
||||
if (!isHeader && ((MapUtils.isEmpty(matchParam) && CollectionUtils.isNotEmpty(matchRules)) ||
|
||||
(CollectionUtils.isEmpty(matchRules) && MapUtils.isNotEmpty(matchParam)))) {
|
||||
return false;
|
||||
}
|
||||
if (isMatchAll) {
|
||||
|
|
Loading…
Reference in New Issue