fix(接口测试): 修复接口导入用例ID生成问题
--user=郭雨琦 --bug=1014868 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014868
This commit is contained in:
parent
4dc817436d
commit
c1840fc32e
|
@ -833,12 +833,10 @@ public class ApiDefinitionService {
|
|||
} else {
|
||||
apiDefinition.setVersionId(apiTestImportRequest.getDefaultVersion());
|
||||
}
|
||||
batchMapper.insert(apiDefinition);
|
||||
String requestStr = setImportHashTree(apiDefinition);
|
||||
|
||||
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
|
||||
apiDefinition.setRequest(requestStr);
|
||||
|
||||
batchMapper.insert(apiDefinition);
|
||||
importCase(apiDefinition, apiTestCaseMapper, caseList);
|
||||
extApiDefinitionMapper.clearLatestVersion(apiDefinition.getRefId());
|
||||
extApiDefinitionMapper.addLatestVersion(apiDefinition.getRefId());
|
||||
|
@ -857,7 +855,8 @@ public class ApiDefinitionService {
|
|||
if (caseList == null || caseList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : caseList) {
|
||||
for (int i = 0; i < caseList.size(); i++) {
|
||||
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = caseList.get(i);
|
||||
apiTestCaseWithBLOBs.setApiDefinitionId(apiDefinition.getId());
|
||||
apiTestCaseWithBLOBs.setVersionId(apiDefinition.getVersionId());
|
||||
if (apiTestCaseWithBLOBs.getCreateTime() == null) {
|
||||
|
@ -877,7 +876,7 @@ public class ApiDefinitionService {
|
|||
apiTestCaseWithBLOBs.setOrder(getImportNextCaseOrder(apiDefinition.getProjectId()));
|
||||
}
|
||||
if (apiTestCaseWithBLOBs.getNum() == null) {
|
||||
apiTestCaseWithBLOBs.setNum(testCaseService.getNextNum(apiDefinition.getId()));
|
||||
apiTestCaseWithBLOBs.setNum(apiTestCaseService.getNextNum(apiDefinition.getId(), apiDefinition.getNum() + i, apiDefinition.getProjectId()));
|
||||
}
|
||||
if (StringUtils.isBlank(apiTestCaseWithBLOBs.getPriority())) {
|
||||
apiTestCaseWithBLOBs.setPriority("P0");
|
||||
|
@ -941,9 +940,9 @@ public class ApiDefinitionService {
|
|||
|
||||
reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum());
|
||||
if (StringUtils.equalsIgnoreCase(apiDefinition.getProtocol(), RequestType.HTTP)) {
|
||||
batchMapper.insert(apiDefinition);
|
||||
String request = setImportHashTree(apiDefinition);
|
||||
apiDefinition.setRequest(request);
|
||||
batchMapper.insert(apiDefinition);
|
||||
} else {
|
||||
if (StringUtils.equalsAnyIgnoreCase(apiDefinition.getProtocol(), RequestType.TCP)) {
|
||||
setImportTCPHashTree(apiDefinition);
|
||||
|
|
|
@ -637,7 +637,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
//导入的case,导入的接口是有ID的,所以导入的case已经标记过一遍接口ID了,这里是处理覆盖时接口ID的变动
|
||||
List<ApiTestCaseWithBLOBs> importCases = apiImport.getCases();
|
||||
List<ApiTestCaseWithBLOBs> optionDataCases = new ArrayList<>();
|
||||
//将ID全部置于null,覆盖的时候会增加ID,用以区分更新还是新增
|
||||
//将ID,num全部置于null,覆盖的时候会增加ID,用以区分更新还是新增
|
||||
removeRepeatCase(fullCoverage, importCases, optionDataCases);
|
||||
|
||||
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
|
||||
|
@ -803,11 +803,13 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
if (fullCoverage) {
|
||||
apiIdNameMap.forEach((k, v) -> {
|
||||
v.get(v.size() - 1).setId(null);
|
||||
v.get(v.size() - 1).setNum(null);
|
||||
optionDataCases.add(v.get(v.size() - 1));
|
||||
});
|
||||
} else {
|
||||
apiIdNameMap.forEach((k, v) -> {
|
||||
v.get(0).setId(null);
|
||||
v.get(0).setNum(null);
|
||||
optionDataCases.add(v.get(0));
|
||||
});
|
||||
}
|
||||
|
@ -1159,6 +1161,7 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs1 = oldCaseNameMap.get(name);
|
||||
if (apiTestCaseWithBLOBs1 != null) {
|
||||
caseWithBLOBs1.setId(apiTestCaseWithBLOBs1.getId());
|
||||
caseWithBLOBs1.setNum(apiTestCaseWithBLOBs1.getNum());
|
||||
caseWithBLOBs1.setVersion(apiTestCaseWithBLOBs1.getVersion() == null ? 0 : apiTestCaseWithBLOBs1.getVersion() + 1);
|
||||
oldCaseNameMap.remove(name);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue