feat(测试计划): 资源关联增加归属测试计划选项

This commit is contained in:
Jianguo-Genius 2024-12-09 16:18:00 +08:00 committed by Craftsman
parent b4046ad7d5
commit 01bd11b858
6 changed files with 100 additions and 0 deletions

View File

@ -442,6 +442,15 @@
<property name="column" value="api_definition.path"/>
</include>
</if>
<if test="condition.name == 'belongTestPlan' and condition.operator == 'EQUALS'">
api_definition.id in (
select api.id from api_definition api inner join api_test_case apiCase ON api.id =
apiCase.api_definition_id
WHERE api.deleted IS FALSE and apiCase.deleted IS FALSE and apiCase.id in (
select api_case_id from test_plan_api_case where test_plan_id = #{condition.value}
)
)
</if>
<if test="condition.name == 'caseTotal'">
<choose>
<when test="condition.operator == 'NOT_EMPTY'">

View File

@ -325,6 +325,12 @@
<property name="condition" value="condition"/>
<property name="tablePrefix" value="api_scenario"/>
</include>
<if test="condition.name == 'belongTestPlan' and condition.operator == 'EQUALS'">
api_scenario.id in (
select test_plan_api_scenario.api_scenario_id from test_plan_api_scenario where
test_plan_api_scenario.test_plan_id = #{condition.value}
)
</if>
<!-- 场景等级 -->
<if test="condition.name == 'priority'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">

View File

@ -608,6 +608,12 @@
<property name="condition" value="condition"/>
<property name="tablePrefix" value="atc"/>
</include>
<if test="condition.name == 'belongTestPlan' and condition.operator == 'EQUALS'">
atc.id in (
select test_plan_api_case.api_case_id from test_plan_api_case where
test_plan_api_case.test_plan_id = #{condition.value}
)
</if>
<!-- 模块ID -->
<if test="condition.name == 'moduleId'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">

View File

@ -353,6 +353,12 @@
<property name="condition" value="condition"/>
</include>
</if>
<if test="condition.name == 'belongTestPlan' and condition.operator == 'EQUALS'">
functional_case.id in (
select functional_case_id from test_plan_functional_case where test_plan_id
= #{condition.value}
)
</if>
<!-- 关联附件 -->
<if test="condition.name == 'attachment'">
<include refid="io.metersphere.system.mapper.BaseMapper.associationCondition">

View File

@ -411,6 +411,15 @@
<property name="column" value="a.protocol"/>
</include>
</if>
<if test="condition.name == 'belongTestPlan' and condition.operator == 'EQUALS'">
a.id in (
select api.id from api_definition api inner join api_test_case apiCase ON api.id =
apiCase.api_definition_id
WHERE api.deleted IS FALSE and apiCase.deleted IS FALSE and apiCase.id in (
select api_case_id from test_plan_api_case where test_plan_id = #{condition.value}
)
)
</if>
<if test="condition.name == 'status'">
<include refid="io.metersphere.system.mapper.BaseMapper.condition">
<property name="condition" value="condition"/>
@ -505,6 +514,11 @@
<property name="condition" value="condition"/>
<property name="tablePrefix" value="atc"/>
</include>
<if test="condition.name == 'belongTestPlan' and condition.operator == 'EQUALS'">
atc.id in (
select api_case_id from test_plan_api_case where test_plan_id = #{condition.value}
)
</if>
<!-- 所属模块(项目ID_模块ID 组合查询) -->
<if test="condition.name == 'moduleId'">
<choose>

View File

@ -5,6 +5,8 @@ import io.metersphere.functional.request.FunctionalCasePageRequest;
import io.metersphere.plan.dto.request.TestPlanApiCaseRequest;
import io.metersphere.plan.dto.request.TestPlanApiRequest;
import io.metersphere.plan.dto.request.TestPlanApiScenarioRequest;
import io.metersphere.sdk.dto.CombineCondition;
import io.metersphere.sdk.dto.CombineSearch;
import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
@ -16,6 +18,7 @@ import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.web.servlet.MvcResult;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -49,6 +52,20 @@ public class TestPlanAssociateControllerTests extends BaseTest {
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
request.setCombineSearch(
new CombineSearch() {{
this.setConditions(Collections.singletonList(new CombineCondition() {{
this.setName("belongTestPlan");
this.setOperator(CombineConditionOperator.EQUALS.name());
this.setValue("testABCD");
}}));
}}
);
mvcResult = this.requestPostWithOkAndReturn(FUNCTIONAL_CASE_ASSOCIATION_URL, request);
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
}
@Test
@ -71,6 +88,20 @@ public class TestPlanAssociateControllerTests extends BaseTest {
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
request.setCombineSearch(
new CombineSearch() {{
this.setConditions(Collections.singletonList(new CombineCondition() {{
this.setName("belongTestPlan");
this.setOperator(CombineConditionOperator.EQUALS.name());
this.setValue("testABCD");
}}));
}}
);
mvcResult = this.requestPostWithOkAndReturn(API_ASSOCIATION_URL, request);
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
}
@Test
@ -94,6 +125,20 @@ public class TestPlanAssociateControllerTests extends BaseTest {
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
request.setCombineSearch(
new CombineSearch() {{
this.setConditions(Collections.singletonList(new CombineCondition() {{
this.setName("belongTestPlan");
this.setOperator(CombineConditionOperator.EQUALS.name());
this.setValue("testABCD");
}}));
}}
);
mvcResult = this.requestPostWithOkAndReturn(API_CASE_ASSOCIATION_URL, request);
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
}
@Test
@ -115,6 +160,19 @@ public class TestPlanAssociateControllerTests extends BaseTest {
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
request.setCombineSearch(
new CombineSearch() {{
this.setConditions(Collections.singletonList(new CombineCondition() {{
this.setName("belongTestPlan");
this.setOperator(CombineConditionOperator.EQUALS.name());
this.setValue("testABCD");
}}));
}}
);
mvcResult = this.requestPostWithOkAndReturn(API_SCENARIO_URL, request);
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
}
@Test
@ -130,6 +188,7 @@ public class TestPlanAssociateControllerTests extends BaseTest {
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
Assertions.assertNotNull(resultHolder);
}
}