mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 05:29:29 +08:00
refactor: 检查测试用例是否关联测试
This commit is contained in:
parent
5cc3755dcd
commit
c3e32f2df8
@ -27,6 +27,7 @@ import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.job.sechedule.ApiTestJob;
|
||||
import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import io.metersphere.track.service.TestCaseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -58,6 +59,8 @@ public class APITestService {
|
||||
private ScheduleService scheduleService;
|
||||
@Resource
|
||||
private TestCaseMapper testCaseMapper;
|
||||
@Resource
|
||||
private TestCaseService testCaseService;
|
||||
|
||||
public List<APITestResult> list(QueryAPITestRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
@ -130,20 +133,7 @@ public class APITestService {
|
||||
}
|
||||
|
||||
public void delete(String testId) {
|
||||
|
||||
// 是否关联测试用例
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andTestIdEqualTo(testId);
|
||||
List<TestCase> testCases = testCaseMapper.selectByExample(testCaseExample);
|
||||
if (testCases.size() > 0) {
|
||||
String caseName = "";
|
||||
for (int i = 0; i < testCases.size(); i++) {
|
||||
caseName = caseName + testCases.get(i).getName() + ",";
|
||||
}
|
||||
caseName = caseName.substring(0, caseName.length() - 1);
|
||||
MSException.throwException(Translator.get("related_case_del_fail_prefix") + caseName + Translator.get("related_case_del_fail_suffix"));
|
||||
}
|
||||
|
||||
testCaseService.checkIsRelateTest(testId);
|
||||
deleteFileByTestId(testId);
|
||||
apiReportService.deleteByTestId(testId);
|
||||
apiTestMapper.deleteByPrimaryKey(testId);
|
||||
|
@ -22,6 +22,7 @@ import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import io.metersphere.service.TestResourceService;
|
||||
import io.metersphere.track.request.testplan.*;
|
||||
import io.metersphere.track.service.TestCaseService;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -73,6 +74,8 @@ public class PerformanceTestService {
|
||||
private ScheduleService scheduleService;
|
||||
@Resource
|
||||
private TestCaseMapper testCaseMapper;
|
||||
@Resource
|
||||
private TestCaseService testCaseService;
|
||||
|
||||
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
@ -82,18 +85,7 @@ public class PerformanceTestService {
|
||||
public void delete(DeleteTestPlanRequest request) {
|
||||
String testId = request.getId();
|
||||
|
||||
// 是否关联测试用例
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andTestIdEqualTo(testId);
|
||||
List<TestCase> testCases = testCaseMapper.selectByExample(testCaseExample);
|
||||
if (testCases.size() > 0) {
|
||||
String caseName = "";
|
||||
for (int i = 0; i < testCases.size(); i++) {
|
||||
caseName = caseName + testCases.get(i).getName() + ",";
|
||||
}
|
||||
caseName = caseName.substring(0, caseName.length() - 1);
|
||||
MSException.throwException(Translator.get("related_case_del_fail_prefix") + caseName + Translator.get("related_case_del_fail_suffix"));
|
||||
}
|
||||
testCaseService.checkIsRelateTest(testId);
|
||||
|
||||
LoadTestReportExample loadTestReportExample = new LoadTestReportExample();
|
||||
loadTestReportExample.createCriteria().andTestIdEqualTo(testId);
|
||||
|
@ -410,4 +410,23 @@ public class TestCaseService {
|
||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||
testCaseMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否关联测试
|
||||
*
|
||||
* @param testId
|
||||
*/
|
||||
public void checkIsRelateTest(String testId) {
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andTestIdEqualTo(testId);
|
||||
List<TestCase> testCases = testCaseMapper.selectByExample(testCaseExample);
|
||||
StringBuilder caseName = new StringBuilder();
|
||||
if (testCases.size() > 0) {
|
||||
for (TestCase testCase : testCases) {
|
||||
caseName = caseName.append(testCase.getName()).append(",");
|
||||
}
|
||||
String str = caseName.toString().substring(0, caseName.length() - 1);
|
||||
MSException.throwException(Translator.get("related_case_del_fail_prefix") + " " + str + " " + Translator.get("related_case_del_fail_suffix"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user