feat(功能用例): 评审详情页面创建用例
This commit is contained in:
parent
d5ec1cf140
commit
4e4f17f195
|
@ -71,5 +71,8 @@ public class FunctionalCaseAddRequest implements Serializable {
|
|||
@Schema(description = "关联文件ID集合")
|
||||
private List<String> relateFileMetaIds;
|
||||
|
||||
@Schema(description = "评审id")
|
||||
private String reviewId;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package io.metersphere.functional.service;
|
||||
|
||||
|
||||
import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
|
||||
import io.metersphere.functional.domain.CaseReviewFunctionalCase;
|
||||
import io.metersphere.functional.domain.CaseReviewFunctionalCaseExample;
|
||||
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
||||
import io.metersphere.functional.dto.ReviewsDTO;
|
||||
|
@ -13,6 +15,7 @@ import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
|
|||
import io.metersphere.project.domain.ProjectVersion;
|
||||
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -43,6 +46,8 @@ public class CaseReviewFunctionalCaseService {
|
|||
private ExtCaseReviewFunctionalCaseUserMapper extCaseReviewFunctionalCaseUserMapper;
|
||||
@Resource
|
||||
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
|
||||
@Resource
|
||||
private CaseReviewService caseReviewService;
|
||||
|
||||
/**
|
||||
* 通过评审id获取关联的用例id集合
|
||||
|
@ -116,4 +121,26 @@ public class CaseReviewFunctionalCaseService {
|
|||
return request.getSelectIds();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 评审详情页面 创建用例并关联
|
||||
*
|
||||
* @param caseId
|
||||
* @param userId
|
||||
* @param reviewId
|
||||
*/
|
||||
public void addCaseReviewFunctionalCase(String caseId, String userId, String reviewId) {
|
||||
CaseReviewFunctionalCase reviewFunctionalCase = new CaseReviewFunctionalCase();
|
||||
reviewFunctionalCase.setId(IDGenerator.nextStr());
|
||||
reviewFunctionalCase.setCaseId(caseId);
|
||||
reviewFunctionalCase.setReviewId(reviewId);
|
||||
reviewFunctionalCase.setStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString());
|
||||
reviewFunctionalCase.setCreateUser(userId);
|
||||
reviewFunctionalCase.setCreateTime(System.currentTimeMillis());
|
||||
reviewFunctionalCase.setUpdateTime(System.currentTimeMillis());
|
||||
reviewFunctionalCase.setPos(caseReviewService.getCaseFunctionalCaseNextPos(reviewId));
|
||||
caseReviewFunctionalCaseMapper.insertSelective(reviewFunctionalCase);
|
||||
|
||||
}
|
||||
}
|
|
@ -213,7 +213,7 @@ public class CaseReviewService {
|
|||
//保存和评审人的关系
|
||||
addCaseReviewUser(request, caseReviewId, mapper);
|
||||
//保存和用例的关系
|
||||
addCaseReviewFunctionalCase(caseIds, request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||
addCaseReviewFunctionalCase(caseIds, userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||
//保存用例和用例评审人的关系
|
||||
addCaseReviewFunctionalCaseUser(caseIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
||||
sqlSession.flushStatements();
|
||||
|
@ -353,7 +353,7 @@ public class CaseReviewService {
|
|||
*
|
||||
* @param caseReviewId 用例评审id
|
||||
*/
|
||||
private CaseReview checkCaseReview(String caseReviewId) {
|
||||
public CaseReview checkCaseReview(String caseReviewId) {
|
||||
CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(caseReviewId);
|
||||
if (caseReview == null) {
|
||||
throw new MSException(CaseManagementResultCode.CASE_REVIEW_NOT_FOUND);
|
||||
|
@ -391,13 +391,13 @@ public class CaseReviewService {
|
|||
* 保存用例评审和功能用例的关系
|
||||
*
|
||||
* @param caseIds 功能用例Ids
|
||||
* @param projectId 项目ID
|
||||
* @param userId 当前操作人
|
||||
* @param caseReviewId 用例评审id
|
||||
* @param caseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper
|
||||
*/
|
||||
private void addCaseReviewFunctionalCase(List<String> caseIds, String projectId, String userId, String caseReviewId, CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper) {
|
||||
private void addCaseReviewFunctionalCase(List<String> caseIds, String userId, String caseReviewId, CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper) {
|
||||
if (CollectionUtils.isNotEmpty(caseIds)) {
|
||||
Long nextPos = getCaseFunctionalCaseNextPos(caseReviewId);
|
||||
caseIds.forEach(caseId -> {
|
||||
CaseReviewFunctionalCase caseReviewFunctionalCase = new CaseReviewFunctionalCase();
|
||||
caseReviewFunctionalCase.setReviewId(caseReviewId);
|
||||
|
@ -407,7 +407,7 @@ public class CaseReviewService {
|
|||
caseReviewFunctionalCase.setCreateTime(System.currentTimeMillis());
|
||||
caseReviewFunctionalCase.setUpdateTime(System.currentTimeMillis());
|
||||
caseReviewFunctionalCase.setId(IDGenerator.nextStr());
|
||||
caseReviewFunctionalCase.setPos(getCaseFunctionalCaseNextPos(caseReviewId));
|
||||
caseReviewFunctionalCase.setPos(nextPos + POS_STEP);
|
||||
caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase);
|
||||
});
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ public class CaseReviewService {
|
|||
CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper = sqlSession.getMapper(CaseReviewFunctionalCaseUserMapper.class);
|
||||
try {
|
||||
//保存和用例的关系
|
||||
addCaseReviewFunctionalCase(caseRealIds, request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||
addCaseReviewFunctionalCase(caseRealIds, userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||
//保存用例和用例评审人的关系
|
||||
addCaseReviewFunctionalCaseUser(caseRealIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
||||
sqlSession.flushStatements();
|
||||
|
@ -582,7 +582,7 @@ public class CaseReviewService {
|
|||
BigDecimal passCount = BigDecimal.valueOf(passList.size());
|
||||
BigDecimal totalCount = BigDecimal.valueOf(caseReview.getCaseCount());
|
||||
BigDecimal passRate;
|
||||
if (totalCount.compareTo(BigDecimal.ZERO)==0) {
|
||||
if (totalCount.compareTo(BigDecimal.ZERO) == 0) {
|
||||
passRate = BigDecimal.ZERO;
|
||||
} else {
|
||||
passRate = passCount.divide(totalCount, 2, RoundingMode.HALF_UP);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class FunctionalCaseService {
|
|||
private FunctionalCaseFollowerMapper functionalCaseFollowerMapper;
|
||||
|
||||
@Resource
|
||||
private DeleteFunctionalCaseService deleteFunctionalCaseService;
|
||||
private CaseReviewService caseReviewService;
|
||||
|
||||
@Resource
|
||||
SqlSessionFactory sqlSessionFactory;
|
||||
|
@ -83,6 +83,9 @@ public class FunctionalCaseService {
|
|||
@Resource
|
||||
private FunctionalCaseModuleService functionalCaseModuleService;
|
||||
|
||||
@Resource
|
||||
private CaseReviewFunctionalCaseService caseReviewFunctionalCaseService;
|
||||
|
||||
private static final String CASE_MODULE_COUNT_ALL = "all";
|
||||
|
||||
private static final String ADD_FUNCTIONAL_CASE_FILE_LOG_URL = "/functional/case/add";
|
||||
|
@ -102,11 +105,25 @@ public class FunctionalCaseService {
|
|||
functionalCaseAttachmentService.association(request.getRelateFileMetaIds(), caseId, userId, ADD_FUNCTIONAL_CASE_FILE_LOG_URL, request.getProjectId());
|
||||
}
|
||||
|
||||
addCaseReviewCase(request.getReviewId(), caseId, userId);
|
||||
|
||||
return functionalCase;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加用例评审和用例关联关系
|
||||
*
|
||||
* @param reviewId reviewId
|
||||
*/
|
||||
private void addCaseReviewCase(String reviewId, String caseId, String userId) {
|
||||
if (StringUtils.isNotBlank(reviewId)) {
|
||||
caseReviewService.checkCaseReview(reviewId);
|
||||
caseReviewFunctionalCaseService.addCaseReviewFunctionalCase(caseId, userId, reviewId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加功能用例
|
||||
*
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
package io.metersphere.functional.controller;
|
||||
|
||||
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
|
||||
import io.metersphere.functional.request.FunctionalCaseAddRequest;
|
||||
import io.metersphere.functional.request.FunctionalCasePageRequest;
|
||||
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.sdk.BaseCondition;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
import org.springframework.test.context.jdbc.SqlConfig;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
|
@ -26,6 +30,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
|
||||
public static final String REVIEW_CASE_PAGE = "/case/review/detail/page";
|
||||
public static final String BATCH_DELETE_URL = "/case/review/detail/batch/disassociate";
|
||||
public static final String FUNCTIONAL_CASE_ADD_URL = "/functional/case/add";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
|
@ -105,4 +110,34 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
public void testCaseReviewAddCase() throws Exception {
|
||||
//新增
|
||||
FunctionalCaseAddRequest request = creatFunctionalCase();
|
||||
LinkedMultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
|
||||
List<MockMultipartFile> files = new ArrayList<>();
|
||||
paramMap.add("request", JSON.toJSONString(request));
|
||||
paramMap.add("files", files);
|
||||
MvcResult mvcResult = this.requestMultipartWithOkAndReturn(FUNCTIONAL_CASE_ADD_URL, paramMap);
|
||||
// 获取返回值
|
||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
// 返回请求正常
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
}
|
||||
|
||||
|
||||
private FunctionalCaseAddRequest creatFunctionalCase() {
|
||||
FunctionalCaseAddRequest functionalCaseAddRequest = new FunctionalCaseAddRequest();
|
||||
functionalCaseAddRequest.setProjectId(DEFAULT_PROJECT_ID);
|
||||
functionalCaseAddRequest.setTemplateId("default_template_id");
|
||||
functionalCaseAddRequest.setName("测试评审详情创建用例");
|
||||
functionalCaseAddRequest.setCaseEditType("STEP");
|
||||
functionalCaseAddRequest.setModuleId("TEST_MODULE_ID");
|
||||
functionalCaseAddRequest.setReviewId("wx_review_id_1");
|
||||
return functionalCaseAddRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue