diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ResourcePoolTypeEnum.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ResourcePoolTypeEnum.java index 608da243aa..4d8b73e42c 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ResourcePoolTypeEnum.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ResourcePoolTypeEnum.java @@ -1,5 +1,8 @@ package io.metersphere.sdk.constants; +import lombok.Getter; + +@Getter public enum ResourcePoolTypeEnum { /** * node controller 资源池 @@ -7,10 +10,10 @@ public enum ResourcePoolTypeEnum { NODE("Node"), K8S("Kubernetes"); - private String name; + private final String name; ResourcePoolTypeEnum(String name) { - this.name = name; + this.name = name; } } \ No newline at end of file diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java index 629c76a6f0..858a059743 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiExecuteService.java @@ -227,7 +227,7 @@ public class ApiExecuteService { } // 判断是否为 K8S 资源池 - boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.name()); + boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.getName()); boolean isDebugMode = ApiExecuteRunMode.isDebug(taskInfo.getRunMode()); if (isK8SResourcePool) { @@ -310,7 +310,7 @@ public class ApiExecuteService { taskInfo.setMsUrl(testResourcePool.getServerUrl()); } // 判断是否为 K8S 资源池 - boolean isK8SResourcePool = StringUtils.equals(testResourcePool.getType(), ResourcePoolTypeEnum.K8S.name()); + boolean isK8SResourcePool = StringUtils.equals(testResourcePool.getType(), ResourcePoolTypeEnum.K8S.getName()); if (isK8SResourcePool) { TestResourceDTO testResourceDTO = new TestResourceDTO(); BeanUtils.copyBean(testResourceDTO, testResourcePool.getTestResourceReturnDTO()); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java index 70a4287223..a20e575bad 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/ApiTaskCenterService.java @@ -285,7 +285,7 @@ public class ApiTaskCenterService { reportList.removeAll(request.getExcludeIds()); } - boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.name()); + boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.getName()); if (isK8SResourcePool) { handleK8STask(request, reports, reportList, testResourcePoolDTO); diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java index bc5b62f49a..2060c427b6 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/TestResourcePoolControllerTests.java @@ -246,7 +246,7 @@ class TestResourcePoolControllerTests extends BaseTest { void addTestResourcePoolSeven() throws Exception { //资源池的应用与类型无关 这里资源池正确的顺序就到此为止。换个类型只测一遍就行 // 不选全部资源池,部分有值 资源池节点为NODE use: api - this.addTestResourcePoolSuccess("test_pool_7", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); + this.addTestResourcePoolSuccess("test_pool_7", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName()); } @@ -299,7 +299,7 @@ class TestResourcePoolControllerTests extends BaseTest { @Test @Order(11) void getResourcePoolsDetailWidthBlobK8s() throws Exception { - TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_k8s", false, true, true, true, true, false, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_k8s", false, true, true, true, true, false, ResourcePoolTypeEnum.K8S.getName()); String id = testResourcePoolRequest1.getId(); MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/test/resource/pool/detail/" + id) .header(SessionConstants.HEADER_TOKEN, sessionId) @@ -349,7 +349,7 @@ class TestResourcePoolControllerTests extends BaseTest { @Test @Order(13) void getResourcePoolsDetailWidthBlobNoOrgIds() throws Exception { - TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_org_id", true, false, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_org_id", true, false, true, false, false, false, ResourcePoolTypeEnum.K8S.getName()); String id = testResourcePoolRequest1.getId(); QueryResourcePoolRequest request = new QueryResourcePoolRequest(); request.setCurrent(1); @@ -375,7 +375,7 @@ class TestResourcePoolControllerTests extends BaseTest { String id = "1034"; getDetail("/test/resource/pool/detail/" + id, ERROR_REQUEST_MATCHER); - TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_node", true, false, true, false, false, true, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob_no_node", true, false, true, false, false, true, ResourcePoolTypeEnum.K8S.getName()); getDetail("/test/resource/pool/detail/" + testResourcePoolRequest1.getId(), status().isOk()); } @@ -397,7 +397,7 @@ class TestResourcePoolControllerTests extends BaseTest { @Order(15) void updateTestResourcePool() throws Exception { createMockUrl(); - TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName()); String id = testResourcePoolRequest1.getId(); TestResourcePoolRequest testResourcePoolRequest = new TestResourcePoolRequest(); testResourcePoolRequest.setId(id); @@ -422,7 +422,7 @@ class TestResourcePoolControllerTests extends BaseTest { @Order(16) void updateTestResourcePoolWithOrgIds() throws Exception { createMockUrl(); - TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob3", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob3", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName()); String id = testResourcePoolRequest1.getId(); TestResourcePoolRequest testResourcePoolRequest = new TestResourcePoolRequest(); testResourcePoolRequest.setId(id); @@ -494,7 +494,7 @@ class TestResourcePoolControllerTests extends BaseTest { testResourcePoolRequest.setId(""); this.requestPost(urlType, url, id, testResourcePoolRequest, status().isBadRequest()); - TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.name()); + TestResourcePool testResourcePoolRequest1 = this.addTestResourcePoolSuccess("test_pool_blob2", false, true, true, false, false, false, ResourcePoolTypeEnum.K8S.getName()); id = testResourcePoolRequest1.getId(); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java index 30eef29aed..0f3926816d 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanTaskCenterService.java @@ -337,7 +337,7 @@ public class TestPlanTaskCenterService { poolIdMap.forEach((poolId, reportList) -> { TestResourcePoolReturnDTO testResourcePoolDTO = testResourcePoolService.getTestResourcePoolDetail(poolId); // 判断是否为 K8S 资源池 - boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.name()); + boolean isK8SResourcePool = StringUtils.equals(testResourcePoolDTO.getType(), ResourcePoolTypeEnum.K8S.getName()); if (isK8SResourcePool) { SubListUtils.dealForSubList(reportList, 100, (subList) -> { try {