From 16ac406fbd5669f58e01dccfe5ae05f69cb44683 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 15 Jun 2021 19:03:03 +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=8D=E6=8E=A5=E5=8F=A3/=E7=94=A8=E4=BE=8B=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E6=A8=A1=E5=9D=97=E5=8C=B9=E9=85=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/sampler/MsHTTPSamplerProxy.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 892f87faff..706eebd7c8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -276,8 +276,8 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (httpConfig == null && !isURL(this.getUrl())) { MSException.throwException("未匹配到环境,请检查环境配置"); } - if(StringUtils.isEmpty(httpConfig.getProtocol())){ - MSException.throwException(this.getName() +"接口,对应的环境无协议,请完善环境信息"); + if (StringUtils.isEmpty(httpConfig.getProtocol())) { + MSException.throwException(this.getName() + "接口,对应的环境无协议,请完善环境信息"); } if (StringUtils.isEmpty(this.useEnvironment)) { this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid(); @@ -398,6 +398,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { /** * 加载SSL认证 + * * @param config * @param httpSamplerTree * @return @@ -454,6 +455,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { /** * 自定义请求如果是完整url时不拼接mock信息 + * * @param url * @return */ @@ -461,7 +463,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (isCustomizeReq() && (url.startsWith("http://") || url.startsWith("https://"))) { return true; } - return false; + return false; } // 兼容旧数据 @@ -622,12 +624,14 @@ public class MsHTTPSamplerProxy extends MsTestElement { break; } } else if (item.getType().equals(ConditionType.MODULE.name())) { - ApiDefinition apiDefinition; + ApiDefinition apiDefinition = null; ApiDefinitionService apiDefinitionService = CommonBeanFactory.getBean(ApiDefinitionService.class); ApiTestCaseService apiTestCaseService = CommonBeanFactory.getBean(ApiTestCaseService.class); - if (StringUtils.isNotEmpty(this.getReferenced()) && this.getReferenced().equals("REF") && StringUtils.isNotEmpty(this.getRefType()) && this.getRefType().equals("CASE")) { + if (StringUtils.isNotEmpty(this.getRefType()) && this.getRefType().equals("CASE")) { ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseService.get(this.getId()); - apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId()); + if (caseWithBLOBs != null) { + apiDefinition = apiDefinitionService.get(caseWithBLOBs.getApiDefinitionId()); + } } else { apiDefinition = apiDefinitionService.get(this.getId()); if (apiDefinition == null) { @@ -702,7 +706,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { } public static List findHttpSampleFromHashTree(MsTestElement hashTree) { - return findFromHashTreeByType(hashTree, MsHTTPSamplerProxy.class, null); + return findFromHashTreeByType(hashTree, MsHTTPSamplerProxy.class, null); } }