DefaultUserServiceAdapter implements UserServiceAdapter { @Override public RoleInfo addUserToRole(String roleName, String username) { Role roleEntity = this.roleCurator.getByName(roleName); if (roleEntity == null) { throw new IllegalStateException("Role does not exist: " + roleName); } User userEntity = this.userCurator.findByLogin(username); if (userEntity == null) { throw new IllegalStateException("User does not exist: " + username); } roleEntity.addUser(userEntity); return this.roleCurator.merge(roleEntity); } @Inject  DefaultUserServiceAdapter(UserCurator userCurator, RoleCurator roleCurator,
        PermissionBlueprintCurator permissionCurator, OwnerCurator ownerCurator,
        PermissionFactory permissionFactory); @Override UserInfo createUser(UserInfo user); @Override UserInfo updateUser(String username, UserInfo user); @Override List<? extends UserInfo> listUsers(); @Override boolean validateUser(String username, String password); @Override void deleteUser(String username); @Override UserInfo findByLogin(String login); @Override Collection<? extends OwnerInfo> getAccessibleOwners(String username); @Override RoleInfo createRole(RoleInfo role); @Override RoleInfo updateRole(String roleName, RoleInfo role); @Override RoleInfo addUserToRole(String roleName, String username); @Override RoleInfo removeUserFromRole(String roleName, String username); @Override RoleInfo addPermissionToRole(String roleName, PermissionBlueprintInfo permission); @Override RoleInfo removePermissionFromRole(String roleName, String permissionId); @Override void deleteRole(String role); @Override RoleInfo getRole(String roleName); @Override List<? extends RoleInfo> listRoles();  }
@Test public void addUserToRole() { Role adminRole = createAdminRole(owner); roleCurator.create(adminRole); User user = new User("testuser", "password"); service.createUser(user); service.addUserToRole(adminRole.getName(), user.getUsername()); RoleInfo updated = service.getRole(adminRole.getName()); assertEquals(1, updated.getUsers().size()); }