refactor(功能用例): 增加用例功能相关的检查
This commit is contained in:
parent
35a95cb40e
commit
581de62928
|
@ -1,7 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.functional.mapper.ExtFunctionalCaseMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.functional.domain.FunctionalCase">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="num" jdbcType="BIGINT" property="num" />
|
||||
<result column="module_id" jdbcType="VARCHAR" property="moduleId" />
|
||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||
<result column="template_id" jdbcType="VARCHAR" property="templateId" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="review_status" jdbcType="VARCHAR" property="reviewStatus" />
|
||||
<result column="tags" jdbcType="VARCHAR" property="tags" typeHandler="io.metersphere.handler.ListTypeHandler" />
|
||||
<result column="case_edit_type" jdbcType="VARCHAR" property="caseEditType" />
|
||||
<result column="pos" jdbcType="BIGINT" property="pos" />
|
||||
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
|
||||
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
|
||||
<result column="last_execute_result" jdbcType="VARCHAR" property="lastExecuteResult" />
|
||||
<result column="deleted" jdbcType="BIT" property="deleted" />
|
||||
<result column="public_case" jdbcType="BIT" property="publicCase" />
|
||||
<result column="latest" jdbcType="BIT" property="latest" />
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||
<result column="update_user" jdbcType="VARCHAR" property="updateUser" />
|
||||
<result column="delete_user" jdbcType="VARCHAR" property="deleteUser" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="delete_time" jdbcType="BIGINT" property="deleteTime" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getPos" resultType="java.lang.Long">
|
||||
SELECT
|
||||
|
@ -516,7 +539,7 @@
|
|||
</update>
|
||||
|
||||
|
||||
<select id="getTagsByIds" resultType="io.metersphere.functional.domain.FunctionalCase">
|
||||
<select id="getTagsByIds" resultMap="BaseResultMap">
|
||||
select id, tags from functional_case
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
|
|
|
@ -566,6 +566,8 @@ public class CaseReviewService {
|
|||
}
|
||||
|
||||
public void disassociate(String reviewId, String caseId, String userId) {
|
||||
checkCaseReview(reviewId);
|
||||
checkCase(caseId);
|
||||
//1.刪除评审与功能用例关联关系
|
||||
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
|
||||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo(caseId);
|
||||
|
@ -579,6 +581,13 @@ public class CaseReviewService {
|
|||
provider.updateCaseReview(param);
|
||||
}
|
||||
|
||||
private void checkCase(String caseId) {
|
||||
FunctionalCase functionalCase = functionalCaseMapper.selectByPrimaryKey(caseId);
|
||||
if (functionalCase == null) {
|
||||
throw new MSException(CaseManagementResultCode.FUNCTIONAL_CASE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Long> moduleCount(CaseReviewPageRequest request) {
|
||||
//查出每个模块节点下的资源数量。 不需要按照模块进行筛选
|
||||
request.setModuleIds(null);
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.metersphere.system.service.NoticeSendService;
|
|||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.beanutils.BeanMap;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -221,6 +222,9 @@ public class FunctionalCaseCommentService {
|
|||
functionalCaseCommentExample.createCriteria().andCaseIdEqualTo(caseId);
|
||||
List<FunctionalCaseComment> functionalCaseComments = functionalCaseCommentMapper.selectByExampleWithBLOBs(functionalCaseCommentExample);
|
||||
List<String> userIds = getUserIds(functionalCaseComments);
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<String, User> userMap = getUserMap(userIds);
|
||||
return buildData(functionalCaseComments, userMap);
|
||||
}
|
||||
|
|
|
@ -587,7 +587,6 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(caseReviewId);
|
||||
Assertions.assertEquals(0, caseReview.getPassRate().compareTo(BigDecimal.ZERO));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -598,7 +597,7 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(status().is5xxServerError())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
|
||||
String caseReviewId = caseReviews.get(0).getId();
|
||||
|
@ -606,7 +605,7 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(status().is5xxServerError())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import io.metersphere.system.domain.CustomField;
|
|||
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
|
@ -397,7 +398,17 @@ public class FunctionalCaseCommentControllerTests {
|
|||
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||
List<FunctionalCaseCommentDTO> list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalCaseCommentDTO.class);
|
||||
System.out.println(JSON.toJSONString(list));
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(list));
|
||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(GET_URL + "xiaomeinvGTestTwo").header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||
list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), FunctionalCaseCommentDTO.class);
|
||||
Assertions.assertTrue(CollectionUtils.isEmpty(list));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -72,6 +72,10 @@ INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, r
|
|||
VALUES ('xiaomeinvGTestOne', 1000001, 'test_guo', 'project-case-comment-test', 'test_guo', 'gyqTest1', 'UN_REVIEWED', null, 'text',
|
||||
10001, '111', 'xiaomeinvGTestOne', 'success', false, false, true, 'gyq', 'gyq', null, 1698058347559,
|
||||
1698058347559,
|
||||
null),
|
||||
('xiaomeinvGTestTwo', 1000001, 'test_guo', 'project-case-comment-test', 'test_guo', 'gyqTest2', 'UN_REVIEWED', null, 'text',
|
||||
10001, '111', 'xiaomeinvGTestTwo', 'success', false, false, true, 'gyq', 'gyq', null, 1698058347559,
|
||||
1698058347559,
|
||||
null);
|
||||
|
||||
INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||
|
|
Loading…
Reference in New Issue