fix(接口测试): 修复导入har文件自定义请求不勾选环境,执行时提示选择环境的缺陷

--bug=1018879 --user=王孝刚
【接口测试】github#18808。接口自动化导入har包后,不勾选引用环境,执行时还提示要选择运行环境
https://www.tapd.cn/55049933/s/1277068
This commit is contained in:
wxg0103 2022-10-25 19:01:40 +08:00 committed by wxg0103
parent 8effbd93d6
commit 94dcf2158d
1 changed files with 8 additions and 9 deletions

View File

@ -10,24 +10,23 @@ import io.metersphere.api.dto.definition.request.MsScenario;
import io.metersphere.api.dto.definition.request.ParameterConfig; import io.metersphere.api.dto.definition.request.ParameterConfig;
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy; import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.scenario.environment.EnvironmentConfig; import io.metersphere.api.dto.scenario.environment.EnvironmentConfig;
import io.metersphere.service.definition.ApiDefinitionService;
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
import io.metersphere.commons.utils.GenerateHashTreeUtil;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.ApiTestEnvironmentMapper;
import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.plan.TestPlanApiScenarioMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ElementConstants; import io.metersphere.commons.constants.ElementConstants;
import io.metersphere.commons.constants.MsTestElementConstants; import io.metersphere.commons.constants.MsTestElementConstants;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.*;
import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.RunModeConfigDTO; import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.environment.service.BaseEnvGroupProjectService; import io.metersphere.environment.service.BaseEnvGroupProjectService;
import io.metersphere.environment.service.BaseEnvironmentService; import io.metersphere.environment.service.BaseEnvironmentService;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.plugin.core.MsTestElement; import io.metersphere.plugin.core.MsTestElement;
import io.metersphere.commons.utils.JSONUtil; import io.metersphere.service.definition.ApiDefinitionService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -141,7 +140,7 @@ public class ApiScenarioEnvService {
MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) testElement; MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) testElement;
if (httpSamplerProxy.isCustomizeReq()) { if (httpSamplerProxy.isCustomizeReq()) {
env.getProjectIds().add(httpSamplerProxy.getProjectId()); env.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(httpSamplerProxy.getIsRefEnvironment() == null ? true : httpSamplerProxy.getIsRefEnvironment()); env.setFullUrl(httpSamplerProxy.getIsRefEnvironment() == null ? true : !httpSamplerProxy.getIsRefEnvironment());
} else if (!StringUtils.equalsIgnoreCase(httpSamplerProxy.getReferenced(), "Created") || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) { } else if (!StringUtils.equalsIgnoreCase(httpSamplerProxy.getReferenced(), "Created") || (httpSamplerProxy.getIsRefEnvironment() != null && httpSamplerProxy.getIsRefEnvironment())) {
env.getProjectIds().add(httpSamplerProxy.getProjectId()); env.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(false); env.setFullUrl(false);