code: @RunAsSystem
    public void addMember(final Group group, final User user, final Role role) {
      ArrayList<Role> groupRoles = newArrayList(group.getRoles());
      Collection<RoleMembership> memberships = roleMembershipService.getMemberships(groupRoles);
      boolean isGroupRole = groupRoles.stream().anyMatch(gr -> gr.getName().equals(role.getName()));
  
      if (!isGroupRole) {
        throw new NotAValidGroupRoleException(role, group);
      }
  
      boolean isMember = memberships.stream().parallel().anyMatch(m -> m.getUser().equals(user));
  
      if (isMember) {
        throw new IsAlreadyMemberException(user, group);
      }
  
      roleMembershipService.addUserToRole(user, role);
    }
docs: Add member to group. User can only be added to a role that belongs to the group. The user can
  only have a single role within the group
  
  @param group group to add the user to in the given role
  @param user user to be added in the given role to the given group
  @param role role in which the given user is to be added to given group