fix(用例管理):用例评审详情页模块显示多个项目的模块树
This commit is contained in:
parent
9ebe3a657b
commit
21a711e954
|
@ -61,12 +61,12 @@ public class CaseReviewFunctionalCaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/tree/{projectId}/{reviewId}")
|
@GetMapping("/tree/{reviewId}")
|
||||||
@Operation(summary = "用例管理-用例评审-评审列表-评审详情-已关联用例列表模块树")
|
@Operation(summary = "用例管理-用例评审-评审列表-评审详情-已关联用例列表模块树")
|
||||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ)
|
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ)
|
||||||
@CheckOwner(resourceId = "#projectId", resourceType = "project")
|
@CheckOwner(resourceId = "#reviewId", resourceType = "case_review")
|
||||||
public List<BaseTreeNode> getTree(@PathVariable String projectId, @PathVariable String reviewId) {
|
public List<BaseTreeNode> getTree(@PathVariable String reviewId) {
|
||||||
return caseReviewFunctionalCaseService.getTree(projectId, reviewId);
|
return caseReviewFunctionalCaseService.getTree(reviewId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package io.metersphere.functional.dto;
|
||||||
|
|
||||||
|
import io.metersphere.project.dto.ModuleCountDTO;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FunctionalCaseModuleCountDTO extends ModuleCountDTO {
|
||||||
|
@Schema(description = "项目id")
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
@Schema(description = "项目名称")
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package io.metersphere.functional.dto;
|
||||||
|
|
||||||
|
import io.metersphere.functional.domain.FunctionalCaseModule;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FunctionalCaseModuleDTO extends FunctionalCaseModule {
|
||||||
|
@Schema(description = "项目名称")
|
||||||
|
private String projectName;
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package io.metersphere.functional.mapper;
|
package io.metersphere.functional.mapper;
|
||||||
|
|
||||||
import io.metersphere.functional.domain.CaseReviewFunctionalCase;
|
import io.metersphere.functional.domain.CaseReviewFunctionalCase;
|
||||||
|
import io.metersphere.functional.dto.FunctionalCaseModuleCountDTO;
|
||||||
import io.metersphere.functional.dto.FunctionalCaseReviewDTO;
|
import io.metersphere.functional.dto.FunctionalCaseReviewDTO;
|
||||||
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
||||||
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
|
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
|
||||||
import io.metersphere.functional.request.FunctionalCaseReviewListRequest;
|
import io.metersphere.functional.request.FunctionalCaseReviewListRequest;
|
||||||
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
|
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
|
||||||
import io.metersphere.project.dto.ModuleCountDTO;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -41,7 +41,8 @@ public interface ExtCaseReviewFunctionalCaseMapper {
|
||||||
|
|
||||||
List<CaseReviewFunctionalCase> getCaseIdsByIds(@Param("ids") List<String> ids);
|
List<CaseReviewFunctionalCase> getCaseIdsByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
List<ModuleCountDTO> countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId);
|
List<FunctionalCaseModuleCountDTO> countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId);
|
||||||
|
|
||||||
long caseCount(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId);
|
long caseCount(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
WHERE
|
WHERE
|
||||||
review_id = #{request.reviewId}
|
review_id = #{request.reviewId}
|
||||||
AND functional_case.deleted = #{deleted}
|
AND functional_case.deleted = #{deleted}
|
||||||
AND functional_case.project_id = #{request.projectId}
|
|
||||||
<if test="userId != null and userId != ''">
|
<if test="userId != null and userId != ''">
|
||||||
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
||||||
</if>
|
</if>
|
||||||
|
@ -382,14 +381,15 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countModuleIdByRequest" resultType="io.metersphere.project.dto.ModuleCountDTO">
|
<select id="countModuleIdByRequest" resultType="io.metersphere.functional.dto.FunctionalCaseModuleCountDTO">
|
||||||
SELECT functional_case.module_id AS moduleId, count(functional_case.id) AS dataCount
|
SELECT functional_case.module_id AS moduleId, count(functional_case.id) AS dataCount, functional_case.project_id AS projectId, project.name AS projectName
|
||||||
FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id
|
FROM case_review_functional_case crfc
|
||||||
|
LEFT JOIN functional_case ON crfc.case_id = functional_case.id
|
||||||
|
LEFT JOIN project ON functional_case.project_id = project.id
|
||||||
WHERE crfc.review_id = #{request.reviewId}
|
WHERE crfc.review_id = #{request.reviewId}
|
||||||
AND functional_case.deleted = #{deleted}
|
AND functional_case.deleted = #{deleted}
|
||||||
AND functional_case.project_id = #{request.projectId}
|
|
||||||
<if test="userId != null and userId != ''">
|
<if test="userId != null and userId != ''">
|
||||||
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
AND crfc.case_id in (select crfcu.case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
||||||
</if>
|
</if>
|
||||||
<choose>
|
<choose>
|
||||||
<when test='request.searchMode == "AND"'>
|
<when test='request.searchMode == "AND"'>
|
||||||
|
@ -410,7 +410,6 @@
|
||||||
FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id
|
FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id
|
||||||
WHERE crfc.review_id = #{request.reviewId}
|
WHERE crfc.review_id = #{request.reviewId}
|
||||||
AND functional_case.deleted = #{deleted}
|
AND functional_case.deleted = #{deleted}
|
||||||
AND functional_case.project_id = #{request.projectId}
|
|
||||||
<if test="userId != null and userId != ''">
|
<if test="userId != null and userId != ''">
|
||||||
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId})
|
||||||
</if>
|
</if>
|
||||||
|
@ -426,4 +425,5 @@
|
||||||
</choose>
|
</choose>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.functional.mapper;
|
package io.metersphere.functional.mapper;
|
||||||
|
|
||||||
|
import io.metersphere.functional.dto.FunctionalCaseModuleDTO;
|
||||||
import io.metersphere.project.dto.NodeSortQueryParam;
|
import io.metersphere.project.dto.NodeSortQueryParam;
|
||||||
import io.metersphere.request.AssociateCaseModuleRequest;
|
import io.metersphere.request.AssociateCaseModuleRequest;
|
||||||
import io.metersphere.system.dto.sdk.BaseModule;
|
import io.metersphere.system.dto.sdk.BaseModule;
|
||||||
|
@ -11,7 +12,7 @@ import java.util.List;
|
||||||
public interface ExtFunctionalCaseModuleMapper {
|
public interface ExtFunctionalCaseModuleMapper {
|
||||||
List<BaseTreeNode> selectBaseByProjectId(@Param("projectId")String projectId);
|
List<BaseTreeNode> selectBaseByProjectId(@Param("projectId")String projectId);
|
||||||
|
|
||||||
List<String> selectBaseByProjectIdAndReviewId(@Param("projectId")String projectId, @Param("reviewId")String reviewId);
|
List<FunctionalCaseModuleDTO> selectBaseByProjectIdAndReviewId(@Param("reviewId")String reviewId);
|
||||||
|
|
||||||
List<BaseTreeNode> selectBaseByIds(@Param("ids") List<String> ids);
|
List<BaseTreeNode> selectBaseByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
WHERE project_id = #{projectId}
|
WHERE project_id = #{projectId}
|
||||||
ORDER BY pos
|
ORDER BY pos
|
||||||
</select>
|
</select>
|
||||||
<select id="selectBaseByProjectIdAndReviewId" resultType="java.lang.String">
|
<select id="selectBaseByProjectIdAndReviewId" resultType="io.metersphere.functional.dto.FunctionalCaseModuleDTO">
|
||||||
SELECT fcm.id
|
SELECT fcm.id, fcm.project_id, p.name as projectName
|
||||||
FROM functional_case_module fcm
|
FROM functional_case_module fcm
|
||||||
WHERE fcm.project_id = #{projectId}
|
LEFT JOIN project p ON fcm.project_id = p.id
|
||||||
AND fcm.id IN
|
WHERE fcm.id IN
|
||||||
(SELECT fc.module_id FROM functional_case fc LEFT JOIN case_review_functional_case crfc ON crfc.case_id = fc.id WHERE crfc.review_id = #{reviewId} AND fc.deleted = false)
|
(SELECT fc.module_id FROM functional_case fc LEFT JOIN case_review_functional_case crfc ON crfc.case_id = fc.id WHERE crfc.review_id = #{reviewId} AND fc.deleted = false)
|
||||||
ORDER BY pos
|
ORDER BY pos
|
||||||
</select>
|
</select>
|
||||||
|
@ -95,10 +95,9 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectIdByProjectIdAndReviewId" resultType="java.lang.String">
|
<select id="selectIdByProjectIdAndReviewId" resultType="java.lang.String">
|
||||||
SELECT fcm.id
|
SELECT fcm.id, fcm.project_id
|
||||||
FROM functional_case_module fcm
|
FROM functional_case_module fcm
|
||||||
WHERE fcm.project_id = #{projectId}
|
WHERE fcm.id IN
|
||||||
AND fcm.id IN
|
|
||||||
(SELECT fc.module_id FROM functional_case fc LEFT JOIN case_review_functional_case crfc ON crfc.case_id = fc.id WHERE crfc.review_id = #{reviewId} AND fc.deleted = false)
|
(SELECT fc.module_id FROM functional_case fc LEFT JOIN case_review_functional_case crfc ON crfc.case_id = fc.id WHERE crfc.review_id = #{reviewId} AND fc.deleted = false)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,10 @@ import io.metersphere.functional.constants.CaseFileSourceType;
|
||||||
import io.metersphere.functional.constants.CaseReviewPassRule;
|
import io.metersphere.functional.constants.CaseReviewPassRule;
|
||||||
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
||||||
import io.metersphere.functional.domain.*;
|
import io.metersphere.functional.domain.*;
|
||||||
import io.metersphere.functional.dto.CaseReviewHistoryDTO;
|
import io.metersphere.functional.dto.*;
|
||||||
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
|
||||||
import io.metersphere.functional.dto.ReviewsDTO;
|
|
||||||
import io.metersphere.functional.mapper.*;
|
import io.metersphere.functional.mapper.*;
|
||||||
import io.metersphere.functional.request.*;
|
import io.metersphere.functional.request.*;
|
||||||
|
import io.metersphere.project.domain.Project;
|
||||||
import io.metersphere.project.domain.ProjectApplication;
|
import io.metersphere.project.domain.ProjectApplication;
|
||||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||||
import io.metersphere.project.domain.ProjectVersion;
|
import io.metersphere.project.domain.ProjectVersion;
|
||||||
|
@ -18,8 +17,10 @@ import io.metersphere.project.dto.ModuleCountDTO;
|
||||||
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||||
import io.metersphere.provider.BaseCaseProvider;
|
import io.metersphere.provider.BaseCaseProvider;
|
||||||
|
import io.metersphere.sdk.constants.ModuleConstants;
|
||||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
|
import io.metersphere.sdk.util.BeanUtils;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||||
|
@ -586,21 +587,51 @@ public class CaseReviewFunctionalCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaseTreeNode> getTree(String projectId, String reviewId) {
|
public List<BaseTreeNode> getTree(String reviewId) {
|
||||||
List<String> functionalModuleIds = extFunctionalCaseModuleMapper.selectBaseByProjectIdAndReviewId(projectId, reviewId);
|
List<BaseTreeNode> returnList = new ArrayList<>();
|
||||||
List<BaseTreeNode> nodeByNodeIds = functionalCaseModuleService.getNodeByNodeIds(functionalModuleIds);
|
List<FunctionalCaseModuleDTO> functionalModuleIds = extFunctionalCaseModuleMapper.selectBaseByProjectIdAndReviewId(reviewId);
|
||||||
return functionalCaseModuleService.buildTreeAndCountResource(nodeByNodeIds, true, Translator.get("default.module"));
|
Map<String, List<FunctionalCaseModuleDTO>> projectModuleMap = functionalModuleIds.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getProjectId));
|
||||||
|
projectModuleMap.forEach((projectId,moduleList)->{
|
||||||
|
BaseTreeNode projectNode = new BaseTreeNode(projectId, moduleList.get(0).getProjectName(), Project.class.getName());
|
||||||
|
returnList.add(projectNode);
|
||||||
|
List<String> projectModuleIds = moduleList.stream().map(FunctionalCaseModule::getId).toList();
|
||||||
|
List<BaseTreeNode> nodeByNodeIds = functionalCaseModuleService.getNodeByNodeIds(projectModuleIds);
|
||||||
|
List<BaseTreeNode> list = nodeByNodeIds.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getId(), ModuleConstants.DEFAULT_NODE_ID.toString())).toList();
|
||||||
|
boolean haveVirtualRootNode = list.isEmpty();
|
||||||
|
List<BaseTreeNode> baseTreeNodes = functionalCaseModuleService.buildTreeAndCountResource(nodeByNodeIds, haveVirtualRootNode, Translator.get("default.module"));
|
||||||
|
for (BaseTreeNode baseTreeNode : baseTreeNodes) {
|
||||||
|
projectNode.addChild(baseTreeNode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Long> moduleCount(ReviewFunctionalCasePageRequest request, boolean deleted, String userId) {
|
public Map<String, Long> moduleCount(ReviewFunctionalCasePageRequest request, boolean deleted, String userId) {
|
||||||
//查出每个模块节点下的资源数量。 不需要按照模块进行筛选
|
//查出每个模块节点下的资源数量。 不需要按照模块进行筛选
|
||||||
request.setModuleIds(null);
|
request.setModuleIds(null);
|
||||||
List<ModuleCountDTO> moduleCountDTOList = extCaseReviewFunctionalCaseMapper.countModuleIdByRequest(request, deleted, userId);
|
List<FunctionalCaseModuleCountDTO> projectModuleCountDTOList = extCaseReviewFunctionalCaseMapper.countModuleIdByRequest(request, deleted, userId);
|
||||||
Map<String, Long> moduleCountMap = getModuleCountMap(request.getProjectId(), request.getReviewId(), moduleCountDTOList);
|
Map<String, List<FunctionalCaseModuleCountDTO>> projectCountMap = projectModuleCountDTOList.stream().collect(Collectors.groupingBy(FunctionalCaseModuleCountDTO::getProjectId));
|
||||||
|
Map<String, Long> projectModuleCountMap = new HashMap<>();
|
||||||
|
projectCountMap.forEach((projectId,moduleCountDTOList)->{
|
||||||
|
List<ModuleCountDTO>moduleCountDTOS = new ArrayList<>();
|
||||||
|
for (FunctionalCaseModuleCountDTO functionalCaseModuleCountDTO : moduleCountDTOList) {
|
||||||
|
ModuleCountDTO moduleCountDTO = new ModuleCountDTO();
|
||||||
|
BeanUtils.copyBean(moduleCountDTO,functionalCaseModuleCountDTO);
|
||||||
|
moduleCountDTOS.add(moduleCountDTO);
|
||||||
|
}
|
||||||
|
int sum = moduleCountDTOList.stream().mapToInt(FunctionalCaseModuleCountDTO::getDataCount).sum();
|
||||||
|
Map<String, Long> moduleCountMap = getModuleCountMap(projectId, request.getReviewId(), moduleCountDTOS);
|
||||||
|
moduleCountMap.forEach((k,v)->{
|
||||||
|
if (projectModuleCountMap.get(k)==null || projectModuleCountMap.get(k) == 0L){
|
||||||
|
projectModuleCountMap.put(k,v);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
projectModuleCountMap.put(projectId, (long)sum);
|
||||||
|
});
|
||||||
//查出全部用例数量
|
//查出全部用例数量
|
||||||
long allCount = extCaseReviewFunctionalCaseMapper.caseCount(request, deleted, userId);
|
long allCount = extCaseReviewFunctionalCaseMapper.caseCount(request, deleted, userId);
|
||||||
moduleCountMap.put(CASE_MODULE_COUNT_ALL, allCount);
|
projectModuleCountMap.put(CASE_MODULE_COUNT_ALL, allCount);
|
||||||
return moduleCountMap;
|
return projectModuleCountMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -609,6 +640,7 @@ public class CaseReviewFunctionalCaseService {
|
||||||
public Map<String, Long> getModuleCountMap(String projectId, String reviewId, List<ModuleCountDTO> moduleCountDTOList) {
|
public Map<String, Long> getModuleCountMap(String projectId, String reviewId, List<ModuleCountDTO> moduleCountDTOList) {
|
||||||
//构建模块树,并计算每个节点下的所有数量(包含子节点)
|
//构建模块树,并计算每个节点下的所有数量(包含子节点)
|
||||||
List<BaseTreeNode> treeNodeList = this.getTreeOnlyIdsAndResourceCount(projectId, reviewId, moduleCountDTOList);
|
List<BaseTreeNode> treeNodeList = this.getTreeOnlyIdsAndResourceCount(projectId, reviewId, moduleCountDTOList);
|
||||||
|
|
||||||
//通过广度遍历的方式构建返回值
|
//通过广度遍历的方式构建返回值
|
||||||
return functionalCaseModuleService.getIdCountMapByBreadth(treeNodeList);
|
return functionalCaseModuleService.getIdCountMapByBreadth(treeNodeList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import io.metersphere.functional.domain.CaseReviewFunctionalCaseExample;
|
||||||
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
||||||
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
|
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
|
||||||
import io.metersphere.functional.request.*;
|
import io.metersphere.functional.request.*;
|
||||||
import io.metersphere.sdk.constants.ModuleConstants;
|
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
|
@ -142,17 +141,26 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
@Order(4)
|
@Order(4)
|
||||||
public void emptyDataTest() throws Exception {
|
public void emptyDataTest() throws Exception {
|
||||||
//空数据下,检查模块树
|
List<BaseTreeNode> treeNodes = this.getCaseReviewModuleTreeNode("wx_test_project","wx_review_id_2");
|
||||||
List<BaseTreeNode> treeNodes = this.getCaseReviewModuleTreeNode("wx_test_project","wx_review_id_1");
|
String jsonString = JSON.toJSONString(treeNodes);
|
||||||
//检查有没有默认节点
|
System.out.println(jsonString);
|
||||||
boolean hasNode = false;
|
Assertions.assertTrue(CollectionUtils.isNotEmpty(treeNodes));
|
||||||
for (BaseTreeNode baseTreeNode : treeNodes) {
|
ReviewFunctionalCasePageRequest request = new ReviewFunctionalCasePageRequest();
|
||||||
if (StringUtils.equals(baseTreeNode.getId(), ModuleConstants.DEFAULT_NODE_ID)) {
|
request.setReviewId("wx_review_id_2");
|
||||||
hasNode = true;
|
request.setProjectId("wx_test_project");
|
||||||
}
|
request.setCurrent(1);
|
||||||
Assertions.assertNotNull(baseTreeNode.getParentId());
|
request.setPageSize(10);
|
||||||
}
|
MvcResult mvcResult = this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request);
|
||||||
Assertions.assertTrue(hasNode);
|
Map<String, Integer> moduleCountResult = JSON.parseObject(JSON.toJSONString(
|
||||||
|
JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||||
|
Map.class);
|
||||||
|
System.out.println(JSON.toJSONString(moduleCountResult));
|
||||||
|
|
||||||
|
MvcResult mvcResultPage = this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request);
|
||||||
|
Pager<List<ReviewFunctionalCaseDTO>> tableData = JSON.parseObject(JSON.toJSONString(
|
||||||
|
JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
|
||||||
|
Pager.class);
|
||||||
|
System.out.println(JSON.toJSONString(tableData.getList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,7 +412,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
||||||
|
|
||||||
|
|
||||||
private List<BaseTreeNode> getCaseReviewModuleTreeNode(String projectId, String reviewId) throws Exception {
|
private List<BaseTreeNode> getCaseReviewModuleTreeNode(String projectId, String reviewId) throws Exception {
|
||||||
MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(URL_MODULE_TREE+"/"+projectId+"/"+reviewId).header(SessionConstants.HEADER_TOKEN, sessionId)
|
MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(URL_MODULE_TREE+"/"+reviewId).header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
|
|
@ -13,7 +13,12 @@ VALUES ('gyq_case_id_4', 106, 'TEST_MODULE_ID', 'wx_test_project', '100001', '
|
||||||
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
|
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
|
||||||
VALUES ('gyq_case_id_5', 102, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_4', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
VALUES ('gyq_case_id_5', 102, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_4', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
||||||
('gyq_case_id_7', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_7', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
('gyq_case_id_7', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_7', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
||||||
('gyq_case_id_8', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_8', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
('gyq_case_id_8', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_8', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
||||||
|
('gyq_case_id_9', 104, 'TEST_MODULE_ID_COUNT_four', 'wx_test_project_review_two', '100001', '测试模块2-1', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_9', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
||||||
|
('gyq_case_id_a', 105, 'TEST_MODULE_ID_COUNT_five', 'wx_test_project_review_two', '100001', '测试模块2-2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_a', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
||||||
|
('gyq_case_id_b', 105, 'TEST_MODULE_ID_COUNT_six', 'wx_test_project_review_one', '100001', '测试模块2-2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_a', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL),
|
||||||
|
('gyq_case_id_c', 105, 'TEST_MODULE_ID_COUNT_seven', 'wx_test_project_review_one', '100001', '测试模块2-2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_a', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
|
INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time)
|
||||||
VALUES ('wx_case_id_3', 104, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'TEST_REF_ID', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
VALUES ('wx_case_id_3', 104, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'TEST_REF_ID', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL);
|
||||||
|
@ -51,7 +56,11 @@ VALUES ('wx_test_1', 'wx_review_id_1', 'wx_case_id_1', 'PASS', 1698058347559,'ad
|
||||||
('gyq_test_5', 'wx_review_id_1', 'gyq_case_id_5', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
('gyq_test_5', 'wx_review_id_1', 'gyq_case_id_5', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
('gyq_test_7', 'wx_review_id_1', 'gyq_case_id_7', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
('gyq_test_7', 'wx_review_id_1', 'gyq_case_id_7', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
('gyq_test_8', 'wx_review_id_1', 'gyq_case_id_8', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
('gyq_test_8', 'wx_review_id_1', 'gyq_case_id_8', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
('wx_test_2', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
('gyq_test_9', 'wx_review_id_2', 'gyq_case_id_9', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
|
('gyq_test_a', 'wx_review_id_2', 'gyq_case_id_a', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
|
('gyq_test_b', 'wx_review_id_2', 'gyq_case_id_b', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
|
('gyq_test_c', 'wx_review_id_2', 'gyq_case_id_c', 'PASS', 1698058347559,'admin',1698058347559, 2000),
|
||||||
|
('wx_test_2', 'wx_review_id_2', 'wx_case_id_3', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
||||||
('wx_test_3', 'wx_review_id_2', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
('wx_test_3', 'wx_review_id_2', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
||||||
('wx_test_4', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
('wx_test_4', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
||||||
('wx_test_5', 'wx_review_id_3', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
('wx_test_5', 'wx_review_id_3', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000),
|
||||||
|
@ -83,8 +92,17 @@ INSERT INTO case_review_module(id, project_id, name, parent_id, pos, create_time
|
||||||
INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user)
|
INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user)
|
||||||
VALUES ('TEST_MODULE_ID', 'wx_test_project', '测试所属模块', 'NONE', 1568, 1669174143999, 1669174143999, 'admin', 'admin'),
|
VALUES ('TEST_MODULE_ID', 'wx_test_project', '测试所属模块', 'NONE', 1568, 1669174143999, 1669174143999, 'admin', 'admin'),
|
||||||
('TEST_MODULE_ID_COUNT_ID', 'wx_test_project', '测试所属模块子集', 'TEST_MODULE_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin'),
|
('TEST_MODULE_ID_COUNT_ID', 'wx_test_project', '测试所属模块子集', 'TEST_MODULE_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin'),
|
||||||
('TEST_MODULE_ID_COUNT_three', 'wx_test_project', '测试所属模块子集2', 'TEST_MODULE_ID_COUNT_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin');
|
('TEST_MODULE_ID_COUNT_three', 'wx_test_project', '测试所属模块子集2', 'TEST_MODULE_ID_COUNT_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin'),
|
||||||
|
('TEST_MODULE_ID_COUNT_six', 'wx_test_project_review_one', '测试多项目模块3', 'NONE', 8, 1669174143999, 1669174143999, 'admin', 'admin'),
|
||||||
|
('TEST_MODULE_ID_COUNT_seven', 'wx_test_project_review_one', '测试多项目模块4', 'TEST_MODULE_ID_COUNT_six', 16, 1669174143999, 1669174143999, 'admin', 'admin'),
|
||||||
|
('TEST_MODULE_ID_COUNT_four', 'wx_test_project_review_two', '测试多项目模块', 'NONE', 56, 1669174143999, 1669174143999, 'admin', 'admin'),
|
||||||
|
('TEST_MODULE_ID_COUNT_five', 'wx_test_project_review_two', '测试多项目模块2', 'TEST_MODULE_ID_COUNT_four', 48, 1669174143999, 1669174143999, 'admin', 'admin');
|
||||||
|
|
||||||
|
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time)
|
||||||
|
VALUES ('wx_test_project_review_one', null, 'organization-associate-case-test', '评审跨项目关联用例', '系统默认创建的项目',
|
||||||
|
'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
|
||||||
|
('wx_test_project_review_two', null, 'organization-associate-case-test', '评审跨项目关联用例2', '系统默认创建的项目',
|
||||||
|
'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class BaseTreeNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(BaseTreeNode node) {
|
public void addChild(BaseTreeNode node) {
|
||||||
|
node.setParentId(this.getId());
|
||||||
children.add(node);
|
children.add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue