From b287613efd8a5cffbf22f511b82355c29e532972 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 19 Dec 2022 11:04:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=BC=BA=E5=B0=91xpack=E4=BB=A3=E7=A0=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definition/ApiTestCaseService.java | 24 +++++++++++-------- .../service/PerformanceTestCaseService.java | 12 ++++++---- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index 09b1c6cdcb..07e03e7125 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -1165,11 +1165,13 @@ public class ApiTestCaseService { List apiTestCaseDTOS = extApiTestCaseMapper.relevanceApiList(request); List versionIds = apiTestCaseDTOS.stream().map(ApiTestCaseDTO::getVersionId).collect(Collectors.toList()); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); - Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() - .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); - apiTestCaseDTOS.forEach(apiTestCaseDTO -> { - apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId())); - }); + if (projectVersionService != null) { + Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() + .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); + apiTestCaseDTOS.forEach(apiTestCaseDTO -> { + apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId())); + }); + } return apiTestCaseDTOS; } @@ -1177,11 +1179,13 @@ public class ApiTestCaseService { List apiScenarioDTOS = extApiScenarioMapper.relevanceScenarioList(request); List versionIds = apiScenarioDTOS.stream().map(ApiScenarioDTO::getVersionId).collect(Collectors.toList()); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); - Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() - .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); - apiScenarioDTOS.forEach(apiTestCaseDTO -> { - apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId())); - }); + if (projectVersionService != null) { + Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() + .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); + apiScenarioDTOS.forEach(apiTestCaseDTO -> { + apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId())); + }); + } return apiScenarioDTOS; } diff --git a/performance-test/backend/src/main/java/io/metersphere/track/service/PerformanceTestCaseService.java b/performance-test/backend/src/main/java/io/metersphere/track/service/PerformanceTestCaseService.java index c2572a3082..f81bcb3d61 100644 --- a/performance-test/backend/src/main/java/io/metersphere/track/service/PerformanceTestCaseService.java +++ b/performance-test/backend/src/main/java/io/metersphere/track/service/PerformanceTestCaseService.java @@ -31,10 +31,12 @@ public class PerformanceTestCaseService { public void buildVersionInfo(List loadTests) { List versionIds = loadTests.stream().map(LoadTestDTO::getVersionId).collect(Collectors.toList()); ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class); - Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() - .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); - loadTests.forEach(loadTest -> { - loadTest.setVersionName(projectVersionMap.get(loadTest.getVersionId())); - }); + if(projectVersionService != null) { + Map projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream() + .collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName)); + loadTests.forEach(loadTest -> { + loadTest.setVersionName(projectVersionMap.get(loadTest.getVersionId())); + }); + } } }