fix(接口测试): 导入接口后,手动添加一个接口用例,删除其他用例,再次导入,报错

--user=郭雨琦
--bug=1015643
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001015643
This commit is contained in:
guoyuqi 2022-08-03 10:10:09 +08:00 committed by jianxing
parent 6b6cea1db4
commit 6a79e1068b
1 changed files with 28 additions and 26 deletions

View File

@ -1166,36 +1166,38 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
//如果导入的有重名覆盖接口ID替换成系统内的 //如果导入的有重名覆盖接口ID替换成系统内的
caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId()); caseWithBLOBs1.setApiDefinitionId(definitionWithBLOBs.getId());
List<ApiTestCaseWithBLOBs> caseWithBLOBs = oldCaseNameMap.get(name); List<ApiTestCaseWithBLOBs> caseWithBLOBs = oldCaseNameMap.get(name);
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs1 = caseWithBLOBs.get(0); if (CollectionUtils.isNotEmpty(caseWithBLOBs)) {
if (apiTestCaseWithBLOBs1 != null) { ApiTestCaseWithBLOBs apiTestCaseWithBLOBs1 = caseWithBLOBs.get(0);
if (caseWithBLOBs.size() > 1) { if (apiTestCaseWithBLOBs1 != null) {
for (int i = 0; i < caseWithBLOBs.size(); i++) { if (caseWithBLOBs.size() > 1) {
int version = 0; for (int i = 0; i < caseWithBLOBs.size(); i++) {
if (caseWithBLOBs.get(i).getVersion() != null) { int version = 0;
version = caseWithBLOBs.get(i).getVersion() + 1; if (caseWithBLOBs.get(i).getVersion() != null) {
} version = caseWithBLOBs.get(i).getVersion() + 1;
if (i == 0) { }
caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); if (i == 0) {
caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum()); caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId());
caseWithBLOBs1.setVersion(version); caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum());
} else { caseWithBLOBs1.setVersion(version);
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs(); } else {
BeanUtils.copyBean(apiTestCaseWithBLOBs, caseWithBLOBs1); ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = new ApiTestCaseWithBLOBs();
apiTestCaseWithBLOBs.setId(caseWithBLOBs.get(i).getId()); BeanUtils.copyBean(apiTestCaseWithBLOBs, caseWithBLOBs1);
apiTestCaseWithBLOBs.setNum(caseWithBLOBs.get(i).getNum()); apiTestCaseWithBLOBs.setId(caseWithBLOBs.get(i).getId());
apiTestCaseWithBLOBs.setVersion(version); apiTestCaseWithBLOBs.setNum(caseWithBLOBs.get(i).getNum());
apiTestCaseWithBLOBs.setVersionId("create_repeat"); apiTestCaseWithBLOBs.setVersion(version);
optionDataCases.add(apiTestCaseWithBLOBs); apiTestCaseWithBLOBs.setVersionId("create_repeat");
optionDataCases.add(apiTestCaseWithBLOBs);
}
} }
} else {
caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId());
caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum());
caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : apiTestCaseWithBLOBs1.getVersion() + 1);
} }
oldCaseNameMap.remove(name);
} else { } else {
caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId()); caseWithBLOBs1.setVersion(0);
caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum());
caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : apiTestCaseWithBLOBs1.getVersion() + 1);
} }
oldCaseNameMap.remove(name);
} else {
caseWithBLOBs1.setVersion(0);
} }
}); });
} else { } else {