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; }