fix(用例管理): 修复用例评审周期时间可以早于当前时间问题

--bug=1036045 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036045
This commit is contained in:
guoyuqi 2024-03-07 20:38:28 +08:00 committed by 刘瑞斌
parent babf25ea74
commit d398de2246
7 changed files with 46 additions and 3 deletions

View File

@ -6,6 +6,9 @@ permission.functional_case.minder=脑图编辑
permission.case_review.name=用例评审 permission.case_review.name=用例评审
permission.case_review.review=评审 permission.case_review.review=评审
permission.case_review.relevance=关联/取消关联 permission.case_review.relevance=关联/取消关联
permission.case_review.start_time=评审周期开始时间不得早于当前时间
permission.case_review.end_time=评审周期结束时间不得早于当前时间
#moduleFunctionalCase #moduleFunctionalCase
functional_case.module.default.name=未规划用例 functional_case.module.default.name=未规划用例
review.module.default.name=未规划评审 review.module.default.name=未规划评审

View File

@ -6,6 +6,8 @@ permission.functional_case.comment=Comment
permission.case_review.name=Case review permission.case_review.name=Case review
permission.case_review.review=Review permission.case_review.review=Review
permission.case_review.relevance=Associate/Disassociate permission.case_review.relevance=Associate/Disassociate
permission.case_review.startTime=The start time of the cycle review cannot be earlier than the current time
permission.case_review.endTime=The review cycle end time cannot be earlier than the current time
#moduleFunctionalCase #moduleFunctionalCase
functional_case.module.default.name=Unplanned case functional_case.module.default.name=Unplanned case

View File

@ -6,6 +6,8 @@ permission.functional_case.minder=脑图编辑
permission.case_review.name=用例评审 permission.case_review.name=用例评审
permission.case_review.review=评审 permission.case_review.review=评审
permission.case_review.relevance=关联/取消关联 permission.case_review.relevance=关联/取消关联
permission.case_review.start_time=评审周期开始时间不得早于当前时间
permission.case_review.end_time=评审周期结束时间不得早于当前时间
#moduleFunctionalCase #moduleFunctionalCase
functional_case.module.default.name=未规划用例 functional_case.module.default.name=未规划用例
review.module.default.name=未规划评审 review.module.default.name=未规划评审

View File

@ -6,6 +6,8 @@ permission.functional_case.comment=評論
permission.case_review.name=用例評審 permission.case_review.name=用例評審
permission.case_review.review=評審 permission.case_review.review=評審
permission.case_review.relevance=關聯/取消關聯 permission.case_review.relevance=關聯/取消關聯
permission.case_review.start_time=週期評審開始時間不得早於目前時間
permission.case_review.end_time=評審週期結束時間不得早於目前時間
#moduleFunctionalCase #moduleFunctionalCase
functional_case.module.default.name=未規劃用例 functional_case.module.default.name=未規劃用例

View File

@ -16,6 +16,7 @@ import io.metersphere.provider.BaseCaseProvider;
import io.metersphere.sdk.constants.ApplicationNumScope; import io.metersphere.sdk.constants.ApplicationNumScope;
import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.Translator;
import io.metersphere.system.dto.sdk.request.PosRequest; import io.metersphere.system.dto.sdk.request.PosRequest;
import io.metersphere.system.dto.user.UserDTO; import io.metersphere.system.dto.user.UserDTO;
import io.metersphere.system.mapper.ExtUserMapper; import io.metersphere.system.mapper.ExtUserMapper;
@ -376,12 +377,12 @@ public class CaseReviewService {
private void checkAndSetStartAndEndTime(CaseReviewRequest request, CaseReview caseReview) { private void checkAndSetStartAndEndTime(CaseReviewRequest request, CaseReview caseReview) {
long currentZeroTime = getCurrentZeroTime(); long currentZeroTime = getCurrentZeroTime();
if (request.getStartTime() != null && request.getStartTime() < currentZeroTime) { if (request.getStartTime() != null && request.getStartTime() < currentZeroTime) {
throw new MSException("评审周期开始时间不得早于当前时间"); throw new MSException(Translator.get("permission.case_review.start_time"));
} else { } else {
caseReview.setStartTime(request.getStartTime()); caseReview.setStartTime(request.getStartTime());
} }
if (request.getEndTime() != null && request.getEndTime() < currentZeroTime) { if (request.getEndTime() != null && request.getEndTime() < currentZeroTime) {
throw new MSException("评审周期结束时间不得早于当前时间"); throw new MSException(Translator.get("permission.case_review.end_time"));
} else { } else {
caseReview.setEndTime(request.getEndTime()); caseReview.setEndTime(request.getEndTime());
} }

View File

@ -142,6 +142,10 @@ public class CaseReviewControllerTests extends BaseTest {
caseReviewRequest.setEndTime(1678188103000L); caseReviewRequest.setEndTime(1678188103000L);
this.requestPost(ADD_CASE_REVIEW, caseReviewRequest).andExpect(status().is5xxServerError()); this.requestPost(ADD_CASE_REVIEW, caseReviewRequest).andExpect(status().is5xxServerError());
caseReviewRequest.setStartTime(1901791303000L);
caseReviewRequest.setEndTime(1678188103000L);
this.requestPost(ADD_CASE_REVIEW, caseReviewRequest).andExpect(status().is5xxServerError());
} }
private List<CaseReview> getCaseReviews(String name) { private List<CaseReview> getCaseReviews(String name) {
@ -232,6 +236,9 @@ public class CaseReviewControllerTests extends BaseTest {
caseReviewRequestWidthStartTime.setStartTime(1678188043000L); caseReviewRequestWidthStartTime.setStartTime(1678188043000L);
caseReviewRequestWidthStartTime.setEndTime(1678188103000L); caseReviewRequestWidthStartTime.setEndTime(1678188103000L);
this.requestPost(ADD_CASE_REVIEW, caseReviewRequestWidthStartTime).andExpect(status().is5xxServerError()); this.requestPost(ADD_CASE_REVIEW, caseReviewRequestWidthStartTime).andExpect(status().is5xxServerError());
caseReviewRequestWidthStartTime.setStartTime(1901791303000L);
caseReviewRequestWidthStartTime.setEndTime(1678188103000L);
this.requestPost(ADD_CASE_REVIEW, caseReviewRequestWidthStartTime).andExpect(status().is5xxServerError());
} }
@Test @Test
@ -297,6 +304,9 @@ public class CaseReviewControllerTests extends BaseTest {
caseReviewRequestWidthStartTime.setStartTime(1678188043000L); caseReviewRequestWidthStartTime.setStartTime(1678188043000L);
caseReviewRequestWidthStartTime.setEndTime(1678188103000L); caseReviewRequestWidthStartTime.setEndTime(1678188103000L);
this.requestPost(ADD_CASE_REVIEW, caseReviewRequestWidthStartTime).andExpect(status().is5xxServerError()); this.requestPost(ADD_CASE_REVIEW, caseReviewRequestWidthStartTime).andExpect(status().is5xxServerError());
caseReviewRequestWidthStartTime.setStartTime(1901791303000L);
caseReviewRequestWidthStartTime.setEndTime(1678188103000L);
this.requestPost(ADD_CASE_REVIEW, caseReviewRequestWidthStartTime).andExpect(status().is5xxServerError());
} }
@Test @Test
@ -512,6 +522,28 @@ public class CaseReviewControllerTests extends BaseTest {
caseReviewDTOS = JSON.parseArray(JSON.toJSONString(pageData.getList()), CaseReviewDTO.class); caseReviewDTOS = JSON.parseArray(JSON.toJSONString(pageData.getList()), CaseReviewDTO.class);
Assertions.assertTrue(CollectionUtils.isNotEmpty(caseReviewDTOS)); Assertions.assertTrue(CollectionUtils.isNotEmpty(caseReviewDTOS));
request = new CaseReviewPageRequest();
filters = new HashMap<>();
request.setFilter(filters);
request.setCombine(caseReviewCombine);
request.setProjectId("project-gyq-case-review-test_gt");
request.setCurrent(1);
request.setPageSize(10);
mvcResult = this.requestPostWithOkAndReturn(PAGE_CASE_REVIEW, request);
// 获取返回值
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
pageData = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), Pager.class);
// 返回值不为空
Assertions.assertNotNull(pageData);
// 返回值的页码和当前页码相同
Assertions.assertEquals(pageData.getCurrent(), request.getCurrent());
// 返回的数据量不超过规定要返回的数据量相同
Assertions.assertTrue(JSON.parseArray(JSON.toJSONString(pageData.getList())).size() <= request.getPageSize());
caseReviewDTOS = JSON.parseArray(JSON.toJSONString(pageData.getList()), CaseReviewDTO.class);
Assertions.assertTrue(CollectionUtils.isEmpty(caseReviewDTOS));
} }
@Test @Test

View File

@ -2,7 +2,8 @@
INSERT INTO organization(id, num, name, description, create_time, update_time, create_user, update_user, deleted, delete_user, delete_time) VALUE INSERT INTO organization(id, num, name, description, create_time, update_time, create_user, update_user, deleted, delete_user, delete_time) VALUE
('organization-gyq-case-review-test', null, 'organization-gyq-case-review-test', 'organization-gyq-case-review-test', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', 0, null, null); ('organization-gyq-case-review-test', null, 'organization-gyq-case-review-test', 'organization-gyq-case-review-test', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', 0, null, null);
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES
('project-gyq-case-review-test', null, 'organization-gyq-case-review-test', '用例评审项目', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000); ('project-gyq-case-review-test', null, 'organization-gyq-case-review-test', '用例评审项目', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
('project-gyq-case-review-test_gt', null, 'organization-gyq-case-review-test', '用例评审项目2', '系统默认创建的项目', 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);
INSERT INTO template (id, name, remark, internal, update_time, create_time, create_user, scope_type, scope_id, enable_third_part, ref_id, scene) INSERT INTO template (id, name, remark, internal, update_time, create_time, create_user, scope_type, scope_id, enable_third_part, ref_id, scene)