fix(接口测试): 解决其他协议在没有任何接口时导入会报错问题
This commit is contained in:
parent
079b569742
commit
660df9a548
|
@ -1013,33 +1013,35 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, ApiDefinitionWithBLOBs> repeatDataMap, Map<String, ApiModule> moduleMap,
|
Map<String, ApiDefinitionWithBLOBs> repeatDataMap, Map<String, ApiModule> moduleMap,
|
||||||
String versionId,
|
String versionId,
|
||||||
List<ApiTestCaseWithBLOBs> optionDataCases) {
|
List<ApiTestCaseWithBLOBs> optionDataCases) {
|
||||||
if (nameModuleMap != null) {
|
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
|
||||||
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionDatas.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
return;
|
||||||
repeatDataMap.forEach((k, v) -> {
|
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
|
|
||||||
List<ApiTestCaseWithBLOBs> distinctNameCases = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
|
|
||||||
String modulePath = apiDefinitionWithBLOBs.getModulePath();
|
|
||||||
List<ApiDefinitionWithBLOBs> moduleDatas = moduleOptionData.get(modulePath);
|
|
||||||
if (moduleDatas != null && moduleDatas.size() <= 1) {
|
|
||||||
moduleMap.remove(modulePath);
|
|
||||||
removeModulePath(moduleMap, moduleOptionData, modulePath);
|
|
||||||
moduleDatas.remove(apiDefinitionWithBLOBs);
|
|
||||||
}
|
|
||||||
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
|
||||||
if (v.getVersionId().equals(versionId)) {
|
|
||||||
optionDatas.remove(apiDefinitionWithBLOBs);
|
|
||||||
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//这里是为了标识当前数据是需要创建版本的,不是全新增的数据
|
|
||||||
addNewVersionApi(apiDefinitionWithBLOBs, v, "new");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionDatas.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
||||||
|
repeatDataMap.forEach((k, v) -> {
|
||||||
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
||||||
|
if (apiDefinitionWithBLOBs == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
|
||||||
|
List<ApiTestCaseWithBLOBs> distinctNameCases = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
|
||||||
|
String modulePath = apiDefinitionWithBLOBs.getModulePath();
|
||||||
|
List<ApiDefinitionWithBLOBs> moduleDatas = moduleOptionData.get(modulePath);
|
||||||
|
if (moduleDatas != null && moduleDatas.size() <= 1) {
|
||||||
|
moduleMap.remove(modulePath);
|
||||||
|
removeModulePath(moduleMap, moduleOptionData, modulePath);
|
||||||
|
moduleDatas.remove(apiDefinitionWithBLOBs);
|
||||||
|
}
|
||||||
|
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
||||||
|
if (v.getVersionId().equals(versionId)) {
|
||||||
|
optionDatas.remove(apiDefinitionWithBLOBs);
|
||||||
|
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
||||||
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//这里是为了标识当前数据是需要创建版本的,不是全新增的数据
|
||||||
|
addNewVersionApi(apiDefinitionWithBLOBs, v, "new");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addNewVersionApi(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, ApiDefinitionWithBLOBs v, String version) {
|
private void addNewVersionApi(ApiDefinitionWithBLOBs apiDefinitionWithBLOBs, ApiDefinitionWithBLOBs v, String version) {
|
||||||
|
|
Loading…
Reference in New Issue