refactor(用例评审): 关联功能用例增加全选功能

This commit is contained in:
guoyuqi 2023-12-12 17:35:59 +08:00 committed by Craftsman
parent df52fff6c9
commit 24b6d9b5f2
12 changed files with 179 additions and 51 deletions

View File

@ -24,6 +24,7 @@ public interface ExtCaseReviewFunctionalCaseMapper {
List<ReviewFunctionalCaseDTO> page(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId, @Param("sort") String sort); List<ReviewFunctionalCaseDTO> page(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId, @Param("sort") String sort);
Long getPos(@Param("reviewId") String reviewId);
List<String> getIds(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted); List<String> getIds(@Param("request") BaseReviewCaseBatchRequest request, @Param("userId") String userId, @Param("deleted") boolean deleted);
} }

View File

@ -274,4 +274,16 @@
1=1 1=1
</sql> </sql>
<select id="getPos" resultType="java.lang.Long">
SELECT
pos
FROM
case_review_functional_case
WHERE
review_id = #{reviewId}
ORDER BY
pos DESC
LIMIT 1;
</select>
</mapper> </mapper>

View File

@ -83,6 +83,21 @@
<property name="searchMode" value="request.condition.searchMode"/> <property name="searchMode" value="request.condition.searchMode"/>
</include> </include>
</if> </if>
<if test="request.createByMe != null">
case_review.create_user = #{request.createByMe}
<include refid="queryType">
<property name="searchMode" value="request.searchMode"/>
</include>
</if>
<if test="request.reviewByMe != null">
case_review.id in
(
select case_review_user.review_id from case_review_user where case_review_user.user_id = #{request.reviewByMe}
)
<include refid="queryType">
<property name="searchMode" value="request.searchMode"/>
</include>
</if>
<include refid="filters"> <include refid="filters">
<property name="filter" value="request.condition.filter"/> <property name="filter" value="request.condition.filter"/>
</include> </include>

View File

@ -0,0 +1,15 @@
package io.metersphere.functional.request;
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
public class BaseAssociateCaseRequest extends BaseFunctionalCaseBatchDTO {
@Schema(description = "功能用例选择的项目id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{case_review_associate_request.project_id.not_blank}")
private String projectId;
}

View File

@ -3,6 +3,7 @@ package io.metersphere.functional.request;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.io.Serial; import java.io.Serial;
@ -14,7 +15,6 @@ import java.util.List;
*/ */
@Data @Data
public class CaseReviewAssociateRequest implements Serializable { public class CaseReviewAssociateRequest implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -22,16 +22,16 @@ public class CaseReviewAssociateRequest implements Serializable {
@NotBlank(message = "{case_review_associate_request.case_review_id.not_blank}") @NotBlank(message = "{case_review_associate_request.case_review_id.not_blank}")
private String reviewId; private String reviewId;
@Schema(description = "项目id", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "用例评审所在的项目id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{case_review_associate_request.project_id.not_blank}") @NotBlank(message = "{case_review_associate_request.project_id.not_blank}")
private String projectId; private String projectId;
@Schema(description = "功能用例id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "{case_review_associate_request.case_ids.not_empty}")
private List<String> caseIds;
@Schema(description = "评审人") @Schema(description = "评审人")
@NotEmpty(message = "{case_review_associate_request.user_ids.not_empty}") @NotEmpty(message = "{case_review_associate_request.user_ids.not_empty}")
private List<String> reviewers; private List<String> reviewers;
@Schema(description = "查询功能用例的条件")
@NotNull(message = "{case_review_associate_request.base_associate_case_request.not_null}")
private BaseAssociateCaseRequest baseAssociateCaseRequest;
} }

View File

@ -26,4 +26,10 @@ public class CaseReviewBatchRequest extends TableBatchProcessDTO implements Seri
@Schema(description = "模块id") @Schema(description = "模块id")
private List<String> moduleIds; private List<String> moduleIds;
@Schema(description = "我评审的")
private String reviewByMe;
@Schema(description = "我创建的")
private String createByMe;
} }

View File

@ -28,7 +28,7 @@ public class CaseReviewRequest implements Serializable {
@NotBlank(message = "{case_review.name.not_blank}") @NotBlank(message = "{case_review.name.not_blank}")
private String name; private String name;
@Schema(description = "模块id", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "用例评审的模块id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{case_review.module_id.not_blank}") @NotBlank(message = "{case_review.module_id.not_blank}")
private String moduleId; private String moduleId;
@ -52,6 +52,6 @@ public class CaseReviewRequest implements Serializable {
@NotEmpty(message = "{case_review.reviewers.not_empty}") @NotEmpty(message = "{case_review.reviewers.not_empty}")
private List<String> reviewers; private List<String> reviewers;
@Schema(description = "关联的用例id", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "查询功能用例的条件")
private List<String> caseIds; private BaseAssociateCaseRequest baseAssociateCaseRequest;
} }

View File

@ -4,9 +4,12 @@ import io.metersphere.functional.domain.CaseReview;
import io.metersphere.functional.domain.CaseReviewFunctionalCase; import io.metersphere.functional.domain.CaseReviewFunctionalCase;
import io.metersphere.functional.domain.FunctionalCase; import io.metersphere.functional.domain.FunctionalCase;
import io.metersphere.functional.domain.FunctionalCaseExample; import io.metersphere.functional.domain.FunctionalCaseExample;
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
import io.metersphere.functional.mapper.CaseReviewMapper; import io.metersphere.functional.mapper.CaseReviewMapper;
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
import io.metersphere.functional.mapper.FunctionalCaseMapper; import io.metersphere.functional.mapper.FunctionalCaseMapper;
import io.metersphere.functional.request.BaseAssociateCaseRequest;
import io.metersphere.functional.request.BaseReviewCaseBatchRequest; import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
import io.metersphere.functional.request.CaseReviewAssociateRequest; import io.metersphere.functional.request.CaseReviewAssociateRequest;
import io.metersphere.functional.request.CaseReviewRequest; import io.metersphere.functional.request.CaseReviewRequest;
@ -41,6 +44,8 @@ public class CaseReviewLogService {
@Resource @Resource
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
@Resource
private ExtFunctionalCaseMapper extFunctionalCaseMapper;
/** /**
* 新增用例评审 日志 * 新增用例评审 日志
@ -144,7 +149,11 @@ public class CaseReviewLogService {
return null; return null;
} }
List<LogDTO> dtoList = new ArrayList<>(); List<LogDTO> dtoList = new ArrayList<>();
List<String> caseIds = request.getCaseIds(); BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
if (CollectionUtils.isEmpty(caseIds)) {
return null;
}
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
functionalCaseExample.createCriteria().andIdIn(caseIds); functionalCaseExample.createCriteria().andIdIn(caseIds);
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
@ -221,4 +230,17 @@ public class CaseReviewLogService {
return dtoList; return dtoList;
} }
public <T> List<String> doSelectIds(T dto, String projectId) {
BaseFunctionalCaseBatchDTO request = (BaseFunctionalCaseBatchDTO) dto;
if (request.isSelectAll()) {
List<String> ids = extFunctionalCaseMapper.getIds(request, projectId, false);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
ids.removeAll(request.getExcludeIds());
}
return ids;
} else {
return request.getSelectIds();
}
}
} }

View File

@ -4,13 +4,11 @@ package io.metersphere.functional.service;
import io.metersphere.functional.constants.CaseReviewStatus; import io.metersphere.functional.constants.CaseReviewStatus;
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.BaseFunctionalCaseBatchDTO;
import io.metersphere.functional.dto.CaseReviewDTO; import io.metersphere.functional.dto.CaseReviewDTO;
import io.metersphere.functional.dto.CaseReviewUserDTO; import io.metersphere.functional.dto.CaseReviewUserDTO;
import io.metersphere.functional.mapper.*; import io.metersphere.functional.mapper.*;
import io.metersphere.functional.request.CaseReviewAssociateRequest; import io.metersphere.functional.request.*;
import io.metersphere.functional.request.CaseReviewBatchRequest;
import io.metersphere.functional.request.CaseReviewPageRequest;
import io.metersphere.functional.request.CaseReviewRequest;
import io.metersphere.functional.result.CaseManagementResultCode; import io.metersphere.functional.result.CaseManagementResultCode;
import io.metersphere.project.dto.ModuleCountDTO; import io.metersphere.project.dto.ModuleCountDTO;
import io.metersphere.sdk.constants.ApplicationNumScope; import io.metersphere.sdk.constants.ApplicationNumScope;
@ -75,7 +73,11 @@ public class CaseReviewService {
@Resource @Resource
private CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper; private CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper;
@Resource @Resource
private ExtCaseReviewFunctionalCaseMapper extCaseReviewFunctionalCaseMapper;
@Resource
private CaseReviewModuleService caseReviewModuleService; private CaseReviewModuleService caseReviewModuleService;
@Resource
private ExtFunctionalCaseMapper extFunctionalCaseMapper;
private static final String CASE_MODULE_COUNT_ALL = "all"; private static final String CASE_MODULE_COUNT_ALL = "all";
@ -200,7 +202,9 @@ public class CaseReviewService {
*/ */
public void addCaseReview(CaseReviewRequest request, String userId) { public void addCaseReview(CaseReviewRequest request, String userId) {
String caseReviewId = IDGenerator.nextStr(); String caseReviewId = IDGenerator.nextStr();
addCaseReview(request, userId, caseReviewId); BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
addCaseReview(request, userId, caseReviewId, caseIds);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
CaseReviewUserMapper mapper = sqlSession.getMapper(CaseReviewUserMapper.class); CaseReviewUserMapper mapper = sqlSession.getMapper(CaseReviewUserMapper.class);
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class); CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
@ -209,9 +213,9 @@ public class CaseReviewService {
//保存和评审人的关系 //保存和评审人的关系
addCaseReviewUser(request, caseReviewId, mapper); addCaseReviewUser(request, caseReviewId, mapper);
//保存和用例的关系 //保存和用例的关系
addCaseReviewFunctionalCase(request.getCaseIds(), request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper); addCaseReviewFunctionalCase(caseIds, request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper);
//保存用例和用例评审人的关系 //保存用例和用例评审人的关系
addCaseReviewFunctionalCaseUser(request.getCaseIds(), request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper); addCaseReviewFunctionalCaseUser(caseIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
sqlSession.flushStatements(); sqlSession.flushStatements();
} finally { } finally {
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
@ -316,7 +320,7 @@ public class CaseReviewService {
* @param userId 当前操作人 * @param userId 当前操作人
* @param caseReviewId 用例评审id * @param caseReviewId 用例评审id
*/ */
private void addCaseReview(CaseReviewRequest request, String userId, String caseReviewId) { private void addCaseReview(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds) {
CaseReview caseReview = new CaseReview(); CaseReview caseReview = new CaseReview();
caseReview.setId(caseReviewId); caseReview.setId(caseReviewId);
caseReview.setNum(getNextNum(request.getProjectId())); caseReview.setNum(getNextNum(request.getProjectId()));
@ -330,10 +334,10 @@ public class CaseReviewService {
caseReview.setTags(JSON.toJSONString(request.getTags())); caseReview.setTags(JSON.toJSONString(request.getTags()));
} }
caseReview.setPassRate(BigDecimal.valueOf(0.00)); caseReview.setPassRate(BigDecimal.valueOf(0.00));
if (CollectionUtils.isEmpty(request.getCaseIds())) { if (CollectionUtils.isEmpty(caseIds)) {
caseReview.setCaseCount(0); caseReview.setCaseCount(0);
} else { } else {
caseReview.setCaseCount(request.getCaseIds().size()); caseReview.setCaseCount(caseIds.size());
} }
caseReview.setStartTime(request.getStartTime()); caseReview.setStartTime(request.getStartTime());
caseReview.setEndTime(request.getEndTime()); caseReview.setEndTime(request.getEndTime());
@ -350,8 +354,6 @@ public class CaseReviewService {
* @param caseReviewId 用例评审id * @param caseReviewId 用例评审id
*/ */
private CaseReview checkCaseReview(String caseReviewId) { private CaseReview checkCaseReview(String caseReviewId) {
CaseReviewExample caseReviewExample = new CaseReviewExample();
caseReviewExample.createCriteria().andIdEqualTo(caseReviewId);
CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(caseReviewId); CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(caseReviewId);
if (caseReview == null) { if (caseReview == null) {
throw new MSException(CaseManagementResultCode.CASE_REVIEW_NOT_FOUND); throw new MSException(CaseManagementResultCode.CASE_REVIEW_NOT_FOUND);
@ -368,6 +370,15 @@ public class CaseReviewService {
return (pos == null ? 0 : pos) + POS_STEP; return (pos == null ? 0 : pos) + POS_STEP;
} }
/**
* @param caseReviewId 用例评审id
* @return pos
*/
public Long getCaseFunctionalCaseNextPos(String caseReviewId) {
Long pos = extCaseReviewFunctionalCaseMapper.getPos(caseReviewId);
return (pos == null ? 0 : pos) + POS_STEP;
}
/** /**
* @param projectId 项目id * @param projectId 项目id
* @return num * @return num
@ -396,7 +407,7 @@ public class CaseReviewService {
caseReviewFunctionalCase.setCreateTime(System.currentTimeMillis()); caseReviewFunctionalCase.setCreateTime(System.currentTimeMillis());
caseReviewFunctionalCase.setUpdateTime(System.currentTimeMillis()); caseReviewFunctionalCase.setUpdateTime(System.currentTimeMillis());
caseReviewFunctionalCase.setId(IDGenerator.nextStr()); caseReviewFunctionalCase.setId(IDGenerator.nextStr());
caseReviewFunctionalCase.setPos(getNextPos(projectId)); caseReviewFunctionalCase.setPos(getCaseFunctionalCaseNextPos(caseReviewId));
caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase); caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase);
}); });
} }
@ -428,8 +439,13 @@ public class CaseReviewService {
public void associateCase(CaseReviewAssociateRequest request, String userId) { public void associateCase(CaseReviewAssociateRequest request, String userId) {
String caseReviewId = request.getReviewId(); String caseReviewId = request.getReviewId();
CaseReview caseReviewExist = checkCaseReview(caseReviewId); CaseReview caseReviewExist = checkCaseReview(caseReviewId);
BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
if (CollectionUtils.isEmpty(caseIds)) {
return;
}
FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample(); FunctionalCaseExample functionalCaseExample = new FunctionalCaseExample();
functionalCaseExample.createCriteria().andIdIn(request.getCaseIds()); functionalCaseExample.createCriteria().andIdIn(caseIds);
List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample); List<FunctionalCase> functionalCases = functionalCaseMapper.selectByExample(functionalCaseExample);
if (CollectionUtils.isEmpty(functionalCases)) { if (CollectionUtils.isEmpty(functionalCases)) {
return; return;
@ -438,7 +454,7 @@ public class CaseReviewService {
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviewId); caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(caseReviewId);
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
List<String> castIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).toList(); List<String> castIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).toList();
List<String> caseRealIds = request.getCaseIds().stream().filter(t -> !castIds.contains(t)).toList(); List<String> caseRealIds = caseIds.stream().filter(t -> !castIds.contains(t)).toList();
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class); CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper = sqlSession.getMapper(CaseReviewFunctionalCaseUserMapper.class); CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper = sqlSession.getMapper(CaseReviewFunctionalCaseUserMapper.class);
@ -464,6 +480,19 @@ public class CaseReviewService {
caseReviewMapper.updateByPrimaryKeySelective(caseReview); caseReviewMapper.updateByPrimaryKeySelective(caseReview);
} }
public <T> List<String> doSelectIds(T dto, String projectId) {
BaseFunctionalCaseBatchDTO request = (BaseFunctionalCaseBatchDTO) dto;
if (request.isSelectAll()) {
List<String> ids = extFunctionalCaseMapper.getIds(request, projectId, false);
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
ids.removeAll(request.getExcludeIds());
}
return ids;
} else {
return request.getSelectIds();
}
}
/** /**
* 用例评审列表拖拽排序 * 用例评审列表拖拽排序
* *

View File

@ -127,6 +127,9 @@ public class CaseReviewControllerTests extends BaseTest {
caseReviewRequest.setName(name); caseReviewRequest.setName(name);
caseReviewRequest.setModuleId("CASE_REVIEW_REAL_MODULE_ID"); caseReviewRequest.setModuleId("CASE_REVIEW_REAL_MODULE_ID");
caseReviewRequest.setReviewPassRule(reviewPassRule); caseReviewRequest.setReviewPassRule(reviewPassRule);
BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest();
baseAssociateCaseRequest.setProjectId(projectId);
baseAssociateCaseRequest.setSelectAll(false);
List<String> reviewers = new ArrayList<>(); List<String> reviewers = new ArrayList<>();
reviewers.add("admin"); reviewers.add("admin");
if (reviewer) { if (reviewer) {
@ -135,13 +138,14 @@ public class CaseReviewControllerTests extends BaseTest {
if (StringUtils.isNotBlank(caseId)) { if (StringUtils.isNotBlank(caseId)) {
List<String> caseIds = new ArrayList<>(); List<String> caseIds = new ArrayList<>();
caseIds.add(caseId); caseIds.add(caseId);
caseReviewRequest.setCaseIds(caseIds); baseAssociateCaseRequest.setSelectIds(caseIds);
} }
if (tag) { if (tag) {
List<String> tags = new ArrayList<>(); List<String> tags = new ArrayList<>();
tags.add("11"); tags.add("11");
caseReviewRequest.setTags(tags); caseReviewRequest.setTags(tags);
} }
caseReviewRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
return caseReviewRequest; return caseReviewRequest;
} }
@ -276,13 +280,11 @@ public class CaseReviewControllerTests extends BaseTest {
CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest();
caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setProjectId(projectId);
caseReviewAssociateRequest.setReviewId(caseReviewId); caseReviewAssociateRequest.setReviewId(caseReviewId);
List<String> caseIds = new ArrayList<>(); BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest();
caseIds.add("CASE_REVIEW_TEST_GYQ_ID2"); baseAssociateCaseRequest.setProjectId(projectId);
caseIds.add("CASE_REVIEW_TEST_GYQ_ID3"); baseAssociateCaseRequest.setSelectAll(true);
caseIds.add("CASE_REVIEW_TEST_GYQ_ID4"); baseAssociateCaseRequest.setExcludeIds(List.of("CASE_REVIEW_TEST_GYQ_ID"));
caseIds.add("CASE_REVIEW_TEST_GYQ_ID5"); caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
caseIds.add("CASE_REVIEW_TEST_GYQ_ID6");
caseReviewAssociateRequest.setCaseIds(caseIds);
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add("gyq_review_test"); userIds.add("gyq_review_test");
userIds.add("gyq_review_test2"); userIds.add("gyq_review_test2");
@ -307,9 +309,10 @@ public class CaseReviewControllerTests extends BaseTest {
CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest();
caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setProjectId(projectId);
caseReviewAssociateRequest.setReviewId("caseReviewIdXXXX"); caseReviewAssociateRequest.setReviewId("caseReviewIdXXXX");
List<String> caseIds = new ArrayList<>(); BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest();
caseIds.add("CASE_REVIEW_TEST_GYQ_ID2"); baseAssociateCaseRequest.setProjectId(projectId);
caseReviewAssociateRequest.setCaseIds(caseIds); baseAssociateCaseRequest.setSelectAll(true);
caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add("gyq_review_test"); userIds.add("gyq_review_test");
userIds.add("gyq_review_test2"); userIds.add("gyq_review_test2");
@ -319,9 +322,25 @@ public class CaseReviewControllerTests extends BaseTest {
caseReviewAssociateRequest = new CaseReviewAssociateRequest(); caseReviewAssociateRequest = new CaseReviewAssociateRequest();
caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setProjectId(projectId);
caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId()); caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId());
caseIds = new ArrayList<>(); baseAssociateCaseRequest = new BaseAssociateCaseRequest();
caseIds.add("CASE_REVIEW_TEST_GYQ_XX"); baseAssociateCaseRequest.setProjectId(projectId);
caseReviewAssociateRequest.setCaseIds(caseIds); baseAssociateCaseRequest.setSelectAll(false);
baseAssociateCaseRequest.setSelectIds(List.of("CASE_REVIEW_TEST_GYQ_XX"));
caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
userIds = new ArrayList<>();
userIds.add("gyq_review_test");
userIds.add("gyq_review_test2");
caseReviewAssociateRequest.setReviewers(userIds);
this.requestPostWithOk(ASSOCIATE_CASE_REVIEW, caseReviewAssociateRequest);
caseReviewAssociateRequest = new CaseReviewAssociateRequest();
caseReviewAssociateRequest.setProjectId(projectId);
caseReviewAssociateRequest.setReviewId(caseReviews.get(0).getId());
baseAssociateCaseRequest = new BaseAssociateCaseRequest();
baseAssociateCaseRequest.setProjectId("project-gyq-case-review-testYY");
baseAssociateCaseRequest.setSelectAll(true);
baseAssociateCaseRequest.setSelectIds(List.of("CASE_REVIEW_TEST_GYQ_XX"));
caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
userIds = new ArrayList<>(); userIds = new ArrayList<>();
userIds.add("gyq_review_test"); userIds.add("gyq_review_test");
userIds.add("gyq_review_test2"); userIds.add("gyq_review_test2");
@ -509,15 +528,15 @@ public class CaseReviewControllerTests extends BaseTest {
request.setSelectAll(false); request.setSelectAll(false);
this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request);
request.setSelectAll(true); request.setSelectAll(true);
request.setExcludeIds(List.of(caseReviews.get(0).getId()));
this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request);
caseReviews = getCaseReviews("创建评审更新1"); caseReviews = getCaseReviews("创建评审更新1");
String moduleIdNew = caseReviews.get(0).getModuleId(); String moduleIdNew = caseReviews.get(0).getModuleId();
Assertions.assertFalse(StringUtils.equals(moduleId, moduleIdNew)); Assertions.assertTrue(StringUtils.equals(moduleId, moduleIdNew));
request = new CaseReviewBatchRequest(); request = new CaseReviewBatchRequest();
request.setProjectId(projectId); request.setProjectId(projectId);
request.setMoveModuleId("CASE_REVIEW_REAL_MODULE_ID2"); request.setMoveModuleId("CASE_REVIEW_REAL_MODULE_ID2");
request.setSelectAll(false); request.setSelectAll(false);
request.setExcludeIds(List.of(caseReviews.get(0).getId()));
this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request); this.requestPostWithOkAndReturn(BATCH_MOVE_CASE_REVIEW, request);
caseReviews = getCaseReviews("创建评审更新1"); caseReviews = getCaseReviews("创建评审更新1");
String moduleIdNewOne = caseReviews.get(0).getModuleId(); String moduleIdNewOne = caseReviews.get(0).getModuleId();
@ -533,6 +552,8 @@ public class CaseReviewControllerTests extends BaseTest {
notificationExample.createCriteria().andResourceTypeEqualTo(NoticeConstants.TaskType.CASE_REVIEW_TASK).andResourceIdEqualTo(caseReviews.get(0).getId()).andOperationEqualTo("DELETE"); notificationExample.createCriteria().andResourceTypeEqualTo(NoticeConstants.TaskType.CASE_REVIEW_TASK).andResourceIdEqualTo(caseReviews.get(0).getId()).andOperationEqualTo("DELETE");
List<Notification> notifications = notificationMapper.selectByExampleWithBLOBs(notificationExample); List<Notification> notifications = notificationMapper.selectByExampleWithBLOBs(notificationExample);
Assertions.assertEquals(1, notifications.size()); Assertions.assertEquals(1, notifications.size());
delCaseReview("caseReviewIdX");
} }
@ -563,9 +584,11 @@ public class CaseReviewControllerTests extends BaseTest {
CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest(); CaseReviewAssociateRequest caseReviewAssociateRequest = new CaseReviewAssociateRequest();
caseReviewAssociateRequest.setProjectId(projectId); caseReviewAssociateRequest.setProjectId(projectId);
caseReviewAssociateRequest.setReviewId(caseReviewId); caseReviewAssociateRequest.setReviewId(caseReviewId);
List<String> caseIds = new ArrayList<>(); BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest();
caseIds.add("CASE_REVIEW_TEST_GYQ_ID2"); baseAssociateCaseRequest.setProjectId(projectId);
caseReviewAssociateRequest.setCaseIds(caseIds); baseAssociateCaseRequest.setSelectAll(false);
baseAssociateCaseRequest.setSelectIds(List.of("CASE_REVIEW_TEST_GYQ_ID2"));
caseReviewAssociateRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add("gyq_review_test"); userIds.add("gyq_review_test");
userIds.add("gyq_review_test2"); userIds.add("gyq_review_test2");

View File

@ -8,6 +8,7 @@ import io.metersphere.functional.dto.CaseReviewHistoryDTO;
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
import io.metersphere.functional.mapper.CaseReviewHistoryMapper; import io.metersphere.functional.mapper.CaseReviewHistoryMapper;
import io.metersphere.functional.mapper.CaseReviewMapper; import io.metersphere.functional.mapper.CaseReviewMapper;
import io.metersphere.functional.request.BaseAssociateCaseRequest;
import io.metersphere.functional.request.CaseReviewRequest; import io.metersphere.functional.request.CaseReviewRequest;
import io.metersphere.functional.request.ReviewFunctionalCaseRequest; import io.metersphere.functional.request.ReviewFunctionalCaseRequest;
import io.metersphere.project.domain.Notification; import io.metersphere.project.domain.Notification;
@ -255,7 +256,11 @@ public class ReviewFunctionalCaseControllerTests extends BaseTest {
caseReviewRequest.setModuleId("CASE_REVIEW_REAL_MODULE_ID"); caseReviewRequest.setModuleId("CASE_REVIEW_REAL_MODULE_ID");
caseReviewRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString()); caseReviewRequest.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
caseReviewRequest.setReviewers(reviewers); caseReviewRequest.setReviewers(reviewers);
caseReviewRequest.setCaseIds(caseIds); BaseAssociateCaseRequest baseAssociateCaseRequest = new BaseAssociateCaseRequest();
baseAssociateCaseRequest.setSelectAll(false);
baseAssociateCaseRequest.setProjectId(projectId);
baseAssociateCaseRequest.setSelectIds(caseIds);
caseReviewRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
List<String> tags = new ArrayList<>(); List<String> tags = new ArrayList<>();
tags.add("11"); tags.add("11");
caseReviewRequest.setTags(tags); caseReviewRequest.setTags(tags);

View File

@ -9,22 +9,22 @@ INSERT INTO template (id, name, remark, internal, update_time, create_time, crea
VALUES ('test_template_case_review_gyq_id', 'functional_case_review_gyq', '', b'0', 1696992836000, 1696992836000, 'admin', 'PROJECT', 'project-gyq-case-review-test', b'0', NULL, 'FUNCTIONAL'); VALUES ('test_template_case_review_gyq_id', 'functional_case_review_gyq', '', b'0', 1696992836000, 1696992836000, 'admin', 'PROJECT', 'project-gyq-case-review-test', b'0', NULL, 'FUNCTIONAL');
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 ('CASE_REVIEW_TEST_GYQ_ID', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试1', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('CASE_REVIEW_TEST_GYQ_ID', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试1', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 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 ('CASE_REVIEW_TEST_GYQ_ID2', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试2', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID2', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('CASE_REVIEW_TEST_GYQ_ID2', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试2', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID2', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 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 ('CASE_REVIEW_TEST_GYQ_ID3', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试3', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID3', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('CASE_REVIEW_TEST_GYQ_ID3', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试3', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID3', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 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 ('CASE_REVIEW_TEST_GYQ_ID4', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试4', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID4', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('CASE_REVIEW_TEST_GYQ_ID4', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试4', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID4', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 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 ('CASE_REVIEW_TEST_GYQ_ID5', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试5', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID5', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('CASE_REVIEW_TEST_GYQ_ID5', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试5', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID5', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 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 ('CASE_REVIEW_TEST_GYQ_ID6', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试6', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID6', 'UN_EXECUTED', true, b'0', b'0', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL); VALUES ('CASE_REVIEW_TEST_GYQ_ID6', 1, 'CASE_REVIEW_TEST_MODULE_ID', 'project-gyq-case-review-test', '100001', '关联需求测试6', 'UN_REVIEWED', NULL, 'STEP', 0, 'v1.0.0', 'CASE_REVIEW_TEST_GYQ_ID6', 'UN_EXECUTED', false, b'0', b'1', 'gyq', 'gyq', '', 1698058347559, 1698058347559, NULL);
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('CASE_REVIEW_TEST_GYQ_ID', 'gyq_custom_id_review1', '22'); INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('CASE_REVIEW_TEST_GYQ_ID', 'gyq_custom_id_review1', '22');
INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('CASE_REVIEW_TEST_GYQ_ID', 'gyq_custom_id_review2', '33'); INSERT INTO functional_case_custom_field(case_id, field_id, value) VALUES ('CASE_REVIEW_TEST_GYQ_ID', 'gyq_custom_id_review2', '33');