mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-30 02:58:31 +08:00
fix(接口测试): 修复测试计划执行报告结果显示错误问题
--bug=1020245 --user=赵勇 【测试计划】计划中关联1400+的接口用例和20条场景用例,执行该测试计划成功后-报告统计中未更新 https://www.tapd.cn/55049933/s/1304778
This commit is contained in:
parent
8d943d4245
commit
d0021e6b08
@ -7,7 +7,6 @@ import io.metersphere.api.dto.definition.request.ElementUtil;
|
||||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiScenarioMapper;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
|
||||
@ -39,8 +38,6 @@ public class MsHashTreeService {
|
||||
@Resource
|
||||
private ApiDefinitionService apiDefinitionService;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
@Resource
|
||||
private ExtApiScenarioMapper extApiScenarioMapper;
|
||||
@Resource
|
||||
private BaseProjectApplicationService baseProjectApplicationService;
|
||||
|
@ -14,7 +14,6 @@ import io.metersphere.commons.enums.ApiReportStatus;
|
||||
import io.metersphere.commons.enums.ExecutionExecuteTypeEnum;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.DateUtils;
|
||||
import io.metersphere.commons.utils.HttpHeaderUtils;
|
||||
import io.metersphere.constants.RunModeConstants;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.dto.ResultDTO;
|
||||
@ -27,7 +26,6 @@ import io.metersphere.service.scenario.ApiScenarioReportStructureService;
|
||||
import io.metersphere.service.scenario.ApiScenarioService;
|
||||
import org.apache.commons.beanutils.BeanMap;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -88,17 +86,6 @@ public class TestResultService {
|
||||
* @param dto 执行结果
|
||||
*/
|
||||
public void saveResults(ResultDTO dto) {
|
||||
String userId = null;
|
||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("userId")) {
|
||||
userId = dto.getExtendedParameters().get("userId").toString();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
User user = new User();
|
||||
user.setId(userId);
|
||||
user.setName(userId);
|
||||
HttpHeaderUtils.runAsUser(user);
|
||||
}
|
||||
|
||||
// 处理环境
|
||||
List<String> environmentList = new LinkedList<>();
|
||||
if (dto.getArbitraryData() != null && dto.getArbitraryData().containsKey("ENV")) {
|
||||
@ -119,10 +106,6 @@ public class TestResultService {
|
||||
// 场景报告结果处理
|
||||
apiScenarioReportService.saveResult(dto);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
HttpHeaderUtils.clearUser();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,14 +134,11 @@ public class TestResultService {
|
||||
}
|
||||
}
|
||||
//测试计划定时任务-接口执行逻辑的话,需要同步测试计划的报告数据
|
||||
if (StringUtils.equals(key, "schedule-task")) {
|
||||
apiDefinitionExecResultService.batchSaveApiResult(resultDTOS, true);
|
||||
} else if (StringUtils.equals(key, "api-test-case-task")) {
|
||||
apiDefinitionExecResultService.batchSaveApiResult(resultDTOS, false);
|
||||
if (StringUtils.equalsAny(key, "schedule-task", "api-test-case-task")) {
|
||||
apiDefinitionExecResultService.batchSaveApiResult(resultDTOS);
|
||||
} else if (StringUtils.equalsAny(key, "api-scenario-task")) {
|
||||
apiScenarioReportService.batchSaveResult(resultDTOS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class ApiDefinitionExecResultService {
|
||||
}
|
||||
}
|
||||
|
||||
public void batchSaveApiResult(List<ResultDTO> resultDTOS, boolean isSchedule) {
|
||||
public void batchSaveApiResult(List<ResultDTO> resultDTOS) {
|
||||
if (CollectionUtils.isEmpty(resultDTOS)) {
|
||||
return;
|
||||
}
|
||||
@ -134,17 +134,6 @@ public class ApiDefinitionExecResultService {
|
||||
ApiTestCaseMapper batchApiTestCaseMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
|
||||
|
||||
for (ResultDTO dto : resultDTOS) {
|
||||
String userId = null;
|
||||
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("userId")) {
|
||||
userId = dto.getExtendedParameters().get("userId").toString();
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
User user = new User();
|
||||
user.setId(userId);
|
||||
user.setName(userId);
|
||||
HttpHeaderUtils.runAsUser(user);
|
||||
}
|
||||
|
||||
this.mergeRetryResults(dto);
|
||||
if (CollectionUtils.isNotEmpty(dto.getRequestResults())) {
|
||||
for (RequestResult item : dto.getRequestResults()) {
|
||||
@ -168,10 +157,6 @@ public class ApiDefinitionExecResultService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
HttpHeaderUtils.clearUser();
|
||||
}
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
if (sqlSession != null && sqlSessionFactory != null) {
|
||||
@ -403,8 +388,8 @@ public class ApiDefinitionExecResultService {
|
||||
if (StringUtils.isNotEmpty(saveResult.getTriggerMode()) && saveResult.getTriggerMode().equals("CASE")) {
|
||||
saveResult.setTriggerMode(TriggerMode.MANUAL.name());
|
||||
}
|
||||
editStatus(saveResult, type, status, saveResult.getCreateTime(), saveResult.getId(), testId);
|
||||
if (batchMapper == null) {
|
||||
editStatus(saveResult, type, status, saveResult.getCreateTime(), saveResult.getId(), testId);
|
||||
apiDefinitionExecResultMapper.updateByPrimaryKeySelective(saveResult);
|
||||
} else {
|
||||
batchMapper.updateByPrimaryKeySelective(saveResult);
|
||||
|
Loading…
Reference in New Issue
Block a user