chore: 统一规范执行状态和结果状态
This commit is contained in:
parent
f0f3f69b7a
commit
a339c813f6
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.sdk.constants;
|
||||
|
||||
/**
|
||||
* 报告执行状态
|
||||
* 执行状态
|
||||
*/
|
||||
public enum ExecStatus {
|
||||
/**
|
||||
|
@ -23,23 +23,5 @@ public enum ExecStatus {
|
|||
/**
|
||||
* 完成
|
||||
*/
|
||||
COMPLETED,
|
||||
|
||||
/**
|
||||
* 通过
|
||||
*/
|
||||
SUCCESS,
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
ERROR,
|
||||
/**
|
||||
* 阻塞
|
||||
*/
|
||||
BLOCKED,
|
||||
/**
|
||||
* 误报
|
||||
*/
|
||||
FAKE_ERROR
|
||||
COMPLETED
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package io.metersphere.sdk.constants;
|
||||
|
||||
/**
|
||||
* 报告状态
|
||||
* 结果状态
|
||||
*/
|
||||
public enum ReportStatus {
|
||||
public enum ResultStatus {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
|
@ -17,5 +17,9 @@ public enum ReportStatus {
|
|||
/**
|
||||
* 误报
|
||||
*/
|
||||
FAKE_ERROR
|
||||
FAKE_ERROR,
|
||||
/**
|
||||
* 阻塞
|
||||
*/
|
||||
BLOCKED,
|
||||
}
|
|
@ -49,7 +49,6 @@ public class MinioRepository implements FileRepository {
|
|||
try {
|
||||
Object serverUrl = minioConfig.get(ENDPOINT).toString();
|
||||
if (ObjectUtils.isNotEmpty(serverUrl)) {
|
||||
LogUtils.info("开始初始化MinIO插件");
|
||||
// 创建 MinioClient 客户端
|
||||
client = MinioClient.builder()
|
||||
.endpoint(minioConfig.get(ENDPOINT).toString())
|
||||
|
@ -59,7 +58,6 @@ public class MinioRepository implements FileRepository {
|
|||
if (!exist) {
|
||||
client.makeBucket(MakeBucketArgs.builder().bucket(BUCKET).build());
|
||||
}
|
||||
LogUtils.info("初始化MinIO成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error("MinIOClient初始化失败!", e);
|
||||
|
|
|
@ -28,8 +28,7 @@ public class DateUtils {
|
|||
}
|
||||
|
||||
public static String getDateString(long timeStamp) throws Exception {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN);
|
||||
return dateFormat.format(timeStamp);
|
||||
return getDataStr(timeStamp);
|
||||
}
|
||||
|
||||
public static String getTimeString(Date date) throws Exception {
|
||||
|
|
|
@ -26,12 +26,10 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class GitRepositoryUtil {
|
||||
private final String REF_SPACE = "+refs/heads/*:refs/heads/*";
|
||||
private final String DEFAULT_GIT_USERNAME = "PRIVATE-TOKEN";
|
||||
|
||||
private String repositoryUrl;
|
||||
private String userName;
|
||||
private String token;
|
||||
private final String repositoryUrl;
|
||||
private final String userName;
|
||||
private final String token;
|
||||
|
||||
private Git git;
|
||||
|
||||
|
@ -40,14 +38,11 @@ public class GitRepositoryUtil {
|
|||
if (StringUtils.isNotBlank(userName)) {
|
||||
this.userName = StringUtils.trim(userName);
|
||||
} else {
|
||||
this.userName = this.DEFAULT_GIT_USERNAME;
|
||||
this.userName = "PRIVATE-TOKEN";
|
||||
}
|
||||
this.token = StringUtils.trim(token);
|
||||
LogUtils.info("初始化文件库完成. repositoryUrl:" + repositoryUrl + "; userName:" + userName + "; token:" + token);
|
||||
}
|
||||
|
||||
//以下方法先注释掉,用到了再打开
|
||||
|
||||
public byte[] getFile(String filePath, String commitId) throws Exception {
|
||||
LogUtils.info("准备获取文件. repositoryUrl:" + repositoryUrl + "; filePath:" + filePath + "; commitId:" + commitId);
|
||||
|
||||
|
@ -156,6 +151,7 @@ public class GitRepositoryUtil {
|
|||
InMemoryRepository repo = new InMemoryRepository(repoDesc);
|
||||
CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(userName, token);
|
||||
git = new Git(repo);
|
||||
String REF_SPACE = "+refs/heads/*:refs/heads/*";
|
||||
git.fetch().setRemote(repositoryUrl).setRefSpecs(new RefSpec(REF_SPACE)).setCredentialsProvider(credentialsProvider).call();
|
||||
repo.getObjectDatabase();
|
||||
return repo;
|
||||
|
|
|
@ -108,7 +108,7 @@ public class XMLUtils {
|
|||
}
|
||||
|
||||
public static Document stringToDocument(String xml) throws Exception {
|
||||
return getDocument(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8.name())));
|
||||
return getDocument(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
public static Map<String, Object> xmlStringToJson(String xml) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.metersphere.api.listener;
|
||||
|
||||
import io.metersphere.api.event.ApiEventSource;
|
||||
import io.metersphere.api.invoker.ApiExecuteCallbackServiceInvoker;
|
||||
import io.metersphere.api.mapper.ApiReportMapper;
|
||||
import io.metersphere.api.mapper.ApiScenarioReportMapper;
|
||||
|
@ -162,6 +161,6 @@ public class MessageListener {
|
|||
}
|
||||
|
||||
private boolean isStopOnFailure(ApiNoticeDTO dto) {
|
||||
return BooleanUtils.isTrue(dto.getRunModeConfig().getStopOnFailure()) && StringUtils.equals(dto.getReportStatus(), ReportStatus.ERROR.name());
|
||||
return BooleanUtils.isTrue(dto.getRunModeConfig().getStopOnFailure()) && StringUtils.equals(dto.getReportStatus(), ResultStatus.ERROR.name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import io.metersphere.api.mapper.*;
|
|||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
|
@ -97,11 +97,11 @@ public class ApiReportSendNoticeService {
|
|||
noticeType = NoticeConstants.TaskType.API_SCENARIO_TASK;
|
||||
report = apiScenarioReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
||||
reportUrl = String.format(reportUrl, project.getOrganizationId(), project.getId(), ApiExecuteResourceType.API_SCENARIO.name(), report.getId());
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.SUCCESS.name())) {
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.SUCCESS.name())) {
|
||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_SUCCESSFUL;
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.FAKE_ERROR.name())) {
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.FAKE_ERROR.name())) {
|
||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAKE_ERROR;
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.ERROR.name())) {
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.ERROR.name())) {
|
||||
event = NoticeConstants.Event.SCENARIO_EXECUTE_FAILED;
|
||||
}
|
||||
shareUrl = String.format(shareUrl, "shareReportScenario");
|
||||
|
@ -129,11 +129,11 @@ public class ApiReportSendNoticeService {
|
|||
ApiReport apiReport = apiReportMapper.selectByPrimaryKey(noticeDTO.getReportId());
|
||||
reportUrl = String.format(reportUrl, project.getOrganizationId(), project.getId(), ApiExecuteResourceType.API_CASE.name(), apiReport.getId());
|
||||
BeanUtils.copyBean(report, apiReport);
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.SUCCESS.name())) {
|
||||
if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.SUCCESS.name())) {
|
||||
event = NoticeConstants.Event.CASE_EXECUTE_SUCCESSFUL;
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.FAKE_ERROR.name())) {
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.FAKE_ERROR.name())) {
|
||||
event = NoticeConstants.Event.CASE_EXECUTE_FAKE_ERROR;
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ReportStatus.ERROR.name())) {
|
||||
} else if (StringUtils.endsWithIgnoreCase(noticeDTO.getReportStatus(), ResultStatus.ERROR.name())) {
|
||||
event = NoticeConstants.Event.CASE_EXECUTE_FAILED;
|
||||
}
|
||||
shareUrl = String.format(shareUrl, "shareReportCase");
|
||||
|
@ -161,9 +161,9 @@ public class ApiReportSendNoticeService {
|
|||
|
||||
|
||||
String reportStatus = report.getStatus();
|
||||
if (StringUtils.endsWithIgnoreCase(reportStatus, ReportStatus.SUCCESS.name())) {
|
||||
if (StringUtils.endsWithIgnoreCase(reportStatus, ResultStatus.SUCCESS.name())) {
|
||||
reportStatus = Translator.get("report.status.success");
|
||||
} else if (StringUtils.endsWithIgnoreCase(reportStatus, ReportStatus.FAKE_ERROR.name())) {
|
||||
} else if (StringUtils.endsWithIgnoreCase(reportStatus, ResultStatus.FAKE_ERROR.name())) {
|
||||
reportStatus = Translator.get("report.status.fake_error");
|
||||
} else {
|
||||
reportStatus = Translator.get("report.status.error");
|
||||
|
|
|
@ -378,7 +378,7 @@ public class ApiTestCaseBatchRunService {
|
|||
BeanUtils.copyBean(apiScenarioReport, report);
|
||||
apiScenarioReport = apiBatchRunBaseService.computeRequestRate(apiScenarioReport, total);
|
||||
BeanUtils.copyBean(report, apiScenarioReport);
|
||||
report.setStatus(ReportStatus.ERROR.name());
|
||||
report.setStatus(ResultStatus.ERROR.name());
|
||||
report.setExecStatus(ExecStatus.COMPLETED.name());
|
||||
apiReportMapper.updateByPrimaryKeySelective(report);
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ public class ApiScenarioBatchRunService {
|
|||
// 计算各种通过率
|
||||
long total = apiScenarioReportService.getRequestTotal(report);
|
||||
report = apiBatchRunBaseService.computeRequestRate(report, total);
|
||||
report.setStatus(ReportStatus.ERROR.name());
|
||||
report.setStatus(ResultStatus.ERROR.name());
|
||||
report.setExecStatus(ExecStatus.COMPLETED.name());
|
||||
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import io.metersphere.api.dto.scenario.ApiScenarioReportDetailDTO;
|
|||
import io.metersphere.api.dto.scenario.ApiScenarioReportStepDTO;
|
||||
import io.metersphere.api.mapper.*;
|
||||
import io.metersphere.sdk.constants.ExecStatus;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentGroup;
|
||||
import io.metersphere.sdk.mapper.EnvironmentGroupMapper;
|
||||
|
@ -210,10 +210,10 @@ public class ApiScenarioReportService {
|
|||
scenarioReportDTO.setRequestTotal(getRequestTotal(scenarioReportDTO));
|
||||
scenarioReportDTO.setChildren(steps);
|
||||
|
||||
scenarioReportDTO.setStepErrorCount(steps.stream().filter(step -> StringUtils.equals(ReportStatus.ERROR.name(), step.getStatus())).count());
|
||||
scenarioReportDTO.setStepSuccessCount(steps.stream().filter(step -> StringUtils.equals(ReportStatus.SUCCESS.name(), step.getStatus())).count());
|
||||
scenarioReportDTO.setStepErrorCount(steps.stream().filter(step -> StringUtils.equals(ResultStatus.ERROR.name(), step.getStatus())).count());
|
||||
scenarioReportDTO.setStepSuccessCount(steps.stream().filter(step -> StringUtils.equals(ResultStatus.SUCCESS.name(), step.getStatus())).count());
|
||||
scenarioReportDTO.setStepPendingCount(steps.stream().filter(step -> StringUtils.equals(ExecStatus.PENDING.name(), step.getStatus()) || StringUtils.isBlank(step.getStatus())).count());
|
||||
scenarioReportDTO.setStepFakeErrorCount(steps.stream().filter(step -> StringUtils.equals(ReportStatus.FAKE_ERROR.name(), step.getStatus())).count());
|
||||
scenarioReportDTO.setStepFakeErrorCount(steps.stream().filter(step -> StringUtils.equals(ResultStatus.FAKE_ERROR.name(), step.getStatus())).count());
|
||||
//控制台信息 console
|
||||
ApiScenarioReportLogExample example = new ApiScenarioReportLogExample();
|
||||
example.createCriteria().andReportIdEqualTo(id);
|
||||
|
@ -251,7 +251,7 @@ public class ApiScenarioReportService {
|
|||
scenarioReportSteps.parallelStream().forEach(step -> {
|
||||
if (StringUtils.equals(ApiScenarioStepType.CONSTANT_TIMER.name(), step.getStepType())) {
|
||||
if (CollectionUtils.isNotEmpty(detailMap.get(step.getStepId()))) {
|
||||
step.setStatus(ReportStatus.SUCCESS.name());
|
||||
step.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else {
|
||||
step.setStatus(ExecStatus.PENDING.name());
|
||||
}
|
||||
|
@ -273,13 +273,13 @@ public class ApiScenarioReportService {
|
|||
step.setRequestTime(details.stream().mapToLong(ApiScenarioReportStepDTO::getRequestTime).sum());
|
||||
step.setResponseSize(details.stream().mapToLong(ApiScenarioReportStepDTO::getResponseSize).sum());
|
||||
List<String> requestStatus = details.stream().map(ApiScenarioReportStepDTO::getStatus).toList();
|
||||
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ReportStatus.SUCCESS.name(), status)).toList();
|
||||
if (requestStatus.contains(ReportStatus.ERROR.name())) {
|
||||
step.setStatus(ReportStatus.ERROR.name());
|
||||
} else if (requestStatus.contains(ReportStatus.FAKE_ERROR.name())) {
|
||||
step.setStatus(ReportStatus.FAKE_ERROR.name());
|
||||
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ResultStatus.SUCCESS.name(), status)).toList();
|
||||
if (requestStatus.contains(ResultStatus.ERROR.name())) {
|
||||
step.setStatus(ResultStatus.ERROR.name());
|
||||
} else if (requestStatus.contains(ResultStatus.FAKE_ERROR.name())) {
|
||||
step.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||
} else if (successStatus.size() == details.size()) {
|
||||
step.setStatus(ReportStatus.SUCCESS.name());
|
||||
step.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else {
|
||||
step.setStatus(ExecStatus.PENDING.name());
|
||||
}
|
||||
|
@ -324,14 +324,14 @@ public class ApiScenarioReportService {
|
|||
//获取为执行的状态
|
||||
List<String> pendingStatus = requestStatus.stream().filter(status -> StringUtils.equals(ExecStatus.PENDING.name(), status) || StringUtils.isBlank(status)).toList();
|
||||
//过滤出来SUCCESS的状态
|
||||
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ReportStatus.SUCCESS.name(), status)).toList();
|
||||
List<String> successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ResultStatus.SUCCESS.name(), status)).toList();
|
||||
//只要包含ERROR 就是ERROR
|
||||
if (requestStatus.contains(ReportStatus.ERROR.name())) {
|
||||
step.setStatus(ReportStatus.ERROR.name());
|
||||
} else if (requestStatus.contains(ReportStatus.FAKE_ERROR.name())) {
|
||||
step.setStatus(ReportStatus.FAKE_ERROR.name());
|
||||
if (requestStatus.contains(ResultStatus.ERROR.name())) {
|
||||
step.setStatus(ResultStatus.ERROR.name());
|
||||
} else if (requestStatus.contains(ResultStatus.FAKE_ERROR.name())) {
|
||||
step.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||
} else if (successStatus.size() + pendingStatus.size() == children.size() && !successStatus.isEmpty()) {
|
||||
step.setStatus(ReportStatus.SUCCESS.name());
|
||||
step.setStatus(ResultStatus.SUCCESS.name());
|
||||
}
|
||||
} else if (stepTypes.contains(step.getStepType())) {
|
||||
step.setStatus(ExecStatus.PENDING.name());
|
||||
|
|
|
@ -100,9 +100,9 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||
apiReport.setRunMode("api-run-mode" + i);
|
||||
if (i % 50 == 0) {
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else if (i % 39 == 0) {
|
||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
||||
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||
apiReport.setIntegrated(true);
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
|
@ -166,7 +166,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
Assertions.assertTrue(((List<ApiScenarioDTO>) returnPager.getList()).size() <= request.getPageSize());
|
||||
//过滤
|
||||
request.setFilter(new HashMap<>() {{
|
||||
put("status", List.of(ReportStatus.SUCCESS.name(), ReportStatus.ERROR.name()));
|
||||
put("status", List.of(ResultStatus.SUCCESS.name(), ResultStatus.ERROR.name()));
|
||||
}});
|
||||
mvcResult = responsePost(PAGE, request);
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
|
@ -175,7 +175,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||
List<ApiReport> list = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiReport.class);
|
||||
list.forEach(apiReport -> {
|
||||
Assertions.assertTrue(apiReport.getStatus().equals(ReportStatus.SUCCESS.name()) || apiReport.getStatus().equals(ReportStatus.ERROR.name()));
|
||||
Assertions.assertTrue(apiReport.getStatus().equals(ResultStatus.SUCCESS.name()) || apiReport.getStatus().equals(ResultStatus.ERROR.name()));
|
||||
});
|
||||
request.setFilter(new HashMap<>() {{
|
||||
put("integrated", List.of("true"));
|
||||
|
@ -267,7 +267,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
apiReport.setPoolId(testResourcePools.getFirst().getId());
|
||||
apiReport.setEnvironmentId(environments.getFirst().getId());
|
||||
apiReport.setRunMode("api-run-mode");
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
apiReport.setTriggerMode("api-trigger-mode");
|
||||
apiReport.setIntegrated(true);
|
||||
reports.add(apiReport);
|
||||
|
@ -334,7 +334,7 @@ public class ApiReportControllerTests extends BaseTest {
|
|||
apiReport.setPoolId(testResourcePools.getFirst().getId());
|
||||
apiReport.setEnvironmentId(environments.getFirst().getId());
|
||||
apiReport.setRunMode("api-run-mode");
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
apiReport.setTriggerMode("api-trigger-mode");
|
||||
apiReport.setIntegrated(true);
|
||||
reports.add(apiReport);
|
||||
|
|
|
@ -7,7 +7,7 @@ import io.metersphere.api.service.ApiReportSendNoticeService;
|
|||
import io.metersphere.api.service.definition.ApiReportService;
|
||||
import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.dto.api.notice.ApiNoticeDTO;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
|
@ -93,11 +93,11 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
apiReport.setEnvironmentId("api-environment-id");
|
||||
apiReport.setRunMode("api-run-mode");
|
||||
if (i == 0) {
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else if (i == 1) {
|
||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
||||
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||
} else {
|
||||
apiReport.setStatus(ReportStatus.FAKE_ERROR.name());
|
||||
apiReport.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
reports.add(apiReport);
|
||||
|
@ -109,7 +109,7 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
apiReportService.insertApiReport(reports, records);
|
||||
ApiNoticeDTO noticeDTO = new ApiNoticeDTO();
|
||||
noticeDTO.setReportId("send-api-case-report-id0");
|
||||
noticeDTO.setReportStatus(ReportStatus.SUCCESS.name());
|
||||
noticeDTO.setReportStatus(ResultStatus.SUCCESS.name());
|
||||
noticeDTO.setResourceId("send-api-case-id");
|
||||
noticeDTO.setResourceType("API_CASE");
|
||||
noticeDTO.setUserId("admin");
|
||||
|
@ -117,10 +117,10 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
noticeDTO.getRunModeConfig().setEnvironmentId("api-environment-id");
|
||||
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ReportStatus.ERROR.name());
|
||||
noticeDTO.setReportStatus(ResultStatus.ERROR.name());
|
||||
noticeDTO.setReportId("send-api-case-report-id1");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ReportStatus.FAKE_ERROR.name());
|
||||
noticeDTO.setReportStatus(ResultStatus.FAKE_ERROR.name());
|
||||
noticeDTO.setReportId("send-api-case-report-id2");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
|
||||
|
@ -161,11 +161,11 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
scenarioReport.setCreateUser("admin");
|
||||
scenarioReport.setUpdateUser("admin");
|
||||
if (i == 0) {
|
||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else if (i == 1) {
|
||||
scenarioReport.setStatus(ReportStatus.ERROR.name());
|
||||
scenarioReport.setStatus(ResultStatus.ERROR.name());
|
||||
} else {
|
||||
scenarioReport.setStatus(ReportStatus.FAKE_ERROR.name());
|
||||
scenarioReport.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||
}
|
||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||
scenarioReport.setPoolId("api-pool-id" + i);
|
||||
|
@ -183,7 +183,7 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
|
||||
noticeDTO = new ApiNoticeDTO();
|
||||
noticeDTO.setReportId("send-scenario-report-id0");
|
||||
noticeDTO.setReportStatus(ReportStatus.SUCCESS.name());
|
||||
noticeDTO.setReportStatus(ResultStatus.SUCCESS.name());
|
||||
noticeDTO.setResourceId("send-api-case-id");
|
||||
noticeDTO.setResourceType("API_SCENARIO");
|
||||
noticeDTO.setUserId("admin");
|
||||
|
@ -191,10 +191,10 @@ public class ApiReportSendNoticeTests extends BaseTest {
|
|||
noticeDTO.getRunModeConfig().setEnvironmentId("api-environment-id");
|
||||
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ReportStatus.ERROR.name());
|
||||
noticeDTO.setReportStatus(ResultStatus.ERROR.name());
|
||||
noticeDTO.setReportId("send-scenario-report-id1");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
noticeDTO.setReportStatus(ReportStatus.FAKE_ERROR.name());
|
||||
noticeDTO.setReportStatus(ResultStatus.FAKE_ERROR.name());
|
||||
noticeDTO.setReportId("send-scenario-report-id2");
|
||||
apiReportSendNoticeService.sendNotice(noticeDTO);
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
scenarioReport.setStartTime(System.currentTimeMillis());
|
||||
scenarioReport.setCreateUser("admin");
|
||||
scenarioReport.setUpdateUser("admin");
|
||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||
scenarioReport.setPoolId("api-pool-id");
|
||||
scenarioReport.setEnvironmentId("api-environment-id");
|
||||
|
@ -2662,7 +2662,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
testPlanApiScenario.setCreateTime(System.currentTimeMillis());
|
||||
testPlanApiScenario.setLastExecTime(System.currentTimeMillis());
|
||||
testPlanApiScenario.setLastExecReportId(IDGenerator.nextStr());
|
||||
testPlanApiScenario.setLastExecResult(ExecStatus.SUCCESS.name());
|
||||
testPlanApiScenario.setLastExecResult(ResultStatus.SUCCESS.name());
|
||||
testPlanApiScenario.setPos(1024l);
|
||||
testPlanApiScenario.setTestPlanCollectionId(planId);
|
||||
testPlanApiScenarioMapper.insert(testPlanApiScenario);
|
||||
|
@ -2679,10 +2679,10 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||
apiReport.setRunMode("api-run-mode" + i);
|
||||
if (i % 2 == 0) {
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else {
|
||||
apiReport.setTestPlanScenarioId(testPlanApiScenario.getId());
|
||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
||||
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
reports.add(apiReport);
|
||||
|
@ -2701,7 +2701,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
request.setFilter(new HashMap<>() {{
|
||||
put("status", List.of(ReportStatus.SUCCESS.name()));
|
||||
put("status", List.of(ResultStatus.SUCCESS.name()));
|
||||
}});
|
||||
request.setSort(new HashMap<>() {{
|
||||
put("startTime", "desc");
|
||||
|
@ -2713,7 +2713,7 @@ public class ApiScenarioControllerTests extends BaseTest {
|
|||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
||||
reportDTOS.forEach(apiReport -> {
|
||||
Assertions.assertEquals(apiReport.getStatus(), ReportStatus.SUCCESS.name());
|
||||
Assertions.assertEquals(apiReport.getStatus(), ResultStatus.SUCCESS.name());
|
||||
});
|
||||
request.setId("data-is-null");
|
||||
responsePost(BASE_PATH + "execute/page", request);
|
||||
|
|
|
@ -19,7 +19,7 @@ import io.metersphere.project.domain.ProjectApplication;
|
|||
import io.metersphere.project.domain.ProjectApplicationExample;
|
||||
import io.metersphere.project.mapper.ProjectApplicationMapper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.constants.ShareInfoType;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
|
@ -102,9 +102,9 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
scenarioReport.setCreateUser("admin");
|
||||
scenarioReport.setUpdateUser("admin");
|
||||
if (i % 50 == 0) {
|
||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else if (i % 39 == 0) {
|
||||
scenarioReport.setStatus(ReportStatus.ERROR.name());
|
||||
scenarioReport.setStatus(ResultStatus.ERROR.name());
|
||||
}
|
||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||
scenarioReport.setPoolId("api-pool-id" + i);
|
||||
|
@ -171,7 +171,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
Assertions.assertTrue(((List<ApiScenarioDTO>) returnPager.getList()).size() <= request.getPageSize());
|
||||
//过滤
|
||||
request.setFilter(new HashMap<>() {{
|
||||
put("status", List.of(ReportStatus.SUCCESS.name(), ReportStatus.ERROR.name()));
|
||||
put("status", List.of(ResultStatus.SUCCESS.name(), ResultStatus.ERROR.name()));
|
||||
}});
|
||||
mvcResult = responsePost(PAGE, request);
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
|
@ -180,7 +180,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||
List<ApiReport> list = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ApiReport.class);
|
||||
list.forEach(apiReport -> {
|
||||
Assertions.assertTrue(apiReport.getStatus().equals(ReportStatus.SUCCESS.name()) || apiReport.getStatus().equals(ReportStatus.ERROR.name()));
|
||||
Assertions.assertTrue(apiReport.getStatus().equals(ResultStatus.SUCCESS.name()) || apiReport.getStatus().equals(ResultStatus.ERROR.name()));
|
||||
});
|
||||
|
||||
//校验权限
|
||||
|
@ -302,7 +302,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
apiReportDetail.setStepId("test-scenario-report-step-id" + i);
|
||||
apiReportDetail.setSort((long) i);
|
||||
if (i % 2 == 0) {
|
||||
apiReportDetail.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReportDetail.setStatus(ResultStatus.SUCCESS.name());
|
||||
apiReportDetail.setResponseSize(1L);
|
||||
apiReportDetail.setRequestTime(2L);
|
||||
} else if (i % 3 == 0) {
|
||||
|
@ -310,7 +310,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
|||
apiReportDetail.setResponseSize(0L);
|
||||
apiReportDetail.setRequestTime(2L);
|
||||
} else {
|
||||
apiReportDetail.setStatus(ReportStatus.FAKE_ERROR.name());
|
||||
apiReportDetail.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||
apiReportDetail.setResponseSize(1L);
|
||||
apiReportDetail.setRequestTime(2L);
|
||||
}
|
||||
|
|
|
@ -788,7 +788,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
testPlanApiCase.setCreateTime(System.currentTimeMillis());
|
||||
testPlanApiCase.setLastExecTime(System.currentTimeMillis());
|
||||
testPlanApiCase.setLastExecReportId(IDGenerator.nextStr());
|
||||
testPlanApiCase.setLastExecResult(ExecStatus.SUCCESS.name());
|
||||
testPlanApiCase.setLastExecResult(ResultStatus.SUCCESS.name());
|
||||
testPlanApiCase.setPos(1024l);
|
||||
testPlanApiCase.setTestPlanCollectionId(planId);
|
||||
testPlanApiCaseMapper.insert(testPlanApiCase);
|
||||
|
@ -806,10 +806,10 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||
apiReport.setRunMode("api-run-mode" + i);
|
||||
if (i % 2 == 0) {
|
||||
apiReport.setStatus(ExecStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else {
|
||||
apiReport.setTestPlanCaseId(testPlanApiCase.getId());
|
||||
apiReport.setStatus(ExecStatus.ERROR.name());
|
||||
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
reports.add(apiReport);
|
||||
|
@ -828,7 +828,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
//返回值不为空
|
||||
Assertions.assertNotNull(returnPager);
|
||||
request.setFilter(new HashMap<>() {{
|
||||
put("status", List.of(ReportStatus.SUCCESS.name()));
|
||||
put("status", List.of(ResultStatus.SUCCESS.name()));
|
||||
}});
|
||||
mvcResult = requestPostWithOkAndReturn(EXECUTE, request);
|
||||
returnPager = parseObjectFromMvcResult(mvcResult, Pager.class);
|
||||
|
@ -837,7 +837,7 @@ public class ApiTestCaseControllerTests extends BaseTest {
|
|||
Assertions.assertTrue(((List<ApiReport>) returnPager.getList()).size() <= request.getPageSize());
|
||||
List<ExecuteReportDTO> reportDTOS = JSON.parseArray(JSON.toJSONString(returnPager.getList()), ExecuteReportDTO.class);
|
||||
reportDTOS.forEach(apiReport -> {
|
||||
Assertions.assertEquals(apiReport.getStatus(), ReportStatus.SUCCESS.name());
|
||||
Assertions.assertEquals(apiReport.getStatus(), ResultStatus.SUCCESS.name());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import io.metersphere.api.service.scenario.ApiScenarioReportService;
|
|||
import io.metersphere.api.service.schedule.SwaggerUrlImportJob;
|
||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||
import io.metersphere.sdk.constants.ProjectApplicationType;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.constants.ScheduleType;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
import io.metersphere.system.invoker.ProjectServiceInvoker;
|
||||
|
@ -250,9 +250,9 @@ public class CleanupApiTests {
|
|||
apiReport.setEnvironmentId("api-environment-id" + i);
|
||||
apiReport.setRunMode("api-run-mode" + i);
|
||||
if (i % 50 == 0) {
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else if (i % 39 == 0) {
|
||||
apiReport.setStatus(ReportStatus.ERROR.name());
|
||||
apiReport.setStatus(ResultStatus.ERROR.name());
|
||||
}
|
||||
apiReport.setTriggerMode("api-trigger-mode" + i);
|
||||
reports.add(apiReport);
|
||||
|
@ -284,9 +284,9 @@ public class CleanupApiTests {
|
|||
scenarioReport.setCreateUser("admin");
|
||||
scenarioReport.setUpdateUser("admin");
|
||||
if (i % 50 == 0) {
|
||||
scenarioReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
scenarioReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
} else if (i % 39 == 0) {
|
||||
scenarioReport.setStatus(ReportStatus.ERROR.name());
|
||||
scenarioReport.setStatus(ResultStatus.ERROR.name());
|
||||
}
|
||||
scenarioReport.setUpdateTime(System.currentTimeMillis());
|
||||
scenarioReport.setPoolId("api-pool-id" + i);
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.metersphere.plan.mapper.TestPlanReportApiScenarioMapper;
|
|||
import io.metersphere.plan.mapper.TestPlanReportMapper;
|
||||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||
import io.metersphere.sdk.constants.ExecStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.dto.queue.TestPlanExecutionQueue;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
|
@ -26,8 +27,6 @@ import java.util.concurrent.TimeUnit;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class TestPlanExecuteSupportService {
|
||||
|
||||
@Resource
|
||||
private TestPlanService testPlanService;
|
||||
@Resource
|
||||
private TestPlanReportService testPlanReportService;
|
||||
@Resource
|
||||
|
@ -83,7 +82,7 @@ public class TestPlanExecuteSupportService {
|
|||
LogUtils.error("测试计划报告汇总失败!reportId:" + reportId, e);
|
||||
TestPlanReport stopReport = testPlanReportService.selectById(reportId);
|
||||
stopReport.setId(reportId);
|
||||
stopReport.setExecStatus(ExecStatus.ERROR.name());
|
||||
stopReport.setExecStatus(ResultStatus.ERROR.name());
|
||||
stopReport.setEndTime(System.currentTimeMillis());
|
||||
testPlanReportMapper.updateByPrimaryKeySelective(stopReport);
|
||||
}
|
||||
|
|
|
@ -645,12 +645,12 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
|
|||
testPlanSendNoticeService.sendNoticeCase(relatedUsers, userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_AT, testPlanId);
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(lastExecResult, ExecStatus.SUCCESS.name())) {
|
||||
if (StringUtils.equalsIgnoreCase(lastExecResult, ResultStatus.SUCCESS.name())) {
|
||||
//成功 发送通知
|
||||
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_PASSED, testPlanId);
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(lastExecResult, ExecStatus.ERROR.name())) {
|
||||
if (StringUtils.equalsIgnoreCase(lastExecResult, ResultStatus.ERROR.name())) {
|
||||
//失败 发送通知
|
||||
testPlanSendNoticeService.sendNoticeCase(new ArrayList<>(), userId, caseId, NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.EXECUTE_FAIL, testPlanId);
|
||||
}
|
||||
|
|
|
@ -479,11 +479,11 @@ public class TestPlanReportService {
|
|||
if (planReport.getIntegrated()) {
|
||||
// 计划组的(执行)结果状态: 子计划全部成功 ? 成功 : 失败
|
||||
TestPlanReportExample reportExample = new TestPlanReportExample();
|
||||
reportExample.createCriteria().andParentIdEqualTo(postParam.getReportId()).andIntegratedEqualTo(false).andResultStatusNotEqualTo(ReportStatus.SUCCESS.name());
|
||||
planReport.setResultStatus(testPlanReportMapper.countByExample(reportExample) == 0 ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name());
|
||||
reportExample.createCriteria().andParentIdEqualTo(postParam.getReportId()).andIntegratedEqualTo(false).andResultStatusNotEqualTo(ResultStatus.SUCCESS.name());
|
||||
planReport.setResultStatus(testPlanReportMapper.countByExample(reportExample) == 0 ? ResultStatus.SUCCESS.name() : ResultStatus.ERROR.name());
|
||||
} else {
|
||||
// 计划的(执行)结果状态: 通过率 >= 阈值 ? 成功 : 失败
|
||||
planReport.setResultStatus(planReport.getPassRate() >= planReport.getPassThreshold() ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name());
|
||||
planReport.setResultStatus(planReport.getPassRate() >= planReport.getPassThreshold() ? ResultStatus.SUCCESS.name() : ResultStatus.ERROR.name());
|
||||
}
|
||||
|
||||
testPlanReportMapper.updateByPrimaryKeySelective(planReport);
|
||||
|
@ -532,7 +532,7 @@ public class TestPlanReportService {
|
|||
TestPlanReportExample reportExample = new TestPlanReportExample();
|
||||
reportExample.createCriteria().andParentIdEqualTo(reportId).andIntegratedEqualTo(false);
|
||||
List<TestPlanReport> testPlanReports = testPlanReportMapper.selectByExample(reportExample);
|
||||
long planPassCount = testPlanReports.stream().filter(report -> StringUtils.equals(ExecStatus.SUCCESS.name(), report.getResultStatus())).count();
|
||||
long planPassCount = testPlanReports.stream().filter(report -> StringUtils.equals(ResultStatus.SUCCESS.name(), report.getResultStatus())).count();
|
||||
planReportDetail.setPassCountOfPlan((int) planPassCount);
|
||||
planReportDetail.setFailCountOfPlan(planReportDetail.getPlanCount() - planReportDetail.getPassCountOfPlan());
|
||||
}
|
||||
|
@ -929,11 +929,11 @@ public class TestPlanReportService {
|
|||
private CaseCount countMap(List<CaseStatusCountMap> resultMapList) {
|
||||
CaseCount caseCount = new CaseCount();
|
||||
Map<String, Long> resultMap = resultMapList.stream().collect(Collectors.toMap(CaseStatusCountMap::getStatus, CaseStatusCountMap::getCount));
|
||||
caseCount.setSuccess(resultMap.getOrDefault(ExecStatus.SUCCESS.name(), 0L).intValue());
|
||||
caseCount.setError(resultMap.getOrDefault(ExecStatus.ERROR.name(), 0L).intValue());
|
||||
caseCount.setSuccess(resultMap.getOrDefault(ResultStatus.SUCCESS.name(), 0L).intValue());
|
||||
caseCount.setError(resultMap.getOrDefault(ResultStatus.ERROR.name(), 0L).intValue());
|
||||
caseCount.setPending(resultMap.getOrDefault(ExecStatus.PENDING.name(), 0L).intValue() + resultMap.getOrDefault(ExecStatus.STOPPED.name(), 0L).intValue());
|
||||
caseCount.setBlock(resultMap.getOrDefault(ExecStatus.BLOCKED.name(), 0L).intValue());
|
||||
caseCount.setFakeError(resultMap.getOrDefault(ExecStatus.FAKE_ERROR.name(), 0L).intValue());
|
||||
caseCount.setBlock(resultMap.getOrDefault(ResultStatus.BLOCKED.name(), 0L).intValue());
|
||||
caseCount.setFakeError(resultMap.getOrDefault(ResultStatus.FAKE_ERROR.name(), 0L).intValue());
|
||||
return caseCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import io.metersphere.plan.dto.request.TestPlanUpdateRequest;
|
|||
import io.metersphere.plan.mapper.TestPlanConfigMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanFollowerMapper;
|
||||
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.constants.TaskTriggerMode;
|
||||
import io.metersphere.sdk.constants.TestPlanConstants;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
|
@ -185,10 +185,10 @@ public class TestPlanSendNoticeService {
|
|||
User user = userMapper.selectByPrimaryKey(currentUser);
|
||||
setLanguage(user.getLanguage());
|
||||
Map<String, String> defaultTemplateMap = MessageTemplateUtils.getDefaultTemplateMap();
|
||||
String template = defaultTemplateMap.get(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
||||
String template = defaultTemplateMap.get(StringUtils.equals(executeResult, ResultStatus.SUCCESS.name()) ?
|
||||
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
||||
Map<String, String> defaultSubjectMap = MessageTemplateUtils.getDefaultTemplateSubjectMap();
|
||||
String subject = defaultSubjectMap.get(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
||||
String subject = defaultSubjectMap.get(StringUtils.equals(executeResult, ResultStatus.SUCCESS.name()) ?
|
||||
NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_SUCCESSFUL : NoticeConstants.TemplateText.TEST_PLAN_TASK_EXECUTE_FAILED);
|
||||
Map<String, Object> paramMap = new HashMap<>(4);
|
||||
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, user.getName());
|
||||
|
@ -197,7 +197,7 @@ public class TestPlanSendNoticeService {
|
|||
paramMap.put("id", planId);
|
||||
paramMap.put("Language", user.getLanguage());
|
||||
NoticeModel noticeModel = NoticeModel.builder().operator(currentUser).excludeSelf(false)
|
||||
.context(template).subject(subject).paramMap(paramMap).event(StringUtils.equals(executeResult, ReportStatus.SUCCESS.name()) ?
|
||||
.context(template).subject(subject).paramMap(paramMap).event(StringUtils.equals(executeResult, ResultStatus.SUCCESS.name()) ?
|
||||
NoticeConstants.Event.EXECUTE_SUCCESSFUL : NoticeConstants.Event.EXECUTE_FAILED).build();
|
||||
noticeSendService.send(StringUtils.equals(TaskTriggerMode.API.name(), triggerMode) ?
|
||||
NoticeConstants.TaskType.JENKINS_TASK : NoticeConstants.TaskType.TEST_PLAN_TASK, noticeModel);
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.plan.dto.response.TestPlanStatisticsResponse;
|
|||
import io.metersphere.plan.mapper.*;
|
||||
import io.metersphere.plan.utils.RateCalculateUtils;
|
||||
import io.metersphere.sdk.constants.ExecStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.constants.ScheduleResourceType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.domain.Schedule;
|
||||
|
@ -126,10 +127,10 @@ public class TestPlanStatisticsService {
|
|||
Map<String, Long> apiScenarioResultCountMap = CollectionUtils.isEmpty(apiScenarios) ? new HashMap<>(16) : apiScenarios.stream().collect(
|
||||
Collectors.groupingBy(apiScenario -> Optional.ofNullable(apiScenario.getLastExecResult()).orElse(ExecStatus.PENDING.name()), Collectors.counting()));
|
||||
// 用例数据汇总
|
||||
statisticsResponse.setSuccessCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.SUCCESS.name()));
|
||||
statisticsResponse.setErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.ERROR.name()));
|
||||
statisticsResponse.setFakeErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.FAKE_ERROR.name()));
|
||||
statisticsResponse.setBlockCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.BLOCKED.name()));
|
||||
statisticsResponse.setSuccessCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.SUCCESS.name()));
|
||||
statisticsResponse.setErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.ERROR.name()));
|
||||
statisticsResponse.setFakeErrorCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.FAKE_ERROR.name()));
|
||||
statisticsResponse.setBlockCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ResultStatus.BLOCKED.name()));
|
||||
statisticsResponse.setPendingCount(countCaseMap(functionalCaseResultCountMap, apiCaseResultCountMap, apiScenarioResultCountMap, ExecStatus.PENDING.name()));
|
||||
statisticsResponse.setCaseTotal(statisticsResponse.getFunctionalCaseCount() + statisticsResponse.getApiCaseCount() + statisticsResponse.getApiScenarioCount());
|
||||
// 通过率 {通过用例数/总用例数} && 执行进度 {非未执行的用例数/总用例数}
|
||||
|
|
|
@ -31,7 +31,7 @@ import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
|||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||
import io.metersphere.sdk.constants.ApiExecuteResourceType;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
|
||||
import io.metersphere.sdk.dto.api.task.TaskItem;
|
||||
import io.metersphere.sdk.util.CommonBeanFactory;
|
||||
|
@ -445,7 +445,7 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
|
|||
apiReport.setEnvironmentId("test-env");
|
||||
apiReport.setRunMode("api-run-mode");
|
||||
apiReport.setTestPlanCaseId("test-plan-case-id");
|
||||
apiReport.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReport.setStatus(ResultStatus.SUCCESS.name());
|
||||
apiReport.setTriggerMode("api-trigger-mode");
|
||||
apiReport.setIntegrated(true);
|
||||
reports.add(apiReport);
|
||||
|
|
|
@ -32,7 +32,7 @@ import io.metersphere.project.mapper.ExtBaseProjectVersionMapper;
|
|||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||
import io.metersphere.sdk.constants.MsAssertionCondition;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.ReportStatus;
|
||||
import io.metersphere.sdk.constants.ResultStatus;
|
||||
import io.metersphere.sdk.dto.api.task.GetRunScriptRequest;
|
||||
import io.metersphere.sdk.dto.api.task.TaskItem;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
|
@ -493,7 +493,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
|
|||
apiReportDetail.setStepId("plan-test-scenario-report-step-id" + i);
|
||||
apiReportDetail.setSort((long) i);
|
||||
if (i % 2 == 0) {
|
||||
apiReportDetail.setStatus(ReportStatus.SUCCESS.name());
|
||||
apiReportDetail.setStatus(ResultStatus.SUCCESS.name());
|
||||
apiReportDetail.setResponseSize(1L);
|
||||
apiReportDetail.setRequestTime(2L);
|
||||
} else if (i % 3 == 0) {
|
||||
|
@ -501,7 +501,7 @@ public class TestPlanApiScenarioControllerTests extends BaseTest {
|
|||
apiReportDetail.setResponseSize(0L);
|
||||
apiReportDetail.setRequestTime(2L);
|
||||
} else {
|
||||
apiReportDetail.setStatus(ReportStatus.FAKE_ERROR.name());
|
||||
apiReportDetail.setStatus(ResultStatus.FAKE_ERROR.name());
|
||||
apiReportDetail.setResponseSize(1L);
|
||||
apiReportDetail.setRequestTime(2L);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue