fix(接口测试): 解决接口导入覆盖模式,被覆盖接口无case,新case导入失败问题
--user=郭雨琦 --bug=1015475 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015475
This commit is contained in:
parent
ff80fb362e
commit
837d5e01a9
|
@ -856,7 +856,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
//不覆盖选择版本,如果被选版本有同接口,不导入,否则创建新版本接口
|
||||||
if (v.getVersionId().equals(versionId)) {
|
if (v.getVersionId().equals(versionId)) {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionData.remove(apiDefinitionWithBLOBs);
|
||||||
if (distinctNameCases != null && !distinctNameCases.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -897,7 +897,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//该接口的case
|
//该接口的case
|
||||||
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (MapUtils.isNotEmpty(caseNameMap)) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, v, optionDataCases);
|
buildCaseList(oldCaseMap, caseNameMap, v, optionDataCases);
|
||||||
}
|
}
|
||||||
updateEsb(esbApiParamsMap, v.getId(), apiDefinitionWithBLOBs.getId());
|
updateEsb(esbApiParamsMap, v.getId(), apiDefinitionWithBLOBs.getId());
|
||||||
|
@ -964,7 +964,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
//该接口的case
|
//该接口的case
|
||||||
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (MapUtils.isNotEmpty(caseNameMap)) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, v, optionDataCases);
|
buildCaseList(oldCaseMap, caseNameMap, v, optionDataCases);
|
||||||
}
|
}
|
||||||
updateEsb(esbApiParamsMap, v.getId(), apiDefinitionWithBLOBs.getId());
|
updateEsb(esbApiParamsMap, v.getId(), apiDefinitionWithBLOBs.getId());
|
||||||
|
@ -1055,7 +1055,7 @@ 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 (!sameVersionList.isEmpty()) {
|
||||||
optionData.remove(apiDefinitionWithBLOBs);
|
optionData.remove(apiDefinitionWithBLOBs);
|
||||||
if (distinctNameCases != null && !distinctNameCases.isEmpty()) {
|
if (CollectionUtils.isNotEmpty(distinctNameCases)) {
|
||||||
distinctNameCases.forEach(optionDataCases::remove);
|
distinctNameCases.forEach(optionDataCases::remove);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1121,7 +1121,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (MapUtils.isNotEmpty(caseNameMap)) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs, optionDataCases);
|
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs, optionDataCases);
|
||||||
}
|
}
|
||||||
ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs();
|
ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs();
|
||||||
|
@ -1195,13 +1195,22 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
caseWithBLOBs1.setVersion(0);
|
caseWithBLOBs1.setVersion(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
//否则直接给新增接口赋值新的接口ID
|
||||||
|
caseNameMap.forEach((name, caseWithBLOBs1) -> {
|
||||||
|
//如果导入的有重名,覆盖,接口ID替换成系统内的
|
||||||
|
caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Map<String, ApiTestCaseWithBLOBs> getDistinctCaseNameMap(Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp, ApiDefinitionWithBLOBs apiDefinitionWithBLOBs) {
|
private Map<String, ApiTestCaseWithBLOBs> getDistinctCaseNameMap(Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp, ApiDefinitionWithBLOBs apiDefinitionWithBLOBs) {
|
||||||
|
if (MapUtils.isEmpty(definitionIdCaseMAp)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
List<ApiTestCaseWithBLOBs> caseWithBLOBs = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
|
List<ApiTestCaseWithBLOBs> caseWithBLOBs = definitionIdCaseMAp.get(apiDefinitionWithBLOBs.getId());
|
||||||
if (caseWithBLOBs != null) {
|
if (CollectionUtils.isNotEmpty(caseWithBLOBs)) {
|
||||||
return caseWithBLOBs.stream().filter(t -> !t.getVersionId().equals("create_repeat")).collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase));
|
return caseWithBLOBs.stream().filter(t -> !t.getVersionId().equals("create_repeat")).collect(Collectors.toMap(ApiTestCase::getName, testCase -> testCase));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1227,7 +1236,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//组合case
|
//组合case
|
||||||
if (caseNameMap != null) {
|
if (MapUtils.isNotEmpty(caseNameMap)) {
|
||||||
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs, optionDataCases);
|
buildCaseList(oldCaseMap, caseNameMap, definitionWithBLOBs, optionDataCases);
|
||||||
}
|
}
|
||||||
ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs();
|
ApiDefinitionWithBLOBs api = new ApiDefinitionWithBLOBs();
|
||||||
|
|
Loading…
Reference in New Issue