feat(用例管理): 增加用例评审删除,状态变成上一个评审的状态功能
--task=1016125 --user=郭雨琦 https://www.tapd.cn/55049933/prong/tasks/view/1155049933001016125
This commit is contained in:
parent
d4b7cec42b
commit
c22c9c47af
|
@ -80,8 +80,6 @@ public class CaseReviewService {
|
|||
@Resource
|
||||
private BaseCaseProvider provider;
|
||||
@Resource
|
||||
private ExtCaseReviewHistoryMapper extCaseReviewHistoryMapper;
|
||||
@Resource
|
||||
private UserLoginService userLoginService;
|
||||
|
||||
|
||||
|
@ -619,9 +617,41 @@ public class CaseReviewService {
|
|||
}
|
||||
|
||||
public void deleteCaseReview(String reviewId, String projectId) {
|
||||
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
|
||||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId);
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
List<String> caseIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).toList();
|
||||
deleteCaseReviewService.deleteCaseReviewResource(List.of(reviewId), projectId);
|
||||
//将评审历史状态置为true
|
||||
extCaseReviewHistoryMapper.updateDelete(new ArrayList<>(), reviewId, true);
|
||||
//将用例置为上一次的评审的结果
|
||||
if (CollectionUtils.isEmpty(caseIds)) {
|
||||
return;
|
||||
}
|
||||
caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
|
||||
caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(caseIds);
|
||||
caseReviewFunctionalCaseExample.setOrderByClause("update_time DESC");
|
||||
caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
Map<String, List<CaseReviewFunctionalCase>> caseReviewMap = caseReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId));
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
FunctionalCaseMapper mapper = sqlSession.getMapper(FunctionalCaseMapper.class);
|
||||
try {
|
||||
for (String caseId : caseIds) {
|
||||
FunctionalCase functionalCase = new FunctionalCase();
|
||||
functionalCase.setId(caseId);
|
||||
String status;
|
||||
List<CaseReviewFunctionalCase> statuList = caseReviewMap.get(caseId);
|
||||
if (CollectionUtils.isNotEmpty(statuList)) {
|
||||
List<CaseReviewFunctionalCase> list = statuList.stream().sorted(Comparator.comparing(CaseReviewFunctionalCase::getUpdateTime).reversed()).toList();
|
||||
status = list.getFirst().getStatus();
|
||||
} else {
|
||||
status = FunctionalCaseReviewStatus.UN_REVIEWED.toString();
|
||||
}
|
||||
functionalCase.setReviewStatus(status);
|
||||
mapper.updateByPrimaryKeySelective(functionalCase);
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
} finally {
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
public void disassociate(String reviewId, String caseId, String userId) {
|
||||
|
|
|
@ -623,7 +623,45 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
public void testDelete() throws Exception {
|
||||
List<CaseReview> caseReviews = getCaseReviews("创建评审更新2");
|
||||
delCaseReview(caseReviews.getFirst().getId());
|
||||
CaseReview caseReview = new CaseReview();
|
||||
String id = UUID.randomUUID().toString();
|
||||
caseReview.setId(id);
|
||||
caseReview.setNum(1001L);
|
||||
caseReview.setPos(1020L);
|
||||
caseReview.setCaseCount(2);
|
||||
caseReview.setStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString());
|
||||
caseReview.setPassRate(BigDecimal.ZERO);
|
||||
caseReview.setName("dddd");
|
||||
caseReview.setModuleId("root");
|
||||
caseReview.setProjectId(DEFAULT_PROJECT_ID );
|
||||
caseReview.setReviewPassRule(CaseReviewPassRule.SINGLE.toString());
|
||||
caseReview.setCreateUser("Gyq");
|
||||
caseReview.setCreateTime(System.currentTimeMillis());
|
||||
caseReview.setUpdateTime(System.currentTimeMillis());
|
||||
caseReview.setUpdateUser("Gyq");
|
||||
caseReviewMapper.insert(caseReview);
|
||||
CaseReviewFunctionalCase caseReviewFunctionalCase = new CaseReviewFunctionalCase();
|
||||
caseReviewFunctionalCase.setCaseId("CASE_REVIEW_TEST_GYQ_ID2");
|
||||
caseReviewFunctionalCase.setReviewId(id);
|
||||
caseReviewFunctionalCase.setId(UUID.randomUUID().toString());
|
||||
caseReviewFunctionalCase.setStatus(FunctionalCaseReviewStatus.PASS.name());
|
||||
caseReviewFunctionalCase.setPos(110L);
|
||||
caseReviewFunctionalCase.setCreateUser("Gyq");
|
||||
caseReviewFunctionalCase.setCreateTime(System.currentTimeMillis());
|
||||
caseReviewFunctionalCase.setUpdateTime(System.currentTimeMillis());
|
||||
caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase);
|
||||
|
||||
caseReviewFunctionalCase = new CaseReviewFunctionalCase();
|
||||
caseReviewFunctionalCase.setId(UUID.randomUUID().toString());
|
||||
caseReviewFunctionalCase.setCaseId("CASE_REVIEW_TEST_GYQ_ID3");
|
||||
caseReviewFunctionalCase.setReviewId(id);
|
||||
caseReviewFunctionalCase.setStatus(FunctionalCaseReviewStatus.PASS.name());
|
||||
caseReviewFunctionalCase.setPos(110L);
|
||||
caseReviewFunctionalCase.setCreateUser("Gyq");
|
||||
caseReviewFunctionalCase.setCreateTime(System.currentTimeMillis());
|
||||
caseReviewFunctionalCase.setUpdateTime(System.currentTimeMillis());
|
||||
caseReviewFunctionalCaseMapper.insert(caseReviewFunctionalCase);
|
||||
delCaseReview(id);
|
||||
delCaseReview("caseReviewIdX");
|
||||
}
|
||||
|
||||
|
@ -702,7 +740,7 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
}
|
||||
|
||||
private void delCaseReview(String reviewId) throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(DELETE_CASE_REVIEW+reviewId+"/"+projectId).header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(DELETE_CASE_REVIEW+projectId+"/"+reviewId).header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
|
|
Loading…
Reference in New Issue