private Mono<ServerResponse> createUser(ServerRequest request) {
        return request.bodyToMono(CreateUserRequest.class)
            .doOnNext(createUserRequest -> {
                if (StringUtils.isBlank(createUserRequest.name())) {
                    throw new ServerWebInputException("Name is required");
                }
                if (StringUtils.isBlank(createUserRequest.email())) {
                    throw new ServerWebInputException("Email is required");
                }
            })
            .flatMap(userRequest -> {
                User newUser = CreateUserRequest.from(userRequest);
                var encryptedPwd = userService.encryptPassword(userRequest.password());
                newUser.getSpec().setPassword(encryptedPwd);
                return userService.createUser(newUser, userRequest.roles());
            })
            .flatMap(user -> ServerResponse.ok()
                .contentType(MediaType.APPLICATION_JSON)
                .bodyValue(user)
            );
    }
@Test
    void createWhenNameDuplicate() {
        when(userService.createUser(any(User.class), anySet()))
            .thenReturn(Mono.just(new User()));
        when(userService.updateWithRawPassword(anyString(), anyString()))
            .thenReturn(Mono.just(new User()));
        var userRequest = new UserEndpoint.CreateUserRequest("fake-user",
            "fake-email",
            "",
            "",
            "",
            "",
            "",
            Map.of(),
            Set.of());
        webClient.post().uri("/users")
            .bodyValue(userRequest)
            .exchange()
            .expectStatus().isOk();
    }