refactor(接口导入): 接口导入覆盖模式规则优化
--user=郭雨琦 --bug=1015688 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015688
This commit is contained in:
parent
4ba842b889
commit
11cdba122d
|
@ -664,11 +664,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, List<ApiModule>> pidChildrenMap, Map<String, String> idPathMap,
|
Map<String, List<ApiModule>> pidChildrenMap, Map<String, String> idPathMap,
|
||||||
Map<String, ApiModuleDTO> idModuleMap, ApiTestImportRequest request,
|
Map<String, ApiModuleDTO> idModuleMap, ApiTestImportRequest request,
|
||||||
Boolean fullCoverage, List<ApiTestCaseWithBLOBs> importCases, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
|
Boolean fullCoverage, List<ApiTestCaseWithBLOBs> importCases, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
|
||||||
List<ApiDefinitionWithBLOBs> optionData = new ArrayList<>();
|
List<ApiDefinitionWithBLOBs> optionDatas = new ArrayList<>();
|
||||||
//系统原有的需要更新的list,
|
//系统原有的需要更新的list,
|
||||||
List<ApiDefinitionWithBLOBs> toUpdateList = new ArrayList<>();
|
List<ApiDefinitionWithBLOBs> toUpdateList = new ArrayList<>();
|
||||||
//去重,TCP,SQL,DUBBO 模块下名称唯一
|
//去重,TCP,SQL,DUBBO 模块下名称唯一
|
||||||
removeRepeatOrigin(data, fullCoverage, optionData);
|
removeRepeatOrigin(data, fullCoverage, optionDatas);
|
||||||
//上传文件时选的模块ID
|
//上传文件时选的模块ID
|
||||||
String chooseModuleId = request.getModuleId();
|
String chooseModuleId = request.getModuleId();
|
||||||
//获取选中的模块
|
//获取选中的模块
|
||||||
|
@ -682,27 +682,34 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//需要新增的模块,key 为模块路径
|
//需要新增的模块,key 为模块路径
|
||||||
Map<String, ApiModule> moduleMap = new HashMap<>();
|
Map<String, ApiModule> moduleMap = new HashMap<>();
|
||||||
//处理模块
|
//处理模块
|
||||||
setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionData, chooseModule);
|
setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionDatas, chooseModule);
|
||||||
|
|
||||||
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = getApiDefinitionWithBLOBsList(request, optionData);
|
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = getApiDefinitionWithBLOBsList(request, optionDatas);
|
||||||
//重复接口的case
|
//重复接口的case
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
|
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
|
||||||
}
|
}
|
||||||
Map<String, ApiDefinitionWithBLOBs> repeatDataMap = null;
|
Map<String, ApiDefinitionWithBLOBs> repeatDataMap = null;
|
||||||
Map<String, ApiDefinitionWithBLOBs> optionMap = new HashMap<>();
|
Map<String, ApiDefinitionWithBLOBs> optionMap = new HashMap<>();
|
||||||
|
|
||||||
if (chooseModule != null) {
|
if (chooseModule != null) {
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
|
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
|
||||||
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
|
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
|
||||||
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + chooseModulePath, api -> api));
|
if (fullCoverage) {
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModuleId)).collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
List<ApiDefinitionWithBLOBs> singleOptionDatas = new ArrayList<>();
|
||||||
|
removeOtherChooseModuleRepeat(optionDatas, singleOptionDatas, chooseModulePath);
|
||||||
|
optionDatas = singleOptionDatas;
|
||||||
|
optionMap = optionDatas.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), api -> api));
|
||||||
|
} else {
|
||||||
|
getNoHChooseModuleUrlRepeatOptionMap(optionDatas, optionMap, chooseModulePath);
|
||||||
|
}
|
||||||
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModuleId)).collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buildOptionMap(optionData, optionMap);
|
buildOptionMap(optionDatas, optionMap);
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
|
||||||
}
|
}
|
||||||
Boolean fullCoverageApi = getFullCoverageApi(request);
|
Boolean fullCoverageApi = getFullCoverageApi(request);
|
||||||
String updateVersionId = getUpdateVersionId(request);
|
String updateVersionId = getUpdateVersionId(request);
|
||||||
|
@ -716,43 +723,60 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//不覆盖
|
//不覆盖
|
||||||
removeRepeat(optionData, optionMap, repeatDataMap, moduleMap, versionId, optionDataCases);
|
removeRepeat(optionDatas, optionMap, repeatDataMap, moduleMap, versionId, optionDataCases);
|
||||||
}
|
}
|
||||||
|
|
||||||
//系统内检查重复
|
//系统内检查重复
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
|
||||||
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + t.getModulePath(), api -> api));
|
optionMap = optionDatas.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getModulePath()), api -> api));
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
cover(moduleMap, toUpdateList, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap, esbApiParamsMap);
|
cover(moduleMap, toUpdateList, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap, esbApiParamsMap);
|
||||||
} else {
|
} else {
|
||||||
//不覆盖,同一接口不做更新
|
//不覆盖,同一接口不做更新
|
||||||
removeRepeat(optionData, optionMap, repeatDataMap, moduleMap, versionId, optionDataCases);
|
removeRepeat(optionDatas, optionMap, repeatDataMap, moduleMap, versionId, optionDataCases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionData.isEmpty()) {
|
if (optionDatas.isEmpty()) {
|
||||||
moduleMap = new HashMap<>();
|
moduleMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
//将原来的case和更改的case组合在一起,为了同步的设置
|
//将原来的case和更改的case组合在一起,为了同步的设置
|
||||||
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||||
buildCases(optionDataCases, oldCaseMap, caseIds);
|
buildCases(optionDataCases, oldCaseMap, caseIds);
|
||||||
return getUpdateApiModuleDTO(moduleMap, toUpdateList, optionData, optionDataCases);
|
return getUpdateApiModuleDTO(moduleMap, toUpdateList, optionDatas, optionDataCases);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildOptionMap(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> optionMap) {
|
private void getNoHChooseModuleUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionDatas, Map<String, ApiDefinitionWithBLOBs> optionMap, String chooseModulePath) {
|
||||||
for (ApiDefinitionWithBLOBs optionDatum : optionData) {
|
for (ApiDefinitionWithBLOBs optionDatum : optionDatas) {
|
||||||
|
if (optionDatum.getModulePath() == null) {
|
||||||
|
optionMap.put(optionDatum.getName().concat(chooseModulePath), optionDatum);
|
||||||
|
} else {
|
||||||
|
optionMap.put(optionDatum.getName().concat(chooseModulePath).concat(optionDatum.getModulePath()), optionDatum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeOtherChooseModuleRepeat(List<ApiDefinitionWithBLOBs> optionDatas, List<ApiDefinitionWithBLOBs> singleOptionDatas, String chooseModulePath) {
|
||||||
|
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = optionDatas.stream().collect(Collectors.groupingBy(t -> t.getName().concat(chooseModulePath), LinkedHashMap::new, Collectors.toList()));
|
||||||
|
methodPathMap.forEach((k, v) -> {
|
||||||
|
singleOptionDatas.add(v.get(v.size() - 1));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildOptionMap(List<ApiDefinitionWithBLOBs> optionDatas, Map<String, ApiDefinitionWithBLOBs> optionMap) {
|
||||||
|
for (ApiDefinitionWithBLOBs optionDatum : optionDatas) {
|
||||||
if (optionDatum.getModulePath() == null) {
|
if (optionDatum.getModulePath() == null) {
|
||||||
optionMap.put(optionDatum.getName(), optionDatum);
|
optionMap.put(optionDatum.getName(), optionDatum);
|
||||||
} else {
|
} else {
|
||||||
optionMap.put(optionDatum.getName() + optionDatum.getModulePath(), optionDatum);
|
optionMap.put(optionDatum.getName().concat(optionDatum.getModulePath()), optionDatum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ApiDefinitionWithBLOBs> getApiDefinitionWithBLOBsList(ApiTestImportRequest request, List<ApiDefinitionWithBLOBs> optionData) {
|
private List<ApiDefinitionWithBLOBs> getApiDefinitionWithBLOBsList(ApiTestImportRequest request, List<ApiDefinitionWithBLOBs> optionDatas) {
|
||||||
//处理数据
|
//处理数据
|
||||||
List<String> nameList = optionData.stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
|
List<String> nameList = optionDatas.stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList());
|
||||||
String projectId = request.getProjectId();
|
String projectId = request.getProjectId();
|
||||||
String protocol = request.getProtocol();
|
String protocol = request.getProtocol();
|
||||||
//获取系统内重复数据
|
//获取系统内重复数据
|
||||||
|
@ -764,12 +788,12 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, ApiModuleDTO> idModuleMap, ApiTestImportRequest request,
|
Map<String, ApiModuleDTO> idModuleMap, ApiTestImportRequest request,
|
||||||
Boolean fullCoverage, boolean urlRepeat, List<ApiTestCaseWithBLOBs> importCases) {
|
Boolean fullCoverage, boolean urlRepeat, List<ApiTestCaseWithBLOBs> importCases) {
|
||||||
|
|
||||||
List<ApiDefinitionWithBLOBs> optionData = new ArrayList<>();
|
List<ApiDefinitionWithBLOBs> optionDatas = new ArrayList<>();
|
||||||
//系统原有的需要更新的list,
|
//系统原有的需要更新的list,
|
||||||
List<ApiDefinitionWithBLOBs> toUpdateList = new ArrayList<>();
|
List<ApiDefinitionWithBLOBs> toUpdateList = new ArrayList<>();
|
||||||
//去重 如果url可重复 则模块+名称+请求方式+路径 唯一,否则 请求方式+路径唯一,
|
//去重 如果url可重复 则模块+名称+请求方式+路径 唯一,否则 请求方式+路径唯一,
|
||||||
//覆盖模式留重复的最后一个,不覆盖留第一个
|
//覆盖模式留重复的最后一个,不覆盖留第一个
|
||||||
removeHTTPRepeat(data, fullCoverage, urlRepeat, optionData);
|
removeHttpRepeat(data, fullCoverage, urlRepeat, optionDatas);
|
||||||
|
|
||||||
//上传文件时选的模块ID
|
//上传文件时选的模块ID
|
||||||
String chooseModuleId = request.getModuleId();
|
String chooseModuleId = request.getModuleId();
|
||||||
|
@ -784,24 +808,23 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//需要新增的模块,key 为模块路径
|
//需要新增的模块,key 为模块路径
|
||||||
Map<String, ApiModule> moduleMap = new HashMap<>();
|
Map<String, ApiModule> moduleMap = new HashMap<>();
|
||||||
//处理模块
|
//处理模块
|
||||||
setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionData, chooseModule);
|
setModule(moduleMap, pidChildrenMap, idPathMap, idModuleMap, optionDatas, chooseModule);
|
||||||
|
|
||||||
if (urlRepeat) {
|
if (urlRepeat) {
|
||||||
dealHttpUrlRepeat(chooseModule, idPathMap, optionData, fullCoverage, request, moduleMap, toUpdateList, optionDataCases);
|
optionDatas = dealHttpUrlRepeat(chooseModule, idPathMap, optionDatas, fullCoverage, request, moduleMap, toUpdateList, optionDataCases);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dealHttpUrlNoRepeat(optionData, fullCoverage, request, moduleMap, toUpdateList, optionDataCases);
|
dealHttpUrlNoRepeat(optionDatas, fullCoverage, request, moduleMap, toUpdateList, optionDataCases);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optionData.isEmpty()) {
|
if (optionDatas.isEmpty()) {
|
||||||
moduleMap = new HashMap<>();
|
moduleMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return getUpdateApiModuleDTO(moduleMap, toUpdateList, optionData, optionDataCases);
|
return getUpdateApiModuleDTO(moduleMap, toUpdateList, optionDatas, optionDataCases);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dealHttpUrlNoRepeat(List<ApiDefinitionWithBLOBs> optionData,
|
private void dealHttpUrlNoRepeat(List<ApiDefinitionWithBLOBs> optionDatas,
|
||||||
Boolean fullCoverage, ApiTestImportRequest request, Map<String, ApiModule> moduleMap,
|
Boolean fullCoverage, ApiTestImportRequest request, Map<String, ApiModule> moduleMap,
|
||||||
List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
||||||
|
|
||||||
|
@ -813,36 +836,36 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Boolean fullCoverageApi = getFullCoverageApi(request);
|
Boolean fullCoverageApi = getFullCoverageApi(request);
|
||||||
String projectId = request.getProjectId();
|
String projectId = request.getProjectId();
|
||||||
//系统内重复的数据
|
//系统内重复的数据
|
||||||
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionData, projectId);
|
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionDatas, projectId);
|
||||||
|
|
||||||
//这个是系统内重复的数据
|
//这个是系统内重复的数据
|
||||||
Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getMethod() + t.getPath()));
|
Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getMethod().concat(t.getPath())));
|
||||||
|
|
||||||
//按照原来的顺序
|
//按照原来的顺序
|
||||||
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getMethod() + t.getPath(), api -> api));
|
optionMap = optionDatas.stream().collect(Collectors.toMap(t -> t.getMethod().concat(t.getPath()), api -> api));
|
||||||
|
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
||||||
|
|
||||||
//重复接口的case
|
//重复接口的case
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
|
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
if (fullCoverageApi) {
|
if (fullCoverageApi) {
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
startCoverModule(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
startCoverModule(toUpdateList, optionDatas, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//不覆盖模块
|
//不覆盖模块
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
startCover(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
startCover(toUpdateList, optionDatas, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//不覆盖,同一接口不做更新
|
//不覆盖,同一接口不做更新
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
removeSameData(repeatDataMap, optionMap, optionData, moduleMap, versionId, optionDataCases);
|
removeSameData(repeatDataMap, optionMap, optionDatas, moduleMap, versionId, optionDataCases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//将原来的case和更改的case组合在一起,为了同步的设置
|
//将原来的case和更改的case组合在一起,为了同步的设置
|
||||||
|
@ -850,7 +873,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
buildCases(optionDataCases, oldCaseMap, caseIds);
|
buildCases(optionDataCases, oldCaseMap, caseIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dealHttpUrlRepeat(ApiModuleDTO chooseModule, Map<String, String> idPathMap, List<ApiDefinitionWithBLOBs> optionData,
|
private List<ApiDefinitionWithBLOBs> dealHttpUrlRepeat(ApiModuleDTO chooseModule, Map<String, String> idPathMap, List<ApiDefinitionWithBLOBs> optionDatas,
|
||||||
Boolean fullCoverage, ApiTestImportRequest request, Map<String, ApiModule> moduleMap,
|
Boolean fullCoverage, ApiTestImportRequest request, Map<String, ApiModule> moduleMap,
|
||||||
List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
||||||
String updateVersionId = getUpdateVersionId(request);
|
String updateVersionId = getUpdateVersionId(request);
|
||||||
|
@ -858,7 +881,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Boolean fullCoverageApi = getFullCoverageApi(request);
|
Boolean fullCoverageApi = getFullCoverageApi(request);
|
||||||
String projectId = request.getProjectId();
|
String projectId = request.getProjectId();
|
||||||
//系统内重复的数据
|
//系统内重复的数据
|
||||||
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionData, projectId);
|
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionDatas, projectId);
|
||||||
|
|
||||||
//这个是名称加请求方式加路径加模块为key的map 就是为了去重
|
//这个是名称加请求方式加路径加模块为key的map 就是为了去重
|
||||||
Map<String, ApiDefinitionWithBLOBs> optionMap = new HashMap<>();
|
Map<String, ApiDefinitionWithBLOBs> optionMap = new HashMap<>();
|
||||||
|
@ -866,66 +889,90 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap;
|
Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap;
|
||||||
//按照原来的顺序
|
//按照原来的顺序
|
||||||
if (chooseModule != null) {
|
if (chooseModule != null) {
|
||||||
//如果有选中的模块,则在选中的模块下过滤
|
//如果有选中的模块,则在选中的模块下过滤 过滤规则是 选择的模块路径+名称+method+path
|
||||||
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
|
String chooseModuleParentId = getChooseModuleParentId(chooseModule);
|
||||||
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
|
String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId);
|
||||||
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + t.getMethod() + t.getPath() + chooseModulePath, api -> api));
|
//这样的过滤规则下可能存在重复接口,如果是覆盖模块,需要按照去重规则再次去重,否则就加上接口原有的模块
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModule.getId())).collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + t.getModulePath()));
|
if (fullCoverage) {
|
||||||
|
List<ApiDefinitionWithBLOBs> singleOptionDatas = new ArrayList<>();
|
||||||
|
removeHttpChooseModuleRepeat(optionDatas, singleOptionDatas, chooseModulePath);
|
||||||
|
optionDatas = singleOptionDatas;
|
||||||
|
optionMap = optionDatas.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), api -> api));
|
||||||
|
} else {
|
||||||
|
getChooseModuleUrlRepeatOptionMap(optionDatas, optionMap, chooseModulePath);
|
||||||
|
}
|
||||||
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().filter(t -> t.getModuleId().equals(chooseModule.getId())).collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
|
||||||
} else {
|
} else {
|
||||||
//否则在整个系统中过滤
|
//否则在整个系统中过滤
|
||||||
getUrlRepeatOptionMap(optionData, optionMap);
|
getUrlRepeatOptionMap(optionDatas, optionMap);
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + t.getModulePath()));
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
|
||||||
}
|
}
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap = new HashMap<>();
|
||||||
//重复接口的case
|
//重复接口的case
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
|
oldCaseMap = getOldCaseMap(repeatApiDefinitionWithBLOBs);
|
||||||
}
|
}
|
||||||
//覆盖接口
|
//覆盖接口
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
//允许覆盖模块,用导入的重复数据的最后一条覆盖查询的所有重复数据; case 在覆盖的时候,是拼接到原来的case,name唯一;不覆盖,就用原来的
|
//允许覆盖模块,用导入的重复数据的最后一条覆盖查询的所有重复数据; case 在覆盖的时候,是拼接到原来的case,name唯一;不覆盖,就用原来的
|
||||||
if (fullCoverageApi) {
|
if (fullCoverageApi) {
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
startCoverModule(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
startCoverModule(toUpdateList, optionDatas, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//覆盖但不覆盖模块
|
//覆盖但不覆盖模块
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
//过滤同一层级重复模块,导入文件没有新增接口无需创建接口模块
|
//过滤同一层级重复模块,导入文件没有新增接口无需创建接口模块
|
||||||
moduleMap = judgeModuleMap(moduleMap, optionMap, repeatDataMap);
|
moduleMap = judgeModuleMap(moduleMap, optionMap, repeatDataMap);
|
||||||
startCover(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
startCover(toUpdateList, optionDatas, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//不覆盖,同一接口不做更新;可能创建新版本,case也直接创建,
|
//不覆盖,同一接口不做更新;可能创建新版本,case也直接创建,
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
removeSameData(repeatDataMap, optionMap, optionData, moduleMap, versionId, optionDataCases);
|
removeSameData(repeatDataMap, optionMap, optionDatas, moduleMap, versionId, optionDataCases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//最后在整个体统内检查一遍(防止在有选择的模块时,未找到重复,直接创建的情况)
|
//最后在整个体统内检查一遍(防止在有选择的模块时,未找到重复,直接创建的情况)
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + t.getModulePath()));
|
repeatDataMap = repeatApiDefinitionWithBLOBs.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath())));
|
||||||
optionMap = optionData.stream().collect(Collectors.toMap(t -> t.getName() + t.getMethod() + t.getPath() + t.getModulePath(), api -> api));
|
optionMap = optionDatas.stream().collect(Collectors.toMap(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(t.getModulePath()), api -> api));
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
startCover(toUpdateList, optionData, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
startCover(toUpdateList, optionDatas, optionMap, repeatDataMap, updateVersionId, optionDataCases, oldCaseMap);
|
||||||
} else {
|
} else {
|
||||||
//不覆盖,同一接口不做更新
|
//不覆盖,同一接口不做更新
|
||||||
if (!repeatApiDefinitionWithBLOBs.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(repeatApiDefinitionWithBLOBs)) {
|
||||||
removeSameData(repeatDataMap, optionMap, optionData, moduleMap, versionId, optionDataCases);
|
removeSameData(repeatDataMap, optionMap, optionDatas, moduleMap, versionId, optionDataCases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//将原来的case和更改的case组合在一起,为了同步的设置
|
//将原来的case和更改的case组合在一起,为了同步的设置
|
||||||
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
List<String> caseIds = optionDataCases.stream().map(ApiTestCase::getId).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||||
buildCases(optionDataCases, oldCaseMap, caseIds);
|
buildCases(optionDataCases, oldCaseMap, caseIds);
|
||||||
|
return optionDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> optionMap) {
|
private void removeHttpChooseModuleRepeat(List<ApiDefinitionWithBLOBs> optionDatas, List<ApiDefinitionWithBLOBs> singleOptionDatas, String chooseModulePath) {
|
||||||
for (ApiDefinitionWithBLOBs optionDatum : optionData) {
|
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = optionDatas.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getMethod()).concat(t.getPath()).concat(chooseModulePath), LinkedHashMap::new, Collectors.toList()));
|
||||||
|
methodPathMap.forEach((k, v) -> singleOptionDatas.add(v.get(v.size() - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getChooseModuleUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionDatas, Map<String, ApiDefinitionWithBLOBs> optionMap, String chooseModulePath) {
|
||||||
|
for (ApiDefinitionWithBLOBs optionDatum : optionDatas) {
|
||||||
if (optionDatum.getModulePath() == null) {
|
if (optionDatum.getModulePath() == null) {
|
||||||
optionMap.put(optionDatum.getName() + optionDatum.getMethod() + optionDatum.getPath(), optionDatum);
|
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()).concat(chooseModulePath), optionDatum);
|
||||||
} else {
|
} else {
|
||||||
optionMap.put(optionDatum.getName() + optionDatum.getMethod() + optionDatum.getPath() + optionDatum.getModulePath(), optionDatum);
|
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()).concat(chooseModulePath).concat(optionDatum.getModulePath()), optionDatum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getUrlRepeatOptionMap(List<ApiDefinitionWithBLOBs> optionDatas, Map<String, ApiDefinitionWithBLOBs> optionMap) {
|
||||||
|
for (ApiDefinitionWithBLOBs optionDatum : optionDatas) {
|
||||||
|
if (optionDatum.getModulePath() == null) {
|
||||||
|
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()), optionDatum);
|
||||||
|
} else {
|
||||||
|
optionMap.put(optionDatum.getName().concat(optionDatum.getMethod()).concat(optionDatum.getPath()).concat(optionDatum.getModulePath()), optionDatum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -965,7 +1012,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeRepeatCase(Boolean fullCoverage, List<ApiTestCaseWithBLOBs> importCases, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
private void removeRepeatCase(Boolean fullCoverage, List<ApiTestCaseWithBLOBs> importCases, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
||||||
LinkedHashMap<String, List<ApiTestCaseWithBLOBs>> apiIdNameMap = importCases.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getApiDefinitionId(), LinkedHashMap::new, Collectors.toList()));
|
LinkedHashMap<String, List<ApiTestCaseWithBLOBs>> apiIdNameMap = importCases.stream().collect(Collectors.groupingBy(t -> t.getName().concat(t.getApiDefinitionId()), LinkedHashMap::new, Collectors.toList()));
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
apiIdNameMap.forEach((k, v) -> {
|
apiIdNameMap.forEach((k, v) -> {
|
||||||
v.get(v.size() - 1).setId(null);
|
v.get(v.size() - 1).setId(null);
|
||||||
|
@ -992,21 +1039,21 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private UpdateApiModuleDTO getUpdateApiModuleDTO(Map<String, ApiModule> moduleMap, List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
private UpdateApiModuleDTO getUpdateApiModuleDTO(Map<String, ApiModule> moduleMap, List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionDatas, List<ApiTestCaseWithBLOBs> optionDataCases) {
|
||||||
UpdateApiModuleDTO updateApiModuleDTO = new UpdateApiModuleDTO();
|
UpdateApiModuleDTO updateApiModuleDTO = new UpdateApiModuleDTO();
|
||||||
updateApiModuleDTO.setModuleList(new ArrayList<>(moduleMap.values()));
|
updateApiModuleDTO.setModuleList(new ArrayList<>(moduleMap.values()));
|
||||||
updateApiModuleDTO.setNeedUpdateList(toUpdateList);
|
updateApiModuleDTO.setNeedUpdateList(toUpdateList);
|
||||||
updateApiModuleDTO.setDefinitionWithBLOBs(optionData);
|
updateApiModuleDTO.setDefinitionWithBLOBs(optionDatas);
|
||||||
updateApiModuleDTO.setCaseWithBLOBs(optionDataCases);
|
updateApiModuleDTO.setCaseWithBLOBs(optionDataCases);
|
||||||
return updateApiModuleDTO;
|
return updateApiModuleDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeRepeat(List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiDefinitionWithBLOBs> nameModuleMap,
|
private void removeRepeat(List<ApiDefinitionWithBLOBs> optionDatas, Map<String, ApiDefinitionWithBLOBs> nameModuleMap,
|
||||||
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 (nameModuleMap != null) {
|
||||||
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionDatas.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
if (apiDefinitionWithBLOBs != null) {
|
||||||
|
@ -1021,8 +1068,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
||||||
if (v.getVersionId().equals(versionId)) {
|
if (v.getVersionId().equals(versionId)) {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionDatas.remove(apiDefinitionWithBLOBs);
|
||||||
if (distinctNameCases != null && !distinctNameCases.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1134,29 +1181,29 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeRepeatOrigin(List<ApiDefinitionWithBLOBs> data, Boolean fullCoverage, List<ApiDefinitionWithBLOBs> optionData) {
|
private void removeRepeatOrigin(List<ApiDefinitionWithBLOBs> data, Boolean fullCoverage, List<ApiDefinitionWithBLOBs> optionDatas) {
|
||||||
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList()));
|
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList()));
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
methodPathMap.forEach((k, v) -> optionData.add(v.get(v.size() - 1)));
|
methodPathMap.forEach((k, v) -> optionDatas.add(v.get(v.size() - 1)));
|
||||||
} else {
|
} else {
|
||||||
methodPathMap.forEach((k, v) -> optionData.add(v.get(0)));
|
methodPathMap.forEach((k, v) -> optionDatas.add(v.get(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeHTTPRepeat(List<ApiDefinitionWithBLOBs> data, Boolean fullCoverage, boolean urlRepeat, List<ApiDefinitionWithBLOBs> optionData) {
|
private void removeHttpRepeat(List<ApiDefinitionWithBLOBs> data, Boolean fullCoverage, boolean urlRepeat, List<ApiDefinitionWithBLOBs> optionDatas) {
|
||||||
if (urlRepeat) {
|
if (urlRepeat) {
|
||||||
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList()));
|
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getName() + t.getMethod() + t.getPath() + (t.getModulePath() == null ? "" : t.getModulePath()), LinkedHashMap::new, Collectors.toList()));
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
methodPathMap.forEach((k, v) -> optionData.add(v.get(v.size() - 1)));
|
methodPathMap.forEach((k, v) -> optionDatas.add(v.get(v.size() - 1)));
|
||||||
} else {
|
} else {
|
||||||
methodPathMap.forEach((k, v) -> optionData.add(v.get(0)));
|
methodPathMap.forEach((k, v) -> optionDatas.add(v.get(0)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getMethod() + t.getPath(), LinkedHashMap::new, Collectors.toList()));
|
LinkedHashMap<String, List<ApiDefinitionWithBLOBs>> methodPathMap = data.stream().collect(Collectors.groupingBy(t -> t.getMethod().concat(t.getPath()), LinkedHashMap::new, Collectors.toList()));
|
||||||
if (fullCoverage) {
|
if (fullCoverage) {
|
||||||
methodPathMap.forEach((k, v) -> optionData.add(v.get(v.size() - 1)));
|
methodPathMap.forEach((k, v) -> optionDatas.add(v.get(v.size() - 1)));
|
||||||
} else {
|
} else {
|
||||||
methodPathMap.forEach((k, v) -> optionData.add(v.get(0)));
|
methodPathMap.forEach((k, v) -> optionDatas.add(v.get(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1182,10 +1229,10 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeSameData(Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap, Map<String, ApiDefinitionWithBLOBs> methodPathMap,
|
private void removeSameData(Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap, Map<String, ApiDefinitionWithBLOBs> methodPathMap,
|
||||||
List<ApiDefinitionWithBLOBs> optionData, Map<String, ApiModule> moduleMap, String versionId,
|
List<ApiDefinitionWithBLOBs> optionDatas, Map<String, ApiModule> moduleMap, String versionId,
|
||||||
List<ApiTestCaseWithBLOBs> optionDataCases) {
|
List<ApiTestCaseWithBLOBs> optionDataCases) {
|
||||||
|
|
||||||
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionDatas.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k);
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k);
|
||||||
if (apiDefinitionWithBLOBs != null) {
|
if (apiDefinitionWithBLOBs != null) {
|
||||||
|
@ -1200,8 +1247,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
||||||
List<ApiDefinitionWithBLOBs> sameVersionList = v.stream().filter(t -> t.getVersionId().equals(versionId)).collect(Collectors.toList());
|
List<ApiDefinitionWithBLOBs> sameVersionList = v.stream().filter(t -> t.getVersionId().equals(versionId)).collect(Collectors.toList());
|
||||||
if (!sameVersionList.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(sameVersionList)) {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionDatas.remove(apiDefinitionWithBLOBs);
|
||||||
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1286,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCoverModule(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData,
|
private void startCoverModule(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionDatas,
|
||||||
Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap,
|
Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap,
|
||||||
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
|
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap) {
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap) {
|
||||||
|
@ -1276,11 +1323,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
|
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionDatas.remove(apiDefinitionWithBLOBs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buildOtherParam(toUpdateList, optionData, coverApiList, updateApiList);
|
buildOtherParam(toUpdateList, optionDatas, coverApiList, updateApiList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildCaseList(Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap,
|
private void buildCaseList(Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap,
|
||||||
|
@ -1291,7 +1338,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//map List 结构是因为表里可能一个接口有多个同名case的可能
|
//map List 结构是因为表里可能一个接口有多个同名case的可能
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseNameMap;
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseNameMap;
|
||||||
//如果有重复接口,处理重复接口
|
//如果有重复接口,处理重复接口
|
||||||
if (apiTestCases != null && !apiTestCases.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(apiTestCases)) {
|
||||||
oldCaseNameMap = apiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getName));
|
oldCaseNameMap = apiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getName));
|
||||||
caseNameMap.forEach((name, caseWithBLOBs1) -> {
|
caseNameMap.forEach((name, caseWithBLOBs1) -> {
|
||||||
//如果导入的有重名,覆盖,接口ID替换成系统内的
|
//如果导入的有重名,覆盖,接口ID替换成系统内的
|
||||||
|
@ -1352,7 +1399,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCover(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData,
|
private void startCover(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionDatas,
|
||||||
Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap,
|
Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap,
|
||||||
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
|
String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap) {
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap) {
|
||||||
|
@ -1389,11 +1436,11 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
|
addNewVersionApi(apiDefinitionWithBLOBs, v.get(0), "update");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionDatas.remove(apiDefinitionWithBLOBs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buildOtherParam(toUpdateList, optionData, coverApiList, updateApiList);
|
buildOtherParam(toUpdateList, optionDatas, coverApiList, updateApiList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, ApiModule> judgeModuleMap(Map<String, ApiModule> moduleMap, Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap) {
|
private Map<String, ApiModule> judgeModuleMap(Map<String, ApiModule> moduleMap, Map<String, ApiDefinitionWithBLOBs> methodPathMap, Map<String, List<ApiDefinitionWithBLOBs>> repeatDataMap) {
|
||||||
|
@ -1409,8 +1456,8 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
return moduleMap;
|
return moduleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildOtherParam(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionData, List<ApiDefinitionWithBLOBs> coverApiList, List<ApiDefinitionWithBLOBs> updateApiList) {
|
private void buildOtherParam(List<ApiDefinitionWithBLOBs> toUpdateList, List<ApiDefinitionWithBLOBs> optionDatas, List<ApiDefinitionWithBLOBs> coverApiList, List<ApiDefinitionWithBLOBs> updateApiList) {
|
||||||
optionData.addAll(coverApiList);
|
optionDatas.addAll(coverApiList);
|
||||||
toUpdateList.addAll(updateApiList);
|
toUpdateList.addAll(updateApiList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1509,7 +1556,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
for (int i = 0; i < tagTree.length; i++) {
|
for (int i = 0; i < tagTree.length; i++) {
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
List<ApiModule> collect = new ArrayList<>();
|
List<ApiModule> collect = new ArrayList<>();
|
||||||
if (parentModuleList != null && !parentModuleList.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(parentModuleList)) {
|
||||||
collect = parentModuleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList());
|
collect = parentModuleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
if (collect.isEmpty()) {
|
if (collect.isEmpty()) {
|
||||||
|
@ -1521,7 +1568,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
parentModule.setLevel(0);
|
parentModule.setLevel(0);
|
||||||
parentModule.setProtocol(pidChildrenMap.get("root").get(0).getProtocol());
|
parentModule.setProtocol(pidChildrenMap.get("root").get(0).getProtocol());
|
||||||
} else {
|
} else {
|
||||||
if (parentModuleList != null && !parentModuleList.isEmpty() && parentModule == null) {
|
if (CollectionUtils.isNotEmpty(parentModuleList) && parentModule == null) {
|
||||||
String parentId = parentModuleList.get(0).getParentId();
|
String parentId = parentModuleList.get(0).getParentId();
|
||||||
ApiModuleDTO apiModuleDTO = idModuleMap.get(parentId);
|
ApiModuleDTO apiModuleDTO = idModuleMap.get(parentId);
|
||||||
parentModule = JSON.parseObject(JSON.toJSONString(apiModuleDTO), ApiModule.class);
|
parentModule = JSON.parseObject(JSON.toJSONString(apiModuleDTO), ApiModule.class);
|
||||||
|
|
Loading…
Reference in New Issue