From 01defd278387f6dc66dbe507d85f94d9d15fd6ce Mon Sep 17 00:00:00 2001 From: yangzl Date: Mon, 21 Oct 2024 23:02:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Aadd=20unit=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ConfigsExportServiceTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/ConfigsExportServiceTest.java b/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/ConfigsExportServiceTest.java index c7b0ba3f874..381441f13a6 100644 --- a/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/ConfigsExportServiceTest.java +++ b/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/ConfigsExportServiceTest.java @@ -83,6 +83,18 @@ public class ConfigsExportServiceTest extends AbstractUnitTest { @Test public void testNamespaceExportImport() throws FileNotFoundException { + // Test with fillItemDetail = true + testExportImportScenario(true); + } + + @Test + public void testNamespaceExportImportWithFillItemDetail() throws FileNotFoundException { + // Test with fillItemDetail = false + testExportImportScenario(false); + } + + private void testExportImportScenario(boolean fillItemDetail) throws FileNotFoundException { + File temporaryFolder = Files.newTemporaryFolder(); temporaryFolder.deleteOnExit(); String filePath = temporaryFolder + File.separator + "export.zip"; @@ -146,10 +158,10 @@ public void testNamespaceExportImport() throws FileNotFoundException { when(permissionValidator.isAppAdmin(any())).thenReturn(true); when(clusterService.findClusters(env, appId1)).thenReturn(app1Clusters); when(clusterService.findClusters(env, appId2)).thenReturn(app2Clusters); - when(namespaceService.findNamespaceBOs(appId1, Env.DEV, clusterName1, true, false)).thenReturn(app1Cluster1Namespace); - when(namespaceService.findNamespaceBOs(appId1, Env.DEV, clusterName2, true, false)).thenReturn(app1Cluster2Namespace); - when(namespaceService.findNamespaceBOs(appId2, Env.DEV, clusterName1, true, false)).thenReturn(app2Cluster1Namespace); - when(namespaceService.findNamespaceBOs(appId2, Env.DEV, clusterName2, true, false)).thenReturn(app2Cluster2Namespace); + when(namespaceService.findNamespaceBOs(appId1, Env.DEV, clusterName1, fillItemDetail, false)).thenReturn(app1Cluster1Namespace); + when(namespaceService.findNamespaceBOs(appId1, Env.DEV, clusterName2, fillItemDetail, false)).thenReturn(app1Cluster2Namespace); + when(namespaceService.findNamespaceBOs(appId2, Env.DEV, clusterName1, fillItemDetail, false)).thenReturn(app2Cluster1Namespace); + when(namespaceService.findNamespaceBOs(appId2, Env.DEV, clusterName2, fillItemDetail, false)).thenReturn(app2Cluster2Namespace); FileOutputStream fileOutputStream = new FileOutputStream(filePath);