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

View File

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