refactor(测试计划): 测试计划关联用例部分调整

This commit is contained in:
WangXu10 2024-07-17 10:44:47 +08:00 committed by 刘瑞斌
parent 711e25bb83
commit 2ebb114cba
8 changed files with 28 additions and 3 deletions

View File

@ -461,7 +461,7 @@
</foreach>
</if>
<if test="request.collectionId != null and request.collectionId != ''">
and t.test_plan_collection_id = #{request.collectionId}
and test_plan_api_scenario.test_plan_collection_id = #{request.collectionId}
</if>
<include refid="filters">
<property name="filter" value="request.condition.filter"/>

View File

@ -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<String, ModuleSelectDTO> moduleMaps = apiCase.getModules().getModuleMaps();
moduleMaps.remove(MODULE_ALL);
if (selectAllModule) {
// 选择了全部模块
List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectAllApiCase(isRepeat, apiCase.getModules().getProjectId(), testPlan.getId());

View File

@ -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<String, ModuleSelectDTO> moduleMaps = apiScenario.getModules().getModuleMaps();
moduleMaps.remove(MODULE_ALL);
if (selectAllModule) {
// 选择了全部模块
List<ApiScenario> scenarioList = extApiScenarioMapper.selectAllCase(isRepeat, apiScenario.getModules().getProjectId(), testPlan.getId());

View File

@ -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<String, ModuleSelectDTO> moduleMaps = functional.getModules().getModuleMaps();
moduleMaps.remove(MODULE_ALL);
if (selectAllModule) {
// 选择了全部模块
List<FunctionalCase> functionalCaseList = extFunctionalCaseMapper.selectAllFunctionalCase(isRepeat, functional.getModules().getProjectId(), testPlan.getId());

View File

@ -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<String> 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();

View File

@ -320,6 +320,13 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
associateDTO.setSelectAllModule(true);
associateDTO.setAssociateType(type);
associateDTO.setProjectId("wxx_1234");
Map<String, ModuleSelectDTO> moduleMap = new HashMap<>();
ModuleSelectDTO moduleSelectDTO = new ModuleSelectDTO();
moduleSelectDTO.setSelectAll(true);
moduleSelectDTO.setSelectIds(new ArrayList<>());
moduleMap.put("123", moduleSelectDTO);
associateDTO.setModuleMaps(moduleMap);
return associateDTO;
}

View File

@ -309,6 +309,13 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
associateDTO.setSelectAllModule(true);
associateDTO.setAssociateType(AssociateCaseType.API_SCENARIO);
associateDTO.setProjectId("wxx_project_1234");
Map<String, ModuleSelectDTO> 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;
}

View File

@ -409,6 +409,13 @@ public class TestPlanCaseControllerTests extends BaseTest {
associateDTO.setSelectAllModule(true);
associateDTO.setAssociateType(AssociateCaseType.FUNCTIONAL);
associateDTO.setProjectId("123");
Map<String, ModuleSelectDTO> moduleMap = new HashMap<>();
ModuleSelectDTO moduleSelectDTO = new ModuleSelectDTO();
moduleSelectDTO.setSelectAll(true);
moduleSelectDTO.setSelectIds(new ArrayList<>());
moduleMap.put("100001", moduleSelectDTO);
associateDTO.setModuleMaps(moduleMap);
return associateDTO;
}