From 5c0fa0dc609ea06c83c92e74c1bd3510e86f0210 Mon Sep 17 00:00:00 2001 From: "blake.qiu" <46370663+Bo-Qiu@users.noreply.github.com> Date: Thu, 7 Nov 2024 09:58:47 +0800 Subject: [PATCH] fix(#11930): the information of default namespace should be consistent. (#12815) fix(#11930): the information of default namespace should be consistent. fix(#11930): the information of default namespace should be consistent. --- .../core/service/NamespaceOperationService.java | 12 +++++------- .../core/service/NamespaceOperationServiceTest.java | 9 ++++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java b/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java index 47ec6e44367..2e0777214fe 100644 --- a/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java +++ b/core/src/main/java/com/alibaba/nacos/core/service/NamespaceOperationService.java @@ -43,12 +43,10 @@ public class NamespaceOperationService { private final NamespacePersistService namespacePersistService; + + private static final String DEFAULT_NAMESPACE_SHOW_NAME = "public"; - private static final String DEFAULT_NAMESPACE = "public"; - - private static final String DEFAULT_NAMESPACE_SHOW_NAME = "Public"; - - private static final String DEFAULT_NAMESPACE_DESCRIPTION = "Public Namespace"; + private static final String DEFAULT_NAMESPACE_DESCRIPTION = "Default Namespace"; private static final int DEFAULT_QUOTA = 200; @@ -64,8 +62,8 @@ public List getNamespaceList() { // TODO 获取用kp List tenantInfos = namespacePersistService.findTenantByKp(DEFAULT_KP); - Namespace namespace0 = new Namespace(NamespaceUtil.getNamespaceDefaultId(), DEFAULT_NAMESPACE, DEFAULT_QUOTA, 0, - NamespaceTypeEnum.GLOBAL.getType()); + Namespace namespace0 = new Namespace(NamespaceUtil.getNamespaceDefaultId(), DEFAULT_NAMESPACE_SHOW_NAME, + DEFAULT_NAMESPACE_DESCRIPTION, DEFAULT_QUOTA, 0, NamespaceTypeEnum.GLOBAL.getType()); NamespaceDetailInjectorHolder.getInstance().injectDetail(namespace0); List namespaceList = new ArrayList<>(); namespaceList.add(namespace0); diff --git a/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java b/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java index 6cb70e825bb..e8ccd86bb13 100644 --- a/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java +++ b/core/src/test/java/com/alibaba/nacos/core/service/NamespaceOperationServiceTest.java @@ -57,7 +57,9 @@ class NamespaceOperationServiceTest { private static final String TEST_NAMESPACE_DESC = "testDesc"; - private static final String DEFAULT_NAMESPACE = "public"; + private static final String DEFAULT_NAMESPACE_SHOW_NAME = "public"; + + private static final String DEFAULT_NAMESPACE_DESCRIPTION = "Default Namespace"; private static final int DEFAULT_QUOTA = 200; @@ -93,7 +95,8 @@ void testGetNamespaceList() { assertEquals(2, list.size()); Namespace namespaceA = list.get(0); assertEquals("", namespaceA.getNamespace()); - assertEquals(DEFAULT_NAMESPACE, namespaceA.getNamespaceShowName()); + assertEquals(DEFAULT_NAMESPACE_SHOW_NAME, namespaceA.getNamespaceShowName()); + assertEquals(DEFAULT_NAMESPACE_DESCRIPTION, namespaceA.getNamespaceDesc()); assertEquals(DEFAULT_QUOTA, namespaceA.getQuota()); assertEquals(1, namespaceA.getConfigCount()); @@ -104,7 +107,7 @@ void testGetNamespaceList() { } @Test - void testGetNamespace() throws NacosException { + void testGetNamespace() { assertThrows(NacosApiException.class, () -> { TenantInfo tenantInfo = new TenantInfo();