### Question:
AcmGrantedAuthoritiesMapper { public Collection<AcmGrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> grantedAuthorities) { Predicate<GrantedAuthority> authorityNotBlank = authority -> authority != null && StringUtils.isNotBlank(authority.getAuthority()); return grantedAuthorities.stream() .filter(authorityNotBlank) .map(authority -> authority.getAuthority().trim().toUpperCase()) .peek(groupName -> log.debug(String.format("Incoming group: [%s]", groupName))) .filter(groupName -> roleToGroupMapping.getGroupToRolesMap().containsKey(groupName)) .flatMap(groupName -> roleToGroupMapping.getGroupToRolesMap().get(groupName).stream()) .map(AcmGrantedAuthority::new) .collect(Collectors.toSet()); }  void initBean(); Collection<AcmGrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> grantedAuthorities); Collection<AcmGrantedAuthority> getAuthorityGroups(AcmUser user); void setRoleToGroupMapping(AcmRoleToGroupMapping roleToGroupMapping); AcmRoleToGroupMapping getRoleToGroupMapping(); GroupService getGroupService(); void setGroupService(GroupService groupService);  }### Answer:
@Test public void mapAuthorities() { Map<String, List<String>> groupsToRoles = new HashMap<>(); List<String> roles1 = new ArrayList<>(); roles1.add("ROLE_INVESTIGATOR"); roles1.add("ROLE_INVESTIGATOR_SUPERVISOR"); groupsToRoles.put("GROUP1", roles1); List<String> roles2 = new ArrayList<>(); roles2.add("ROLE_ANALYST"); groupsToRoles.put("GROUP2", roles2); GrantedAuthority auth1 = new AcmGrantedAuthority("GROUP1"); GrantedAuthority auth2 = new AcmGrantedAuthority("GROUP2"); GrantedAuthority authNotMapped = new AcmGrantedAuthority("NONE"); List<GrantedAuthority> auths = Arrays.asList(auth1, auth2, authNotMapped); expect(roleToGroupMappingMock.getGroupToRolesMap()).andReturn(groupsToRoles).anyTimes(); replayAll(); Collection<? extends GrantedAuthority> found = unit.mapAuthorities(auths); verifyAll(); assertEquals(3, found.size()); assertTrue(found.contains(new AcmGrantedAuthority("ROLE_INVESTIGATOR"))); assertTrue(found.contains(new AcmGrantedAuthority("ROLE_INVESTIGATOR_SUPERVISOR"))); assertTrue(found.contains(new AcmGrantedAuthority("ROLE_ANALYST"))); }