### Question:
AuthUserRestAPIConfiguration { static UserDetails adoptUser(AuthUser entity) { UserBuilder builder = User.builder(); builder.username(entity.getUserId()); String hashedApiToken = entity.getHashedApiToken(); builder.password(hashedApiToken); List<String> authorities = accumulateAuthorities(entity); builder.authorities(authorities.toArray(new String[authorities.size()])); boolean disabled = hashedApiToken==null || hashedApiToken.isEmpty(); builder.disabled(disabled); UserDetails details = builder.build(); LOG.trace("User:{} has authorities: {}, entity:{}",entity.getUserId(), details.getAuthorities(),entity); return details; }  @Bean UserDetailsService userDetailsService(final AuthUserRepository repository);  }### Answer:
@Test public void adoptUserAcumultesAuthorities() { AuthUser entity = createAuthUser(); entity.setRoleOwner(true); entity.setRoleUser(true); entity.setRoleSuperAdmin(true); UserDetails result = AuthUserRestAPIConfiguration.adoptUser(entity); assertHasAuthority(result, RoleConstants.ROLE_USER,RoleConstants.ROLE_SUPERADMIN, RoleConstants.ROLE_OWNER); }
@Test public void adoptUser_with_role_user() { AuthUser entity = createAuthUser(); entity.setRoleOwner(false); entity.setRoleUser(true); entity.setRoleSuperAdmin(false); UserDetails result = AuthUserRestAPIConfiguration.adoptUser(entity); assertHasAuthority(result, RoleConstants.ROLE_USER); }
@Test public void adoptUser_with_role_owner() { AuthUser entity = createAuthUser(); entity.setRoleOwner(true); entity.setRoleUser(false); entity.setRoleSuperAdmin(false); UserDetails result = AuthUserRestAPIConfiguration.adoptUser(entity); assertHasAuthority(result, RoleConstants.ROLE_OWNER); }
@Test public void adoptUser_with_role_superadmin() { AuthUser entity = createAuthUser(); entity.setRoleOwner(false); entity.setRoleUser(false); entity.setRoleSuperAdmin(true); UserDetails result = AuthUserRestAPIConfiguration.adoptUser(entity); assertHasAuthority(result, RoleConstants.ROLE_SUPERADMIN); }