fix: 旧版本导出文件接口定义导入失败

This commit is contained in:
chenjianxing 2021-03-29 18:50:59 +08:00
parent cda0b0d1bf
commit b6faf61f73
1 changed files with 10 additions and 8 deletions

View File

@ -58,14 +58,16 @@ public class MsDefinitionParser extends MsAbstractParser<ApiDefinitionImport> {
private ApiDefinitionImport parseMsFormat(String testStr, ApiTestImportRequest importRequest) {
ApiDefinitionImport apiDefinitionImport = JSON.parseObject(testStr, ApiDefinitionImport.class);
Map<String, List<ApiTestCaseWithBLOBs>> caseMap = new HashMap<>();
apiDefinitionImport.getCases().forEach(item -> {
List<ApiTestCaseWithBLOBs> caseList = caseMap.get(item.getApiDefinitionId());
if (caseList == null) {
caseList = new ArrayList<>();
caseMap.put(item.getApiDefinitionId(), caseList);
}
caseList.add(item);
});
if (apiDefinitionImport.getCases() != null) {
apiDefinitionImport.getCases().forEach(item -> {
List<ApiTestCaseWithBLOBs> caseList = caseMap.get(item.getApiDefinitionId());
if (caseList == null) {
caseList = new ArrayList<>();
caseMap.put(item.getApiDefinitionId(), caseList);
}
caseList.add(item);
});
}
apiDefinitionImport.getData().forEach(apiDefinition -> {
parseApiDefinition(apiDefinition, importRequest, caseMap);
});