refactor(接口测试): 优化接口定时清理报告的逻辑
This commit is contained in:
parent
15fc7e84ae
commit
25fc319557
|
@ -33,8 +33,8 @@ public class ApiDefinitionModuleController {
|
||||||
@Operation(summary = "接口测试-接口管理-模块-查找模块")
|
@Operation(summary = "接口测试-接口管理-模块-查找模块")
|
||||||
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
|
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
|
||||||
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||||
public List<BaseTreeNode> getTree(@RequestBody @Validated ApiModuleRequest request) {
|
public List<BaseTreeNode> getTreeAndRequest(@RequestBody @Validated ApiModuleRequest request) {
|
||||||
return apiDefinitionModuleService.getTree(request, false);
|
return apiDefinitionModuleService.getTree(request, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
|
@ -97,4 +97,12 @@ public class ApiDefinitionModuleController {
|
||||||
public EnvApiTreeDTO envTree(@RequestBody @Validated EnvApiModuleRequest request) {
|
public EnvApiTreeDTO envTree(@RequestBody @Validated EnvApiModuleRequest request) {
|
||||||
return apiDefinitionModuleService.envTree(request);
|
return apiDefinitionModuleService.envTree(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/only/tree")
|
||||||
|
@Operation(summary = "接口测试-接口管理-模块-不包含请求数据的模块树")
|
||||||
|
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ)
|
||||||
|
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
|
||||||
|
public List<BaseTreeNode> getTree(@RequestBody @Validated ApiModuleRequest request) {
|
||||||
|
return apiDefinitionModuleService.getTree(request, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class ApiReportShareService {
|
||||||
@Resource
|
@Resource
|
||||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||||
|
|
||||||
private static final Long DEFAULT = 1000L * 60 * 60 * 24 * 30;
|
private static final Long DEFAULT = 1000L * 60 * 60 * 24;
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
@Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||||
public void validateExpired(ShareInfo shareInfo) {
|
public void validateExpired(ShareInfo shareInfo) {
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
package io.metersphere.api.service;
|
||||||
|
|
||||||
|
import io.metersphere.api.domain.*;
|
||||||
|
import io.metersphere.api.mapper.*;
|
||||||
|
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||||
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
import io.metersphere.system.service.BaseCleanUpReport;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.metersphere.sdk.util.ShareUtil.getCleanDate;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class CleanupApiReportServiceImpl implements BaseCleanUpReport {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ApiReportMapper apiReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiReportMapper extApiReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiReportStepMapper apiReportStepMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiReportDetailMapper apiReportDetailMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiReportLogMapper apiReportLogMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiScenarioReportMapper apiScenarioReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiScenarioReportMapper extApiScenarioReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiScenarioReportStepMapper apiScenarioReportStepMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiScenarioReportDetailMapper apiScenarioReportDetailMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiScenarioReportLogMapper apiScenarioReportLogMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cleanReport(Map<String, String> map, String projectId) {
|
||||||
|
LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告");
|
||||||
|
String expr = map.get(ProjectApplicationType.API.API_CLEAN_REPORT.name());
|
||||||
|
long timeMills = getCleanDate(expr);
|
||||||
|
int apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId);
|
||||||
|
while (apiReportCount > 0) {
|
||||||
|
List<String> ids = extApiReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
||||||
|
ApiReportExample reportExample = new ApiReportExample();
|
||||||
|
reportExample.createCriteria().andIdIn(ids);
|
||||||
|
ApiReport report = new ApiReport();
|
||||||
|
report.setDeleted(true);
|
||||||
|
apiReportMapper.updateByExampleSelective(report, reportExample);
|
||||||
|
deleteApiReport(ids);
|
||||||
|
apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId);
|
||||||
|
}
|
||||||
|
int scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId);
|
||||||
|
while (scenarioReportCount > 0) {
|
||||||
|
List<String> ids = extApiScenarioReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
||||||
|
ApiScenarioReportExample reportExample = new ApiScenarioReportExample();
|
||||||
|
reportExample.createCriteria().andIdIn(ids);
|
||||||
|
ApiScenarioReport report = new ApiScenarioReport();
|
||||||
|
report.setDeleted(true);
|
||||||
|
apiScenarioReportMapper.updateByExampleSelective(report, reportExample);
|
||||||
|
deleteScenarioReport(ids);
|
||||||
|
scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteApiReport(List<String> ids) {
|
||||||
|
ApiReportStepExample stepExample = new ApiReportStepExample();
|
||||||
|
stepExample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiReportStepMapper.deleteByExample(stepExample);
|
||||||
|
ApiReportDetailExample detailExample = new ApiReportDetailExample();
|
||||||
|
detailExample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiReportDetailMapper.deleteByExample(detailExample);
|
||||||
|
ApiReportLogExample logExample = new ApiReportLogExample();
|
||||||
|
logExample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiReportLogMapper.deleteByExample(logExample);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteScenarioReport(List<String> ids) {
|
||||||
|
ApiScenarioReportStepExample stepExample = new ApiScenarioReportStepExample();
|
||||||
|
stepExample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiScenarioReportStepMapper.deleteByExample(stepExample);
|
||||||
|
ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample();
|
||||||
|
detailExample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiScenarioReportDetailMapper.deleteByExample(detailExample);
|
||||||
|
ApiScenarioReportLogExample logExample = new ApiScenarioReportLogExample();
|
||||||
|
logExample.createCriteria().andReportIdIn(ids);
|
||||||
|
apiScenarioReportLogMapper.deleteByExample(logExample);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,12 +3,8 @@ package io.metersphere.api.service;
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.mapper.*;
|
import io.metersphere.api.mapper.*;
|
||||||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
||||||
import io.metersphere.project.domain.ProjectApplication;
|
|
||||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
|
||||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
|
||||||
import io.metersphere.sdk.constants.DefaultRepositoryDir;
|
import io.metersphere.sdk.constants.DefaultRepositoryDir;
|
||||||
import io.metersphere.sdk.constants.OperationLogConstants;
|
import io.metersphere.sdk.constants.OperationLogConstants;
|
||||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
|
||||||
import io.metersphere.sdk.domain.ShareInfoExample;
|
import io.metersphere.sdk.domain.ShareInfoExample;
|
||||||
import io.metersphere.sdk.mapper.ShareInfoMapper;
|
import io.metersphere.sdk.mapper.ShareInfoMapper;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
@ -28,12 +24,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static io.metersphere.sdk.util.ShareUtil.getCleanDate;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class CleanupApiResourceService implements CleanupProjectResourceService {
|
public class CleanupApiResourceServiceImpl implements CleanupProjectResourceService {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
||||||
|
@ -88,12 +81,8 @@ public class CleanupApiResourceService implements CleanupProjectResourceService
|
||||||
@Resource
|
@Resource
|
||||||
private ShareInfoMapper shareInfoMapper;
|
private ShareInfoMapper shareInfoMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiDefinitionSwaggerMapper apiDefinitionSwaggerMapper;
|
private ApiDefinitionSwaggerMapper apiDefinitionSwaggerMapper;
|
||||||
|
|
||||||
private static final String DEFAULT = "30D";
|
|
||||||
|
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,46 +108,6 @@ public class CleanupApiResourceService implements CleanupProjectResourceService
|
||||||
shareInfoMapper.deleteByExample(example);
|
shareInfoMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关接口测试报告资源");
|
|
||||||
//只是删除报告的详情, 但是会保存执行历史
|
|
||||||
ProjectApplicationExample example = new ProjectApplicationExample();
|
|
||||||
example.createCriteria().andProjectIdEqualTo(projectId).andTypeEqualTo(ProjectApplicationType.API.API_CLEAN_REPORT.name());
|
|
||||||
List<ProjectApplication> projectApplications = projectApplicationMapper.selectByExample(example);
|
|
||||||
long timeMills = 0;
|
|
||||||
if (CollectionUtils.isNotEmpty(projectApplications)) {
|
|
||||||
String expr = projectApplications.getFirst().getTypeValue();
|
|
||||||
timeMills = getCleanDate(expr);
|
|
||||||
} else {
|
|
||||||
timeMills = getCleanDate(DEFAULT);
|
|
||||||
}
|
|
||||||
int apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId);
|
|
||||||
while (apiReportCount > 0) {
|
|
||||||
List<String> ids = extApiReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
|
||||||
ApiReportExample reportExample = new ApiReportExample();
|
|
||||||
reportExample.createCriteria().andIdIn(ids);
|
|
||||||
ApiReport report = new ApiReport();
|
|
||||||
report.setDeleted(true);
|
|
||||||
apiReportMapper.updateByExampleSelective(report, reportExample);
|
|
||||||
deleteApiReport(ids);
|
|
||||||
apiReportCount = extApiReportMapper.selectApiReportByTime(timeMills, projectId);
|
|
||||||
}
|
|
||||||
|
|
||||||
int scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId);
|
|
||||||
while (scenarioReportCount > 0) {
|
|
||||||
List<String> ids = extApiScenarioReportMapper.selectApiReportByProjectIdAndTime(timeMills, projectId);
|
|
||||||
ApiScenarioReportExample reportExample = new ApiScenarioReportExample();
|
|
||||||
reportExample.createCriteria().andIdIn(ids);
|
|
||||||
ApiScenarioReport report = new ApiScenarioReport();
|
|
||||||
report.setDeleted(true);
|
|
||||||
apiScenarioReportMapper.updateByExampleSelective(report, reportExample);
|
|
||||||
deleteScenarioReport(ids);
|
|
||||||
scenarioReportCount = extApiScenarioReportMapper.selectScenarioReportByTime(timeMills, projectId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void delScenarioModule(String projectId) {
|
private void delScenarioModule(String projectId) {
|
||||||
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
|
ApiScenarioModuleExample apiScenarioModuleExample = new ApiScenarioModuleExample();
|
||||||
apiScenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
apiScenarioModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
|
@ -61,10 +61,13 @@ public class ApiDefinitionModuleService extends ModuleTreeService {
|
||||||
@Resource
|
@Resource
|
||||||
private ApiTestCaseService apiTestCaseService;
|
private ApiTestCaseService apiTestCaseService;
|
||||||
|
|
||||||
public List<BaseTreeNode> getTree(ApiModuleRequest request, boolean deleted) {
|
public List<BaseTreeNode> getTree(ApiModuleRequest request, boolean deleted, boolean containRequest) {
|
||||||
//接口的树结构是 模块:子模块+接口 接口为非delete状态的
|
//接口的树结构是 模块:子模块+接口 接口为非delete状态的
|
||||||
List<BaseTreeNode> fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(request);
|
List<BaseTreeNode> fileModuleList = extApiDefinitionModuleMapper.selectBaseByRequest(request);
|
||||||
List<BaseTreeNode> baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API));
|
List<BaseTreeNode> baseTreeNodes = super.buildTreeAndCountResource(fileModuleList, true, Translator.get(UNPLANNED_API));
|
||||||
|
if (!containRequest) {
|
||||||
|
return baseTreeNodes;
|
||||||
|
}
|
||||||
List<ApiTreeNode> apiTreeNodeList = extApiDefinitionModuleMapper.selectApiDataByRequest(request, deleted);
|
List<ApiTreeNode> apiTreeNodeList = extApiDefinitionModuleMapper.selectApiDataByRequest(request, deleted);
|
||||||
return apiDebugModuleService.getBaseTreeNodes(apiTreeNodeList, baseTreeNodes);
|
return apiDebugModuleService.getBaseTreeNodes(apiTreeNodeList, baseTreeNodes);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
|
||||||
private static final String URL_FILE_MODULE_COUNT = "/api/definition/module/count";
|
private static final String URL_FILE_MODULE_COUNT = "/api/definition/module/count";
|
||||||
private static final String URL_MODULE_TRASH_TREE = "/api/definition/module/trash/tree";
|
private static final String URL_MODULE_TRASH_TREE = "/api/definition/module/trash/tree";
|
||||||
private static final String URL_MODULE_TRASH_COUNT = "/api/definition/module/trash/count";
|
private static final String URL_MODULE_TRASH_COUNT = "/api/definition/module/trash/count";
|
||||||
|
private static final String URL_MODULE_ONLY_TREE = "/api/definition/module/only/tree";
|
||||||
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||||
private static Project project;
|
private static Project project;
|
||||||
|
@ -953,6 +954,10 @@ public class ApiDefinitionModuleControllerTests extends BaseTest {
|
||||||
this.setProtocol("HTTP");
|
this.setProtocol("HTTP");
|
||||||
this.setProjectId(project.getId());
|
this.setProjectId(project.getId());
|
||||||
}});
|
}});
|
||||||
|
this.requestPostWithOkAndReturn(URL_MODULE_ONLY_TREE, new ApiModuleRequest() {{
|
||||||
|
this.setProtocol("HTTP");
|
||||||
|
this.setProjectId(project.getId());
|
||||||
|
}});
|
||||||
String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
return JSON.parseArray(JSON.toJSONString(resultHolder.getData()), BaseTreeNode.class);
|
||||||
|
|
|
@ -2,12 +2,11 @@ package io.metersphere.api.controller;
|
||||||
|
|
||||||
import io.metersphere.api.domain.*;
|
import io.metersphere.api.domain.*;
|
||||||
import io.metersphere.api.mapper.*;
|
import io.metersphere.api.mapper.*;
|
||||||
import io.metersphere.api.service.CleanupApiResourceService;
|
import io.metersphere.api.service.CleanupApiReportServiceImpl;
|
||||||
|
import io.metersphere.api.service.CleanupApiResourceServiceImpl;
|
||||||
import io.metersphere.api.service.definition.ApiReportService;
|
import io.metersphere.api.service.definition.ApiReportService;
|
||||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
||||||
import io.metersphere.project.domain.ProjectApplication;
|
|
||||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
|
||||||
import io.metersphere.sdk.constants.ApiReportStatus;
|
import io.metersphere.sdk.constants.ApiReportStatus;
|
||||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||||
import io.metersphere.sdk.constants.ScheduleType;
|
import io.metersphere.sdk.constants.ScheduleType;
|
||||||
|
@ -25,7 +24,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
@ -34,7 +35,7 @@ import java.util.List;
|
||||||
public class CleanupApiTests {
|
public class CleanupApiTests {
|
||||||
private final ProjectServiceInvoker serviceInvoker;
|
private final ProjectServiceInvoker serviceInvoker;
|
||||||
@Resource
|
@Resource
|
||||||
private CleanupApiResourceService cleanupApiResourceService;
|
private CleanupApiResourceServiceImpl cleanupApiResourceServiceImpl;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
private ApiDefinitionModuleMapper apiDefinitionModuleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -52,11 +53,7 @@ public class CleanupApiTests {
|
||||||
@Resource
|
@Resource
|
||||||
private ScheduleMapper scheduleMapper;
|
private ScheduleMapper scheduleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
private CleanupApiReportServiceImpl cleanupApiReportServiceImpl;
|
||||||
@Resource
|
|
||||||
private ApiReportMapper apiReportMapper;
|
|
||||||
@Resource
|
|
||||||
private ApiScenarioReportMapper apiScenarioReportMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CleanupApiTests(ProjectServiceInvoker serviceInvoker) {
|
public CleanupApiTests(ProjectServiceInvoker serviceInvoker) {
|
||||||
|
@ -144,7 +141,7 @@ public class CleanupApiTests {
|
||||||
initReportData("test");
|
initReportData("test");
|
||||||
initScheduleData();
|
initScheduleData();
|
||||||
serviceInvoker.invokeServices("test");
|
serviceInvoker.invokeServices("test");
|
||||||
cleanupApiResourceService.deleteResources("test");
|
cleanupApiResourceServiceImpl.deleteResources("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initScheduleData() {
|
private void initScheduleData() {
|
||||||
|
@ -169,21 +166,9 @@ public class CleanupApiTests {
|
||||||
@Order(2)
|
@Order(2)
|
||||||
public void testCleanupReport() throws Exception {
|
public void testCleanupReport() throws Exception {
|
||||||
initReportData("test-clean-project");
|
initReportData("test-clean-project");
|
||||||
cleanupApiResourceService.cleanReportResources("test-clean-project");
|
Map<String, String> map = new HashMap<>();
|
||||||
ApiReportExample apiReportExample = new ApiReportExample();
|
map.put(ProjectApplicationType.API.API_CLEAN_REPORT.name(), "1D");
|
||||||
apiReportExample.createCriteria().andProjectIdEqualTo("test-clean-project");
|
cleanupApiReportServiceImpl.cleanReport(map, "test-clean-project");
|
||||||
apiReportMapper.deleteByExample(apiReportExample);
|
|
||||||
ApiScenarioReportExample apiScenarioReportExample = new ApiScenarioReportExample();
|
|
||||||
apiScenarioReportExample.createCriteria().andProjectIdEqualTo("test-clean-project");
|
|
||||||
apiScenarioReportMapper.deleteByExample(apiScenarioReportExample);
|
|
||||||
// 清理报告有数据
|
|
||||||
ProjectApplication projectApplication = new ProjectApplication();
|
|
||||||
projectApplication.setProjectId("test-clean-project-report");
|
|
||||||
projectApplication.setType(ProjectApplicationType.API.API_CLEAN_REPORT.name());
|
|
||||||
projectApplication.setTypeValue("1D");
|
|
||||||
projectApplicationMapper.insert(projectApplication);
|
|
||||||
initReportData("test-clean-project1");
|
|
||||||
cleanupApiResourceService.cleanReportResources("test-clean-project1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initReportData(String projectId) {
|
private void initReportData(String projectId) {
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
package io.metersphere.api.controller;
|
|
||||||
|
|
||||||
import io.metersphere.api.service.CleanupApiResourceService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
||||||
@AutoConfigureMockMvc
|
|
||||||
public class CleanupResourceTests {
|
|
||||||
@Resource
|
|
||||||
private CleanupApiResourceService resourceService;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(1)
|
|
||||||
public void testCleanupResource() throws Exception {
|
|
||||||
resourceService.deleteResources("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(1)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,96 +17,90 @@ import java.util.List;
|
||||||
@Component
|
@Component
|
||||||
public class CleanupBugResourceService implements CleanupProjectResourceService {
|
public class CleanupBugResourceService implements CleanupProjectResourceService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private BugMapper bugMapper;
|
private BugMapper bugMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugContentMapper bugContentMapper;
|
private BugContentMapper bugContentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugFollowerMapper bugFollowerMapper;
|
private BugFollowerMapper bugFollowerMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugLocalAttachmentMapper bugLocalAttachmentMapper;
|
private BugLocalAttachmentMapper bugLocalAttachmentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugCommentMapper bugCommentMapper;
|
private BugCommentMapper bugCommentMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugCustomFieldMapper bugCustomFieldMapper;
|
private BugCustomFieldMapper bugCustomFieldMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private BugRelationCaseMapper bugRelationCaseMapper;
|
private BugRelationCaseMapper bugRelationCaseMapper;
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public void deleteResources(String projectId) {
|
public void deleteResources(String projectId) {
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关缺陷测试资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关缺陷测试资源");
|
||||||
List<String> deleteIds = getBugIds(projectId);
|
List<String> deleteIds = getBugIds(projectId);
|
||||||
if (CollectionUtils.isNotEmpty(deleteIds)) {
|
if (CollectionUtils.isNotEmpty(deleteIds)) {
|
||||||
// 清理缺陷
|
// 清理缺陷
|
||||||
deleteBug(deleteIds);
|
deleteBug(deleteIds);
|
||||||
// 清理缺陷内容
|
// 清理缺陷内容
|
||||||
deleteBugContent(deleteIds);
|
deleteBugContent(deleteIds);
|
||||||
// 清理缺陷关注人信息
|
// 清理缺陷关注人信息
|
||||||
deleteBugFollower(deleteIds);
|
deleteBugFollower(deleteIds);
|
||||||
// 清理缺陷本地附件
|
// 清理缺陷本地附件
|
||||||
deleteBugLocalAttachment(deleteIds);
|
deleteBugLocalAttachment(deleteIds);
|
||||||
// 清理缺陷评论
|
// 清理缺陷评论
|
||||||
deleteBugComment(deleteIds);
|
deleteBugComment(deleteIds);
|
||||||
// 清理缺陷自定义字段
|
// 清理缺陷自定义字段
|
||||||
deleteBugCustomField(deleteIds);
|
deleteBugCustomField(deleteIds);
|
||||||
// 清理缺陷关联用例
|
// 清理缺陷关联用例
|
||||||
deleteBugRelateCase(deleteIds);
|
deleteBugRelateCase(deleteIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
private List<String> getBugIds(String projectId) {
|
||||||
@Override
|
BugExample example = new BugExample();
|
||||||
public void cleanReportResources(String projectId) {
|
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关缺陷测试报告资源");
|
List<Bug> bugs = bugMapper.selectByExample(example);
|
||||||
}
|
return bugs.stream().map(Bug::getId).toList();
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> getBugIds(String projectId) {
|
private void deleteBug(List<String> bugIds) {
|
||||||
BugExample example = new BugExample();
|
BugExample example = new BugExample();
|
||||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
example.createCriteria().andIdIn(bugIds);
|
||||||
List<Bug> bugs = bugMapper.selectByExample(example);
|
bugMapper.deleteByExample(example);
|
||||||
return bugs.stream().map(Bug::getId).toList();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteBug(List<String> bugIds) {
|
private void deleteBugContent(List<String> bugIds) {
|
||||||
BugExample example = new BugExample();
|
BugContentExample example = new BugContentExample();
|
||||||
example.createCriteria().andIdIn(bugIds);
|
example.createCriteria().andBugIdIn(bugIds);
|
||||||
bugMapper.deleteByExample(example);
|
bugContentMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBugContent(List<String> bugIds) {
|
private void deleteBugFollower(List<String> bugIds) {
|
||||||
BugContentExample example = new BugContentExample();
|
BugFollowerExample example = new BugFollowerExample();
|
||||||
example.createCriteria().andBugIdIn(bugIds);
|
example.createCriteria().andBugIdIn(bugIds);
|
||||||
bugContentMapper.deleteByExample(example);
|
bugFollowerMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBugFollower(List<String> bugIds) {
|
private void deleteBugLocalAttachment(List<String> bugIds) {
|
||||||
BugFollowerExample example = new BugFollowerExample();
|
BugLocalAttachmentExample example = new BugLocalAttachmentExample();
|
||||||
example.createCriteria().andBugIdIn(bugIds);
|
example.createCriteria().andBugIdIn(bugIds);
|
||||||
bugFollowerMapper.deleteByExample(example);
|
bugLocalAttachmentMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBugLocalAttachment(List<String> bugIds) {
|
private void deleteBugComment(List<String> bugIds) {
|
||||||
BugLocalAttachmentExample example = new BugLocalAttachmentExample();
|
BugCommentExample example = new BugCommentExample();
|
||||||
example.createCriteria().andBugIdIn(bugIds);
|
example.createCriteria().andBugIdIn(bugIds);
|
||||||
bugLocalAttachmentMapper.deleteByExample(example);
|
bugCommentMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBugComment(List<String> bugIds) {
|
private void deleteBugCustomField(List<String> bugIds) {
|
||||||
BugCommentExample example = new BugCommentExample();
|
BugCustomFieldExample example = new BugCustomFieldExample();
|
||||||
example.createCriteria().andBugIdIn(bugIds);
|
example.createCriteria().andBugIdIn(bugIds);
|
||||||
bugCommentMapper.deleteByExample(example);
|
bugCustomFieldMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBugCustomField(List<String> bugIds) {
|
private void deleteBugRelateCase(List<String> bugIds) {
|
||||||
BugCustomFieldExample example = new BugCustomFieldExample();
|
BugRelationCaseExample example = new BugRelationCaseExample();
|
||||||
example.createCriteria().andBugIdIn(bugIds);
|
example.createCriteria().andBugIdIn(bugIds);
|
||||||
bugCustomFieldMapper.deleteByExample(example);
|
bugRelationCaseMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBugRelateCase(List<String> bugIds) {
|
|
||||||
BugRelationCaseExample example = new BugRelationCaseExample();
|
|
||||||
example.createCriteria().andBugIdIn(bugIds);
|
|
||||||
bugRelationCaseMapper.deleteByExample(example);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,27 +13,25 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.jdbc.Sql;
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
import org.springframework.test.context.jdbc.SqlConfig;
|
import org.springframework.test.context.jdbc.SqlConfig;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
public class CleanBugResourceServiceTests extends BaseTest {
|
public class CleanBugResourceServiceTests extends BaseTest {
|
||||||
|
|
||||||
private final ProjectServiceInvoker serviceInvoker;
|
private final ProjectServiceInvoker serviceInvoker;
|
||||||
@Resource
|
@Resource
|
||||||
private CleanupBugResourceService cleanupBugResourceService;
|
private CleanupBugResourceService cleanupBugResourceService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CleanBugResourceServiceTests(ProjectServiceInvoker serviceInvoker) {
|
public CleanBugResourceServiceTests(ProjectServiceInvoker serviceInvoker) {
|
||||||
this.serviceInvoker = serviceInvoker;
|
this.serviceInvoker = serviceInvoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
@Sql(scripts = {"/dml/init_bug_clean_resource.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
@Sql(scripts = {"/dml/init_bug_clean_resource.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||||
void test() {
|
void test() {
|
||||||
serviceInvoker.invokeServices("default-project-for-clean-resource");
|
serviceInvoker.invokeServices("default-project-for-clean-resource");
|
||||||
serviceInvoker.invokeServices("default-project-for-clean-resource-not-exist");
|
serviceInvoker.invokeServices("default-project-for-clean-resource-not-exist");
|
||||||
cleanupBugResourceService.cleanReportResources("default-project-for-clean-resource");
|
}
|
||||||
cleanupBugResourceService.cleanReportResources("default-project-for-clean-resource-not-exist");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,4 @@ public class CleanupCaseReviewResourceService implements CleanupProjectResourceS
|
||||||
caseReviewModuleMapper.deleteByExample(caseReviewModuleExample);
|
caseReviewModuleMapper.deleteByExample(caseReviewModuleExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关用例评审报告资源");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package io.metersphere.functional.service;
|
||||||
import io.metersphere.functional.domain.FunctionalCaseModuleExample;
|
import io.metersphere.functional.domain.FunctionalCaseModuleExample;
|
||||||
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
import io.metersphere.functional.mapper.ExtFunctionalCaseMapper;
|
||||||
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
|
import io.metersphere.functional.mapper.FunctionalCaseModuleMapper;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
@ -39,9 +38,5 @@ public class CleanupFunctionalCaseResourceService implements CleanupProjectResou
|
||||||
functionalCaseModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
functionalCaseModuleExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||||
functionalCaseModuleMapper.deleteByExample(functionalCaseModuleExample);
|
functionalCaseModuleMapper.deleteByExample(functionalCaseModuleExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.test.context.jdbc.Sql;
|
||||||
import org.springframework.test.context.jdbc.SqlConfig;
|
import org.springframework.test.context.jdbc.SqlConfig;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class CleanupResourceTests {
|
public class CleanupResourceTests {
|
||||||
|
@ -27,9 +27,4 @@ public class CleanupResourceTests {
|
||||||
resourceService.deleteResources("project_clean_gyq");
|
resourceService.deleteResources("project_clean_gyq");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package io.metersphere.project.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.ProjectApplicationExample;
|
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
|
||||||
import io.metersphere.system.schedule.ScheduleService;
|
import io.metersphere.system.schedule.ScheduleService;
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -27,8 +26,4 @@ public class CleanupApplicationResourceService implements CleanupProjectResource
|
||||||
projectApplicationMapper.deleteByExample(example);
|
projectApplicationMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,4 @@ public class CleanupEnvironmentResourceService implements CleanupProjectResource
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,4 @@ public class CleanupMessageTaskService implements CleanupProjectResourceService
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关消息管理资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关消息管理资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关消息管理报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package io.metersphere.project.service;
|
||||||
|
|
||||||
import io.metersphere.project.domain.ProjectRobotExample;
|
import io.metersphere.project.domain.ProjectRobotExample;
|
||||||
import io.metersphere.project.mapper.ProjectRobotMapper;
|
import io.metersphere.project.mapper.ProjectRobotMapper;
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -20,9 +20,4 @@ public class CleanupRobotResourceService implements CleanupProjectResourceServic
|
||||||
robotMapper.deleteByExample(projectExample);
|
robotMapper.deleteByExample(projectExample);
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关消息机器人资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关消息机器人资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关消息机器人报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class CleanupVersionResourceService implements CleanupProjectResourceServ
|
||||||
private ProjectVersionMapper projectVersionMapper;
|
private ProjectVersionMapper projectVersionMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
private ProjectApplicationMapper projectApplicationMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteResources(String projectId) {
|
public void deleteResources(String projectId) {
|
||||||
// 删除所有项目版本
|
// 删除所有项目版本
|
||||||
|
@ -32,8 +33,4 @@ public class CleanupVersionResourceService implements CleanupProjectResourceServ
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关版本资源");
|
LogUtils.info("清理当前项目[" + projectId + "]相关版本资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
||||||
fileModuleRepositoryMapper.deleteByExample(repositoryExample);
|
fileModuleRepositoryMapper.deleteByExample(repositoryExample);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteModule(List<String> deleteIds) {
|
public void deleteModule(List<String> deleteIds) {
|
||||||
if (CollectionUtils.isEmpty(deleteIds)) {
|
if (CollectionUtils.isEmpty(deleteIds)) {
|
||||||
return;
|
return;
|
||||||
|
@ -199,7 +200,6 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找当前项目下模块每个节点对应的资源统计
|
* 查找当前项目下模块每个节点对应的资源统计
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Map<String, Long> getModuleCountMap(String projectId, String storage, List<ModuleCountDTO> moduleCountDTOList) {
|
public Map<String, Long> getModuleCountMap(String projectId, String storage, List<ModuleCountDTO> moduleCountDTOList) {
|
||||||
|
|
||||||
|
@ -242,10 +242,6 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getModuleNameMapByIds(List<String> moduleIds) {
|
public Map<String, String> getModuleNameMapByIds(List<String> moduleIds) {
|
||||||
if (CollectionUtils.isEmpty(moduleIds)) {
|
if (CollectionUtils.isEmpty(moduleIds)) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class CleanupEnvironmentTests {
|
public class CleanupEnvironmentTests {
|
||||||
|
@ -27,6 +27,7 @@ public class CleanupEnvironmentTests {
|
||||||
private EnvironmentGroupMapper environmentGroupMapper;
|
private EnvironmentGroupMapper environmentGroupMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private EnvironmentGroupRelationMapper environmentGroupRelationMapper;
|
private EnvironmentGroupRelationMapper environmentGroupRelationMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CleanupEnvironmentTests(ProjectServiceInvoker serviceInvoker) {
|
public CleanupEnvironmentTests(ProjectServiceInvoker serviceInvoker) {
|
||||||
this.serviceInvoker = serviceInvoker;
|
this.serviceInvoker = serviceInvoker;
|
||||||
|
@ -52,7 +53,6 @@ public class CleanupEnvironmentTests {
|
||||||
environmentGroupRelation.setProjectId("test");
|
environmentGroupRelation.setProjectId("test");
|
||||||
environmentGroupRelationMapper.insert(environmentGroupRelation);
|
environmentGroupRelationMapper.insert(environmentGroupRelation);
|
||||||
serviceInvoker.invokeServices("test");
|
serviceInvoker.invokeServices("test");
|
||||||
cleanupEnvironmentResourceService.cleanReportResources("test");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package io.metersphere.project.controller;
|
package io.metersphere.project.controller;
|
||||||
|
|
||||||
import io.metersphere.project.domain.ProjectRobot;
|
import io.metersphere.project.domain.ProjectRobot;
|
||||||
|
|
||||||
import io.metersphere.project.service.CleanupRobotResourceService;
|
import io.metersphere.project.service.CleanupRobotResourceService;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
@ -45,12 +44,7 @@ public class CleanupRobotResourceTests extends BaseTest {
|
||||||
List<ProjectRobot> projectRobotAfters = getList();
|
List<ProjectRobot> projectRobotAfters = getList();
|
||||||
Assertions.assertTrue(CollectionUtils.isEmpty(projectRobotAfters));
|
Assertions.assertTrue(CollectionUtils.isEmpty(projectRobotAfters));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ProjectRobot> getList() throws Exception {
|
private List<ProjectRobot> getList() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(ROBOT_LIST + "test")
|
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(ROBOT_LIST + "test")
|
||||||
|
|
|
@ -8,7 +8,10 @@ import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
|
import org.junit.jupiter.api.Order;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.TestMethodOrder;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -24,7 +27,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class CleanupMessageTaskResourceTests extends BaseTest {
|
public class CleanupMessageTaskResourceTests extends BaseTest {
|
||||||
|
@ -41,18 +44,6 @@ public class CleanupMessageTaskResourceTests extends BaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupResourceNoMessage() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(3)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<MessageTaskDTO> getList() throws Exception {
|
private List<MessageTaskDTO> getList() throws Exception {
|
||||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/test")
|
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/notice/message/task/get/test")
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
|
|
|
@ -106,4 +106,13 @@ public class OperationLogModule {
|
||||||
//测试计划
|
//测试计划
|
||||||
public static final String TEST_PLAN = "TEST_PLAN";
|
public static final String TEST_PLAN = "TEST_PLAN";
|
||||||
public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE";
|
public static final String TEST_PLAN_MODULE = "TEST_PLAN_MODULE";
|
||||||
|
|
||||||
|
// 个人信息-基本信息
|
||||||
|
public static final String PERSONAL_INFORMATION_BASE_INFO = "PERSONAL_INFORMATION_BASE_INFO";
|
||||||
|
// 个人信息-密码设置
|
||||||
|
public static final String PERSONAL_INFORMATION_PSW = "PERSONAL_INFORMATION_PSW";
|
||||||
|
// 个人信息-本地执行
|
||||||
|
public static final String PERSONAL_INFORMATION_LOCAL_EXECUTE = "PERSONAL_INFORMATION_LOCAL_EXECUTE";
|
||||||
|
// 个人信息-三方平台账号
|
||||||
|
public static final String PERSONAL_INFORMATION_TRIPARTITE = "PERSONAL_INFORMATION_TRIPARTITE";
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,4 @@ public interface CleanupProjectResourceService {
|
||||||
|
|
||||||
void deleteResources(String projectId);
|
void deleteResources(String projectId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 清理报告资源
|
|
||||||
* @param projectId
|
|
||||||
*/
|
|
||||||
void cleanReportResources(String projectId);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ public class CleanupTemplateResourceService implements CleanupProjectResourceSer
|
||||||
private BaseCustomFieldService baseCustomFieldService;
|
private BaseCustomFieldService baseCustomFieldService;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseStatusFlowSettingService baseStatusFlowSettingService;
|
private BaseStatusFlowSettingService baseStatusFlowSettingService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteResources(String projectId) {
|
public void deleteResources(String projectId) {
|
||||||
baseTemplateService.deleteByScopeId(projectId);
|
baseTemplateService.deleteByScopeId(projectId);
|
||||||
|
@ -18,6 +19,4 @@ public class CleanupTemplateResourceService implements CleanupProjectResourceSer
|
||||||
baseStatusFlowSettingService.deleteByScopeId(projectId);
|
baseStatusFlowSettingService.deleteByScopeId(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class UserLocalConfigService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.ADD.name())
|
.type(OperationLogType.ADD.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_CONFIG)
|
.module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_EXECUTE)
|
||||||
.method(HttpMethodConstants.POST.name())
|
.method(HttpMethodConstants.POST.name())
|
||||||
.path("/user/local/config/add")
|
.path("/user/local/config/add")
|
||||||
.sourceId(userLocalConfig.getId())
|
.sourceId(userLocalConfig.getId())
|
||||||
|
@ -111,5 +111,16 @@ public class UserLocalConfigService {
|
||||||
UserLocalConfig userLocalConfig = checkResourceById(request.getId());
|
UserLocalConfig userLocalConfig = checkResourceById(request.getId());
|
||||||
userLocalConfig.setUserUrl(request.getUserUrl());
|
userLocalConfig.setUserUrl(request.getUserUrl());
|
||||||
userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig);
|
userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig);
|
||||||
|
LogDTO dto = LogDTOBuilder.builder()
|
||||||
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
|
.type(OperationLogType.UPDATE.name())
|
||||||
|
.module(OperationLogModule.PERSONAL_INFORMATION_LOCAL_EXECUTE)
|
||||||
|
.method(HttpMethodConstants.POST.name())
|
||||||
|
.path("/user/local/config/update")
|
||||||
|
.sourceId(userLocalConfig.getId())
|
||||||
|
.originalValue(JSON.toJSONBytes(userLocalConfig))
|
||||||
|
.build().getLogDTO();
|
||||||
|
operationLogService.add(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class UserLogService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.UPDATE.name())
|
.type(OperationLogType.UPDATE.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_PERSONAL_SETTINGS)
|
.module(OperationLogModule.PERSONAL_INFORMATION_PSW)
|
||||||
.method(HttpMethodConstants.POST.name())
|
.method(HttpMethodConstants.POST.name())
|
||||||
.path("/personal/update-password")
|
.path("/personal/update-password")
|
||||||
.sourceId(request.getId())
|
.sourceId(request.getId())
|
||||||
|
@ -122,7 +122,7 @@ public class UserLogService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.UPDATE.name())
|
.type(OperationLogType.UPDATE.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_PERSONAL_SETTINGS)
|
.module(OperationLogModule.PERSONAL_INFORMATION_BASE_INFO)
|
||||||
.method(HttpMethodConstants.POST.name())
|
.method(HttpMethodConstants.POST.name())
|
||||||
.path("/personal/update-info")
|
.path("/personal/update-info")
|
||||||
.sourceId(request.getId())
|
.sourceId(request.getId())
|
||||||
|
@ -262,6 +262,7 @@ public class UserLogService {
|
||||||
}
|
}
|
||||||
operationLogService.batchAdd(logs);
|
operationLogService.batchAdd(logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void batchAddOrgLog(UserRoleBatchRelationRequest request, String operator) {
|
public void batchAddOrgLog(UserRoleBatchRelationRequest request, String operator) {
|
||||||
List<LogDTO> logs = new ArrayList<>();
|
List<LogDTO> logs = new ArrayList<>();
|
||||||
List<String> userIds = userToolService.getBatchUserIds(request);
|
List<String> userIds = userToolService.getBatchUserIds(request);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class UserPlatformAccountService {
|
||||||
userExtend.setId(userId);
|
userExtend.setId(userId);
|
||||||
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
||||||
userExtendMapper.insertSelective(userExtend);
|
userExtendMapper.insertSelective(userExtend);
|
||||||
} else if (userExtend.getPlatformInfo() == null){
|
} else if (userExtend.getPlatformInfo() == null) {
|
||||||
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
||||||
userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +82,7 @@ public class UserPlatformAccountService {
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.type(OperationLogType.UPDATE.name())
|
.type(OperationLogType.UPDATE.name())
|
||||||
.module(OperationLogModule.PERSONAL_INFORMATION_APIKEYS)
|
.module(OperationLogModule.PERSONAL_INFORMATION_TRIPARTITE)
|
||||||
.method(HttpMethodConstants.GET.name())
|
.method(HttpMethodConstants.GET.name())
|
||||||
.path("/user/platform/save")
|
.path("/user/platform/save")
|
||||||
.sourceId(userId)
|
.sourceId(userId)
|
||||||
|
@ -93,8 +93,9 @@ public class UserPlatformAccountService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取个人三方平台账号
|
* 获取个人三方平台账号
|
||||||
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param orgId 组织ID
|
* @param orgId 组织ID
|
||||||
* @return 三方平台账号
|
* @return 三方平台账号
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> get(String userId, String orgId) {
|
public Map<String, Object> get(String userId, String orgId) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.system.mock;
|
package io.metersphere.system.mock;
|
||||||
|
|
||||||
import io.metersphere.system.service.CleanupProjectResourceService;
|
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
import io.metersphere.system.service.CleanupProjectResourceService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -12,8 +12,4 @@ public class CleanupTestResourceService implements CleanupProjectResourceService
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]TEST资源");
|
LogUtils.info("删除当前项目[" + projectId + "]TEST资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]TEST报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,4 @@ public class CleanupPlanResourceService implements CleanupProjectResourceService
|
||||||
LogUtils.info("删除当前项目[" + projectId + "]相关测试计划资源");
|
LogUtils.info("删除当前项目[" + projectId + "]相关测试计划资源");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
LogUtils.info("清理当前项目[" + projectId + "]相关测试计划报告资源");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
return super.buildTreeAndCountResource(fileModuleList, true, Translator.get("default.module"));
|
return super.buildTreeAndCountResource(fileModuleList, true, Translator.get("default.module"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaseTreeNode> getTreeOnlyIdsAndResourceCount(String projectId, List<ModuleCountDTO> moduleCountDTOList) {
|
public List<BaseTreeNode> getTreeOnlyIdsAndResourceCount(String projectId, List<ModuleCountDTO> moduleCountDTOList) {
|
||||||
//节点内容只有Id和parentId
|
//节点内容只有Id和parentId
|
||||||
List<BaseTreeNode> fileModuleList = extTestPlanModuleMapper.selectIdAndParentIdByProjectId(projectId);
|
List<BaseTreeNode> fileModuleList = extTestPlanModuleMapper.selectIdAndParentIdByProjectId(projectId);
|
||||||
return super.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get("default.module"));
|
return super.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get("default.module"));
|
||||||
|
@ -70,7 +70,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
testPlanModule.setUpdateUser(operator);
|
testPlanModule.setUpdateUser(operator);
|
||||||
testPlanModuleMapper.insert(testPlanModule);
|
testPlanModuleMapper.insert(testPlanModule);
|
||||||
//记录日志
|
//记录日志
|
||||||
testPlanModuleLogService.saveAddLog(testPlanModule, operator,requestUrl,requestMethod);
|
testPlanModuleLogService.saveAddLog(testPlanModule, operator, requestUrl, requestMethod);
|
||||||
return testPlanModule.getId();
|
return testPlanModule.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
example.clear();
|
example.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(TestPlanModuleUpdateRequest request, String userId,String requestUrl,String requestMethod) {
|
public void update(TestPlanModuleUpdateRequest request, String userId, String requestUrl, String requestMethod) {
|
||||||
TestPlanModule module = testPlanModuleMapper.selectByPrimaryKey(request.getId());
|
TestPlanModule module = testPlanModuleMapper.selectByPrimaryKey(request.getId());
|
||||||
TestPlanModule updateModule = new TestPlanModule();
|
TestPlanModule updateModule = new TestPlanModule();
|
||||||
updateModule.setId(request.getId());
|
updateModule.setId(request.getId());
|
||||||
|
@ -123,7 +123,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
testPlanModuleMapper.updateByPrimaryKeySelective(updateModule);
|
testPlanModuleMapper.updateByPrimaryKeySelective(updateModule);
|
||||||
TestPlanModule newModule = testPlanModuleMapper.selectByPrimaryKey(request.getId());
|
TestPlanModule newModule = testPlanModuleMapper.selectByPrimaryKey(request.getId());
|
||||||
//记录日志
|
//记录日志
|
||||||
testPlanModuleLogService.saveUpdateLog(module, newModule, module.getProjectId(), userId,requestUrl,requestMethod);
|
testPlanModuleLogService.saveUpdateLog(module, newModule, module.getProjectId(), userId, requestUrl, requestMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveNode(NodeMoveRequest request, String currentUser,String requestUrl,String requestMethod) {
|
public void moveNode(NodeMoveRequest request, String currentUser, String requestUrl, String requestMethod) {
|
||||||
|
|
||||||
NodeSortDTO nodeSortDTO = super.getNodeSortDTO(request,
|
NodeSortDTO nodeSortDTO = super.getNodeSortDTO(request,
|
||||||
extTestPlanModuleMapper::selectBaseModuleById,
|
extTestPlanModuleMapper::selectBaseModuleById,
|
||||||
|
@ -171,12 +171,11 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
}
|
}
|
||||||
super.sort(nodeSortDTO);
|
super.sort(nodeSortDTO);
|
||||||
//记录日志
|
//记录日志
|
||||||
testPlanModuleLogService.saveMoveLog(nodeSortDTO, currentUser,requestUrl,requestMethod);
|
testPlanModuleLogService.saveMoveLog(nodeSortDTO, currentUser, requestUrl, requestMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找当前项目下模块每个节点对应的资源统计
|
* 查找当前项目下模块每个节点对应的资源统计
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Map<String, Long> getModuleCountMap(String projectId, List<ModuleCountDTO> moduleCountDTOList) {
|
public Map<String, Long> getModuleCountMap(String projectId, List<ModuleCountDTO> moduleCountDTOList) {
|
||||||
|
|
||||||
|
@ -219,11 +218,6 @@ public class TestPlanModuleService extends ModuleTreeService implements CleanupP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cleanReportResources(String projectId) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNameById(String id) {
|
public String getNameById(String id) {
|
||||||
return extTestPlanModuleMapper.selectNameById(id);
|
return extTestPlanModuleMapper.selectNameById(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class CleanupResourceTests {
|
public class CleanupResourceTests {
|
||||||
|
@ -22,10 +22,4 @@ public class CleanupResourceTests {
|
||||||
public void testCleanupResource() throws Exception {
|
public void testCleanupResource() throws Exception {
|
||||||
resourceService.deleteResources("test");
|
resourceService.deleteResources("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(2)
|
|
||||||
public void testCleanupReportResource() throws Exception {
|
|
||||||
resourceService.cleanReportResources("test");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue