private Mono<ServerResponse> saveNotificationPreferences(ServerRequest request) {
        var username = request.pathVariable("username");
        return request.bodyToMono(ReasonTypeNotifierCollectionRequest.class)
            .flatMap(requestBody -> {
                var reasonTypNotifiers = requestBody.reasonTypeNotifiers();
                return userNotificationPreferenceService.getByUser(username)
                    .flatMap(preference -> {
                        var reasonTypeNotifierMap = preference.getReasonTypeNotifier();
                        reasonTypeNotifierMap.clear();
                        reasonTypNotifiers.forEach(reasonTypeNotifierRequest -> {
                            var reasonType = reasonTypeNotifierRequest.getReasonType();
                            var notifiers = reasonTypeNotifierRequest.getNotifiers();
                            var notifierSetting = new UserNotificationPreference.NotifierSetting();
                            notifierSetting.setNotifiers(
                                notifiers == null ? Set.of() : Set.copyOf(notifiers));
                            reasonTypeNotifierMap.put(reasonType, notifierSetting);
                        });
                        return userNotificationPreferenceService.saveByUser(username, preference);
                    });
            })
            .then(Mono.defer(() -> listReasonTypeNotifierMatrix(username)
                .flatMap(result -> ServerResponse.ok().bodyValue(result)))
            );
    }
@Test
    void saveNotificationPreferences() {
        when(client.list(eq(ReasonType.class), eq(null), any())).thenReturn(Flux.empty());
        when(client.list(eq(NotifierDescriptor.class), eq(null), any())).thenReturn(Flux.empty());
        when(userNotificationPreferenceService.getByUser(any())).thenReturn(Mono.empty());
        webTestClient.post()
            .uri("/userspaces/{username}/notification-preferences", "guqing")
            .exchange()
            .expectStatus()
            .isOk();
    }