fix(接口测试): 检查并赋值测试报告查询方法参数中的必填项

--bug=1015725
--user=宋天阳
【接口测试】接口测试报告-全选接口报告-批量删除,会把场景报告也都删掉,全选场景报告也是
https://www.tapd.cn/55049933/s/1221535
This commit is contained in:
song-tianyang 2022-08-10 16:15:15 +08:00 committed by 建国
parent acf13a286e
commit 4ba842b889
2 changed files with 21 additions and 15 deletions

View File

@ -592,6 +592,7 @@ public class ApiAutomationService {
List<String> ids = list.stream().map(ApiScenarioReport::getId).collect(Collectors.toList());
APIReportBatchRequest reportRequest = new APIReportBatchRequest();
reportRequest.setIds(ids);
reportRequest.setCaseType(ReportTypeConstants.SCENARIO.name());
apiReportService.deleteAPIReportBatch(reportRequest);
}

View File

@ -204,6 +204,10 @@ public class ApiScenarioReportService {
request = this.initRequest(request);
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
//检查必填参数caseType
if (request.getIsUi()) {
//ui报告对应的用例类型也是scenario
request.setCaseType(ReportTypeConstants.SCENARIO.name());
}
if (StringUtils.equalsAny(request.getCaseType(), ReportTypeConstants.API.name(), ReportTypeConstants.SCENARIO.name())) {
return extApiScenarioReportMapper.idList(request);
} else {
@ -651,6 +655,7 @@ public class ApiScenarioReportService {
APIReportBatchRequest reportRequest = new APIReportBatchRequest();
reportRequest.setIsUi(request.getIsUi());
reportRequest.setIds(list);
reportRequest.setCaseType(ReportTypeConstants.SCENARIO.name());
this.deleteAPIReportBatch(reportRequest);
}
}
@ -699,19 +704,12 @@ public class ApiScenarioReportService {
}
public void deleteAPIReportBatch(APIReportBatchRequest reportRequest) {
if (reportRequest.getIsUi()) {
//ui报告对应的用例类型也是scenario
reportRequest.setCaseType(ReportTypeConstants.SCENARIO.name());
}
if (StringUtils.isNotBlank(reportRequest.getCaseType())) {
List<String> ids = getIdsByDeleteBatchRequest(reportRequest);
ids = batchDeleteReportResource(reportRequest, ids, true);
//处理报告关联数据
if (!ids.isEmpty()) {
deleteScenarioReportByIds(ids);
deleteApiDefinitionResultByIds(ids);
}
List<String> ids = getIdsByDeleteBatchRequest(reportRequest);
ids = batchDeleteReportResource(reportRequest, ids, true);
//处理报告关联数据
if (!ids.isEmpty()) {
deleteScenarioReportByIds(ids);
deleteApiDefinitionResultByIds(ids);
}
}
@ -993,12 +991,19 @@ public class ApiScenarioReportService {
public void cleanUpReport(long time, String projectId) {
List<String> ids = extApiScenarioReportMapper.selectByProjectIdAndLessThanTime(projectId, time);
List<String> definitionExecIds = extApiDefinitionExecResultMapper.selectByProjectIdAndLessThanTime(projectId, time);
ids.addAll(definitionExecIds);
if (CollectionUtils.isNotEmpty(ids)) {
APIReportBatchRequest request = new APIReportBatchRequest();
request.setIds(ids);
request.setSelectAllDate(false);
request.setCaseType(ReportTypeConstants.SCENARIO.name());
deleteAPIReportBatch(request);
}
List<String> definitionExecIds = extApiDefinitionExecResultMapper.selectByProjectIdAndLessThanTime(projectId, time);
if (CollectionUtils.isNotEmpty(definitionExecIds)) {
APIReportBatchRequest request = new APIReportBatchRequest();
request.setIds(definitionExecIds);
request.setSelectAllDate(false);
request.setCaseType(ReportTypeConstants.API.name());
deleteAPIReportBatch(request);
}
}