refactor(测试跟踪): 更新用例需求时,调用插件预留的需求更新方法
This commit is contained in:
parent
edf8d8bd2e
commit
9628430583
2
pom.xml
2
pom.xml
|
@ -22,7 +22,7 @@
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<spring-cloud.version>2022.0.2</spring-cloud.version>
|
<spring-cloud.version>2022.0.2</spring-cloud.version>
|
||||||
<dubbo.version>2.7.22</dubbo.version>
|
<dubbo.version>2.7.22</dubbo.version>
|
||||||
<platform-plugin-sdk.version>1.5.0</platform-plugin-sdk.version>
|
<platform-plugin-sdk.version>1.6.0</platform-plugin-sdk.version>
|
||||||
<shiro.version>1.11.0</shiro.version>
|
<shiro.version>1.11.0</shiro.version>
|
||||||
<java-websocket.version>1.5.3</java-websocket.version>
|
<java-websocket.version>1.5.3</java-websocket.version>
|
||||||
<easyexcel.version>3.1.1</easyexcel.version>
|
<easyexcel.version>3.1.1</easyexcel.version>
|
||||||
|
|
|
@ -33,6 +33,8 @@ import io.metersphere.log.vo.OperatingLogDetails;
|
||||||
import io.metersphere.log.vo.track.TestCaseReference;
|
import io.metersphere.log.vo.track.TestCaseReference;
|
||||||
import io.metersphere.plan.service.TestPlanService;
|
import io.metersphere.plan.service.TestPlanService;
|
||||||
import io.metersphere.plan.service.TestPlanTestCaseService;
|
import io.metersphere.plan.service.TestPlanTestCaseService;
|
||||||
|
import io.metersphere.platform.domain.DemandUpdateRequest;
|
||||||
|
import io.metersphere.platform.domain.TestCaseDemandDTO;
|
||||||
import io.metersphere.request.OrderRequest;
|
import io.metersphere.request.OrderRequest;
|
||||||
import io.metersphere.request.ProjectVersionRequest;
|
import io.metersphere.request.ProjectVersionRequest;
|
||||||
import io.metersphere.request.ResetOrderRequest;
|
import io.metersphere.request.ResetOrderRequest;
|
||||||
|
@ -186,6 +188,8 @@ public class TestCaseService {
|
||||||
private ExtTestCaseCountMapper extTestCaseCountMapper;
|
private ExtTestCaseCountMapper extTestCaseCountMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtTestAnalysisMapper extTestAnalysisMapper;
|
private ExtTestAnalysisMapper extTestAnalysisMapper;
|
||||||
|
@Resource
|
||||||
|
private PlatformPluginService platformPluginService;
|
||||||
|
|
||||||
private ThreadLocal<Integer> importCreateNum = new ThreadLocal<>();
|
private ThreadLocal<Integer> importCreateNum = new ThreadLocal<>();
|
||||||
|
|
||||||
|
@ -237,6 +241,8 @@ public class TestCaseService {
|
||||||
|
|
||||||
// 同步用例与需求的关联关系
|
// 同步用例与需求的关联关系
|
||||||
addDemandHyperLink(request, "add");
|
addDemandHyperLink(request, "add");
|
||||||
|
handleDemandUpdate(request, DemandUpdateRequest.OperateType.ADD,
|
||||||
|
projectMapper.selectByPrimaryKey(request.getProjectId()));
|
||||||
|
|
||||||
testCaseMapper.insert(request);
|
testCaseMapper.insert(request);
|
||||||
saveFollows(request.getId(), request.getFollows());
|
saveFollows(request.getId(), request.getFollows());
|
||||||
|
@ -256,6 +262,37 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleDemandUpdate(EditTestCaseRequest request, DemandUpdateRequest.OperateType type, Project project) {
|
||||||
|
handleDemandUpdate(request, type, project, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用例变更时,调用插件的需求变更的方法
|
||||||
|
* @param request
|
||||||
|
* @param type
|
||||||
|
* @param project
|
||||||
|
* @param originDemandId
|
||||||
|
*/
|
||||||
|
private void handleDemandUpdate(EditTestCaseRequest request, DemandUpdateRequest.OperateType type,
|
||||||
|
Project project, String originDemandId) {
|
||||||
|
try {
|
||||||
|
if (!StringUtils.isAllBlank(request.getDemandId(), originDemandId) && PlatformPluginService.isPluginPlatform(project.getPlatform())) {
|
||||||
|
String projectConfig = PlatformPluginService.getCompatibleProjectConfig(project);
|
||||||
|
DemandUpdateRequest demandUpdateRequest = new DemandUpdateRequest();
|
||||||
|
TestCaseDemandDTO testCaseDemandDTO = new TestCaseDemandDTO();
|
||||||
|
BeanUtils.copyBean(testCaseDemandDTO, request);
|
||||||
|
testCaseDemandDTO.setOriginDemandId(originDemandId);
|
||||||
|
demandUpdateRequest.setTestCase(testCaseDemandDTO);
|
||||||
|
demandUpdateRequest.setProjectConfig(projectConfig);
|
||||||
|
demandUpdateRequest.setOperateType(type);
|
||||||
|
platformPluginService.getPlatform(project.getPlatform())
|
||||||
|
.handleDemandUpdate(demandUpdateRequest);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void doAddDemandHyperLink(EditTestCaseRequest request, String type, IssuesRequest updateRequest, Project project) {
|
private void doAddDemandHyperLink(EditTestCaseRequest request, String type, IssuesRequest updateRequest, Project project) {
|
||||||
updateRequest.setWorkspaceId(project.getWorkspaceId());
|
updateRequest.setWorkspaceId(project.getWorkspaceId());
|
||||||
List<IssuesPlatform> platformList = getAddPlatforms(updateRequest);
|
List<IssuesPlatform> platformList = getAddPlatforms(updateRequest);
|
||||||
|
@ -389,6 +426,9 @@ public class TestCaseService {
|
||||||
|
|
||||||
// 同步用例与需求的关联关系
|
// 同步用例与需求的关联关系
|
||||||
addDemandHyperLink(testCase, "edit");
|
addDemandHyperLink(testCase, "edit");
|
||||||
|
|
||||||
|
handleDemandUpdate(testCase, DemandUpdateRequest.OperateType.EDIT,
|
||||||
|
projectMapper.selectByPrimaryKey(testCase.getProjectId()), originCase.getDemandId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
}
|
}
|
||||||
|
@ -722,6 +762,9 @@ public class TestCaseService {
|
||||||
EditTestCaseRequest request = new EditTestCaseRequest();
|
EditTestCaseRequest request = new EditTestCaseRequest();
|
||||||
BeanUtils.copyBean(request, testCaseWithBLOBs);
|
BeanUtils.copyBean(request, testCaseWithBLOBs);
|
||||||
addDemandHyperLink(request, "delete");
|
addDemandHyperLink(request, "delete");
|
||||||
|
|
||||||
|
handleDemandUpdate(request, DemandUpdateRequest.OperateType.DELETE,
|
||||||
|
projectMapper.selectByPrimaryKey(testCase.getProjectId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteTestCaseRequest request = new DeleteTestCaseRequest();
|
DeleteTestCaseRequest request = new DeleteTestCaseRequest();
|
||||||
|
|
Loading…
Reference in New Issue