SecurityManagementUtils { public static Set<String> groupsToString(final Set<Group> groups) { if (null != groups && !groups.isEmpty()) { final Set<String> result = new HashSet<String>(groups.size()); for (final Group group : groups) { result.add(group.getName()); } return result; } return new HashSet<String>(); }  static User createUser(final String id); static User createUser(final String id,
                                  final Set<Group> groups); static User createUser(final String id,
                                  final Set<Group> groups,
                                  final Set<Role> roles); static User createUser(final String id,
                                  final Set<Group> groups,
                                  final Set<Role> roles,
                                  final Map<String, String> properties); static Group createGroup(final String name); static Role createRole(final String name); static User clone(final User user); static Set<Group> getGroups(final UserSystemManager userSystemManager,
                                       final String username); static Set<Role> getRoles(final UserSystemManager userSystemManager,
                                     final String username); static Set<Role> getRegisteredRoles(); static Set<String> getRegisteredRoleNames(); static void populateGroupOrRoles(final String name,
                                            final Set<String> registeredRoles,
                                            final Set<Group> groups,
                                            final Set<Role> roles); static Set<String> rolesToString(final Set<Role> roles); static Set<String> groupsToString(final Set<Group> groups); static final Capability[] USERS_CAPABILITIES; static final Capability[] GROUPS_CAPABILITIES; static final Capability[] ROLES_CAPABILITIES; }
@Test public void testGroupsToString() { Set<Group> roles = new HashSet<Group>(2); Group role1 = mock(Group.class); when(role1.getName()).thenReturn("group1"); Group role2 = mock(Group.class); when(role2.getName()).thenReturn("group2"); roles.add(role1); roles.add(role2); final Set<String> rolesStr = SecurityManagementUtils.groupsToString(roles); assertNotNull(rolesStr); assertTrue(rolesStr.size() == 2); assertTrue(rolesStr.contains("group1")); assertTrue(rolesStr.contains("group2")); }
@Test public void testGroupsToStringEmpty() { final Set<String> rolesStr = SecurityManagementUtils.groupsToString(null); assertNotNull(rolesStr); assertTrue(rolesStr.size() == 0); }