fix(接口测试): 插件导入默认生成case问题
--user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001016605
This commit is contained in:
parent
ee553a8992
commit
f6e5d0a8ed
|
@ -39,4 +39,6 @@ public class ApiTestImportRequest {
|
|||
private Boolean coverModule;
|
||||
// 当前协议
|
||||
private String protocol;
|
||||
//上传文件来源,目前用于辨别是否是idea插件
|
||||
private String origin;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser<ApiDefi
|
|||
public ApiDefinitionImport parse(InputStream source, ApiTestImportRequest request) {
|
||||
String testStr = getApiTestStr(source);
|
||||
this.projectId = request.getProjectId();
|
||||
boolean addCase = !StringUtils.equals("idea", request.getOrigin());
|
||||
JSONObject jsonObject = JSON.parseObject(testStr);
|
||||
Object info = jsonObject.get("info");
|
||||
if (info == null) {
|
||||
|
@ -40,14 +41,14 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser<ApiDefi
|
|||
}
|
||||
List<ApiTestCaseWithBLOBs> cases = new ArrayList<>();
|
||||
parseItem(postmanCollection.getItem(), modulePath, results,
|
||||
cases);
|
||||
cases, addCase);
|
||||
apiImport.setData(results);
|
||||
apiImport.setCases(cases);
|
||||
return apiImport;
|
||||
}
|
||||
|
||||
protected void parseItem(List<PostmanItem> items, String modulePath, List<ApiDefinitionWithBLOBs> results,
|
||||
List<ApiTestCaseWithBLOBs> cases) {
|
||||
List<ApiTestCaseWithBLOBs> cases, boolean addCase) {
|
||||
for (PostmanItem item : items) {
|
||||
List<PostmanItem> childItems = item.getItem();
|
||||
if (childItems != null) {
|
||||
|
@ -57,7 +58,7 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser<ApiDefi
|
|||
} else {
|
||||
itemModulePath = item.getName();
|
||||
}
|
||||
parseItem(childItems, itemModulePath, results, cases);
|
||||
parseItem(childItems, itemModulePath, results, cases, addCase);
|
||||
} else {
|
||||
MsHTTPSamplerProxy msHTTPSamplerProxy = parsePostman(item);
|
||||
HttpResponse response = parsePostmanResponse(item);
|
||||
|
@ -71,6 +72,7 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser<ApiDefi
|
|||
request.setModulePath(modulePath);
|
||||
}
|
||||
results.add(request);
|
||||
if (addCase) {
|
||||
ApiTestCaseWithBLOBs apiTestCase = new ApiTestCaseWithBLOBs();
|
||||
BeanUtils.copyBean(apiTestCase, request);
|
||||
apiTestCase.setApiDefinitionId(request.getId());
|
||||
|
@ -79,4 +81,5 @@ public class PostmanDefinitionParser extends PostmanAbstractParserParser<ApiDefi
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -937,7 +937,8 @@ public class ApiDefinitionService {
|
|||
}
|
||||
|
||||
boolean newCreate = !StringUtils.equals(ApiImportPlatform.Swagger2.name(), apiDefinitionImportParamDTO.getApiTestImportRequest().getPlatform())
|
||||
&& !StringUtils.isNotBlank(apiDefinitionImportParamDTO.getApiTestImportRequest().getSwaggerUrl());
|
||||
&& !StringUtils.isNotBlank(apiDefinitionImportParamDTO.getApiTestImportRequest().getSwaggerUrl())
|
||||
&& !StringUtils.equals("idea", apiDefinitionImportParamDTO.getApiTestImportRequest().getOrigin());
|
||||
caseList = setRequestAndAddNewCase(apiDefinition, caseList, newCreate);
|
||||
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
|
||||
batchMapper.insert(apiDefinition);
|
||||
|
@ -1074,7 +1075,8 @@ public class ApiDefinitionService {
|
|||
|
||||
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
|
||||
boolean newCreate = !StringUtils.equals(ApiImportPlatform.Swagger2.name(), apiDefinitionImportParamDTO.getApiTestImportRequest().getPlatform())
|
||||
&& !StringUtils.isNotBlank(apiDefinitionImportParamDTO.getApiTestImportRequest().getSwaggerUrl());
|
||||
&& !StringUtils.isNotBlank(apiDefinitionImportParamDTO.getApiTestImportRequest().getSwaggerUrl())
|
||||
&& !StringUtils.equals("idea", apiDefinitionImportParamDTO.getApiTestImportRequest().getOrigin());
|
||||
caseList = setRequestAndAddNewCase(apiDefinition, caseList, newCreate);
|
||||
batchMapper.insert(apiDefinition);
|
||||
ApiDefinitionResult apiDefinitionResult = getApiDefinitionResult(apiDefinition, false);
|
||||
|
|
Loading…
Reference in New Issue