refactor(接口测试): 用例彻底删除,及联删除功能用例关联关系表
This commit is contained in:
parent
0eef2ef893
commit
f8e3eb16ce
|
@ -1,6 +1,5 @@
|
||||||
package io.metersphere.api.service.definition;
|
package io.metersphere.api.service.definition;
|
||||||
|
|
||||||
import io.metersphere.sdk.constants.ApiFileResourceType;
|
|
||||||
import io.metersphere.api.constants.ApiResourceType;
|
import io.metersphere.api.constants.ApiResourceType;
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.dto.*;
|
import io.metersphere.api.dto.*;
|
||||||
|
@ -13,6 +12,8 @@ import io.metersphere.api.service.ApiCommonService;
|
||||||
import io.metersphere.api.service.ApiExecuteService;
|
import io.metersphere.api.service.ApiExecuteService;
|
||||||
import io.metersphere.api.service.ApiFileResourceService;
|
import io.metersphere.api.service.ApiFileResourceService;
|
||||||
import io.metersphere.api.utils.ApiDataUtils;
|
import io.metersphere.api.utils.ApiDataUtils;
|
||||||
|
import io.metersphere.functional.domain.FunctionalCaseTestExample;
|
||||||
|
import io.metersphere.functional.mapper.FunctionalCaseTestMapper;
|
||||||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||||
import io.metersphere.project.domain.FileAssociation;
|
import io.metersphere.project.domain.FileAssociation;
|
||||||
import io.metersphere.project.domain.FileMetadata;
|
import io.metersphere.project.domain.FileMetadata;
|
||||||
|
@ -104,6 +105,8 @@ public class ApiTestCaseService extends MoveNodeService {
|
||||||
private ApiTestCaseNoticeService apiTestCaseNoticeService;
|
private ApiTestCaseNoticeService apiTestCaseNoticeService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiReportMapper extApiReportMapper;
|
private ExtApiReportMapper extApiReportMapper;
|
||||||
|
@Resource
|
||||||
|
private FunctionalCaseTestMapper functionalCaseTestMapper;
|
||||||
|
|
||||||
private static final String CASE_TABLE = "api_test_case";
|
private static final String CASE_TABLE = "api_test_case";
|
||||||
private static final int MAX_TAG_SIZE = 10;
|
private static final int MAX_TAG_SIZE = 10;
|
||||||
|
@ -380,7 +383,7 @@ public class ApiTestCaseService extends MoveNodeService {
|
||||||
if (CollectionUtils.isEmpty(ids)) {
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SubListUtils.dealForSubList(ids, 2000, subList -> deleteResourceByIds(subList, request.getProjectId(), userId));
|
SubListUtils.dealForSubList(ids, 200, subList -> deleteResourceByIds(subList, request.getProjectId(), userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteResourceByIds(List<String> ids, String projectId, String userId) {
|
public void deleteResourceByIds(List<String> ids, String projectId, String userId) {
|
||||||
|
@ -400,6 +403,10 @@ public class ApiTestCaseService extends MoveNodeService {
|
||||||
//记录删除日志
|
//记录删除日志
|
||||||
apiTestCaseLogService.deleteBatchLog(caseLists, userId, projectId);
|
apiTestCaseLogService.deleteBatchLog(caseLists, userId, projectId);
|
||||||
//TODO 需要删除测试计划与用例的中间表 功能用例的关联表等
|
//TODO 需要删除测试计划与用例的中间表 功能用例的关联表等
|
||||||
|
FunctionalCaseTestExample functionalCaseTestExample = new FunctionalCaseTestExample();
|
||||||
|
functionalCaseTestExample.createCriteria().andSourceIdIn(ids).andSourceTypeEqualTo("API");
|
||||||
|
functionalCaseTestMapper.deleteByExample(functionalCaseTestExample);
|
||||||
|
|
||||||
//TODO 删除附件关系 不需要删除报告
|
//TODO 删除附件关系 不需要删除报告
|
||||||
//extFileAssociationService.deleteByResourceIds(ids);
|
//extFileAssociationService.deleteByResourceIds(ids);
|
||||||
}
|
}
|
||||||
|
@ -836,6 +843,7 @@ public class ApiTestCaseService extends MoveNodeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验TAG长度
|
* 校验TAG长度
|
||||||
|
*
|
||||||
* @param tags 标签集合
|
* @param tags 标签集合
|
||||||
*/
|
*/
|
||||||
public void checkTagLength(List<String> tags) {
|
public void checkTagLength(List<String> tags) {
|
||||||
|
|
|
@ -27,6 +27,8 @@ import io.metersphere.api.service.definition.ApiDefinitionService;
|
||||||
import io.metersphere.api.service.definition.ApiTestCaseService;
|
import io.metersphere.api.service.definition.ApiTestCaseService;
|
||||||
import io.metersphere.api.utils.ApiDataUtils;
|
import io.metersphere.api.utils.ApiDataUtils;
|
||||||
import io.metersphere.api.utils.ApiScenarioBatchOperationUtils;
|
import io.metersphere.api.utils.ApiScenarioBatchOperationUtils;
|
||||||
|
import io.metersphere.functional.domain.FunctionalCaseTestExample;
|
||||||
|
import io.metersphere.functional.mapper.FunctionalCaseTestMapper;
|
||||||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||||
import io.metersphere.project.api.processor.MsProcessor;
|
import io.metersphere.project.api.processor.MsProcessor;
|
||||||
import io.metersphere.project.api.processor.TimeWaitingProcessor;
|
import io.metersphere.project.api.processor.TimeWaitingProcessor;
|
||||||
|
@ -41,7 +43,9 @@ import io.metersphere.project.dto.environment.http.HttpConfigModuleMatchRule;
|
||||||
import io.metersphere.project.dto.environment.http.SelectModule;
|
import io.metersphere.project.dto.environment.http.SelectModule;
|
||||||
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
||||||
import io.metersphere.project.mapper.ProjectMapper;
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.project.service.*;
|
import io.metersphere.project.service.EnvironmentGroupService;
|
||||||
|
import io.metersphere.project.service.EnvironmentService;
|
||||||
|
import io.metersphere.project.service.MoveNodeService;
|
||||||
import io.metersphere.sdk.constants.*;
|
import io.metersphere.sdk.constants.*;
|
||||||
import io.metersphere.sdk.domain.Environment;
|
import io.metersphere.sdk.domain.Environment;
|
||||||
import io.metersphere.sdk.domain.EnvironmentExample;
|
import io.metersphere.sdk.domain.EnvironmentExample;
|
||||||
|
@ -188,12 +192,15 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
private ApiScenarioNoticeService apiScenarioNoticeService;
|
private ApiScenarioNoticeService apiScenarioNoticeService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiScenarioReportMapper extApiScenarioReportMapper;
|
private ExtApiScenarioReportMapper extApiScenarioReportMapper;
|
||||||
|
@Resource
|
||||||
|
private FunctionalCaseTestMapper functionalCaseTestMapper;
|
||||||
|
|
||||||
public static final String PRIORITY = "Priority";
|
public static final String PRIORITY = "Priority";
|
||||||
public static final String STATUS = "Status";
|
public static final String STATUS = "Status";
|
||||||
public static final String TAGS = "Tags";
|
public static final String TAGS = "Tags";
|
||||||
public static final String ENVIRONMENT = "Environment";
|
public static final String ENVIRONMENT = "Environment";
|
||||||
private static final String SCENARIO_TABLE = "api_scenario";
|
private static final String SCENARIO_TABLE = "api_scenario";
|
||||||
|
private static final String SCENARIO = "SCENARIO";
|
||||||
|
|
||||||
|
|
||||||
public List<ApiScenarioDTO> getScenarioPage(ApiScenarioPageRequest request) {
|
public List<ApiScenarioDTO> getScenarioPage(ApiScenarioPageRequest request) {
|
||||||
|
@ -454,6 +461,7 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理复制场景时的文件复制
|
* 处理复制场景时的文件复制
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param scenario
|
* @param scenario
|
||||||
*/
|
*/
|
||||||
|
@ -1187,6 +1195,12 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
|
|
||||||
//删除定时任务
|
//删除定时任务
|
||||||
scheduleService.deleteByResourceId(scenario.getId(), ApiScenarioScheduleJob.class.getName());
|
scheduleService.deleteByResourceId(scenario.getId(), ApiScenarioScheduleJob.class.getName());
|
||||||
|
|
||||||
|
//删除功能用例关联关系
|
||||||
|
FunctionalCaseTestExample functionalCaseTestExample = new FunctionalCaseTestExample();
|
||||||
|
functionalCaseTestExample.createCriteria().andSourceIdEqualTo(scenario.getId()).andSourceTypeEqualTo(SCENARIO);
|
||||||
|
functionalCaseTestMapper.deleteByExample(functionalCaseTestExample);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteCsvByScenarioId(String id) {
|
private void deleteCsvByScenarioId(String id) {
|
||||||
|
@ -1237,6 +1251,11 @@ public class ApiScenarioService extends MoveNodeService {
|
||||||
}
|
}
|
||||||
apiScenarioCsvMapper.deleteByExample(csvExample);
|
apiScenarioCsvMapper.deleteByExample(csvExample);
|
||||||
|
|
||||||
|
//删除功能用例关联关系
|
||||||
|
FunctionalCaseTestExample functionalCaseTestExample = new FunctionalCaseTestExample();
|
||||||
|
functionalCaseTestExample.createCriteria().andSourceIdIn(scenarioIdList).andSourceTypeEqualTo(SCENARIO);
|
||||||
|
functionalCaseTestMapper.deleteByExample(functionalCaseTestExample);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue