feat(测试计划): 测试计划查询处增加测试计划组内数据的查询功能
This commit is contained in:
parent
2d9648e26c
commit
8ca4f27432
|
@ -17,6 +17,8 @@ public class TestPlanResponse {
|
|||
private String name;
|
||||
@Schema(description = "状态")
|
||||
private String status;
|
||||
@Schema(description = "测试计划类型 测试计划/测试计划组")
|
||||
private String type;
|
||||
@Schema(description = "标签")
|
||||
private List<String> tags;
|
||||
@Schema(description = "定时任务")
|
||||
|
@ -30,7 +32,7 @@ public class TestPlanResponse {
|
|||
@Schema(description = "模块Id")
|
||||
private String moduleId;
|
||||
@Schema(description = "测试计划组内的测试计划")
|
||||
List<TestPlanResponse> testPlanItem;
|
||||
List<TestPlanResponse> children;
|
||||
|
||||
@Schema(description = "测试计划组Id")
|
||||
private String testPlanGroupId;
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.plan.mapper.ExtTestPlanModuleMapper;
|
|||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.dto.ModuleCountDTO;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.TestPlanConstants;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
|
@ -18,6 +19,7 @@ import io.metersphere.system.service.CommonProjectService;
|
|||
import io.metersphere.system.utils.PageUtils;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -74,12 +76,26 @@ public class TestPlanManagementService {
|
|||
private List<TestPlanResponse> getTableList(TestPlanQueryConditions request) {
|
||||
List<TestPlanResponse> testPlanResponses = extTestPlanMapper.selectByConditions(request);
|
||||
testPlanResponses.forEach(item -> {
|
||||
item.setModuleName(testPlanModuleService.getNameById(item.getModuleId()));
|
||||
//todo 定时任务相关信息处理
|
||||
if (StringUtils.equals(item.getType(), TestPlanConstants.TEST_PLAN_TYPE_GROUP)) {
|
||||
TestPlanQueryConditions childrenCondition = new TestPlanQueryConditions();
|
||||
childrenCondition.setProjectId(request.getProjectId());
|
||||
childrenCondition.setGroupId(item.getId());
|
||||
item.setChildren(extTestPlanMapper.selectByConditions(childrenCondition));
|
||||
}
|
||||
this.initTestPlanResponse(item);
|
||||
});
|
||||
return testPlanResponses;
|
||||
}
|
||||
|
||||
private void initTestPlanResponse(TestPlanResponse testPlanResponse) {
|
||||
testPlanResponse.setModuleName(testPlanModuleService.getNameById(testPlanResponse.getModuleId()));
|
||||
//todo 定时任务相关信息处理
|
||||
|
||||
if (CollectionUtils.isNotEmpty(testPlanResponse.getChildren())) {
|
||||
testPlanResponse.getChildren().forEach(this::initTestPlanResponse);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkModuleIsOpen(String resourceId, String resourceType, List<String> moduleMenus) {
|
||||
Project project;
|
||||
|
||||
|
|
|
@ -229,7 +229,6 @@ public class TestPlanService {
|
|||
response.setId(id);
|
||||
/*
|
||||
todo 统计:测试进度、通过率、用例数、Bug数量(这些比较慢的查询,是否需要另开接口查询)
|
||||
Q:测试计划组需要查询这些数据吗?
|
||||
*/
|
||||
|
||||
response.setFunctionalCaseCount(0);
|
||||
|
|
|
@ -749,6 +749,27 @@ public class TestPlanTests extends BaseTest {
|
|||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||
Assertions.assertEquals(result.getTotal(), 111);
|
||||
|
||||
|
||||
//测试根据名称模糊查询(包含测试组的): Plan_7 预期结果: a1Node下有1条(testPlan_7), a2Node下有10条(testPlan_70~testPlan_79),a1b1Node下有100条(testPlan_700~testPlan_799)
|
||||
testPlanTableRequest.setKeyword("Plan_7");
|
||||
testPlanTableRequest.setSort(new HashMap<>() {{
|
||||
this.put("num", "asc");
|
||||
}});
|
||||
moduleCountResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest);
|
||||
moduleCountReturnData = moduleCountResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
moduleCountMap = JSON.parseObject(JSON.toJSONString(JSON.parseObject(moduleCountReturnData, ResultHolder.class).getData()), Map.class);
|
||||
this.checkModuleCount(moduleCountMap, 1, 10, 0, 0, 100);
|
||||
|
||||
pageResult = this.requestPostWithOkAndReturn(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest);
|
||||
returnData = pageResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
result = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), Pager.class);
|
||||
//返回值的页码和当前页码相同
|
||||
Assertions.assertEquals(result.getCurrent(), testPlanTableRequest.getCurrent());
|
||||
//返回的数据量不超过规定要返回的数据量相同
|
||||
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(result.getList())).size() <= testPlanTableRequest.getPageSize());
|
||||
Assertions.assertEquals(result.getTotal(), 111);
|
||||
|
||||
//反例:参数校验(项目ID不存在)
|
||||
testPlanTableRequest.setProjectId(null);
|
||||
this.requestPost(URL_POST_TEST_PLAN_MODULE_COUNT, testPlanTableRequest).andExpect(status().isBadRequest());
|
||||
|
|
Loading…
Reference in New Issue