fix(测试计划): 修复同步关联&重复关联问题
This commit is contained in:
parent
889fecd1ee
commit
6e0c20771e
|
@ -87,7 +87,7 @@ public interface ExtApiScenarioMapper {
|
|||
List<ApiScenario> selectAllCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
||||
|
||||
|
||||
List<ApiScenario> getListBySelectModules(@Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||
List<ApiScenario> getListBySelectModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<ApiScenario> getListBySelectIds(@Param("projectId") String projectId, @Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
|
||||
}
|
||||
|
|
|
@ -708,6 +708,11 @@
|
|||
<foreach collection="moduleIds" item="moduleId" open="(" separator="," close=")">
|
||||
#{moduleId}
|
||||
</foreach>
|
||||
<if test="!isRepeat">
|
||||
AND api_scenario.id not in (
|
||||
select api_scenario_id from test_plan_api_scenario where test_plan_id = #{testPlanId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getListBySelectIds" resultType="io.metersphere.api.domain.ApiScenario">
|
||||
|
|
|
@ -105,7 +105,7 @@ public interface ExtApiTestCaseMapper {
|
|||
|
||||
List<ApiTestCase> selectAllApiCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<ApiTestCase> getListBySelectModules(@Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||
List<ApiTestCase> getListBySelectModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<ApiTestCase> getListBySelectIds(@Param("projectId") String projectId, @Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
|
||||
|
||||
|
|
|
@ -649,6 +649,11 @@
|
|||
<foreach collection="moduleIds" item="moduleId" open="(" separator="," close=")">
|
||||
#{moduleId}
|
||||
</foreach>
|
||||
<if test="!isRepeat">
|
||||
AND api_test_case.id not in (
|
||||
select api_case_id from test_plan_api_case where test_plan_id = #{testPlanId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getListBySelectIds" resultType="io.metersphere.api.domain.ApiTestCase">
|
||||
|
|
|
@ -101,7 +101,7 @@ public interface ExtFunctionalCaseMapper {
|
|||
|
||||
List<FunctionalCase> selectAllFunctionalCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<FunctionalCase> getListBySelectModules(@Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||
List<FunctionalCase> getListBySelectModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<FunctionalCase> getListBySelectIds(@Param("projectId") String projectId, @Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
|
||||
}
|
||||
|
|
|
@ -930,6 +930,11 @@
|
|||
<foreach collection="moduleIds" item="moduleId" open="(" separator="," close=")">
|
||||
#{moduleId}
|
||||
</foreach>
|
||||
<if test="!isRepeat">
|
||||
AND functional_case.id not in (
|
||||
select functional_case_id from test_plan_functional_case where test_plan_id = #{testPlanId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ public interface ExtFunctionalCaseTestMapper {
|
|||
|
||||
List<TestPlanCaseExecuteHistoryDTO> getPlanExecuteHistoryList(@Param("caseId") String caseId, @Param("planId") String planId);
|
||||
|
||||
List<ApiTestCase> selectApiCaseByCaseIds(@Param("caseIds") List<String> caseIds);
|
||||
List<ApiTestCase> selectApiCaseByCaseIds(@Param("isRepeat") boolean isRepeat, @Param("caseIds") List<String> caseIds, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<ApiScenario> selectApiScenarioByCaseIds(@Param("caseIds") List<String> caseIds);
|
||||
List<ApiScenario> selectApiScenarioByCaseIds(@Param("isRepeat") boolean isRepeat, @Param("caseIds") List<String> caseIds, @Param("testPlanId") String testPlanId);
|
||||
|
||||
List<FunctionalCaseTest> selectApiAndScenarioIdsFromCaseIds(@Param("caseIds") List<String> functionalCaseIds);
|
||||
}
|
||||
|
|
|
@ -223,6 +223,11 @@
|
|||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="!isRepeat">
|
||||
AND api_test_case.id not in (
|
||||
select api_case_id from test_plan_api_case where test_plan_id = #{testPlanId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
|
@ -243,6 +248,11 @@
|
|||
#{caseId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="!isRepeat">
|
||||
AND api_scenario.id not in (
|
||||
select api_scenario_id from test_plan_api_scenario where test_plan_id = #{testPlanId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectApiAndScenarioIdsFromCaseIds"
|
||||
resultType="io.metersphere.functional.domain.FunctionalCaseTest">
|
||||
|
|
|
@ -596,7 +596,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
List<ApiTestCase> apiTestCaseList = new ArrayList<>();
|
||||
//获取全选的模块数据
|
||||
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||
apiTestCaseList = extApiTestCaseMapper.getListBySelectModules(apiCase.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
apiTestCaseList = extApiTestCaseMapper.getListBySelectModules(isRepeat, apiCase.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||
|
@ -638,7 +638,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
List<ApiTestCase> apiTestCaseList = new ArrayList<>();
|
||||
//获取全选的模块数据
|
||||
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||
apiTestCaseList = extApiTestCaseMapper.getListBySelectModules(apiCase.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
apiTestCaseList = extApiTestCaseMapper.getListBySelectModules(isRepeat, apiCase.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||
|
|
|
@ -207,7 +207,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
List<ApiScenario> scenarioList = new ArrayList<>();
|
||||
//获取全选的模块数据
|
||||
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||
scenarioList = extApiScenarioMapper.getListBySelectModules(apiScenario.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
scenarioList = extApiScenarioMapper.getListBySelectModules(isRepeat, apiScenario.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||
|
|
|
@ -806,13 +806,13 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
// 选择了全部模块
|
||||
List<FunctionalCase> functionalCaseList = extFunctionalCaseMapper.selectAllFunctionalCase(isRepeat, functional.getModules().getProjectId(), testPlan.getId());
|
||||
buildTestPlanFunctionalCaseDTO(functional, functionalCaseList, testPlan, user, testPlanFunctionalCaseList);
|
||||
handleSyncCase(functionalCaseList, functional, testPlan, user);
|
||||
handleSyncCase(isRepeat, functionalCaseList, functional, testPlan, user);
|
||||
} else {
|
||||
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
||||
List<FunctionalCase> functionalCaseList = new ArrayList<>();
|
||||
//获取全选的模块数据
|
||||
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||
functionalCaseList = extFunctionalCaseMapper.getListBySelectModules(functional.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
functionalCaseList = extFunctionalCaseMapper.getListBySelectModules(isRepeat, functional.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||
|
@ -831,7 +831,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
if (CollectionUtils.isNotEmpty(functionalCaseList)) {
|
||||
List<FunctionalCase> list = functionalCaseList.stream().sorted(Comparator.comparing(FunctionalCase::getPos).reversed()).toList();
|
||||
buildTestPlanFunctionalCaseDTO(functional, list, testPlan, user, testPlanFunctionalCaseList);
|
||||
handleSyncCase(functionalCaseList, functional, testPlan, user);
|
||||
handleSyncCase(isRepeat, functionalCaseList, functional, testPlan, user);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -841,30 +841,32 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
/**
|
||||
* 处理同步添加功能用例关联的用例
|
||||
*
|
||||
* @param isRepeat
|
||||
* @param functionalCaseList
|
||||
* @param functional
|
||||
* @param testPlan
|
||||
* @param user
|
||||
*/
|
||||
private void handleSyncCase(List<FunctionalCase> functionalCaseList, BaseCollectionAssociateRequest functional, TestPlan testPlan, SessionUser user) {
|
||||
private void handleSyncCase(boolean isRepeat, List<FunctionalCase> functionalCaseList, BaseCollectionAssociateRequest functional, TestPlan testPlan, SessionUser user) {
|
||||
if (BooleanUtils.isTrue(functional.getModules().isSyncCase())) {
|
||||
handleApiCaseData(functionalCaseList, functional, testPlan, user);
|
||||
handleApiScenarioData(functionalCaseList, functional, testPlan, user);
|
||||
handleApiCaseData(isRepeat, functionalCaseList, functional, testPlan, user);
|
||||
handleApiScenarioData(isRepeat, functionalCaseList, functional, testPlan, user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理场景用例数据
|
||||
*
|
||||
* @param isRepeat
|
||||
* @param functionalCaseList
|
||||
* @param functional
|
||||
* @param testPlan
|
||||
* @param user
|
||||
*/
|
||||
private void handleApiScenarioData(List<FunctionalCase> functionalCaseList, BaseCollectionAssociateRequest functional, TestPlan testPlan, SessionUser user) {
|
||||
private void handleApiScenarioData(boolean isRepeat, List<FunctionalCase> functionalCaseList, BaseCollectionAssociateRequest functional, TestPlan testPlan, SessionUser user) {
|
||||
if (StringUtils.isNotBlank(functional.getModules().getApiScenarioCollectionId()) && checkApiCollection(testPlan, functional.getModules().getApiScenarioCollectionId(), CaseType.SCENARIO_CASE.getKey())) {
|
||||
List<String> caseIds = functionalCaseList.stream().map(FunctionalCase::getId).toList();
|
||||
List<ApiScenario> scenarioList = extFunctionalCaseTestMapper.selectApiScenarioByCaseIds(caseIds);
|
||||
List<ApiScenario> scenarioList = extFunctionalCaseTestMapper.selectApiScenarioByCaseIds(isRepeat, caseIds, testPlan.getId());
|
||||
List<TestPlanApiScenario> testPlanApiScenarioList = new ArrayList<>();
|
||||
testPlanApiScenarioService.buildTestPlanApiScenarioDTO(functional.getModules().getApiScenarioCollectionId(), scenarioList, testPlan, user, testPlanApiScenarioList);
|
||||
if (CollectionUtils.isNotEmpty(testPlanApiScenarioList)) {
|
||||
|
@ -881,10 +883,10 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
* @param testPlan
|
||||
* @param user
|
||||
*/
|
||||
private void handleApiCaseData(List<FunctionalCase> functionalCaseList, BaseCollectionAssociateRequest functional, TestPlan testPlan, SessionUser user) {
|
||||
private void handleApiCaseData(boolean isRepeat, List<FunctionalCase> functionalCaseList, BaseCollectionAssociateRequest functional, TestPlan testPlan, SessionUser user) {
|
||||
if (StringUtils.isNotBlank(functional.getModules().getApiCaseCollectionId()) && checkApiCollection(testPlan, functional.getModules().getApiCaseCollectionId(), CaseType.API_CASE.getKey())) {
|
||||
List<String> caseIds = functionalCaseList.stream().map(FunctionalCase::getId).toList();
|
||||
List<ApiTestCase> apiTestCaseList = extFunctionalCaseTestMapper.selectApiCaseByCaseIds(caseIds);
|
||||
List<ApiTestCase> apiTestCaseList = extFunctionalCaseTestMapper.selectApiCaseByCaseIds(isRepeat, caseIds, testPlan.getId());
|
||||
List<TestPlanApiCase> testPlanApiCaseList = new ArrayList<>();
|
||||
testPlanApiCaseService.buildTestPlanApiCaseDTO(functional.getModules().getApiCaseCollectionId(), apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
||||
if (CollectionUtils.isNotEmpty(testPlanApiCaseList)) {
|
||||
|
|
Loading…
Reference in New Issue