fix(Mock测试): 解决Mock接口测试时部分rest参数无法匹配的缺陷

--bug=1009070 --user=宋天阳 【接口测试】mock测试,rest参数匹配失败
https://www.tapd.cn/55049933/s/1084084
This commit is contained in:
song-tianyang 2021-12-21 12:56:40 +08:00 committed by song-tianyang
parent 463fa89850
commit 3d2e0362c8
2 changed files with 5 additions and 10 deletions

View File

@ -489,14 +489,7 @@ public class MockApiUtils {
return returnJson;
} else if (StringUtils.startsWithIgnoreCase(request.getContentType(), "text/xml")) {
String xmlString = readXml(request);
org.json.JSONObject xmlJSONObj = XML.toJSONObject(xmlString);
String jsonStr = xmlJSONObj.toString();
JSONObject object = null;
try {
object = JSONObject.parseObject(jsonStr);
} catch (Exception e) {
}
JSONObject object = XMLUtils.XmlToJson(xmlString);
return object;
} else if (StringUtils.startsWithIgnoreCase(request.getContentType(), "application/x-www-form-urlencoded")) {
JSONObject object = new JSONObject();

View File

@ -365,12 +365,14 @@ public class MockConfigService {
if (jsonObject.containsKey("name") && jsonObject.containsKey("value")) {
String headerName = jsonObject.getString("name");
String headerValue = jsonObject.getString("value");
if(StringUtils.isNotEmpty(headerName)){
if (!requestHeaderMap.containsKey(headerName) || !StringUtils.equals(requestHeaderMap.get(headerName), headerValue)) {
return false;
}
}
}
}
}
if (expectParamsObj.containsKey("body")) {
JSONObject expectBodyObject = expectParamsObj.getJSONObject("body");