TomcatUserManager extends BaseTomcatManager implements UserManager,
                                                                    ContextualManager { @Override public void assignGroups(String username, Collection<String> groups) throws SecurityManagementException { Set<String> userRoles = SecurityManagementUtils.rolesToString(SecurityManagementUtils.getRoles(userSystemManager, username)); userRoles.addAll(groups); doAssignGroups(username, userRoles); } TomcatUserManager();  TomcatUserManager(final Map<String, String> gitPrefs);  TomcatUserManager(final ConfigProperties gitPrefs); @Override void initialize(final UserSystemManager userSystemManager); @Override void destroy(); @Override SearchResponse<User> search(SearchRequest request); @Override User get(String identifier); @Override List<User> getAll(); @Override User create(User entity); @Override User update(User entity); @Override void delete(String... identifiers); @Override UserManagerSettings getSettings(); @Override void assignGroups(String username,
                             Collection<String> groups); @Override void assignRoles(String username,
                            Collection<String> roles); @Override void changePassword(String username,
                               String newPassword);  }
@Test public void testAssignGroups() { final User user = mock(User.class); when(user.getIdentifier()).thenReturn("user1"); when(user.getRoles()).thenReturn(new HashSet<Role>()); UserManager userManagerMock = mock(UserManager.class); doAnswer(new Answer<User>() { @Override public User answer(InvocationOnMock invocationOnMock) throws Throwable { return user; } }).when(userManagerMock).get("user1"); when(userSystemManager.users()).thenReturn(userManagerMock); Collection<String> groups = new ArrayList<String>(); groups.add("role1"); groups.add("role3"); usersManager.assignGroups("user1", groups); Set<Group> result = usersManager.get("user1").getGroups(); assertNotNull(result); assertEquals(2, result.size()); }