refactor(测试计划): 测试计划关联用例优化
This commit is contained in:
parent
bb8833b03c
commit
0e06314dbb
|
@ -86,5 +86,8 @@ public interface ExtApiScenarioMapper {
|
||||||
|
|
||||||
List<ApiScenario> selectAllCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
List<ApiScenario> selectAllCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
||||||
|
|
||||||
List<ApiScenario> selectCaseByModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("dto") AssociateCaseDTO dto, @Param("testPlanId") String testPlanId);
|
|
||||||
|
List<ApiScenario> getListBySelectModules(@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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -694,38 +694,36 @@
|
||||||
order by api_scenario.pos asc
|
order by api_scenario.pos asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCaseByModules" resultType="io.metersphere.api.domain.ApiScenario">
|
<select id="getListBySelectModules" resultType="io.metersphere.api.domain.ApiScenario">
|
||||||
select
|
select
|
||||||
api_scenario.id,
|
api_scenario.id,
|
||||||
api_scenario.create_user,
|
api_scenario.create_user,
|
||||||
api_scenario.environment_id,
|
api_scenario.environment_id,
|
||||||
api_scenario.grouped
|
api_scenario.grouped,
|
||||||
|
api_scenario.pos
|
||||||
from api_scenario
|
from api_scenario
|
||||||
where api_scenario.deleted = false
|
where api_scenario.deleted = false
|
||||||
and api_scenario.project_id = #{projectId}
|
and api_scenario.project_id = #{projectId}
|
||||||
<if test="!isRepeat">
|
and api_scenario.module_id in
|
||||||
AND api_scenario.id not in (
|
<foreach collection="moduleIds" item="moduleId" open="(" separator="," close=")">
|
||||||
select test_plan_api_scenario.api_scenario_id from test_plan_api_scenario where test_plan_api_scenario.test_plan_id = #{testPlanId}
|
#{moduleId}
|
||||||
)
|
</foreach>
|
||||||
</if>
|
|
||||||
<if test="dto.moduleIds != null and dto.moduleIds.size() > 0">
|
|
||||||
and api_scenario.module_id in
|
|
||||||
<foreach collection="dto.moduleIds" item="moduleId" open="(" separator="," close=")">
|
|
||||||
#{moduleId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="dto.excludeIds != null and dto.excludeIds.size() > 0">
|
|
||||||
AND api_scenario.id not in
|
|
||||||
<foreach collection="dto.excludeIds" item="excludeId" separator="," open="(" close=")">
|
|
||||||
#{excludeId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="dto.selectIds != null and dto.selectIds.size() > 0">
|
|
||||||
or api_scenario.id in
|
|
||||||
<foreach collection="dto.selectIds" item="selectId" separator="," open="(" close=")">
|
|
||||||
#{selectId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
order by api_scenario.pos asc
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getListBySelectIds" resultType="io.metersphere.api.domain.ApiScenario">
|
||||||
|
select
|
||||||
|
api_scenario.id,
|
||||||
|
api_scenario.create_user,
|
||||||
|
api_scenario.environment_id,
|
||||||
|
api_scenario.grouped,
|
||||||
|
api_scenario.pos
|
||||||
|
from api_scenario
|
||||||
|
where api_scenario.deleted = false
|
||||||
|
and api_scenario.project_id = #{projectId}
|
||||||
|
and api_scenario.id in
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -105,7 +105,9 @@ public interface ExtApiTestCaseMapper {
|
||||||
|
|
||||||
List<ApiTestCase> selectAllApiCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
List<ApiTestCase> selectAllApiCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
||||||
|
|
||||||
List<ApiTestCase> selectCaseByModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("dto") AssociateCaseDTO dto, @Param("testPlanId") String testPlanId);
|
List<ApiTestCase> getListBySelectModules(@Param("projectId") String projectId, @Param("moduleIds") List<String> moduleIds, @Param("testPlanId") String testPlanId);
|
||||||
|
|
||||||
List<ApiTestCase> selectCaseByApiModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("dto") AssociateCaseDTO dto, @Param("testPlanId") String testPlanId);
|
List<ApiTestCase> getListBySelectIds(@Param("projectId") String projectId, @Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
|
||||||
|
|
||||||
|
List<ApiTestCase> getCaseListBySelectIds(@Param("projectId") String projectId, @Param("ids") List<String> ids, @Param("testPlanId") String testPlanId);
|
||||||
}
|
}
|
|
@ -634,75 +634,55 @@
|
||||||
order by api_test_case.pos asc
|
order by api_test_case.pos asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCaseByModules" resultType="io.metersphere.api.domain.ApiTestCase">
|
|
||||||
|
<select id="getListBySelectModules" resultType="io.metersphere.api.domain.ApiTestCase">
|
||||||
select
|
select
|
||||||
api_test_case.id,
|
api_test_case.id,
|
||||||
api_test_case.create_user,
|
api_test_case.create_user,
|
||||||
api_test_case.environment_id
|
api_test_case.environment_id,
|
||||||
|
api_test_case.pos
|
||||||
from api_test_case
|
from api_test_case
|
||||||
inner join api_definition on api_definition.id = api_test_case.api_definition_id
|
inner join api_definition on api_definition.id = api_test_case.api_definition_id
|
||||||
where api_test_case.deleted = false
|
where api_test_case.deleted = false
|
||||||
and api_test_case.project_id = #{projectId}
|
and api_test_case.project_id = #{projectId}
|
||||||
<if test="!isRepeat">
|
and api_definition.module_id in
|
||||||
AND api_test_case.id not in (
|
<foreach collection="moduleIds" item="moduleId" open="(" separator="," close=")">
|
||||||
select test_plan_api_case.api_case_id from test_plan_api_case where test_plan_api_case.test_plan_id = #{testPlanId}
|
#{moduleId}
|
||||||
)
|
</foreach>
|
||||||
</if>
|
|
||||||
<if test="dto.moduleIds != null and dto.moduleIds.size() > 0">
|
|
||||||
and api_definition.module_id in
|
|
||||||
<foreach collection="dto.moduleIds" item="moduleId" open="(" separator="," close=")">
|
|
||||||
#{moduleId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="dto.excludeIds != null and dto.excludeIds.size() > 0">
|
|
||||||
AND api_test_case.id not in
|
|
||||||
<foreach collection="dto.excludeIds" item="excludeId" separator="," open="(" close=")">
|
|
||||||
#{excludeId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="dto.selectIds != null and dto.selectIds.size() > 0">
|
|
||||||
or api_test_case.id in
|
|
||||||
<foreach collection="dto.selectIds" item="selectId" separator="," open="(" close=")">
|
|
||||||
#{selectId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
order by api_test_case.pos asc
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCaseByApiModules" resultType="io.metersphere.api.domain.ApiTestCase">
|
<select id="getListBySelectIds" resultType="io.metersphere.api.domain.ApiTestCase">
|
||||||
select
|
select
|
||||||
api_test_case.id,
|
api_test_case.id,
|
||||||
api_test_case.create_user,
|
api_test_case.create_user,
|
||||||
api_test_case.environment_id
|
api_test_case.environment_id,
|
||||||
|
api_test_case.pos
|
||||||
from api_test_case
|
from api_test_case
|
||||||
inner join api_definition on api_definition.id = api_test_case.api_definition_id
|
inner join api_definition on api_definition.id = api_test_case.api_definition_id
|
||||||
where api_test_case.deleted = false
|
where api_test_case.deleted = false
|
||||||
and api_test_case.project_id = #{projectId}
|
and api_test_case.project_id = #{projectId}
|
||||||
<if test="!isRepeat">
|
AND api_test_case.id in
|
||||||
AND api_test_case.id not in (
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
select test_plan_api_case.api_case_id from test_plan_api_case where test_plan_api_case.test_plan_id =
|
#{id}
|
||||||
#{testPlanId}
|
</foreach>
|
||||||
)
|
|
||||||
</if>
|
|
||||||
<if test="dto.moduleIds != null and dto.moduleIds.size() > 0">
|
|
||||||
and api_definition.module_id in
|
|
||||||
<foreach collection="dto.moduleIds" item="moduleId" open="(" separator="," close=")">
|
|
||||||
#{moduleId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="dto.excludeIds != null and dto.excludeIds.size() > 0">
|
|
||||||
AND api_definition.id not in
|
|
||||||
<foreach collection="dto.excludeIds" item="excludeId" separator="," open="(" close=")">
|
|
||||||
#{excludeId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<if test="dto.selectIds != null and dto.selectIds.size() > 0">
|
|
||||||
or api_definition.id in
|
|
||||||
<foreach collection="dto.selectIds" item="selectId" separator="," open="(" close=")">
|
|
||||||
#{selectId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
order by api_test_case.pos asc
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getCaseListBySelectIds" resultType="io.metersphere.api.domain.ApiTestCase">
|
||||||
|
select
|
||||||
|
api_test_case.id,
|
||||||
|
api_test_case.create_user,
|
||||||
|
api_test_case.environment_id,
|
||||||
|
api_test_case.pos
|
||||||
|
from api_test_case
|
||||||
|
inner join api_definition on api_definition.id = api_test_case.api_definition_id
|
||||||
|
where api_test_case.deleted = false
|
||||||
|
and api_test_case.project_id = #{projectId}
|
||||||
|
and api_definition.id in
|
||||||
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -11,7 +11,6 @@ import io.metersphere.functional.request.*;
|
||||||
import io.metersphere.project.dto.ModuleCountDTO;
|
import io.metersphere.project.dto.ModuleCountDTO;
|
||||||
import io.metersphere.request.AssociateOtherCaseRequest;
|
import io.metersphere.request.AssociateOtherCaseRequest;
|
||||||
import io.metersphere.request.TestCasePageProviderRequest;
|
import io.metersphere.request.TestCasePageProviderRequest;
|
||||||
import io.metersphere.sdk.dto.AssociateCaseDTO;
|
|
||||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@ -102,5 +101,7 @@ public interface ExtFunctionalCaseMapper {
|
||||||
|
|
||||||
List<FunctionalCase> selectAllFunctionalCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
List<FunctionalCase> selectAllFunctionalCase(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("testPlanId") String testPlanId);
|
||||||
|
|
||||||
List<FunctionalCase> selectCaseByModules(@Param("isRepeat") boolean isRepeat, @Param("projectId") String projectId, @Param("dto") AssociateCaseDTO dto, @Param("testPlanId") String testPlanId);
|
List<FunctionalCase> getListBySelectModules(@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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -918,36 +918,32 @@
|
||||||
order by functional_case.pos asc
|
order by functional_case.pos asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCaseByModules" resultType="io.metersphere.functional.domain.FunctionalCase">
|
<select id="getListBySelectModules" resultType="io.metersphere.functional.domain.FunctionalCase">
|
||||||
select
|
select
|
||||||
functional_case.id,
|
functional_case.id,
|
||||||
functional_case.create_user
|
functional_case.create_user,
|
||||||
|
functional_case.pos
|
||||||
from functional_case
|
from functional_case
|
||||||
where functional_case.deleted = false
|
where functional_case.deleted = false
|
||||||
and functional_case.project_id = #{projectId}
|
and functional_case.project_id = #{projectId}
|
||||||
<if test="!isRepeat">
|
and functional_case.module_id in
|
||||||
AND functional_case.id not in (
|
<foreach collection="moduleIds" item="moduleId" open="(" separator="," close=")">
|
||||||
select test_plan_functional_case.functional_case_id from test_plan_functional_case where test_plan_functional_case.test_plan_id = #{testPlanId}
|
#{moduleId}
|
||||||
)
|
</foreach>
|
||||||
</if>
|
</select>
|
||||||
<if test="dto.moduleIds != null and dto.moduleIds.size() > 0">
|
|
||||||
and functional_case.module_id in
|
|
||||||
<foreach collection="dto.moduleIds" item="moduleId" open="(" separator="," close=")">
|
<select id="getListBySelectIds" resultType="io.metersphere.functional.domain.FunctionalCase">
|
||||||
#{moduleId}
|
select
|
||||||
</foreach>
|
functional_case.id,
|
||||||
</if>
|
functional_case.create_user,
|
||||||
<if test="dto.excludeIds != null and dto.excludeIds.size() > 0">
|
functional_case.pos
|
||||||
AND functional_case.id not in
|
from functional_case
|
||||||
<foreach collection="dto.excludeIds" item="excludeId" separator="," open="(" close=")">
|
where functional_case.deleted = false
|
||||||
#{excludeId}
|
and functional_case.project_id = #{projectId}
|
||||||
</foreach>
|
and functional_case.id in
|
||||||
</if>
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||||
<if test="dto.selectIds != null and dto.selectIds.size() > 0">
|
#{id}
|
||||||
or functional_case.id in
|
</foreach>
|
||||||
<foreach collection="dto.selectIds" item="selectId" separator="," open="(" close=")">
|
|
||||||
#{selectId}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
order by functional_case.pos asc
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -595,8 +595,30 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
||||||
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
||||||
} else {
|
} else {
|
||||||
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
||||||
List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectCaseByModules(isRepeat, apiCase.getModules().getProjectId(), dto, testPlan.getId());
|
List<ApiTestCase> apiTestCaseList = new ArrayList<>();
|
||||||
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
//获取全选的模块数据
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||||
|
apiTestCaseList = extApiTestCaseMapper.getListBySelectModules(apiCase.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||||
|
CollectionUtils.removeAll(dto.getSelectIds(), apiTestCaseList.stream().map(ApiTestCase::getId).toList());
|
||||||
|
//获取选中的ids数据
|
||||||
|
List<ApiTestCase> selectIdList = extApiTestCaseMapper.getListBySelectIds(apiCase.getModules().getProjectId(), dto.getSelectIds(), testPlan.getId());
|
||||||
|
apiTestCaseList.addAll(selectIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getExcludeIds())) {
|
||||||
|
//排除的ids
|
||||||
|
List<String> excludeIds = dto.getExcludeIds();
|
||||||
|
apiTestCaseList = apiTestCaseList.stream().filter(item -> !excludeIds.contains(item.getId())).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(apiTestCaseList)) {
|
||||||
|
List<ApiTestCase> list = apiTestCaseList.stream().sorted(Comparator.comparing(ApiTestCase::getPos).reversed()).toList();
|
||||||
|
buildTestPlanApiCaseDTO(apiCase, list, testPlan, user, testPlanApiCaseList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -615,8 +637,30 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
||||||
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
||||||
} else {
|
} else {
|
||||||
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
||||||
List<ApiTestCase> apiTestCaseList = extApiTestCaseMapper.selectCaseByApiModules(isRepeat, apiCase.getModules().getProjectId(), dto, testPlan.getId());
|
List<ApiTestCase> apiTestCaseList = new ArrayList<>();
|
||||||
buildTestPlanApiCaseDTO(apiCase, apiTestCaseList, testPlan, user, testPlanApiCaseList);
|
//获取全选的模块数据
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||||
|
apiTestCaseList = extApiTestCaseMapper.getListBySelectModules(apiCase.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||||
|
CollectionUtils.removeAll(dto.getSelectIds(), apiTestCaseList.stream().map(ApiTestCase::getId).toList());
|
||||||
|
//获取选中的ids数据
|
||||||
|
List<ApiTestCase> selectIdList = extApiTestCaseMapper.getCaseListBySelectIds(apiCase.getModules().getProjectId(), dto.getSelectIds(), testPlan.getId());
|
||||||
|
apiTestCaseList.addAll(selectIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getExcludeIds())) {
|
||||||
|
//排除的ids
|
||||||
|
List<String> excludeIds = dto.getExcludeIds();
|
||||||
|
apiTestCaseList = apiTestCaseList.stream().filter(item -> !excludeIds.contains(item.getId())).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(apiTestCaseList)) {
|
||||||
|
List<ApiTestCase> list = apiTestCaseList.stream().sorted(Comparator.comparing(ApiTestCase::getPos).reversed()).toList();
|
||||||
|
buildTestPlanApiCaseDTO(apiCase, list, testPlan, user, testPlanApiCaseList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -206,8 +203,30 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
||||||
buildTestPlanApiScenarioDTO(apiScenario, scenarioList, testPlan, user, testPlanApiScenarioList);
|
buildTestPlanApiScenarioDTO(apiScenario, scenarioList, testPlan, user, testPlanApiScenarioList);
|
||||||
} else {
|
} else {
|
||||||
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
||||||
List<ApiScenario> scenarioList = extApiScenarioMapper.selectCaseByModules(isRepeat, apiScenario.getModules().getProjectId(), dto, testPlan.getId());
|
List<ApiScenario> scenarioList = new ArrayList<>();
|
||||||
buildTestPlanApiScenarioDTO(apiScenario, scenarioList, testPlan, user, testPlanApiScenarioList);
|
//获取全选的模块数据
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||||
|
scenarioList = extApiScenarioMapper.getListBySelectModules(apiScenario.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||||
|
CollectionUtils.removeAll(dto.getSelectIds(), scenarioList.stream().map(ApiScenario::getId).toList());
|
||||||
|
//获取选中的ids数据
|
||||||
|
List<ApiScenario> selectIdList = extApiScenarioMapper.getListBySelectIds(apiScenario.getModules().getProjectId(), dto.getSelectIds(), testPlan.getId());
|
||||||
|
scenarioList.addAll(selectIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getExcludeIds())) {
|
||||||
|
//排除的ids
|
||||||
|
List<String> excludeIds = dto.getExcludeIds();
|
||||||
|
scenarioList = scenarioList.stream().filter(item -> !excludeIds.contains(item.getId())).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(scenarioList)) {
|
||||||
|
List<ApiScenario> list = scenarioList.stream().sorted(Comparator.comparing(ApiScenario::getPos).reversed()).toList();
|
||||||
|
buildTestPlanApiScenarioDTO(apiScenario, list, testPlan, user, testPlanApiScenarioList);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,9 +807,31 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
||||||
handleSyncCase(functionalCaseList, functional, testPlan, user);
|
handleSyncCase(functionalCaseList, functional, testPlan, user);
|
||||||
} else {
|
} else {
|
||||||
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
AssociateCaseDTO dto = super.getCaseIds(moduleMaps);
|
||||||
List<FunctionalCase> functionalCaseList = extFunctionalCaseMapper.selectCaseByModules(isRepeat, functional.getModules().getProjectId(), dto, testPlan.getId());
|
List<FunctionalCase> functionalCaseList = new ArrayList<>();
|
||||||
buildTestPlanFunctionalCaseDTO(functional, functionalCaseList, testPlan, user, testPlanFunctionalCaseList);
|
//获取全选的模块数据
|
||||||
handleSyncCase(functionalCaseList, functional, testPlan, user);
|
if (CollectionUtils.isNotEmpty(dto.getModuleIds())) {
|
||||||
|
functionalCaseList = extFunctionalCaseMapper.getListBySelectModules(functional.getModules().getProjectId(), dto.getModuleIds(), testPlan.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getSelectIds())) {
|
||||||
|
CollectionUtils.removeAll(dto.getSelectIds(), functionalCaseList.stream().map(FunctionalCase::getId).toList());
|
||||||
|
//获取选中的ids数据
|
||||||
|
List<FunctionalCase> selectIdList = extFunctionalCaseMapper.getListBySelectIds(functional.getModules().getProjectId(), dto.getSelectIds(), testPlan.getId());
|
||||||
|
functionalCaseList.addAll(selectIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(dto.getExcludeIds())) {
|
||||||
|
//排除的ids
|
||||||
|
List<String> excludeIds = dto.getExcludeIds();
|
||||||
|
functionalCaseList = functionalCaseList.stream().filter(item -> !excludeIds.contains(item.getId())).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,9 +115,9 @@ public abstract class TestPlanResourceService extends TestPlanSortService {
|
||||||
.flatMap(moduleSelectDTO -> moduleSelectDTO.getExcludeIds().stream())
|
.flatMap(moduleSelectDTO -> moduleSelectDTO.getExcludeIds().stream())
|
||||||
.toList();
|
.toList();
|
||||||
// 选中的ids
|
// 选中的ids
|
||||||
List<String> selectIds = moduleMaps.entrySet().stream()
|
List<String> selectIds = moduleMaps.values().stream()
|
||||||
.filter(entry -> BooleanUtils.isFalse(entry.getValue().isSelectAll()) && CollectionUtils.isNotEmpty(entry.getValue().getSelectIds()))
|
.filter(moduleSelectDTO -> BooleanUtils.isFalse(moduleSelectDTO.isSelectAll()) && CollectionUtils.isNotEmpty(moduleSelectDTO.getSelectIds()))
|
||||||
.map(Map.Entry::getKey)
|
.flatMap(moduleSelectDTO -> moduleSelectDTO.getSelectIds().stream())
|
||||||
.toList();
|
.toList();
|
||||||
// 全选的模块
|
// 全选的模块
|
||||||
List<String> moduleIds = moduleMaps.entrySet().stream()
|
List<String> moduleIds = moduleMaps.entrySet().stream()
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
|
||||||
collectionAssociates1.put(AssociateCaseType.API_CASE, baseCollectionAssociateRequests1);
|
collectionAssociates1.put(AssociateCaseType.API_CASE, baseCollectionAssociateRequests1);
|
||||||
testPlanApiCaseService.associateCollection("wxxx_1", collectionAssociates1, user);
|
testPlanApiCaseService.associateCollection("wxxx_1", collectionAssociates1, user);
|
||||||
|
|
||||||
baseCollectionAssociateRequest1.setModules(buildModules(AssociateCaseType.API));
|
baseCollectionAssociateRequest1.setModules(buildModules(AssociateCaseType.API_CASE));
|
||||||
testPlanApiCaseService.associateCollection("wxxx_1", collectionAssociates1, user);
|
testPlanApiCaseService.associateCollection("wxxx_1", collectionAssociates1, user);
|
||||||
|
|
||||||
apiTestCase = initApiData();
|
apiTestCase = initApiData();
|
||||||
|
|
Loading…
Reference in New Issue