### Question:
AbiquoUserDetailsService implements UserDetailsService, UserLoginService { protected GrantedAuthority[] loadUserAuthorities(final User user) { List<Privilege> privileges = user.getRole().getPrivileges(); ArrayList<String> grantedAuthority = new ArrayList<String>(); grantedAuthority.add(DEFAULT_ROLE); if (privileges != null) { for (Privilege privilege : privileges) { grantedAuthority.add(DEFAULT_ROLE_PREFIX + privilege.getName()); } } return AuthorityUtils.stringArrayToAuthorityArray(grantedAuthority .toArray(new String[grantedAuthority.size()])); }  AuthType getAuthType(); void setAuthType(final AuthType authType); @PostConstruct void init(); @Override UserDetails loadUserByUsername(final String username); @Override UserDetails getUserDetails(final User user); static final String DEFAULT_ROLE_PREFIX; }### Answer:
@Test public void testLoadUserAuthoritiesWithMultiplePrivileges() throws Exception { Role role = roleGenerator.createInstance(p1, p2); User user = userGenerator.createInstance(role); setup(role, user.getEnterprise(), user); GrantedAuthority[] privileges = userDetailsService.loadUserAuthorities(user); assertEquals(privileges.length, 2 + 1); }
@Test public void testLoadUserAuthoritiesWithSinglePrivilege() throws Exception { Role role = roleGenerator.createInstance(p3); User user = userGenerator.createInstance(role); setup(role, user.getEnterprise(), user); GrantedAuthority[] privileges = userDetailsService.loadUserAuthorities(user); assertEquals(privileges.length, 1 + 1); }
@Test public void testLoadUserAuthoritiesWithoutPrivileges() throws Exception { Role role = roleGenerator.createInstance(); User user = userGenerator.createInstance(role); setup(role, user.getEnterprise(), user); GrantedAuthority[] privileges = userDetailsService.loadUserAuthorities(user); assertEquals(privileges.length, 0 + 1); }