fix(测试跟踪): 缺陷取消关联用例,会把该用例关联与其他缺陷的关联关系清空

--bug=1020038 --user=陈建星 【测试跟踪】测试用例-关联jira缺陷-缺陷管理-取消关联用例-再次查看用例,关联的所有缺陷都被取消了 https://www.tapd.cn/55049933/s/1301042
This commit is contained in:
chenjianxing 2022-11-22 14:53:28 +08:00 committed by jianxing
parent d1e17b93c1
commit fa88d3d321
2 changed files with 10 additions and 28 deletions

View File

@ -298,20 +298,25 @@ public class IssuesService {
} }
} }
protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { public void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) {
String issuesId = issuesRequest.getId(); String issuesId = issuesRequest.getId();
List<String> deleteCaseIds = issuesRequest.getDeleteResourceIds(); List<String> deleteCaseIds = issuesRequest.getDeleteResourceIds();
if (!org.springframework.util.CollectionUtils.isEmpty(deleteCaseIds)) { if (!org.springframework.util.CollectionUtils.isEmpty(deleteCaseIds)) {
TestCaseIssuesExample example = new TestCaseIssuesExample(); TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andResourceIdIn(deleteCaseIds); example.createCriteria()
.andResourceIdIn(deleteCaseIds)
.andIssuesIdEqualTo(issuesId);
// 测试计划的用例 deleteCaseIds 是空的 不会进到这里 // 测试计划的用例 deleteCaseIds 是空的 不会进到这里
example.or(example.createCriteria().andRefIdIn(deleteCaseIds)); example.or(
example.createCriteria()
.andRefIdIn(deleteCaseIds)
.andIssuesIdEqualTo(issuesId)
);
testCaseIssuesMapper.deleteByExample(example); testCaseIssuesMapper.deleteByExample(example);
} }
List<String> addCaseIds = issuesRequest.getAddResourceIds(); List<String> addCaseIds = issuesRequest.getAddResourceIds();
TestCaseIssueService testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class);
if (!org.springframework.util.CollectionUtils.isEmpty(addCaseIds)) { if (!org.springframework.util.CollectionUtils.isEmpty(addCaseIds)) {
if (issuesRequest.getIsPlanEdit()) { if (issuesRequest.getIsPlanEdit()) {

View File

@ -164,30 +164,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
} }
protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) {
String issuesId = issuesRequest.getId(); issuesService.handleTestCaseIssues(issuesRequest);
List<String> deleteCaseIds = issuesRequest.getDeleteResourceIds();
if (!CollectionUtils.isEmpty(deleteCaseIds)) {
TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andResourceIdIn(deleteCaseIds);
// 测试计划的用例 deleteCaseIds 是空的 不会进到这里
example.or(example.createCriteria().andRefIdIn(deleteCaseIds));
testCaseIssuesMapper.deleteByExample(example);
}
List<String> addCaseIds = issuesRequest.getAddResourceIds();
TestCaseIssueService testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class);
if (!CollectionUtils.isEmpty(addCaseIds)) {
if (issuesRequest.getIsPlanEdit()) {
addCaseIds.forEach(caseId -> {
testCaseIssueService.add(issuesId, caseId, issuesRequest.getRefId(), IssueRefType.PLAN_FUNCTIONAL.name());
testCaseIssueService.updateIssuesCount(caseId);
});
} else {
addCaseIds.forEach(caseId -> testCaseIssueService.add(issuesId, caseId, null, IssueRefType.FUNCTIONAL.name()));
}
}
} }
protected void insertIssuesWithoutContext(String id, IssuesUpdateRequest issuesRequest) { protected void insertIssuesWithoutContext(String id, IssuesUpdateRequest issuesRequest) {