feat(消息通知): 测试计划增加执行结果变量

--story=1009289 --user=刘瑞斌 【系统设置】消息通知-测试计划新增通知字段 https://www.tapd.cn/55049933/s/1241750
This commit is contained in:
CaptainB 2022-09-20 12:06:50 +08:00 committed by 刘瑞斌
parent 522374a9d2
commit dfb1651632
1 changed files with 13 additions and 9 deletions

View File

@ -270,7 +270,8 @@ public class TestPlanMessageService {
List<TestPlanFailureApiDTO> apiAllCases = report.getApiAllCases(); List<TestPlanFailureApiDTO> apiAllCases = report.getApiAllCases();
if (CollectionUtils.isNotEmpty(apiAllCases)) { if (CollectionUtils.isNotEmpty(apiAllCases)) {
Map<String, Long> apiCountMap = apiAllCases.stream().collect(Collectors.groupingBy(TestPlanFailureApiDTO::getExecResult, Collectors.counting())); Map<String, Long> apiCountMap = apiAllCases.stream()
.collect(Collectors.groupingBy(plan -> StringUtils.isEmpty(plan.getExecResult()) ? "default" : plan.getExecResult().toLowerCase(), Collectors.counting()));
// ["success", "error", "default", "errorReportResult"] // ["success", "error", "default", "errorReportResult"]
apiCountMap.forEach((k, v) -> { apiCountMap.forEach((k, v) -> {
switch (k) { switch (k) {
@ -283,7 +284,7 @@ public class TestPlanMessageService {
case "default": case "default":
result.put("apiCaseUnExecuteCount", v); result.put("apiCaseUnExecuteCount", v);
break; break;
case "errorReportResult": case "errorreportresult":
result.put("apiCaseErrorReportCount", v); result.put("apiCaseErrorReportCount", v);
break; break;
default: default:
@ -295,20 +296,21 @@ public class TestPlanMessageService {
List<TestPlanFailureScenarioDTO> scenarioAllCases = report.getScenarioAllCases(); List<TestPlanFailureScenarioDTO> scenarioAllCases = report.getScenarioAllCases();
if (CollectionUtils.isNotEmpty(scenarioAllCases)) { if (CollectionUtils.isNotEmpty(scenarioAllCases)) {
Map<String, Long> scenarioCountMap = scenarioAllCases.stream().collect(Collectors.groupingBy(TestPlanFailureScenarioDTO::getLastResult, Collectors.counting())); Map<String, Long> scenarioCountMap = scenarioAllCases.stream()
.collect(Collectors.groupingBy(plan -> StringUtils.isEmpty(plan.getLastResult()) ? "unexecute" : plan.getLastResult().toLowerCase(), Collectors.counting()));
// ["Fail", "Success", "unexecute", "errorReportResult"] // ["Fail", "Success", "unexecute", "errorReportResult"]
scenarioCountMap.forEach((k, v) -> { scenarioCountMap.forEach((k, v) -> {
switch (k) { switch (k) {
case "Success": case "success":
result.put("apiScenarioSuccessCount", v); result.put("apiScenarioSuccessCount", v);
break; break;
case "Fail": case "fail":
result.put("apiScenarioFailedCount", v); result.put("apiScenarioFailedCount", v);
break; break;
case "unexecute": case "unexecute":
result.put("apiScenarioUnExecuteCount", v); result.put("apiScenarioUnExecuteCount", v);
break; break;
case "errorReportResult": case "errorreportresult":
result.put("apiScenarioErrorReportCount", v); result.put("apiScenarioErrorReportCount", v);
break; break;
default: default:
@ -320,13 +322,15 @@ public class TestPlanMessageService {
List<TestPlanUiScenarioDTO> uiAllCases = report.getUiAllCases(); List<TestPlanUiScenarioDTO> uiAllCases = report.getUiAllCases();
if (CollectionUtils.isNotEmpty(uiAllCases)) { if (CollectionUtils.isNotEmpty(uiAllCases)) {
Map<String, Long> uiCountMap = uiAllCases.stream().collect(Collectors.groupingBy(TestPlanUiScenarioDTO::getLastResult, Collectors.counting())); Map<String, Long> uiCountMap = uiAllCases.stream()
.collect(Collectors.groupingBy(plan -> StringUtils.isEmpty(plan.getLastResult()) ? "unexecute" : plan.getLastResult().toLowerCase(), Collectors.counting()));
uiCountMap.forEach((k, v) -> { uiCountMap.forEach((k, v) -> {
switch (k) { switch (k) {
case "Success": case "success":
result.put("uiScenarioSuccessCount", v); result.put("uiScenarioSuccessCount", v);
break; break;
case "Fail": case "fail":
case "error":
result.put("uiScenarioFailedCount", v); result.put("uiScenarioFailedCount", v);
break; break;
case "unexecute": case "unexecute":