From d9773faeedf59751d265b572fb52326cf6691a5c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 31 May 2022 16:19:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtcp=E5=8D=8F=E8=AE=AE=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=8E=AF=E5=A2=83=E9=80=89=E6=8B=A9=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1013593 --user=赵勇 【接口测试】TCP请求CASE,批量执行,没有带上环境信息 https://www.tapd.cn/55049933/s/1170150 --- .../api/dto/definition/request/sampler/MsTCPSampler.java | 4 +++- .../api/exec/scenario/ApiScenarioSerialService.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 1a5f5b276b..77f3cb0c45 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -159,7 +159,9 @@ public class MsTCPSampler extends MsTestElement { } if (config.getConfig() == null) { // 单独接口执行 - this.setProjectId(config.getProjectId()); + if(StringUtils.isNotEmpty(config.getProjectId())) { + this.setProjectId(config.getProjectId()); + } config.setConfig(ElementUtil.getEnvironmentConfig(StringUtils.isNotEmpty(this.getEnvironmentId()) ? this.getEnvironmentId() : useEnvironment, this.getProjectId(), this.isMockEnvironment())); } EnvironmentConfig envConfig = null; diff --git a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java index 8f3ebb3ff8..b795b29085 100644 --- a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java +++ b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java @@ -215,7 +215,7 @@ public class ApiScenarioSerialService { group.setName(runRequest.getReportId()); group.setProjectId(caseWithBLOBs.getProjectId()); - MsTestElement testElement = parse(data, testId, envId); + MsTestElement testElement = parse(data, testId, envId, caseWithBLOBs.getProjectId()); group.setHashTree(new LinkedList<>()); group.getHashTree().add(testElement); testPlan.getHashTree().add(group); @@ -235,7 +235,7 @@ public class ApiScenarioSerialService { return null; } - private MsTestElement parse(String api, String planId, String envId) { + private MsTestElement parse(String api, String planId, String envId, String projectId) { try { JSONObject element = JSON.parseObject(api, Feature.DisableSpecialKeyDetect); ElementUtil.dataFormatting(element); @@ -258,6 +258,9 @@ public class ApiScenarioSerialService { } if (element.getString("type").equals("TCPSampler")) { MsTCPSampler msTCPSampler = JSON.parseObject(api, MsTCPSampler.class, Feature.DisableSpecialKeyDetect); + if (StringUtils.isEmpty(msTCPSampler.getProjectId())) { + msTCPSampler.setProjectId(projectId); + } if (StringUtils.isNotEmpty(envId)) { msTCPSampler.setUseEnvironment(envId); }