### Question:
GrantedAuthorityMapper { public Set<GrantedAuthority> getAuthorities(Collection<Role> roles) { Set<GrantedAuthority> auths = new HashSet<>(); auths.addAll(getPermissionGrants(roles)); auths.addAll(getRoleGrants(roles)); return auths; } GrantedAuthorityMapper(); Set<GrantedAuthority> getAuthorities(Collection<Role> roles);  }### Answer:
@Test public void simpleMapping() { String roleName = "XROAD_REGISTRATION_OFFICER"; Set<GrantedAuthority> authorities = mapper.getAuthorities( Collections.singletonList(Role.valueOf(roleName))); assertTrue(authorities.size() > 1); Set<String> authStrings = authorities.stream().map( auth -> auth.getAuthority()) .collect(Collectors.toSet()); assertTrue(authStrings.contains("ROLE_" + roleName)); assertTrue(authStrings.contains("ADD_CLIENT")); assertFalse(authStrings.contains("INIT_CONFIG")); }
@Test public void simpleMappingSystemAdmin() { String roleName = "XROAD_SYSTEM_ADMINISTRATOR"; Set<GrantedAuthority> authorities = mapper.getAuthorities( Collections.singletonList(Role.valueOf(roleName))); Set<String> authStrings = authorities.stream().map( auth -> auth.getAuthority()) .collect(Collectors.toSet()); assertTrue(authStrings.contains("INIT_CONFIG")); }