feat(功能用例): 评审详情页面创建用例
This commit is contained in:
parent
d5ec1cf140
commit
4e4f17f195
|
@ -71,5 +71,8 @@ public class FunctionalCaseAddRequest implements Serializable {
|
||||||
@Schema(description = "关联文件ID集合")
|
@Schema(description = "关联文件ID集合")
|
||||||
private List<String> relateFileMetaIds;
|
private List<String> relateFileMetaIds;
|
||||||
|
|
||||||
|
@Schema(description = "评审id")
|
||||||
|
private String reviewId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package io.metersphere.functional.service;
|
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.domain.CaseReviewFunctionalCaseExample;
|
||||||
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
|
||||||
import io.metersphere.functional.dto.ReviewsDTO;
|
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.domain.ProjectVersion;
|
||||||
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||||
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -43,6 +46,8 @@ public class CaseReviewFunctionalCaseService {
|
||||||
private ExtCaseReviewFunctionalCaseUserMapper extCaseReviewFunctionalCaseUserMapper;
|
private ExtCaseReviewFunctionalCaseUserMapper extCaseReviewFunctionalCaseUserMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
|
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private CaseReviewService caseReviewService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过评审id获取关联的用例id集合
|
* 通过评审id获取关联的用例id集合
|
||||||
|
@ -116,4 +121,26 @@ public class CaseReviewFunctionalCaseService {
|
||||||
return request.getSelectIds();
|
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);
|
addCaseReviewUser(request, caseReviewId, mapper);
|
||||||
//保存和用例的关系
|
//保存和用例的关系
|
||||||
addCaseReviewFunctionalCase(caseIds, request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
addCaseReviewFunctionalCase(caseIds, userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||||
//保存用例和用例评审人的关系
|
//保存用例和用例评审人的关系
|
||||||
addCaseReviewFunctionalCaseUser(caseIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
addCaseReviewFunctionalCaseUser(caseIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
@ -353,7 +353,7 @@ public class CaseReviewService {
|
||||||
*
|
*
|
||||||
* @param caseReviewId 用例评审id
|
* @param caseReviewId 用例评审id
|
||||||
*/
|
*/
|
||||||
private CaseReview checkCaseReview(String caseReviewId) {
|
public CaseReview checkCaseReview(String 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);
|
||||||
|
@ -391,13 +391,13 @@ public class CaseReviewService {
|
||||||
* 保存用例评审和功能用例的关系
|
* 保存用例评审和功能用例的关系
|
||||||
*
|
*
|
||||||
* @param caseIds 功能用例Ids
|
* @param caseIds 功能用例Ids
|
||||||
* @param projectId 项目ID
|
|
||||||
* @param userId 当前操作人
|
* @param userId 当前操作人
|
||||||
* @param caseReviewId 用例评审id
|
* @param caseReviewId 用例评审id
|
||||||
* @param caseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper
|
* @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)) {
|
if (CollectionUtils.isNotEmpty(caseIds)) {
|
||||||
|
Long nextPos = getCaseFunctionalCaseNextPos(caseReviewId);
|
||||||
caseIds.forEach(caseId -> {
|
caseIds.forEach(caseId -> {
|
||||||
CaseReviewFunctionalCase caseReviewFunctionalCase = new CaseReviewFunctionalCase();
|
CaseReviewFunctionalCase caseReviewFunctionalCase = new CaseReviewFunctionalCase();
|
||||||
caseReviewFunctionalCase.setReviewId(caseReviewId);
|
caseReviewFunctionalCase.setReviewId(caseReviewId);
|
||||||
|
@ -407,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(getCaseFunctionalCaseNextPos(caseReviewId));
|
caseReviewFunctionalCase.setPos(nextPos + POS_STEP);
|
||||||
caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase);
|
caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -460,7 +460,7 @@ public class CaseReviewService {
|
||||||
CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper = sqlSession.getMapper(CaseReviewFunctionalCaseUserMapper.class);
|
CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper = sqlSession.getMapper(CaseReviewFunctionalCaseUserMapper.class);
|
||||||
try {
|
try {
|
||||||
//保存和用例的关系
|
//保存和用例的关系
|
||||||
addCaseReviewFunctionalCase(caseRealIds, request.getProjectId(), userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
addCaseReviewFunctionalCase(caseRealIds, userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||||
//保存用例和用例评审人的关系
|
//保存用例和用例评审人的关系
|
||||||
addCaseReviewFunctionalCaseUser(caseRealIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
addCaseReviewFunctionalCaseUser(caseRealIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
@ -582,7 +582,7 @@ public class CaseReviewService {
|
||||||
BigDecimal passCount = BigDecimal.valueOf(passList.size());
|
BigDecimal passCount = BigDecimal.valueOf(passList.size());
|
||||||
BigDecimal totalCount = BigDecimal.valueOf(caseReview.getCaseCount());
|
BigDecimal totalCount = BigDecimal.valueOf(caseReview.getCaseCount());
|
||||||
BigDecimal passRate;
|
BigDecimal passRate;
|
||||||
if (totalCount.compareTo(BigDecimal.ZERO)==0) {
|
if (totalCount.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
passRate = BigDecimal.ZERO;
|
passRate = BigDecimal.ZERO;
|
||||||
} else {
|
} else {
|
||||||
passRate = passCount.divide(totalCount, 2, RoundingMode.HALF_UP);
|
passRate = passCount.divide(totalCount, 2, RoundingMode.HALF_UP);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class FunctionalCaseService {
|
||||||
private FunctionalCaseFollowerMapper functionalCaseFollowerMapper;
|
private FunctionalCaseFollowerMapper functionalCaseFollowerMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DeleteFunctionalCaseService deleteFunctionalCaseService;
|
private CaseReviewService caseReviewService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
SqlSessionFactory sqlSessionFactory;
|
SqlSessionFactory sqlSessionFactory;
|
||||||
|
@ -83,6 +83,9 @@ public class FunctionalCaseService {
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseModuleService functionalCaseModuleService;
|
private FunctionalCaseModuleService functionalCaseModuleService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CaseReviewFunctionalCaseService caseReviewFunctionalCaseService;
|
||||||
|
|
||||||
private static final String CASE_MODULE_COUNT_ALL = "all";
|
private static final String CASE_MODULE_COUNT_ALL = "all";
|
||||||
|
|
||||||
private static final String ADD_FUNCTIONAL_CASE_FILE_LOG_URL = "/functional/case/add";
|
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());
|
functionalCaseAttachmentService.association(request.getRelateFileMetaIds(), caseId, userId, ADD_FUNCTIONAL_CASE_FILE_LOG_URL, request.getProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addCaseReviewCase(request.getReviewId(), caseId, userId);
|
||||||
|
|
||||||
return functionalCase;
|
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;
|
package io.metersphere.functional.controller;
|
||||||
|
|
||||||
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
|
import io.metersphere.functional.request.BaseReviewCaseBatchRequest;
|
||||||
|
import io.metersphere.functional.request.FunctionalCaseAddRequest;
|
||||||
import io.metersphere.functional.request.FunctionalCasePageRequest;
|
import io.metersphere.functional.request.FunctionalCasePageRequest;
|
||||||
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
|
import io.metersphere.functional.request.ReviewFunctionalCasePageRequest;
|
||||||
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.dto.sdk.BaseCondition;
|
import io.metersphere.system.dto.sdk.BaseCondition;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.*;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
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.Sql;
|
||||||
import org.springframework.test.context.jdbc.SqlConfig;
|
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.*;
|
import java.util.*;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@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 REVIEW_CASE_PAGE = "/case/review/detail/page";
|
||||||
public static final String BATCH_DELETE_URL = "/case/review/detail/batch/disassociate";
|
public static final String BATCH_DELETE_URL = "/case/review/detail/batch/disassociate";
|
||||||
|
public static final String FUNCTIONAL_CASE_ADD_URL = "/functional/case/add";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@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