KeyCloakUserManager extends BaseKeyCloakManager implements UserManager,
                                                                        ContextualManager { @Override public User get(String username) throws SecurityManagementException { checkNotNull("username", username); final User[] user = new User[1]; consumeRealm(realmResource -> { final UsersResource usersResource = realmResource.users(); final UserResource userResource = getUserResource(usersResource, username); final RoleMappingResource roleMappingResource = userResource.roles(); Set<Group> _groups = null; Set<Role> _roles = null; if (roleMappingResource != null) { Set[] gr = getUserGroupsAndRoles(roleMappingResource); if (null != gr) { _groups = gr[0]; _roles = gr[1]; } } user[0] = createUser(userResource.toRepresentation(), _groups, _roles); }); return user[0]; } KeyCloakUserManager(); @Override void initialize(final UserSystemManager userSystemManager); @Override SearchResponse<User> search(SearchRequest request); @Override User get(String username); @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); @Override void destroy();  }
@Test(expected = RealmManagementNotAuthorizedException.class) public void testUserNotAuthorized() throws Exception { initUserManager(); doThrow(mockForbiddenResponse()).when(keycloakMock).realm(); usersManager.get(USERNAME); }
@Test public void testGetUser5() { String username = USERNAME + 5; User user = usersManager.get(username); assertUser(user, username); }
@Test(expected = UserNotFoundException.class) public void testGetUser50() { String username = USERNAME + 50; User user = usersManager.get(username); assertNull(user); }