--bug=1007385 --user=宋天阳 [接口定义]-编辑get接口-添加MOCK期望-修改rest参数-执行test测试mock期望结果未生效 https://www.tapd.cn/55049933/s/1058299;--bug=1007387 --user=宋天阳 [接口定义]-编辑接口-添加mock期望-响应体是自定义脚本,test执行结果返回格式错误 https://www.tapd.cn/55049933/s/1058224;--bug=1007366 --user=宋天阳 【接口定义】-PATCH请求使用MOCK环境测试期望结果失败 https://www.tapd.cn/55049933/s/1058406
This commit is contained in:
parent
1b061f13f0
commit
69b18e97c9
|
@ -123,7 +123,6 @@ public class EsbDataStruct {
|
|||
element.addAttribute("attr", attrString);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(this.name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -163,7 +162,6 @@ public class EsbDataStruct {
|
|||
element.addAttribute("attr", attrString);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(this.name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,6 @@ public class TcpTreeTableDataStruct {
|
|||
element.addAttribute("attr", attrString);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(this.name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -163,7 +162,6 @@ public class TcpTreeTableDataStruct {
|
|||
element.addAttribute("attr", attrString);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(this.name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -424,6 +424,9 @@ public class MockApiUtils {
|
|||
if(StringUtils.isNotEmpty(newScript)){
|
||||
newScript += "\n";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(returnMsg)){
|
||||
returnMsg += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
returnMap.put("script",newScript);
|
||||
|
@ -435,8 +438,8 @@ public class MockApiUtils {
|
|||
JSR223Sampler jmeterScriptSampler = new JSR223Sampler();
|
||||
jmeterScriptSampler.setScriptLanguage(scriptLanguage);
|
||||
jmeterScriptSampler.setScript(script);
|
||||
SampleResult result = jmeterScriptSampler.sample(null);
|
||||
System.out.println(result.getResponseData());
|
||||
jmeterScriptSampler.sample(null);
|
||||
|
||||
}
|
||||
|
||||
public static RequestMockParams getParams(String urlParams, String apiPath, JSONObject queryParamsObject,JSON paramJson){
|
||||
|
@ -492,7 +495,6 @@ public class MockApiUtils {
|
|||
return returnJson;
|
||||
} else if (StringUtils.equalsIgnoreCase("text/xml", request.getContentType())) {
|
||||
String xmlString = readXml(request);
|
||||
System.out.println(xmlString);
|
||||
|
||||
org.json.JSONObject xmlJSONObj = XML.toJSONObject(xmlString);
|
||||
String jsonStr = xmlJSONObj.toString();
|
||||
|
@ -511,6 +513,14 @@ public class MockApiUtils {
|
|||
object.put(key, value);
|
||||
}
|
||||
return object;
|
||||
} else if (StringUtils.equalsIgnoreCase("text/plain", request.getContentType())) {
|
||||
JSONObject object = new JSONObject();
|
||||
String bodyParam = readBody(request);
|
||||
if(StringUtils.isNotEmpty(bodyParam)){
|
||||
object.put("raw",bodyParam);
|
||||
}
|
||||
return object;
|
||||
|
||||
} else {
|
||||
JSONObject object = new JSONObject();
|
||||
String bodyParam = readBody(request);
|
||||
|
|
|
@ -1443,17 +1443,13 @@ public class ApiDefinitionService {
|
|||
// return apiDefinitionMapper.selectByExample(example);
|
||||
// }
|
||||
|
||||
public List<ApiDefinitionWithBLOBs> preparedUrl(String projectId, String method, String url, String urlSuffix) {
|
||||
public List<ApiDefinitionWithBLOBs> preparedUrl(String projectId, String method, String urlSuffix) {
|
||||
|
||||
if (StringUtils.isEmpty(urlSuffix)) {
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
if (StringUtils.equalsAnyIgnoreCase(method, "GET", "DELETE")) {
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
ApiDefinitionExample.Criteria criteria = example.createCriteria().andMethodEqualTo(method).andProjectIdEqualTo(projectId);
|
||||
if (StringUtils.isNotEmpty(url)) {
|
||||
criteria.andPathEqualTo(url);
|
||||
}
|
||||
example.createCriteria().andMethodEqualTo(method).andProjectIdEqualTo(projectId);
|
||||
List<ApiDefinition> apiList = apiDefinitionMapper.selectByExample(example);
|
||||
|
||||
List<String> apiIdList = new ArrayList<>();
|
||||
|
@ -1498,14 +1494,6 @@ public class ApiDefinitionService {
|
|||
example.createCriteria().andIdIn(apiIdList);
|
||||
return apiDefinitionMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
} else {
|
||||
if (!url.startsWith("/")) {
|
||||
url = "/" + url;
|
||||
}
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
ApiDefinitionExample.Criteria criteria = example.createCriteria().andMethodEqualTo(method).andProjectIdEqualTo(projectId).andPathEqualTo(url);
|
||||
return apiDefinitionMapper.selectByExampleWithBLOBs(example);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -605,7 +605,6 @@ public class ApiScenarioReportService {
|
|||
if (obj != null) {
|
||||
ReportCounter counter = (ReportCounter) obj;
|
||||
counter.setNumber(counter.getNumber() + 1);
|
||||
System.out.println("得到统计数量:" + counter.getNumber());
|
||||
MessageCache.cache.put(report.getScenarioId(), counter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1032,7 +1032,7 @@ public class MockConfigService {
|
|||
List<ApiDefinitionWithBLOBs> aualifiedApiList = new ArrayList<>();
|
||||
if (project != null) {
|
||||
String urlSuffix = this.getUrlSuffix(project.getSystemId(), request);
|
||||
aualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, urlSuffix, urlSuffix);
|
||||
aualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, urlSuffix);
|
||||
|
||||
JSON paramJson = MockApiUtils.getPostParamMap(request);
|
||||
JSONObject parameterObject = MockApiUtils.getParameterJsonObject(request);
|
||||
|
@ -1094,7 +1094,7 @@ public class MockConfigService {
|
|||
List<ApiDefinitionWithBLOBs> aualifiedApiList = new ArrayList<>();
|
||||
if (project != null) {
|
||||
String urlSuffix = this.getUrlSuffix(project.getSystemId(), request);
|
||||
aualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, null, urlSuffix);
|
||||
aualifiedApiList = apiDefinitionService.preparedUrl(project.getId(), method, urlSuffix);
|
||||
|
||||
/**
|
||||
* GET/DELETE 这种通过url穿参数的接口,在接口路径相同的情况下可能会出现这样的情况:
|
||||
|
|
|
@ -59,9 +59,15 @@ public class JsonStructUtils {
|
|||
}
|
||||
|
||||
public static boolean checkJsonArrayCompliance(JSONArray sourceArray, JSONArray matchArray) {
|
||||
if (sourceArray == null && matchArray == null) {
|
||||
if(sourceArray == null){
|
||||
sourceArray = new JSONArray();
|
||||
}
|
||||
if(matchArray == null){
|
||||
matchArray = new JSONArray();
|
||||
}
|
||||
if (sourceArray.isEmpty() && matchArray.isEmpty()) {
|
||||
return true;
|
||||
} else if (sourceArray != null && matchArray != null && sourceArray.size() >= matchArray.size()) {
|
||||
} else if (!sourceArray.isEmpty() && !matchArray.isEmpty() && sourceArray.size() >= matchArray.size()) {
|
||||
try {
|
||||
for (int i = 0; i < matchArray.size(); i++) {
|
||||
Object obj = matchArray.get(i);
|
||||
|
|
Loading…
Reference in New Issue