### Question:
RbacAuthoritiesMapper implements GrantedAuthoritiesMapper { @Override public Collection<? extends GrantedAuthority> mapAuthorities( final Collection<? extends GrantedAuthority> authorities) { if (authorities == null || authorities.isEmpty()) { return emptySet(); } final Set<String> roles = AuthorityUtils.authorityListToSet(authorities); return roleMapper.mapRolesToGrantedAuthority(roles); } RbacAuthoritiesMapper(final RoleMapper roleMapper); @Override Collection<? extends GrantedAuthority> mapAuthorities(
			final Collection<? extends GrantedAuthority> authorities);  }### Answer:
@Test public void testNoRolesConversionNullAuthorities() { final Collection<? extends GrantedAuthority> result = converter.mapAuthorities(null); assertThat(result.isEmpty(), is(true)); }
@Test public void testNoRolesConversionEmptyAuthorities() { final Collection<? extends GrantedAuthority> result = converter.mapAuthorities(emptyList()); assertThat(result.isEmpty(), is(true)); }
@Test public void testConversionNoMappedRoles() { final List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("JUST_ANOTHER_ROLE"); final Collection<? extends GrantedAuthority> result = converter.mapAuthorities(authorities); assertThat(result.isEmpty(), is(true)); }
@Test public void testConversionSingleRole() { final List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE1"); final Collection<? extends GrantedAuthority> result = converter.mapAuthorities(authorities); assertThat(result.size(), is(1)); assertThat(result.contains(new SimpleGrantedAuthority("ROLE_PRIVILEGE_1")), is(true)); }
@Test public void testConversionMultipleRoles() { final List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ANOTHER_ROLE", "ROLE1", "JUST_ANOTHER_ROLE", "ROLE2", "AND_ANOTHER_ROLE"); final Collection<? extends GrantedAuthority> result = converter.mapAuthorities(authorities); assertThat(result.size(), is(2)); assertThat(result.contains(new SimpleGrantedAuthority("ROLE_PRIVILEGE_1")), is(true)); assertThat(result.contains(new SimpleGrantedAuthority("ROLE_PRIVILEGE_2")), is(true)); }