@VisibleForTesting
    ResourceGroupNamespaceConfigListener getRgNamespaceConfigListener() {
        return rgNamespaceConfigListener;
    }
@Test
    public void testNewResourceGroupNamespaceConfigListener() {
        PulsarService pulsarService = mock(PulsarService.class);
        PulsarResources pulsarResources = mock(PulsarResources.class);
        doReturn(pulsarResources).when(pulsarService).getPulsarResources();
        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
        doReturn(scheduledExecutorService).when(pulsarService).getExecutor();

        ResourceGroupService resourceGroupService = mock(ResourceGroupService.class);
        ResourceGroupResources resourceGroupResources = mock(ResourceGroupResources.class);
        RuntimeException exception = new RuntimeException("listResourceGroupsAsync error");
        doReturn(CompletableFuture.failedFuture(exception))
                .when(resourceGroupResources).listResourceGroupsAsync();
        doReturn(mock(MetadataStore.class))
                .when(resourceGroupResources).getStore();
        doReturn(resourceGroupResources).when(pulsarResources).getResourcegroupResources();

        ServiceConfiguration ServiceConfiguration = new ServiceConfiguration();
        doReturn(ServiceConfiguration).when(pulsarService).getConfiguration();

        ResourceGroupConfigListener resourceGroupConfigListener =
                new ResourceGroupConfigListener(resourceGroupService, pulsarService);

        // getResourcegroupResources() returns an error, ResourceGroupNamespaceConfigListener doesn't be created.
        Awaitility.await().pollDelay(3, TimeUnit.SECONDS).untilAsserted(() -> {
            assertNull(resourceGroupConfigListener.getRgNamespaceConfigListener());
        });

        // ResourceGroupNamespaceConfigListener will be created, and uses real pulsar resource.
        doReturn(CompletableFuture.completedFuture(new ArrayList<String>()))
                .when(resourceGroupResources).listResourceGroupsAsync();
        doReturn(pulsar.getPulsarResources()).when(pulsarService).getPulsarResources();
        Awaitility.await().untilAsserted(() -> {
            assertNotNull(resourceGroupConfigListener.getRgNamespaceConfigListener());
        });
    }