fix(测试跟踪): 测试计划关联缺陷,用例列表不可见

--bug=1020350 --user=陈建星 [测试跟踪] #20224主线版本测试计划中用例关联缺陷后,在测试计划外的功能用例和缺陷管理看不到两者关联关系。 https://www.tapd.cn/55049933/s/1307032
This commit is contained in:
chenjianxing 2022-11-29 10:42:29 +08:00 committed by jianxing
parent 1727f40062
commit 33c8af78a4
3 changed files with 21 additions and 14 deletions

View File

@ -29,5 +29,5 @@ public class IssueSyncRequest {
private String defaultCustomFields; private String defaultCustomFields;
private Map<String, List<io.metersphere.xpack.track.dto.PlatformAttachment>> attachmentMap = new HashMap<>(); private Map<String, List<PlatformAttachment>> attachmentMap = new HashMap<>();
} }

View File

@ -8,6 +8,7 @@ import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.base.mapper.TestPlanTestCaseMapper; import io.metersphere.base.mapper.TestPlanTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.IssueRefType; import io.metersphere.commons.constants.IssueRefType;
import io.metersphere.commons.constants.MicroServiceName;
import io.metersphere.commons.constants.ProjectApplicationType; import io.metersphere.commons.constants.ProjectApplicationType;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
@ -36,6 +37,7 @@ import io.metersphere.service.*;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.request.testcase.TrackCount; import io.metersphere.request.testcase.TrackCount;
import io.metersphere.request.testreview.SaveCommentRequest; import io.metersphere.request.testreview.SaveCommentRequest;
import io.metersphere.utils.DiscoveryUtil;
import io.metersphere.xpack.track.dto.IssuesDao; import io.metersphere.xpack.track.dto.IssuesDao;
import io.metersphere.xpack.version.service.ProjectVersionService; import io.metersphere.xpack.version.service.ProjectVersionService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -299,9 +301,7 @@ public class TestPlanTestCaseService {
TestPlanCaseDTO testPlanCaseDTO = extTestPlanTestCaseMapper.get(id); TestPlanCaseDTO testPlanCaseDTO = extTestPlanTestCaseMapper.get(id);
ServiceUtils.buildCustomNumInfo(testPlanCaseDTO); ServiceUtils.buildCustomNumInfo(testPlanCaseDTO);
List<TestCaseTestDTO> testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testPlanCaseDTO.getCaseId()); List<TestCaseTestDTO> testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testPlanCaseDTO.getCaseId());
testCaseTestDTOS.forEach(dto -> { testCaseTestDTOS.forEach(this::setTestName);
setTestName(dto);
});
testPlanCaseDTO.setList(testCaseTestDTOS); testPlanCaseDTO.setList(testCaseTestDTOS);
return testPlanCaseDTO; return testPlanCaseDTO;
} }
@ -309,24 +309,31 @@ public class TestPlanTestCaseService {
private void setTestName(TestCaseTestDTO dto) { private void setTestName(TestCaseTestDTO dto) {
String type = dto.getTestType(); String type = dto.getTestType();
String id = dto.getTestId(); String id = dto.getTestId();
Set<String> serviceIdSet = DiscoveryUtil.getServiceIdSet();
switch (type) { switch (type) {
case "performance": case "performance":
if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) {
LoadTest loadTest = planPerformanceTestService.get(id); LoadTest loadTest = planPerformanceTestService.get(id);
if (loadTest != null) { if (loadTest != null) {
dto.setTestName(loadTest.getName()); dto.setTestName(loadTest.getName());
} }
}
break; break;
case "testcase": case "testcase":
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = planApiTestCaseService.get(id); ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = planApiTestCaseService.get(id);
if (apiTestCaseWithBLOBs != null) { if (apiTestCaseWithBLOBs != null) {
dto.setTestName(apiTestCaseWithBLOBs.getName()); dto.setTestName(apiTestCaseWithBLOBs.getName());
} }
}
break; break;
case "automation": case "automation":
if (serviceIdSet.contains(MicroServiceName.API_TEST)) {
ApiScenarioWithBLOBs apiScenarioWithBLOBs = panApiAutomationService.get(id); ApiScenarioWithBLOBs apiScenarioWithBLOBs = panApiAutomationService.get(id);
if (apiScenarioWithBLOBs != null) { if (apiScenarioWithBLOBs != null) {
dto.setTestName(apiScenarioWithBLOBs.getName()); dto.setTestName(apiScenarioWithBLOBs.getName());
} }
}
break; break;
default: default:
break; break;

View File

@ -121,7 +121,7 @@ public class TestCaseIssueService {
testCaseIssues.setIssuesId(issuesId); testCaseIssues.setIssuesId(issuesId);
testCaseIssues.setResourceId(resourceId); testCaseIssues.setResourceId(resourceId);
testCaseIssues.setRefType(refType); testCaseIssues.setRefType(refType);
testCaseIssues.setRefId(StringUtils.isNotBlank(refId) ? null : refId); testCaseIssues.setRefId(StringUtils.isNotBlank(refId) ? refId : null);
testCaseIssues.setRelateTime(System.currentTimeMillis()); testCaseIssues.setRelateTime(System.currentTimeMillis());
testCaseIssuesMapper.insert(testCaseIssues); testCaseIssuesMapper.insert(testCaseIssues);
} }