From 13e34f8ee77b7cf6f6ab2499235a92984d3b8cd5 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 4 Mar 2024 19:35:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E7=8E=AF=E5=A2=83=E7=9A=84http=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/parser/jmeter/MsHTTPElementConverter.java | 7 +++++-- .../controller/ApiScenarioControllerTests.java | 6 +++--- .../project/dto/environment/http/HttpConfig.java | 4 +++- .../project/service/EnvironmentService.java | 4 ++-- .../controller/EnvironmentControllerTests.java | 15 ++++++++++++++- .../EnvironmentGroupControllerTests.java | 2 +- .../src/views/api-test/components/paramTable.vue | 4 ++-- .../project-management/environmental/index.vue | 14 ++++++++++++-- .../environmental/locale/en-US.ts | 2 ++ .../environmental/locale/zh-CN.ts | 1 + 10 files changed, 45 insertions(+), 14 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsHTTPElementConverter.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsHTTPElementConverter.java index 6b84894b92..4f72d8ea72 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsHTTPElementConverter.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/jmeter/MsHTTPElementConverter.java @@ -106,6 +106,7 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter { - DigestAuth digestAuth = httpAuth.getDigestAuth() ; + DigestAuth digestAuth = httpAuth.getDigestAuth(); authorization.setUser(digestAuth.getUserName()); authorization.setPass(digestAuth.getPassword()); }); @@ -136,6 +137,7 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter headers = new ArrayList<>(0); @Schema(description = "描述") private String description; + @Schema(description = "排序") + private int order; public boolean isModuleMatchRule() { diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java index 9964aa30ff..56a8d71498 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/EnvironmentService.java @@ -197,7 +197,7 @@ public class EnvironmentService { List httpConfigs = environmentInfoDTO.getConfig().getHttpConfig(); if (CollectionUtils.isEmpty(httpConfigs)) { HttpConfig httpConfig = new HttpConfig(); - httpConfig.setUrl(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, project.getNum())); + httpConfig.setHostname(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, project.getNum())); httpConfigs.add(new HttpConfig()); } } @@ -446,7 +446,7 @@ public class EnvironmentService { if (BooleanUtils.isTrue(environment.getMock())) { if (StringUtils.isNotEmpty(baseUrl)) { Long projectNum = projectMap.get(environment.getProjectId()).getNum(); - environmentInfo.getConfig().getHttpConfig().getFirst().setUrl(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, projectNum)); + environmentInfo.getConfig().getHttpConfig().getFirst().setHostname(StringUtils.join(baseUrl, MOCK_EVN_SOCKET, projectNum)); } } environmentInfos.add(environmentInfo); diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java index 0ddefc821c..80b392e1a5 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentControllerTests.java @@ -20,6 +20,7 @@ import io.metersphere.project.dto.environment.ssl.KeyStoreConfig; import io.metersphere.project.dto.environment.ssl.KeyStoreEntry; import io.metersphere.project.dto.environment.ssl.KeyStoreFile; import io.metersphere.project.dto.environment.variables.CommonVariables; +import io.metersphere.project.service.EnvironmentService; import io.metersphere.sdk.constants.DefaultRepositoryDir; import io.metersphere.sdk.constants.MsAssertionCondition; import io.metersphere.sdk.constants.PermissionConstants; @@ -111,6 +112,8 @@ public class EnvironmentControllerTests extends BaseTest { private PluginService pluginService; @Resource private PluginScriptMapper pluginScriptMapper; + @Resource + private EnvironmentService environmentService; @Value("${spring.datasource.url}") private String dburl; @Value("${spring.datasource.username}") @@ -231,7 +234,7 @@ public class EnvironmentControllerTests extends BaseTest { keyValue.setValue("value"); headers.add(keyValue); httpConfig.setHeaders(headers); - httpConfig.setUrl("http://www.baidu.com"); + httpConfig.setHostname("http://www.baidu.com"); httpConfigs.add(httpConfig); return httpConfigs; @@ -1217,4 +1220,14 @@ public class EnvironmentControllerTests extends BaseTest { List options = getResultDataArray(mvcResult, EnvironmentOptionsDTO.class); Assertions.assertFalse(options.isEmpty()); } + + @Test + @Order(18) + public void addCover() throws Exception { + List environments = environmentMapper.selectByExample(new EnvironmentExample()); + //获取id集合 过滤一下mock为false的 + List ids = environments.stream().filter(environment -> !environment.getMock()).map(Environment::getId).toList(); + environmentService.getByIds(ids); + environmentService.getEnvironmentBlobsByIds(List.of()); + } } diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentGroupControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentGroupControllerTests.java index d231bb1e46..d04a2e3047 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentGroupControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/EnvironmentGroupControllerTests.java @@ -117,7 +117,7 @@ public class EnvironmentGroupControllerTests extends BaseTest { keyValue.setValue("value"); headers.add(keyValue); httpConfig.setHeaders(headers); - httpConfig.setUrl("http://www.baidu.com"); + httpConfig.setHostname("http://www.baidu.com"); httpConfigs.add(httpConfig); return httpConfigs; diff --git a/frontend/src/views/api-test/components/paramTable.vue b/frontend/src/views/api-test/components/paramTable.vue index 2df5a9f4cc..908039550d 100644 --- a/frontend/src/views/api-test/components/paramTable.vue +++ b/frontend/src/views/api-test/components/paramTable.vue @@ -342,7 +342,7 @@