fix(接口测试):解决接口导入覆盖内容变化更新时间不变问题

--bug=1024797 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001024797
This commit is contained in:
guoyuqi 2023-03-29 13:39:27 +08:00 committed by fit2-zhao
parent d6c41373ac
commit 4747691abc
1 changed files with 8 additions and 8 deletions

View File

@ -267,7 +267,7 @@ public class ApiDefinitionImportUtilService {
if (item.getVersionId() == null || (!item.getVersionId().equals("new") && !item.getVersionId().equals("update"))) { if (item.getVersionId() == null || (!item.getVersionId().equals("new") && !item.getVersionId().equals("update"))) {
item.setNum(num++); item.setNum(num++);
} }
//如果EsbData需要存储,则需要进行接口是否更新的判断
ApiDefinitionImportParamDTO apiDefinitionImportParam = new ApiDefinitionImportParamDTO(item, request, apiImport.getMocks(), toUpdateList, caseList); ApiDefinitionImportParamDTO apiDefinitionImportParam = new ApiDefinitionImportParamDTO(item, request, apiImport.getMocks(), toUpdateList, caseList);
apiDefinitionImportParam.setRepeatList(sameRefIds); apiDefinitionImportParam.setRepeatList(sameRefIds);
ApiImportSendNoticeDTO apiImportSendNoticeDTO = importCreate(batchMapper, apiDefinitionImportParam); ApiImportSendNoticeDTO apiImportSendNoticeDTO = importCreate(batchMapper, apiDefinitionImportParam);
@ -754,17 +754,13 @@ public class ApiDefinitionImportUtilService {
if (CollectionUtils.isEmpty(repeatList)) { if (CollectionUtils.isEmpty(repeatList)) {
return; return;
} }
if (apiDefinition.getLatest()) { for (ApiDefinitionWithBLOBs apiDefinitionWithBLOBs : repeatList) {
for (ApiDefinitionWithBLOBs apiDefinitionWithBLOBs : repeatList) { if (!apiDefinition.getId().equalsIgnoreCase(apiDefinitionWithBLOBs.getId())) {
if (apiDefinitionWithBLOBs.getLatest() && !apiDefinition.getId().equalsIgnoreCase(apiDefinitionWithBLOBs.getId())) { if (apiDefinition.getLatest() && apiDefinitionWithBLOBs.getLatest()) {
apiDefinitionWithBLOBs.setLatest(false); apiDefinitionWithBLOBs.setLatest(false);
} }
batchMapper.updateByPrimaryKey(apiDefinitionWithBLOBs); batchMapper.updateByPrimaryKey(apiDefinitionWithBLOBs);
} }
} else {
for (ApiDefinitionWithBLOBs apiDefinitionWithBLOBs : repeatList) {
batchMapper.updateByPrimaryKey(apiDefinitionWithBLOBs);
}
} }
} }
@ -947,7 +943,9 @@ public class ApiDefinitionImportUtilService {
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) {
//要去覆盖接口的集合
List<ApiDefinitionWithBLOBs> coverApiList = new ArrayList<>(); List<ApiDefinitionWithBLOBs> coverApiList = new ArrayList<>();
//记录已存在数据可以被更新的集合
List<ApiDefinitionWithBLOBs> updateApiList = new ArrayList<>(); List<ApiDefinitionWithBLOBs> updateApiList = new ArrayList<>();
repeatDataMap.forEach((k, v) -> { repeatDataMap.forEach((k, v) -> {
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k); ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k);
@ -956,11 +954,13 @@ public class ApiDefinitionImportUtilService {
Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId)); Map<String, List<ApiTestCaseWithBLOBs>> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId));
Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs); Map<String, ApiTestCaseWithBLOBs> caseNameMap = getDistinctCaseNameMap(definitionIdCaseMAp, apiDefinitionWithBLOBs);
int i = 0; int i = 0;
//定义最新版本
ApiDefinitionWithBLOBs latestApi = null; ApiDefinitionWithBLOBs latestApi = null;
for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) { for (ApiDefinitionWithBLOBs definitionWithBLOBs : v) {
if (definitionWithBLOBs.getLatest()) { if (definitionWithBLOBs.getLatest()) {
latestApi = definitionWithBLOBs; latestApi = definitionWithBLOBs;
} }
//为了记录指定版本是否有数据
if (!definitionWithBLOBs.getVersionId().equals(updateVersionId)) { if (!definitionWithBLOBs.getVersionId().equals(updateVersionId)) {
i += 1; i += 1;
continue; continue;