feat(测试跟踪): 删除功能用例关联的测试列表任显示
--bug=1014506 --user=陈建星 【测试跟踪】功能用例关联测试,接口/场景/性能用例删除后,关联的测试用例没有同步删除 https://www.tapd.cn/55049933/s/1193457
This commit is contained in:
parent
18defbfa05
commit
d1ee38659f
|
@ -48,6 +48,7 @@ import io.metersphere.track.dto.TestPlanDTO;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||||
|
import io.metersphere.track.service.TestCaseService;
|
||||||
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
import io.metersphere.track.service.TestPlanScenarioCaseService;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
@ -111,6 +112,8 @@ public class ApiAutomationService {
|
||||||
@Lazy
|
@Lazy
|
||||||
private TestPlanScenarioCaseService testPlanScenarioCaseService;
|
private TestPlanScenarioCaseService testPlanScenarioCaseService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private TestCaseService testCaseService;
|
||||||
|
@Resource
|
||||||
private EsbApiParamService esbApiParamService;
|
private EsbApiParamService esbApiParamService;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiTestEnvironmentMapper apiTestEnvironmentMapper;
|
private ApiTestEnvironmentMapper apiTestEnvironmentMapper;
|
||||||
|
@ -588,6 +591,7 @@ public class ApiAutomationService {
|
||||||
Map<String, String> scenarioIdDefinitionMap = apiScenarioWithBLOBs.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, scenario -> scenario.getScenarioDefinition() == null ? " " : scenario.getScenarioDefinition()));
|
Map<String, String> scenarioIdDefinitionMap = apiScenarioWithBLOBs.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, scenario -> scenario.getScenarioDefinition() == null ? " " : scenario.getScenarioDefinition()));
|
||||||
preDelAndResource(scenarioIdDefinitionMap);
|
preDelAndResource(scenarioIdDefinitionMap);
|
||||||
testPlanScenarioCaseService.bathDeleteByScenarioIds(scenarioIds);
|
testPlanScenarioCaseService.bathDeleteByScenarioIds(scenarioIds);
|
||||||
|
testCaseService.deleteTestCaseTestByTestIds(ids);
|
||||||
deleteScenarioByIds(scenarioIds);
|
deleteScenarioByIds(scenarioIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1941,7 +1945,9 @@ public class ApiAutomationService {
|
||||||
public List<ApiScenario> getScenarioCaseByIds(List<String> ids) {
|
public List<ApiScenario> getScenarioCaseByIds(List<String> ids) {
|
||||||
if (CollectionUtils.isNotEmpty(ids)) {
|
if (CollectionUtils.isNotEmpty(ids)) {
|
||||||
ApiScenarioExample example = new ApiScenarioExample();
|
ApiScenarioExample example = new ApiScenarioExample();
|
||||||
example.createCriteria().andIdIn(ids);
|
example.createCriteria()
|
||||||
|
.andIdIn(ids)
|
||||||
|
.andStatusNotEqualTo(CommonConstants.TrashStatus);
|
||||||
return apiScenarioMapper.selectByExample(example);
|
return apiScenarioMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
|
@ -54,6 +54,7 @@ import io.metersphere.notice.service.NoticeSendService;
|
||||||
import io.metersphere.service.*;
|
import io.metersphere.service.*;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
|
||||||
|
import io.metersphere.track.service.TestCaseService;
|
||||||
import io.metersphere.track.service.TestPlanService;
|
import io.metersphere.track.service.TestPlanService;
|
||||||
import org.apache.commons.beanutils.BeanComparator;
|
import org.apache.commons.beanutils.BeanComparator;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -132,6 +133,8 @@ public class ApiDefinitionService {
|
||||||
@Resource
|
@Resource
|
||||||
private RelationshipEdgeService relationshipEdgeService;
|
private RelationshipEdgeService relationshipEdgeService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private TestCaseService testCaseService;
|
||||||
|
@Resource
|
||||||
private ApiDefinitionFollowMapper apiDefinitionFollowMapper;
|
private ApiDefinitionFollowMapper apiDefinitionFollowMapper;
|
||||||
@Resource
|
@Resource
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -395,6 +398,8 @@ public class ApiDefinitionService {
|
||||||
FileUtils.deleteBodyFiles(api.getId());
|
FileUtils.deleteBodyFiles(api.getId());
|
||||||
deleteFollows(api.getId());
|
deleteFollows(api.getId());
|
||||||
});
|
});
|
||||||
|
// 删除用例和接口的关联关系
|
||||||
|
testCaseService.deleteTestCaseTestByTestIds(Arrays.asList(apiId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteFollows(String apiId) {
|
private void deleteFollows(String apiId) {
|
||||||
|
@ -416,6 +421,7 @@ public class ApiDefinitionService {
|
||||||
mockConfigService.deleteMockConfigByApiId(apiId);
|
mockConfigService.deleteMockConfigByApiId(apiId);
|
||||||
deleteFollows(apiId);
|
deleteFollows(apiId);
|
||||||
}
|
}
|
||||||
|
testCaseService.deleteTestCaseTestByTestIds(apiIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeToGc(List<String> apiIds) {
|
public void removeToGc(List<String> apiIds) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.*;
|
import io.metersphere.base.mapper.ext.*;
|
||||||
import io.metersphere.commons.constants.APITestStatus;
|
import io.metersphere.commons.constants.APITestStatus;
|
||||||
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.constants.MsTestElementConstants;
|
import io.metersphere.commons.constants.MsTestElementConstants;
|
||||||
import io.metersphere.commons.constants.TestPlanStatus;
|
import io.metersphere.commons.constants.TestPlanStatus;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
@ -35,6 +36,7 @@ import io.metersphere.service.ApiCaseExecutionInfoService;
|
||||||
import io.metersphere.service.FileService;
|
import io.metersphere.service.FileService;
|
||||||
import io.metersphere.service.UserService;
|
import io.metersphere.service.UserService;
|
||||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||||
|
import io.metersphere.track.service.TestPlanApiCaseService;
|
||||||
import io.metersphere.track.service.TestPlanService;
|
import io.metersphere.track.service.TestPlanService;
|
||||||
import org.apache.commons.beanutils.BeanComparator;
|
import org.apache.commons.beanutils.BeanComparator;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -86,6 +88,8 @@ public class ApiTestCaseService {
|
||||||
@Resource
|
@Resource
|
||||||
private EsbApiParamService esbApiParamService;
|
private EsbApiParamService esbApiParamService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private TestPlanApiCaseService testPlanApiCaseService;
|
||||||
|
@Resource
|
||||||
private ApiScenarioReferenceIdService apiScenarioReferenceIdService;
|
private ApiScenarioReferenceIdService apiScenarioReferenceIdService;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiScenarioMapper extApiScenarioMapper;
|
private ExtApiScenarioMapper extApiScenarioMapper;
|
||||||
|
@ -294,6 +298,7 @@ public class ApiTestCaseService {
|
||||||
apiCaseExecutionInfoService.deleteByApiCaseId(testId);
|
apiCaseExecutionInfoService.deleteByApiCaseId(testId);
|
||||||
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
apiTestCaseMapper.deleteByPrimaryKey(testId);
|
||||||
esbApiParamService.deleteByResourceId(testId);
|
esbApiParamService.deleteByResourceId(testId);
|
||||||
|
testPlanApiCaseService.deleteByCaseId(testId);
|
||||||
deleteBodyFiles(testId);
|
deleteBodyFiles(testId);
|
||||||
deleteFollows(testId);
|
deleteFollows(testId);
|
||||||
}
|
}
|
||||||
|
@ -536,9 +541,7 @@ public class ApiTestCaseService {
|
||||||
apiTestCaseMapper.deleteByExample(example);
|
apiTestCaseMapper.deleteByExample(example);
|
||||||
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
|
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
|
||||||
List<String> caseIds = apiTestCases.stream().map(ApiTestCase::getId).collect(Collectors.toList());
|
List<String> caseIds = apiTestCases.stream().map(ApiTestCase::getId).collect(Collectors.toList());
|
||||||
for (String testId : caseIds) {
|
testPlanApiCaseService.deleteByCaseIds(caseIds);
|
||||||
extTestPlanTestCaseMapper.deleteByTestCaseID(testId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void relevanceByApi(ApiCaseRelevanceRequest request) {
|
public void relevanceByApi(ApiCaseRelevanceRequest request) {
|
||||||
|
@ -1085,7 +1088,9 @@ public class ApiTestCaseService {
|
||||||
public List<ApiTestCase> getApiCaseByIds(List<String> apiCaseIds) {
|
public List<ApiTestCase> getApiCaseByIds(List<String> apiCaseIds) {
|
||||||
if (CollectionUtils.isNotEmpty(apiCaseIds)) {
|
if (CollectionUtils.isNotEmpty(apiCaseIds)) {
|
||||||
ApiTestCaseExample example = new ApiTestCaseExample();
|
ApiTestCaseExample example = new ApiTestCaseExample();
|
||||||
example.createCriteria().andIdIn(apiCaseIds);
|
example.createCriteria()
|
||||||
|
.andIdIn(apiCaseIds)
|
||||||
|
.andStatusNotEqualTo(CommonConstants.TrashStatus);
|
||||||
return apiTestCaseMapper.selectByExample(example);
|
return apiTestCaseMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
|
public class CommonConstants {
|
||||||
|
public static final String TrashStatus = "Trash";
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
|
public enum TestCaseTestType {
|
||||||
|
testcase, automation, performance
|
||||||
|
}
|
|
@ -170,6 +170,8 @@ public class PerformanceTestService {
|
||||||
|
|
||||||
testPlanLoadCaseService.deleteByTestId(test.getId());
|
testPlanLoadCaseService.deleteByTestId(test.getId());
|
||||||
|
|
||||||
|
testCaseService.deleteTestCaseTestByTestId(test.getId());
|
||||||
|
|
||||||
detachFileByTestId(test.getId());
|
detachFileByTestId(test.getId());
|
||||||
|
|
||||||
deleteFollows(test.getId());
|
deleteFollows(test.getId());
|
||||||
|
@ -1033,7 +1035,9 @@ public class PerformanceTestService {
|
||||||
public List<LoadTest> getLoadCaseByIds(List<String> ids) {
|
public List<LoadTest> getLoadCaseByIds(List<String> ids) {
|
||||||
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)) {
|
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)) {
|
||||||
LoadTestExample example = new LoadTestExample();
|
LoadTestExample example = new LoadTestExample();
|
||||||
example.createCriteria().andIdIn(ids);
|
example.createCriteria()
|
||||||
|
.andIdIn(ids)
|
||||||
|
.andStatusNotEqualTo(CommonConstants.TrashStatus);
|
||||||
return loadTestMapper.selectByExample(example);
|
return loadTestMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
|
@ -610,6 +610,16 @@ public class TestCaseService {
|
||||||
return testCaseMapper.deleteByPrimaryKey(testCaseId);
|
return testCaseMapper.deleteByPrimaryKey(testCaseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int deleteTestCaseTestByTestId(String testId) {
|
||||||
|
return deleteTestCaseTestByTestIds(Arrays.asList(testId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteTestCaseTestByTestIds(List<String> testIds) {
|
||||||
|
TestCaseTestExample examples = new TestCaseTestExample();
|
||||||
|
examples.createCriteria().andTestIdIn(testIds);
|
||||||
|
return testCaseTestMapper.deleteByExample(examples);
|
||||||
|
}
|
||||||
|
|
||||||
public int deleteTestCaseBySameVersion(String testCaseId) {
|
public int deleteTestCaseBySameVersion(String testCaseId) {
|
||||||
TestCase testCase = testCaseMapper.selectByPrimaryKey(testCaseId);
|
TestCase testCase = testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||||
if (testCase == null) {
|
if (testCase == null) {
|
||||||
|
@ -2415,13 +2425,13 @@ public class TestCaseService {
|
||||||
Map<String, TestCaseTest> testCaseTestsMap = testCaseTests.stream()
|
Map<String, TestCaseTest> testCaseTestsMap = testCaseTests.stream()
|
||||||
.collect(Collectors.toMap(TestCaseTest::getTestId, i -> i));
|
.collect(Collectors.toMap(TestCaseTest::getTestId, i -> i));
|
||||||
List<ApiTestCase> apiCases = apiTestCaseService.getApiCaseByIds(
|
List<ApiTestCase> apiCases = apiTestCaseService.getApiCaseByIds(
|
||||||
getTestIds(testCaseTests, "testcase")
|
getTestIds(testCaseTests, TestCaseTestType.testcase.name())
|
||||||
);
|
);
|
||||||
List<ApiScenario> apiScenarios = apiAutomationService.getScenarioCaseByIds(
|
List<ApiScenario> apiScenarios = apiAutomationService.getScenarioCaseByIds(
|
||||||
getTestIds(testCaseTests, "automation")
|
getTestIds(testCaseTests, TestCaseTestType.automation.name())
|
||||||
);
|
);
|
||||||
List<LoadTest> apiLoadTests = performanceTestService.getLoadCaseByIds(
|
List<LoadTest> apiLoadTests = performanceTestService.getLoadCaseByIds(
|
||||||
getTestIds(testCaseTests, "performance")
|
getTestIds(testCaseTests, TestCaseTestType.performance.name())
|
||||||
);
|
);
|
||||||
List<String> projectIds = apiCases.stream().map(c -> c.getProjectId()).collect(Collectors.toList());
|
List<String> projectIds = apiCases.stream().map(c -> c.getProjectId()).collect(Collectors.toList());
|
||||||
projectIds.addAll(apiScenarios.stream().map(s -> s.getProjectId()).collect(Collectors.toList()));
|
projectIds.addAll(apiScenarios.stream().map(s -> s.getProjectId()).collect(Collectors.toList()));
|
||||||
|
@ -2453,15 +2463,15 @@ public class TestCaseService {
|
||||||
|
|
||||||
List<TestCaseTestDao> testCaseTestList = new ArrayList<>();
|
List<TestCaseTestDao> testCaseTestList = new ArrayList<>();
|
||||||
apiCases.forEach(item -> {
|
apiCases.forEach(item -> {
|
||||||
getTestCaseTestDaoList("testcase", item.getNum(), item.getName(), item.getId(), projectNameMap.get(item.getProjectId()), verisonNameMap.get(item.getVersionId()),
|
getTestCaseTestDaoList(TestCaseTestType.testcase.name(), item.getNum(), item.getName(), item.getId(), projectNameMap.get(item.getProjectId()), verisonNameMap.get(item.getVersionId()),
|
||||||
testCaseTestList, testCaseTestsMap);
|
testCaseTestList, testCaseTestsMap);
|
||||||
});
|
});
|
||||||
apiScenarios.forEach(item -> {
|
apiScenarios.forEach(item -> {
|
||||||
getTestCaseTestDaoList("automation", item.getNum(), item.getName(), item.getId(), projectNameMap.get(item.getProjectId()), verisonNameMap.get(item.getVersionId()),
|
getTestCaseTestDaoList(TestCaseTestType.automation.name(), item.getNum(), item.getName(), item.getId(), projectNameMap.get(item.getProjectId()), verisonNameMap.get(item.getVersionId()),
|
||||||
testCaseTestList, testCaseTestsMap);
|
testCaseTestList, testCaseTestsMap);
|
||||||
});
|
});
|
||||||
apiLoadTests.forEach(item -> {
|
apiLoadTests.forEach(item -> {
|
||||||
getTestCaseTestDaoList("performance", item.getNum(), item.getName(), item.getId(), projectNameMap.get(item.getProjectId()), verisonNameMap.get(item.getVersionId()),
|
getTestCaseTestDaoList(TestCaseTestType.performance.name(), item.getNum(), item.getName(), item.getId(), projectNameMap.get(item.getProjectId()), verisonNameMap.get(item.getVersionId()),
|
||||||
testCaseTestList, testCaseTestsMap);
|
testCaseTestList, testCaseTestsMap);
|
||||||
});
|
});
|
||||||
return testCaseTestList;
|
return testCaseTestList;
|
||||||
|
|
|
@ -19,7 +19,6 @@ import io.metersphere.base.mapper.TestPlanMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper;
|
||||||
import io.metersphere.commons.constants.ExecuteResult;
|
import io.metersphere.commons.constants.ExecuteResult;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.controller.request.OrderRequest;
|
|
||||||
import io.metersphere.controller.request.ResetOrderRequest;
|
import io.metersphere.controller.request.ResetOrderRequest;
|
||||||
import io.metersphere.dto.MsExecResponseDTO;
|
import io.metersphere.dto.MsExecResponseDTO;
|
||||||
import io.metersphere.dto.RunModeConfigDTO;
|
import io.metersphere.dto.RunModeConfigDTO;
|
||||||
|
@ -30,7 +29,6 @@ import io.metersphere.track.dto.TestCaseReportStatusResultDTO;
|
||||||
import io.metersphere.track.dto.TestPlanApiResultReportDTO;
|
import io.metersphere.track.dto.TestPlanApiResultReportDTO;
|
||||||
import io.metersphere.track.dto.TestPlanSimpleReportDTO;
|
import io.metersphere.track.dto.TestPlanSimpleReportDTO;
|
||||||
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
|
import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.session.ExecutorType;
|
import org.apache.ibatis.session.ExecutorType;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
@ -133,7 +131,17 @@ public class TestPlanApiCaseService {
|
||||||
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||||
example.createCriteria()
|
example.createCriteria()
|
||||||
.andIdEqualTo(id);
|
.andIdEqualTo(id);
|
||||||
|
return testPlanApiCaseMapper.deleteByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteByCaseId(String caseId) {
|
||||||
|
return this.deleteByCaseIds(Arrays.asList(caseId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteByCaseIds(List<String> caseIds) {
|
||||||
|
TestPlanApiCaseExample example = new TestPlanApiCaseExample();
|
||||||
|
example.createCriteria()
|
||||||
|
.andApiCaseIdIn(caseIds);
|
||||||
return testPlanApiCaseMapper.deleteByExample(example);
|
return testPlanApiCaseMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue