fix(用例管理): 修复批量重新评审时,多人评审规则的用例结果计算错误问题
This commit is contained in:
parent
8d729e3ea4
commit
de74dac4b8
|
@ -21,6 +21,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -85,6 +86,7 @@ public class CaseReviewFunctionalCaseController {
|
|||
|
||||
@PostMapping("/batch/disassociate")
|
||||
@Operation(summary = "用例管理-用例评审-评审列表-评审详情-列表-批量取消关联用例")
|
||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_RELEVANCE)
|
||||
@Log(type = OperationLogType.DISASSOCIATE, expression = "#msClass.batchDisassociateCaseLog(#request)", msClass = CaseReviewLogService.class)
|
||||
@CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review")
|
||||
public void batchDisassociate(@Validated @RequestBody BaseReviewCaseBatchRequest request) {
|
||||
|
@ -101,15 +103,17 @@ public class CaseReviewFunctionalCaseController {
|
|||
|
||||
@PostMapping("/batch/review")
|
||||
@Operation(summary = "用例管理-用例评审-评审列表-评审详情-列表-批量评审")
|
||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_REVIEW)
|
||||
@RequiresPermissions(value = {PermissionConstants.CASE_REVIEW_REVIEW, PermissionConstants.CASE_REVIEW_READ_UPDATE}, logical = Logical.OR)
|
||||
@CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review")
|
||||
public void batchReview(@Validated @RequestBody BatchReviewFunctionalCaseRequest request) {
|
||||
caseReviewFunctionalCaseService.batchReview(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/batch/edit/reviewers")
|
||||
@Operation(summary = "用例管理-用例评审-评审列表-评审详情-列表-批量修改评审人")
|
||||
@CheckOwner(resourceId = "#request.getReviewId()", resourceType = "case_review")
|
||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ_UPDATE)
|
||||
public void batchEditReviewUser(@Validated @RequestBody BatchEditReviewerRequest request) {
|
||||
caseReviewFunctionalCaseService.batchEditReviewUser(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
|
|
@ -16,8 +16,10 @@ import io.metersphere.project.domain.ProjectVersion;
|
|||
import io.metersphere.project.dto.ModuleCountDTO;
|
||||
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||
import io.metersphere.project.service.PermissionCheckService;
|
||||
import io.metersphere.provider.BaseCaseProvider;
|
||||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||
import io.metersphere.sdk.constants.UserRoleScope;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
|
@ -94,6 +96,10 @@ public class CaseReviewFunctionalCaseService {
|
|||
private CaseReviewUserMapper caseReviewUserMapper;
|
||||
@Resource
|
||||
private UserRoleRelationMapper userRoleRelationMapper;
|
||||
@Resource
|
||||
private PermissionCheckService permissionCheckService;
|
||||
@Resource
|
||||
private CaseReviewMapper caseReviewMapper;
|
||||
|
||||
|
||||
private static final String CASE_MODULE_COUNT_ALL = "all";
|
||||
|
@ -325,7 +331,12 @@ public class CaseReviewFunctionalCaseService {
|
|||
*/
|
||||
public void batchReview(BatchReviewFunctionalCaseRequest request, String userId) {
|
||||
String reviewId = request.getReviewId();
|
||||
|
||||
CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(reviewId);
|
||||
request.setReviewPassRule(caseReview.getReviewPassRule());
|
||||
//检查权限
|
||||
if (!permissionCheckService.userHasProjectPermission(userId, caseReview.getProjectId(), PermissionConstants.CASE_REVIEW_READ_UPDATE) && StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString()) ) {
|
||||
throw new MSException("http_result_forbidden");
|
||||
}
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCaseList = doCaseReviewFunctionalCases(request);
|
||||
if(CollectionUtils.isEmpty(caseReviewFunctionalCaseList)) {
|
||||
return;
|
||||
|
@ -379,7 +390,7 @@ public class CaseReviewFunctionalCaseService {
|
|||
} else {
|
||||
caseHistoryMap.get(caseId).add(caseReviewHistory);
|
||||
}
|
||||
//根据评审规则更新用例评审和功能用例关系表中的状态 1.单人评审直接更新评审结果 2.多人评审需要计算
|
||||
//根据评审规则更新用例评审和功能用例关系表中的状态 1.单人评审直接更新评审结果 2.多人评审需要计算 3.如果是重新评审,直接全部变成重新评审
|
||||
setStatus(request, caseReviewFunctionalCase, caseHistoryMap, reviewerMap, isAdmin);
|
||||
statusMap.put(caseReviewFunctionalCase.getCaseId(), caseReviewFunctionalCase.getStatus());
|
||||
caseReviewFunctionalCaseMapper.updateByPrimaryKeySelective(caseReviewFunctionalCase);
|
||||
|
@ -419,6 +430,10 @@ public class CaseReviewFunctionalCaseService {
|
|||
|
||||
|
||||
private static void setStatus(BatchReviewFunctionalCaseRequest request, CaseReviewFunctionalCase caseReviewFunctionalCase, Map<String, List<CaseReviewHistory>> caseHistoryMap, Map<String, List<CaseReviewFunctionalCaseUser>> reviewerMap, boolean isAdmin) {
|
||||
if (StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.toString())) {
|
||||
caseReviewFunctionalCase.setStatus(request.getStatus());
|
||||
return;
|
||||
}
|
||||
if (StringUtils.equals(request.getReviewPassRule(), CaseReviewPassRule.SINGLE.toString())) {
|
||||
if (!StringUtils.equalsIgnoreCase(request.getStatus(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()) && !isAdmin) {
|
||||
caseReviewFunctionalCase.setStatus(request.getStatus());
|
||||
|
|
|
@ -259,13 +259,66 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
public void testBatchReview() throws Exception {
|
||||
|
||||
BatchReviewFunctionalCaseRequest request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
request.setReviewId("wx_review_id_3");
|
||||
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.PASS.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审通过");
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_2");
|
||||
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.UN_PASS.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审失败");
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
request.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.UN_PASS.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审重新评审");
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
request.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.RE_REVIEWED.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审重新评审");
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
try {
|
||||
caseReviewFunctionalCaseService.batchReview(request, "GGG");
|
||||
} catch (Exception e){
|
||||
Assertions.assertNotNull(e);
|
||||
}
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_4");
|
||||
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.UNDER_REVIEWED.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审人");
|
||||
caseReviewFunctionalCaseService.batchReview(request, "666");
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_4");
|
||||
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.UNDER_REVIEWED.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审人");
|
||||
caseReviewFunctionalCaseService.batchReview(request, "GGG");
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_4");
|
||||
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
|
||||
request.setStatus(FunctionalCaseReviewStatus.UN_PASS.toString());
|
||||
request.setSelectAll(true);
|
||||
request.setContent("测试批量评审人");
|
||||
caseReviewFunctionalCaseService.batchReview(request, "123");
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
request.setReviewPassRule(CaseReviewPassRule.MULTIPLE.toString());
|
||||
|
@ -276,8 +329,6 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
request.setExcludeIds(excludeIds);
|
||||
request.setContent("测试批量评审不通过");
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
CaseReviewFunctionalCase caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_4");
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()));
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
|
@ -288,8 +339,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
ids.add("gyq_test_3");
|
||||
request.setSelectIds(ids);
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_3");
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.PASS.toString()));
|
||||
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
|
@ -301,8 +351,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
ids.add("gyq_test_3");
|
||||
request.setSelectIds(ids);
|
||||
caseReviewFunctionalCaseService.batchReview(request, "multiple_review_admin");
|
||||
caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_3");
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.PASS.toString()));
|
||||
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
|
@ -313,8 +362,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
ids.add("gyq_test_3");
|
||||
request.setSelectIds(ids);
|
||||
caseReviewFunctionalCaseService.batchReview(request, "admin");
|
||||
caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_3");
|
||||
Assertions.assertTrue(StringUtils.equalsIgnoreCase(caseReviewFunctionalCase.getStatus(), FunctionalCaseReviewStatus.PASS.toString()));
|
||||
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
|
@ -337,8 +385,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
request.setSelectIds(ids);
|
||||
request.setContent("测试批量评审通过");
|
||||
this.requestPostWithOk(REVIEW_FUNCTIONAL_CASE_BATCH_REVIEW, request);
|
||||
caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_5");
|
||||
|
||||
CaseReviewFunctionalCase caseReviewFunctionalCase = caseReviewFunctionalCaseMapper.selectByPrimaryKey("gyq_test_5");
|
||||
|
||||
request = new BatchReviewFunctionalCaseRequest();
|
||||
request.setReviewId("wx_review_id_1");
|
||||
|
|
|
@ -115,7 +115,9 @@ INSERT INTO user(id, name, email, password, create_time, update_time, language,
|
|||
last_project_id, create_user, update_user, deleted)
|
||||
VALUES ('gyq_case_review', 'gyq_case_review', 'gyq_case_review_case@fit2cloud.com', MD5('metersphere'),UNIX_TIMESTAMP() * 1000,UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false),
|
||||
('GGG', 'GGG', 'GGG_case_review_case@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false),
|
||||
('multiple_review_admin', 'multiple_review_admin', 'multiple_review_admin@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false);
|
||||
('multiple_review_admin', 'multiple_review_admin', 'multiple_review_admin@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false),
|
||||
('123', '123', '123@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false);
|
||||
|
||||
|
||||
INSERT INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user)
|
||||
VALUE (UUID(), 'multiple_review_admin', 'admin', 'system',
|
||||
|
|
Loading…
Reference in New Issue