UserDetails toUserDetails(UserCredentials userCredentials) {

    return User.withUsername(userCredentials.getUsername())
        .password(userCredentials.getPassword())
        .roles(userCredentials.getRoles().toArray(String[]::new))
        .build();
  }
@Test
  void toUserDetails() {
    // given
    UserCredentials userCredentials =
        UserCredentials.builder()
            .enabled(true)
            .password("password")
            .username("user")
            .roles(Set.of("USER", "ADMIN"))
            .build();

    // when
    UserDetails userDetails = userDetailsMapper.toUserDetails(userCredentials);

    // then
    assertThat(userDetails.getUsername()).isEqualTo("user");
    assertThat(userDetails.getPassword()).isEqualTo("password");
    assertThat(userDetails.isEnabled()).isTrue();
  }