fix(测试计划): 修复查询结果中有null的问题

--bug=1011655 --user=刘瑞斌 【测试跟踪】-  存在 一个测试计划 报告统计 点击会报错 https://www.tapd.cn/55049933/s/1125093
This commit is contained in:
CaptainB 2022-03-24 11:01:04 +08:00 committed by 刘瑞斌
parent 637a6371c1
commit 4f40a481dc

View File

@ -464,7 +464,7 @@ public class TestPlanScenarioCaseService {
getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Pass.name(), stepCount.getScenarioStepSuccess(), stepResult);
getScenarioCaseReportStatusResultDTO(ExecuteResult.errorReportResult.name(), stepCount.getScenarioStepErrorReport(), stepResult);
getScenarioCaseReportStatusResultDTO(TestPlanTestCaseStatus.Underway.name(),
stepCount.getScenarioStepTotal() - stepCount.getScenarioStepSuccess() - stepCount.getScenarioStepError() -stepCount.getScenarioStepErrorReport() + underwayStepsCounts, stepResult);
stepCount.getScenarioStepTotal() - stepCount.getScenarioStepSuccess() - stepCount.getScenarioStepError() - stepCount.getScenarioStepErrorReport() + underwayStepsCounts, stepResult);
apiResult.setApiScenarioData(statusResult);
apiResult.setApiScenarioStepData(stepResult);
}
@ -472,13 +472,7 @@ public class TestPlanScenarioCaseService {
private int getUnderwayStepsCounts(List<String> underwayIds) {
if (CollectionUtils.isNotEmpty(underwayIds)) {
List<Integer> underwayStepsCounts = extTestPlanScenarioCaseMapper.getUnderwaySteps(underwayIds);
Optional<Integer> underwayStepCount = underwayStepsCounts.stream().reduce((total, count) -> {
if (count != null) {
total += count;
}
return total;
});
return underwayStepCount.orElse(0);
return underwayStepsCounts.stream().filter(Objects::nonNull).reduce(0,Integer::sum);
}
return 0;
}
@ -518,21 +512,21 @@ public class TestPlanScenarioCaseService {
return buildCases(apiTestCases);
}
public List<TestPlanFailureScenarioDTO> getAllCases(Map<String,String> idMap) {
public List<TestPlanFailureScenarioDTO> getAllCases(Map<String, String> idMap) {
List<TestPlanFailureScenarioDTO> apiTestCases =
extTestPlanScenarioCaseMapper.getFailureListByIds(idMap.keySet(), null);
String defaultStatus = "Fail";
Map<String,String> reportStatus = apiScenarioReportService.getReportStatusByReportIds(idMap.values());
for (TestPlanFailureScenarioDTO dto: apiTestCases) {
Map<String, String> reportStatus = apiScenarioReportService.getReportStatusByReportIds(idMap.values());
for (TestPlanFailureScenarioDTO dto : apiTestCases) {
String reportId = idMap.get(dto.getId());
dto.setReportId(reportId);
if(reportId != null){
if (reportId != null) {
String status = reportStatus.get(reportId);
if(status == null ){
if (status == null) {
status = defaultStatus;
}else {
if(StringUtils.equalsIgnoreCase(status,"Error")){
} else {
if (StringUtils.equalsIgnoreCase(status, "Error")) {
status = "Fail";
}
}