Mono<Void> saveConfig(String notifierDescriptorName, String key, ObjectNode config) {
        return client.fetch(Secret.class, SECRET_NAME)
            .switchIfEmpty(Mono.defer(() -> {
                Secret secret = new Secret();
                secret.setMetadata(new Metadata());
                secret.getMetadata().setName(SECRET_NAME);
                secret.getMetadata().setFinalizers(Set.of(SYSTEM_FINALIZER));
                secret.setStringData(new HashMap<>());
                return client.create(secret);
            }))
            .flatMap(secret -> {
                if (secret.getStringData() == null) {
                    secret.setStringData(new HashMap<>());
                }
                Map<String, String> map = secret.getStringData();
                ObjectNode wrapperNode = JsonNodeFactory.instance.objectNode();
                wrapperNode.set(key, config);
                map.put(resolveKey(notifierDescriptorName), JsonUtils.objectToJson(wrapperNode));
                return client.update(secret);
            })
            .then();
    }
@Test
    void saveConfigTest() {
        when(client.fetch(eq(Secret.class), eq(SECRET_NAME))).thenReturn(Mono.empty());

        when(client.create(any(Secret.class)))
            .thenAnswer(answer -> Mono.just(answer.getArgument(0, Secret.class)));
        when(client.update(any(Secret.class)))
            .thenAnswer(answer -> Mono.just(answer.getArgument(0, Secret.class)));

        var objectNode = JsonNodeFactory.instance.objectNode();
        objectNode.put("k1", "v1");
        notifierConfigStore.saveConfig("fake-notifier", "fake-key", objectNode)
            .as(StepVerifier::create)
            .verifyComplete();

        verify(client).fetch(eq(Secret.class), eq(SECRET_NAME));
        verify(client).create(assertArg(arg -> {
            assertThat(arg).isInstanceOf(Secret.class);
            var secret = (Secret) arg;
            assertThat(secret.getMetadata().getName()).isEqualTo(SECRET_NAME);
            assertThat(secret.getMetadata().getFinalizers())
                .contains(MetadataUtil.SYSTEM_FINALIZER);
            assertThat(secret.getStringData()).isNotNull();
        }));
        verify(client).update(assertArg(arg -> {
            assertThat(arg).isInstanceOf(Secret.class);
            var secret = (Secret) arg;
            assertThat(secret.getStringData().get("fake-notifier.json"))
                .isEqualTo("{\"fake-key\":{\"k1\":\"v1\"}}");
        }));
    }