fix(接口测试): 修复接口测试报告中接口用例触发方式识别不出jenkins执行的问题

修复接口测试报告中接口用例触发方式识别不出jenkins执行的问题
This commit is contained in:
song-tianyang 2022-09-26 16:24:54 +08:00 committed by 建国
parent a42908fac4
commit 0dae49cfa2
2 changed files with 42 additions and 19 deletions

View File

@ -410,23 +410,28 @@ public class ApiDefinitionExecResultService {
List<ExecutedCaseInfoResult> apiCaseList = extApiDefinitionExecResultMapper.findFaliureApiCaseInfoByProjectID(projectId, startTime.getTime(), limitNumber);
List<ExecutedCaseInfoResult> scenarioCaseList = extApiDefinitionExecResultMapper.findFaliureScenarioInfoByProjectID(projectId, startTime.getTime(), limitNumber);
apiCaseList.forEach(item -> {
if(treeMap.containsKey(item.getFailureTimes())){
treeMap.get(item.getFailureTimes()).add(item);
}else {
treeMap.put(item.getFailureTimes(),new ArrayList<>(){{this.add(item);}});
if (treeMap.containsKey(item.getFailureTimes())) {
treeMap.get(item.getFailureTimes()).add(item);
} else {
treeMap.put(item.getFailureTimes(), new ArrayList<>() {{
this.add(item);
}});
}
});
scenarioCaseList.forEach(item -> {
if(treeMap.containsKey(item.getFailureTimes())){
if (treeMap.containsKey(item.getFailureTimes())) {
treeMap.get(item.getFailureTimes()).add(item);
}else {
treeMap.put(item.getFailureTimes(),new ArrayList<>(){{this.add(item);}});
} else {
treeMap.put(item.getFailureTimes(), new ArrayList<>() {{
this.add(item);
}});
}
});
List<ExecutedCaseInfoResult> returnList = new ArrayList<>(limitNumber);
NavigableMap<Long, List<ExecutedCaseInfoResult>> descendingMap = treeMap.descendingMap();
caseInfoListforeach:for (List<ExecutedCaseInfoResult> itemList : descendingMap.values()) {
caseInfoListforeach:
for (List<ExecutedCaseInfoResult> itemList : descendingMap.values()) {
for (ExecutedCaseInfoResult item : itemList) {
if (returnList.size() <= 10) {
QueryTestPlanRequest planRequest = new QueryTestPlanRequest();
@ -531,6 +536,7 @@ public class ApiDefinitionExecResultService {
public List<ApiDefinitionExecResultExpand> apiReportList(QueryAPIReportRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders(), "end_time"));
this.initReportRequest(request);
List<ApiDefinitionExecResultExpand> list = extApiDefinitionExecResultMapper.list(request);
List<String> userIds = list.stream().map(ApiDefinitionExecResult::getUserId)
.collect(Collectors.toList());
@ -542,4 +548,20 @@ public class ApiDefinitionExecResultService {
});
return list;
}
private void initReportRequest(QueryAPIReportRequest request) {
if (request != null) {
if (MapUtils.isNotEmpty(request.getFilters()) && request.getFilters().containsKey("trigger_mode")) {
boolean filterHasApi = false;
for (String triggerMode : request.getFilters().get("trigger_mode")) {
if (StringUtils.equalsIgnoreCase(triggerMode, "api")) {
filterHasApi = true;
}
}
if (filterHasApi) {
request.getFilters().get("trigger_mode").add("JENKINS");
}
}
}
}
}

View File

@ -1,21 +1,22 @@
<template>
<span>
<span v-if="triggerMode === 'MANUAL'">{{$t('commons.trigger_mode.manual')}}</span>
<span v-if="triggerMode === 'SCHEDULE'">{{$t('commons.trigger_mode.schedule')}}</span>
<span v-if="triggerMode === 'TEST_PLAN_SCHEDULE'">{{$t('commons.trigger_mode.test_plan_schedule')}}</span>
<span v-if="triggerMode === 'TEST_PLAN_API'">{{$t('commons.trigger_mode.test_plan_api')}}</span>
<span v-if="triggerMode === 'API'">{{$t('commons.trigger_mode.api')}}</span>
<span v-if="triggerMode === 'JENKINS_RUN_TEST_PLAN'">{{$t('commons.trigger_mode.api')}}</span>
<span v-if="triggerMode === 'BATCH'">{{$t('api_test.automation.batch_execute')}}</span>
<span v-if="triggerMode === 'MANUAL'">{{ $t('commons.trigger_mode.manual') }}</span>
<span v-if="triggerMode === 'SCHEDULE'">{{ $t('commons.trigger_mode.schedule') }}</span>
<span v-if="triggerMode === 'TEST_PLAN_SCHEDULE'">{{ $t('commons.trigger_mode.test_plan_schedule') }}</span>
<span v-if="triggerMode === 'TEST_PLAN_API'">{{ $t('commons.trigger_mode.test_plan_api') }}</span>
<span v-if="triggerMode === 'API'">{{ $t('commons.trigger_mode.api') }}</span>
<span v-if="triggerMode === 'JENKINS'">{{ $t('commons.trigger_mode.api') }}</span>
<span v-if="triggerMode === 'JENKINS_RUN_TEST_PLAN'">{{ $t('commons.trigger_mode.api') }}</span>
<span v-if="triggerMode === 'BATCH'">{{ $t('api_test.automation.batch_execute') }}</span>
</span>
</template>
<script>
export default {
name: "ReportTriggerModeItem",
props: ['triggerMode']
}
export default {
name: "ReportTriggerModeItem",
props: ['triggerMode']
}
</script>
<style scoped>