From 2ebb114cba3ef44c42068bef843e3b2776710f83 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Wed, 17 Jul 2024 10:44:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=85=B3=E8=81=94?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E9=83=A8=E5=88=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/mapper/ExtTestPlanApiScenarioMapper.xml | 2 +- .../metersphere/plan/service/TestPlanApiCaseService.java | 1 + .../plan/service/TestPlanApiScenarioService.java | 1 + .../plan/service/TestPlanFunctionalCaseService.java | 2 +- .../metersphere/plan/service/TestPlanResourceService.java | 4 +++- .../plan/controller/TestPlanApiCaseControllerTests.java | 7 +++++++ .../controller/TestPlanApiScenarioControllerTests.java | 7 +++++++ .../plan/controller/TestPlanCaseControllerTests.java | 7 +++++++ 8 files changed, 28 insertions(+), 3 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml index 53dcbe7ccd..16866319b8 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml @@ -461,7 +461,7 @@ - and t.test_plan_collection_id = #{request.collectionId} + and test_plan_api_scenario.test_plan_collection_id = #{request.collectionId} diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java index 2bc43e0857..2b376e4269 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java @@ -588,6 +588,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService { super.checkCollection(testPlan.getId(), apiCase.getCollectionId(), CaseType.API_CASE.getKey()); boolean selectAllModule = apiCase.getModules().isSelectAllModule(); Map moduleMaps = apiCase.getModules().getModuleMaps(); + moduleMaps.remove(MODULE_ALL); if (selectAllModule) { // 选择了全部模块 List apiTestCaseList = extApiTestCaseMapper.selectAllApiCase(isRepeat, apiCase.getModules().getProjectId(), testPlan.getId()); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java index 1ba232075d..d99ce3098e 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java @@ -199,6 +199,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService { super.checkCollection(testPlan.getId(), apiScenario.getCollectionId(), CaseType.SCENARIO_CASE.getKey()); boolean selectAllModule = apiScenario.getModules().isSelectAllModule(); Map moduleMaps = apiScenario.getModules().getModuleMaps(); + moduleMaps.remove(MODULE_ALL); if (selectAllModule) { // 选择了全部模块 List scenarioList = extApiScenarioMapper.selectAllCase(isRepeat, apiScenario.getModules().getProjectId(), testPlan.getId()); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index 5d8ef17223..1f53d1b664 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -799,7 +799,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { super.checkCollection(testPlan.getId(), functional.getCollectionId(), CaseType.FUNCTIONAL_CASE.getKey()); boolean selectAllModule = functional.getModules().isSelectAllModule(); Map moduleMaps = functional.getModules().getModuleMaps(); - + moduleMaps.remove(MODULE_ALL); if (selectAllModule) { // 选择了全部模块 List functionalCaseList = extFunctionalCaseMapper.selectAllFunctionalCase(isRepeat, functional.getModules().getProjectId(), testPlan.getId()); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java index 91f35e216b..97170bc6c4 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanResourceService.java @@ -42,6 +42,8 @@ public abstract class TestPlanResourceService extends TestPlanSortService { @Resource private TestPlanCollectionMapper testPlanCollectionMapper; + public static final String MODULE_ALL = "all"; + /** * 取消关联资源od * @@ -118,7 +120,7 @@ public abstract class TestPlanResourceService extends TestPlanSortService { .toList(); // 全选的模块 List moduleIds = moduleMaps.entrySet().stream() - .filter(entry -> BooleanUtils.isTrue(entry.getValue().isSelectAll()) && org.apache.commons.collections.CollectionUtils.isEmpty(entry.getValue().getSelectIds())) + .filter(entry -> BooleanUtils.isTrue(entry.getValue().isSelectAll()) && CollectionUtils.isEmpty(entry.getValue().getSelectIds())) .map(Map.Entry::getKey) .toList(); diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java index 7cfd7e9df1..9e45884866 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiCaseControllerTests.java @@ -320,6 +320,13 @@ public class TestPlanApiCaseControllerTests extends BaseTest { associateDTO.setSelectAllModule(true); associateDTO.setAssociateType(type); associateDTO.setProjectId("wxx_1234"); + + Map moduleMap = new HashMap<>(); + ModuleSelectDTO moduleSelectDTO = new ModuleSelectDTO(); + moduleSelectDTO.setSelectAll(true); + moduleSelectDTO.setSelectIds(new ArrayList<>()); + moduleMap.put("123", moduleSelectDTO); + associateDTO.setModuleMaps(moduleMap); return associateDTO; } diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiScenarioControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiScenarioControllerTests.java index 4d41734e64..30a258f18f 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiScenarioControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanApiScenarioControllerTests.java @@ -309,6 +309,13 @@ public class TestPlanApiScenarioControllerTests extends BaseTest { associateDTO.setSelectAllModule(true); associateDTO.setAssociateType(AssociateCaseType.API_SCENARIO); associateDTO.setProjectId("wxx_project_1234"); + + Map moduleMap = new HashMap<>(); + ModuleSelectDTO moduleSelectDTO = new ModuleSelectDTO(); + moduleSelectDTO.setSelectAll(true); + moduleSelectDTO.setSelectIds(new ArrayList<>()); + moduleMap.put("wx_scenario_module_123", moduleSelectDTO); + associateDTO.setModuleMaps(moduleMap); return associateDTO; } diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java index 41193305b7..33b58028e8 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanCaseControllerTests.java @@ -409,6 +409,13 @@ public class TestPlanCaseControllerTests extends BaseTest { associateDTO.setSelectAllModule(true); associateDTO.setAssociateType(AssociateCaseType.FUNCTIONAL); associateDTO.setProjectId("123"); + + Map moduleMap = new HashMap<>(); + ModuleSelectDTO moduleSelectDTO = new ModuleSelectDTO(); + moduleSelectDTO.setSelectAll(true); + moduleSelectDTO.setSelectIds(new ArrayList<>()); + moduleMap.put("100001", moduleSelectDTO); + associateDTO.setModuleMaps(moduleMap); return associateDTO; }