Skip to content

Commit

Permalink
fix:add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
youngzil committed Oct 21, 2024
1 parent a142330 commit 01defd2
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 01defd2

Please sign in to comment.