@Override
    public Result reconcile(Request request) {
        client.fetch(Theme.class, request.name())
            .ifPresent(theme -> {
                if (isDeleted(theme)) {
                    cleanUpResourcesAndRemoveFinalizer(request.name());
                    return;
                }
                addFinalizerIfNecessary(theme);
                themeSettingDefaultConfig(theme);
                reconcileStatus(request.name());
            });
        return new Result(false, null);
    }
@Test
    void themeSettingDefaultValue() throws IOException, JSONException {
        Path testWorkDir = tempDirectory.resolve("reconcile-setting-value");
        Files.createDirectory(testWorkDir);
        when(themeRoot.get()).thenReturn(testWorkDir);

        Theme theme = new Theme();
        Metadata metadata = new Metadata();
        metadata.setName("theme-test");
        theme.setMetadata(metadata);
        theme.setKind(Theme.KIND);
        theme.setApiVersion("theme.halo.run/v1alpha1");
        Theme.ThemeSpec themeSpec = new Theme.ThemeSpec();
        themeSpec.setSettingName(null);
        theme.setSpec(themeSpec);

        when(extensionClient.fetch(eq(Theme.class), eq(metadata.getName())))
            .thenReturn(Optional.of(theme));
        Reconciler.Result reconcile =
            themeReconciler.reconcile(new Reconciler.Request(metadata.getName()));
        assertThat(reconcile.reEnqueue()).isFalse();
        verify(extensionClient, times(3)).fetch(eq(Theme.class), eq(metadata.getName()));

        // setting exists
        themeSpec.setSettingName("theme-test-setting");
        assertThat(theme.getSpec().getConfigMapName()).isNull();
        ArgumentCaptor<Theme> captor = ArgumentCaptor.forClass(Theme.class);
        themeReconciler.reconcile(new Reconciler.Request(metadata.getName()));
        verify(extensionClient, times(6))
            .fetch(eq(Theme.class), eq(metadata.getName()));
        verify(extensionClient, times(3))
            .update(captor.capture());
        Theme value = captor.getValue();
        assertThat(value.getSpec().getConfigMapName()).isNotNull();

        // populate setting name and configMap name and configMap not exists
        themeSpec.setSettingName("theme-test-setting");
        themeSpec.setConfigMapName("theme-test-configmap");
        when(extensionClient.fetch(eq(ConfigMap.class), any()))
            .thenReturn(Optional.empty());
        when(extensionClient.fetch(eq(Setting.class), eq(themeSpec.getSettingName())))
            .thenReturn(Optional.of(getFakeSetting()));
        themeReconciler.reconcile(new Reconciler.Request(metadata.getName()));
        verify(extensionClient, times(2))
            .fetch(eq(Setting.class), eq(themeSpec.getSettingName()));
        ArgumentCaptor<ConfigMap> configMapCaptor = ArgumentCaptor.forClass(ConfigMap.class);
        verify(extensionClient, times(1)).create(any(ConfigMap.class));
        verify(extensionClient, times(1)).create(configMapCaptor.capture());
        ConfigMap defaultValueConfigMap = configMapCaptor.getValue();
        Map<String, String> data = defaultValueConfigMap.getData();
        JSONAssert.assertEquals("""
                {
                    "sns": "{\\"email\\":\\"example@exmple.com\\"}"
                }
                """,
            JsonUtils.objectToJson(data),
            true);
    }