From 3cb5202f98fb3fea5dc829f7e88b406e37febeaa Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Wed, 15 Nov 2023 11:20:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8F=AA=E6=9C=89=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=9A=84=E6=9D=83=E9=99=90=EF=BC=8C=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E4=BC=9A=E6=9D=83=E9=99=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1032874 --user=陈建星 有测试计划执行的权限,无法执行功能用例 https://www.tapd.cn/55049933/s/1436100 --- .../plan/service/TestPlanTestCaseService.java | 30 ++++++++---- .../metersphere/service/TestCaseService.java | 46 ++++++++++++------- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java index 8f4a0e116f..99cf12953a 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java @@ -327,25 +327,37 @@ public class TestPlanTestCaseService { switch (type) { case "performance": if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) { - LoadTest loadTest = planPerformanceTestService.get(id); - if (loadTest != null) { - dto.setTestName(loadTest.getName()); + try { + LoadTest loadTest = planPerformanceTestService.get(id); + if (loadTest != null) { + dto.setTestName(loadTest.getName()); + } + } catch (Exception e) { + LogUtil.error(e); } } break; case "testcase": if (serviceIdSet.contains(MicroServiceName.API_TEST)) { - ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = planApiTestCaseService.get(id); - if (apiTestCaseWithBLOBs != null) { - dto.setTestName(apiTestCaseWithBLOBs.getName()); + try { + ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = planApiTestCaseService.get(id); + if (apiTestCaseWithBLOBs != null) { + dto.setTestName(apiTestCaseWithBLOBs.getName()); + } + } catch (Exception e) { + LogUtil.error(e); } } break; case "automation": if (serviceIdSet.contains(MicroServiceName.API_TEST)) { - ApiScenarioWithBLOBs apiScenarioWithBLOBs = panApiAutomationService.get(id); - if (apiScenarioWithBLOBs != null) { - dto.setTestName(apiScenarioWithBLOBs.getName()); + try { + ApiScenarioWithBLOBs apiScenarioWithBLOBs = panApiAutomationService.get(id); + if (apiScenarioWithBLOBs != null) { + dto.setTestName(apiScenarioWithBLOBs.getName()); + } + } catch (Exception e) { + LogUtil.error(e); } } break; diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index ec8e8d468e..631171479d 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -2846,29 +2846,41 @@ public class TestCaseService { List uiScenarios = new ArrayList<>(); if (serviceIdSet.contains(MicroServiceName.API_TEST)) { - apiCases = relevanceApiCaseService.getApiCaseByIds( - getTestIds(testCaseTests, TestCaseTestType.testcase.name())); - apiScenarios = relevanceApiCaseService.getScenarioCaseByIds( - getTestIds(testCaseTests, TestCaseTestType.automation.name())); - projectIds.addAll(apiCases.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); - scenarioProjectIds = apiScenarios.stream().map(s -> s.getProjectId()).distinct().collect(Collectors.toList()); - projectIds.addAll(scenarioProjectIds); - versionIds.addAll(apiCases.stream().map(s -> s.getVersionId()).collect(Collectors.toList())); - versionIds.addAll(apiScenarios.stream().map(s -> s.getVersionId()).collect(Collectors.toList())); + try { + apiCases = relevanceApiCaseService.getApiCaseByIds( + getTestIds(testCaseTests, TestCaseTestType.testcase.name())); + apiScenarios = relevanceApiCaseService.getScenarioCaseByIds( + getTestIds(testCaseTests, TestCaseTestType.automation.name())); + projectIds.addAll(apiCases.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); + scenarioProjectIds = apiScenarios.stream().map(s -> s.getProjectId()).distinct().collect(Collectors.toList()); + projectIds.addAll(scenarioProjectIds); + versionIds.addAll(apiCases.stream().map(s -> s.getVersionId()).collect(Collectors.toList())); + versionIds.addAll(apiScenarios.stream().map(s -> s.getVersionId()).collect(Collectors.toList())); + } catch (Exception e) { + LogUtil.error(e); + } } if (serviceIdSet.contains(MicroServiceName.PERFORMANCE_TEST)) { - apiLoadTests = relevanceLoadCaseService.getLoadCaseByIds( - getTestIds(testCaseTests, TestCaseTestType.performance.name())); - projectIds.addAll(apiLoadTests.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); - versionIds.addAll(apiLoadTests.stream().map(l -> l.getVersionId()).collect(Collectors.toList())); + try { + apiLoadTests = relevanceLoadCaseService.getLoadCaseByIds( + getTestIds(testCaseTests, TestCaseTestType.performance.name())); + projectIds.addAll(apiLoadTests.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); + versionIds.addAll(apiLoadTests.stream().map(l -> l.getVersionId()).collect(Collectors.toList())); + } catch (Exception e) { + LogUtil.error(e); + } } if (serviceIdSet.contains(MicroServiceName.UI_TEST)) { - uiScenarios = relevanceUiCaseService.getUiCaseByIds( - getTestIds(testCaseTests, TestCaseTestType.uiAutomation.name())); - projectIds.addAll(uiScenarios.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); - versionIds.addAll(uiScenarios.stream().map(l -> l.getVersionId()).collect(Collectors.toList())); + try { + uiScenarios = relevanceUiCaseService.getUiCaseByIds( + getTestIds(testCaseTests, TestCaseTestType.uiAutomation.name())); + projectIds.addAll(uiScenarios.stream().map(s -> s.getProjectId()).collect(Collectors.toList())); + versionIds.addAll(uiScenarios.stream().map(l -> l.getVersionId()).collect(Collectors.toList())); + } catch (Exception e) { + LogUtil.error(e); + } }