fix(测试跟踪): 批量关联需求AzureDevops添加链接
--bug=1022724 --user=陈建星 【缺陷管理】github #21633,项目关联devops三方平台,批量关联需求后,tfs平台的需求未全部关联上所选用例 https://www.tapd.cn/55049933/s/1340165
This commit is contained in:
parent
fde1df3579
commit
9ee75314e4
|
@ -261,19 +261,28 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDemandHyperLink(EditTestCaseRequest request, String type) {
|
public void addDemandHyperLink(EditTestCaseRequest request, String type) {
|
||||||
|
IssuesRequest updateRequest = getIssuesRequest(request);
|
||||||
|
Project project = baseProjectService.getProjectById(request.getProjectId());
|
||||||
|
if (StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
|
||||||
|
doAddDemandHyperLink(request, type, updateRequest, project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doAddDemandHyperLink(EditTestCaseRequest request, String type, IssuesRequest updateRequest, Project project) {
|
||||||
|
updateRequest.setWorkspaceId(project.getWorkspaceId());
|
||||||
|
List<IssuesPlatform> platformList = getAddPlatforms(updateRequest);
|
||||||
|
platformList.forEach(platform -> {
|
||||||
|
platform.updateDemandHyperLink(request, project, type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private IssuesRequest getIssuesRequest(EditTestCaseRequest request) {
|
||||||
IssuesRequest updateRequest = new IssuesRequest();
|
IssuesRequest updateRequest = new IssuesRequest();
|
||||||
updateRequest.setId(request.getId());
|
updateRequest.setId(request.getId());
|
||||||
updateRequest.setResourceId(request.getDemandId());
|
updateRequest.setResourceId(request.getDemandId());
|
||||||
updateRequest.setProjectId(request.getProjectId());
|
updateRequest.setProjectId(request.getProjectId());
|
||||||
updateRequest.setTestCaseId(request.getId());
|
updateRequest.setTestCaseId(request.getId());
|
||||||
Project project = baseProjectService.getProjectById(request.getProjectId());
|
return updateRequest;
|
||||||
if (StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
|
|
||||||
updateRequest.setWorkspaceId(project.getWorkspaceId());
|
|
||||||
List<IssuesPlatform> platformList = getAddPlatforms(updateRequest);
|
|
||||||
platformList.forEach(platform -> {
|
|
||||||
platform.updateDemandHyperLink(request, project, type);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDemandHyperLinkBatch(List<String> testcaseIds, String projectId) {
|
public void addDemandHyperLinkBatch(List<String> testcaseIds, String projectId) {
|
||||||
|
@ -456,6 +465,10 @@ public class TestCaseService {
|
||||||
if (!StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
|
if (!StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
doUpdateThirdPartyIssuesLink(testCase, project);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doUpdateThirdPartyIssuesLink(EditTestCaseRequest testCase, Project project) {
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
if (!issuesService.isThirdPartTemplate(project)) {
|
if (!issuesService.isThirdPartTemplate(project)) {
|
||||||
issuesRequest.setDefaultCustomFields(issuesService.getDefaultCustomFields(testCase.getProjectId()));
|
issuesRequest.setDefaultCustomFields(issuesService.getDefaultCustomFields(testCase.getProjectId()));
|
||||||
|
@ -3121,8 +3134,26 @@ public class TestCaseService {
|
||||||
TestCaseExample example = new TestCaseExample();
|
TestCaseExample example = new TestCaseExample();
|
||||||
example.createCriteria().andIdIn(request.getIds());
|
example.createCriteria().andIdIn(request.getIds());
|
||||||
List<TestCase> testCaseList = testCaseMapper.selectByExample(example);
|
List<TestCase> testCaseList = testCaseMapper.selectByExample(example);
|
||||||
|
Project project = null;
|
||||||
|
if (CollectionUtils.isNotEmpty(testCaseList)) {
|
||||||
|
project = baseProjectService.getProjectById(testCaseList.get(0).getProjectId());
|
||||||
|
}
|
||||||
|
|
||||||
for (TestCase tc : testCaseList) {
|
for (TestCase tc : testCaseList) {
|
||||||
|
|
||||||
|
if (project != null && StringUtils.equals(project.getPlatform(), IssuesManagePlatform.AzureDevops.name())) {
|
||||||
|
EditTestCaseRequest editTestCaseRequest = new EditTestCaseRequest();
|
||||||
|
BeanUtils.copyBean(editTestCaseRequest, tc);
|
||||||
|
try {
|
||||||
|
doUpdateThirdPartyIssuesLink(editTestCaseRequest, project);
|
||||||
|
// 同步用例与需求的关联关系
|
||||||
|
IssuesRequest updateRequest = getIssuesRequest(editTestCaseRequest);
|
||||||
|
doAddDemandHyperLink(editTestCaseRequest, "edit", updateRequest, project);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tc.setDemandId(demandId);
|
tc.setDemandId(demandId);
|
||||||
tc.setDemandName(demandName);
|
tc.setDemandName(demandName);
|
||||||
mapper.updateByPrimaryKey(tc);
|
mapper.updateByPrimaryKey(tc);
|
||||||
|
|
Loading…
Reference in New Issue