From 31f09fb74f74162ff694818339f727eb30c05414 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 25 Oct 2022 13:58:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=AF=BC=E5=85=A5=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001018819 --user=郭雨琦 --- .../definition/ApiDefinitionService.java | 1 + .../service/definition/ApiModuleService.java | 28 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index 1c2d747336..7500ecd6f9 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -1174,6 +1174,7 @@ public class ApiDefinitionService { } else if (apiTestImportRequest.getCoverModule() != null && apiTestImportRequest.getCoverModule()) { apiDefinition.setUpdateTime(System.currentTimeMillis()); } + if (CollectionUtils.isEmpty(caseList)) { apiDefinition.setToBeUpdated(false); } else { diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java index 3c1fe2cb62..87b29beb83 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiModuleService.java @@ -1021,7 +1021,7 @@ public class ApiModuleService extends NodeTreeService { Map> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath)); repeatDataMap.forEach((k, v) -> { ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k); - if (apiDefinitionWithBLOBs == null){ + if (apiDefinitionWithBLOBs == null) { return; } Map> definitionIdCaseMAp = optionDataCases.stream().collect(Collectors.groupingBy(ApiTestCase::getApiDefinitionId)); @@ -1061,7 +1061,7 @@ public class ApiModuleService extends NodeTreeService { Map> oldCaseMap, Map esbApiParamsMap) { //覆盖但不覆盖模块 if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) { - return moduleMap; + return moduleMap; } //导入文件没有新增接口无需创建接口模块 moduleMap = judgeModule(moduleMap, nameModuleMap, repeatDataMap); @@ -1123,7 +1123,7 @@ public class ApiModuleService extends NodeTreeService { Map repeatDataMap, String updateVersionId, List optionDataCases, Map> oldCaseMap, Map esbApiParamsMap) { if (MapUtils.isEmpty(nameModuleMap) || MapUtils.isEmpty(repeatDataMap)) { - return; + return; } repeatDataMap.forEach((k, v) -> { ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = nameModuleMap.get(k); @@ -1304,7 +1304,7 @@ public class ApiModuleService extends NodeTreeService { List oldApiTestCases = oldCaseMap.get(definitionWithBLOBs.getId()); Map> oldCaseNameMap; - //如果重复用例有多个,则覆盖最后的那个 + //如果同名重复用例有多个,则覆盖最后的那个 if (CollectionUtils.isNotEmpty(oldApiTestCases)) { oldCaseNameMap = oldApiTestCases.stream().collect(Collectors.groupingBy(ApiTestCase::getName)); caseNameMap.forEach((name, importCaseWithBLOBs) -> { @@ -1332,17 +1332,15 @@ public class ApiModuleService extends NodeTreeService { } oldCaseNameMap.remove(name); } - //不同名的旧数据处理 - oldCaseNameMap.forEach((k, v) -> { - if (!StringUtils.equals(k, name)) { - if (CollectionUtils.isNotEmpty(v)) { - for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : v) { - apiTestCaseWithBLOBs.setVersionId("old_case"); - optionDataCases.add(apiTestCaseWithBLOBs); - } - } + }); + //不同名的旧数据处理 + oldCaseNameMap.forEach((k, v) -> { + if (CollectionUtils.isNotEmpty(v)) { + for (ApiTestCaseWithBLOBs apiTestCaseWithBLOBs : v) { + apiTestCaseWithBLOBs.setVersionId("old_case"); + optionDataCases.add(apiTestCaseWithBLOBs); } - }); + } }); } else { //否则直接给新增用例赋值新的接口ID @@ -1617,7 +1615,7 @@ public class ApiModuleService extends NodeTreeService { int i = 0; Map> idModuleMap = new HashMap<>(); 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); } String parentModulePath = parentModulePathMap.get(apiModuleDTO.getParentId());