From 2aa2250b90f7162f1fa8e071da4e0ff6c1f75263 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 22 Nov 2022 15:56:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E4=B8=AD?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=89=A7=E8=A1=8C=E7=94=A8=E4=BE=8B=E8=AF=AF?= =?UTF-8?q?=E6=8A=A5=E6=8E=A5=E5=8F=A3=E7=8A=B6=E6=80=81=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020052 --user=赵勇 【测试跟踪】测试计划中批量执行用例,任务中心 - 接口用例的误报状态没显示 https://www.tapd.cn/55049933/s/1301288 --- .../ApiDefinitionExecResultService.java | 52 ++----------------- 1 file changed, 3 insertions(+), 49 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java index f717df81cb..7b9a64aaab 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java @@ -20,7 +20,6 @@ import io.metersphere.dto.ResultDTO; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.ServiceUtils; -import io.metersphere.service.plan.remote.TestPlanService; import io.metersphere.utils.LoggerUtil; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.collections4.CollectionUtils; @@ -32,7 +31,6 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -63,8 +61,6 @@ public class ApiDefinitionExecResultService { @Resource private ApiCaseExecutionInfoService apiCaseExecutionInfoService; @Resource - private TestPlanService testPlanService; - @Resource private ExtApiTestCaseMapper extApiTestCaseMapper; /** @@ -283,23 +279,14 @@ public class ApiDefinitionExecResultService { for (RequestResult item : dto.getRequestResults()) { LoggerUtil.info("执行结果【 " + item.getName() + " 】入库存储"); if (!StringUtils.startsWithAny(item.getName(), "PRE_PROCESSOR_ENV_", "POST_PROCESSOR_ENV_")) { - //对响应内容进行进一步解析和处理。如果有附加信息(比如误报库信息),则根据附加信息内的数据进行其他判读 - RequestResultExpandDTO expandDTO = ResponseUtil.parseByRequestResult(item); - ApiDefinitionExecResult reportResult = this.editResult(item, dto.getReportId(), dto.getConsole(), dto.getRunMode(), dto.getTestId(), null); if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("userId")) { reportResult.setUserId(String.valueOf(dto.getExtendedParameters().get("userId"))); } - String status = item.isSuccess() ? ApiReportStatus.SUCCESS.name() : ApiReportStatus.ERROR.name(); String triggerMode = StringUtils.EMPTY; if (reportResult != null) { - status = reportResult.getStatus(); triggerMode = reportResult.getTriggerMode(); } - - if (StringUtils.isNotEmpty(expandDTO.getStatus())) { - status = expandDTO.getStatus(); - } if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) { TestPlanApiCase apiCase = testPlanApiCaseMapper.selectByPrimaryKey(dto.getTestId()); if (apiCase != null) { @@ -307,9 +294,9 @@ public class ApiDefinitionExecResultService { String projectId = dto.getExtendedParameters().get("projectId").toString(); ApiDefinition apiDefinition = extApiTestCaseMapper.selectApiBasicInfoByCaseId(apiCase.getId()); String version = apiDefinition == null ? "" : apiDefinition.getVersionId(); - apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), status, triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version); + apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), reportResult.getStatus(), triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version); } - apiCase.setStatus(status); + apiCase.setStatus(reportResult.getStatus()); apiCase.setUpdateTime(System.currentTimeMillis()); testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase); @@ -320,28 +307,13 @@ public class ApiDefinitionExecResultService { } } } else { - this.setExecResult(dto.getTestId(), status, item.getStartTime()); + this.setExecResult(dto.getTestId(), reportResult.getStatus(), item.getStartTime()); } } } } } - public void deleteByResourceId(String resourceId) { - ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample(); - example.createCriteria().andResourceIdEqualTo(resourceId); - apiDefinitionExecResultMapper.deleteByExample(example); - } - - public void deleteByResourceIds(List ids) { - if (CollectionUtils.isEmpty(ids)) { - return; - } - ApiDefinitionExecResultExample example = new ApiDefinitionExecResultExample(); - example.createCriteria().andResourceIdIn(ids); - apiDefinitionExecResultMapper.deleteByExample(example); - } - public long countByTestCaseIDInProjectAndExecutedInThisWeek(String projectId, String version) { Date firstTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()).get("firstTime"); Date lastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()).get("lastTime"); @@ -352,11 +324,6 @@ public class ApiDefinitionExecResultService { } } - public long countByTestCaseIDInProject(String projectId) { - return extApiDefinitionExecResultMapper.countByTestCaseIDInProject(projectId); - - } - public List findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(String projectId, boolean selectFunctionCase, int limitNumber) { //获取7天之前的日期 @@ -442,11 +409,6 @@ public class ApiDefinitionExecResultService { } } - public ApiDefinitionExecResult getInfo(String id) { - return apiDefinitionExecResultMapper.selectByPrimaryKey(id); - } - - public List apiReportList(QueryAPIReportRequest request) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders(), "end_time")); this.initReportRequest(request); @@ -468,14 +430,6 @@ public class ApiDefinitionExecResultService { } } - public void deleteByRelevanceTestPlanReportIds(List testPlanReportIdList) { - if (CollectionUtils.isNotEmpty(testPlanReportIdList)) { - ApiDefinitionExecResultExample apiDefinitionExecResultExample = new ApiDefinitionExecResultExample(); - apiDefinitionExecResultExample.createCriteria().andRelevanceTestPlanReportIdIn(testPlanReportIdList); - apiDefinitionExecResultMapper.deleteByExample(apiDefinitionExecResultExample); - } - } - public List selectForPlanReport(List apiReportIds) { if (CollectionUtils.isEmpty(apiReportIds)) return new ArrayList<>(); return extApiDefinitionExecResultMapper.selectForPlanReport(apiReportIds);