fix(接口测试): 修复接口导入覆盖问题
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001018819 --user=郭雨琦
This commit is contained in:
parent
890b82b1a3
commit
72a7b40584
|
@ -1174,6 +1174,7 @@ public class ApiDefinitionService {
|
||||||
} else if (apiTestImportRequest.getCoverModule() != null && apiTestImportRequest.getCoverModule()) {
|
} else if (apiTestImportRequest.getCoverModule() != null && apiTestImportRequest.getCoverModule()) {
|
||||||
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
apiDefinition.setUpdateTime(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(caseList)) {
|
if (CollectionUtils.isEmpty(caseList)) {
|
||||||
apiDefinition.setToBeUpdated(false);
|
apiDefinition.setToBeUpdated(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath));
|
Map<String, List<ApiDefinitionWithBLOBs>> moduleOptionData = optionData.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) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
|
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
|
||||||
|
@ -1061,7 +1061,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
|
||||||
//覆盖但不覆盖模块
|
//覆盖但不覆盖模块
|
||||||
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
|
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
|
||||||
return moduleMap;
|
return moduleMap;
|
||||||
}
|
}
|
||||||
//导入文件没有新增接口无需创建接口模块
|
//导入文件没有新增接口无需创建接口模块
|
||||||
moduleMap = judgeModule(moduleMap, nameModuleMap, repeatDataMap);
|
moduleMap = judgeModule(moduleMap, nameModuleMap, repeatDataMap);
|
||||||
|
@ -1123,7 +1123,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
Map<String, ApiDefinitionWithBLOBs> repeatDataMap, String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
|
Map<String, ApiDefinitionWithBLOBs> repeatDataMap, String updateVersionId, List<ApiTestCaseWithBLOBs> optionDataCases,
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseMap, Map<String, EsbApiParamsWithBLOBs> esbApiParamsMap) {
|
||||||
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
|
if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
repeatDataMap.forEach((k, v) -> {
|
repeatDataMap.forEach((k, v) -> {
|
||||||
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k);
|
||||||
|
@ -1304,7 +1304,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
List<ApiTestCaseWithBLOBs> oldApiTestCases = oldCaseMap.get(definitionWithBLOBs.getId());
|
List<ApiTestCaseWithBLOBs> oldApiTestCases = oldCaseMap.get(definitionWithBLOBs.getId());
|
||||||
|
|
||||||
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseNameMap;
|
Map<String, List<ApiTestCaseWithBLOBs>> oldCaseNameMap;
|
||||||
//如果重复用例有多个,则覆盖最后的那个
|
//如果同名重复用例有多个,则覆盖最后的那个
|
||||||
if (CollectionUtils.isNotEmpty(oldApiTestCases)) {
|
if (CollectionUtils.isNotEmpty(oldApiTestCases)) {
|
||||||
oldCaseNameMap = oldApiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getName));
|
oldCaseNameMap = oldApiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getName));
|
||||||
caseNameMap.forEach((name, importCaseWithBLOBs) -> {
|
caseNameMap.forEach((name, importCaseWithBLOBs) -> {
|
||||||
|
@ -1332,17 +1332,15 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
}
|
}
|
||||||
oldCaseNameMap.remove(name);
|
oldCaseNameMap.remove(name);
|
||||||
}
|
}
|
||||||
//不同名的旧数据处理
|
});
|
||||||
oldCaseNameMap.forEach((k, v) -> {
|
//不同名的旧数据处理
|
||||||
if (!StringUtils.equals(k, name)) {
|
oldCaseNameMap.forEach((k, v) -> {
|
||||||
if (CollectionUtils.isNotEmpty(v)) {
|
if (CollectionUtils.isNotEmpty(v)) {
|
||||||
for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : v) {
|
for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : v) {
|
||||||
apiTestCaseWithBLOBs.setVersionId("old_case");
|
apiTestCaseWithBLOBs.setVersionId("old_case");
|
||||||
optionDataCases.add(apiTestCaseWithBLOBs);
|
optionDataCases.add(apiTestCaseWithBLOBs);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//否则直接给新增用例赋值新的接口ID
|
//否则直接给新增用例赋值新的接口ID
|
||||||
|
@ -1617,7 +1615,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Map<String, List<ApiModule>> idModuleMap = new HashMap<>();
|
Map<String, List<ApiModule>> idModuleMap = new HashMap<>();
|
||||||
for (ApiModuleDTO apiModuleDTO : nodeTreeByProjectId) {
|
for (ApiModuleDTO apiModuleDTO : nodeTreeByProjectId) {
|
||||||
if (StringUtils.isBlank(apiModuleDTO.getParentId()) || StringUtils.equals(apiModuleDTO.getParentId(),"0")) {
|
if (StringUtils.isBlank(apiModuleDTO.getParentId()) || StringUtils.equals(apiModuleDTO.getParentId(), "0")) {
|
||||||
apiModuleDTO.setParentId(PropertyConstant.ROOT);
|
apiModuleDTO.setParentId(PropertyConstant.ROOT);
|
||||||
}
|
}
|
||||||
String parentModulePath = parentModulePathMap.get(apiModuleDTO.getParentId());
|
String parentModulePath = parentModulePathMap.get(apiModuleDTO.getParentId());
|
||||||
|
|
Loading…
Reference in New Issue