private Group createGroup(Client client) {
   Group group = new Group();
   group.setName("Test Group" + RandomStringUtils.randomAlphanumeric(9));
   group.setClient(clientService.reload(client));
   groupService.save(group);
   return group;
 }
  @Test
  public void addUserAdminToGroup() {
    User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER);

    Organization newOrganization = new Organization();
    newOrganization.setName("New Organization");
    organizationService.add(newOrganization);

    Group group = new Group();
    group.setAccessCode(UUID.randomUUID().toString());
    group.setName("New Group");
    group.setOrganization(newOrganization);
    groupService.save(group);
    groupService.getAll();

    GroupUserRequest groupUserRequest =
        requestService.createGroupUserRequest(user, group.getAccessCode());
    requestService.getAll(group.getId());

    boolean isAdded =
        userService.addUserToGroup(
            groupUserRequest.getUser(),
            groupUserRequest.getGroup().getId(),
            UserRole.ROLE_GROUP_ADMIN);
    assertTrue(isAdded);
  }
  @Test
  public void testCreateGroupMembership() {
    Account account = new Account();
    account.setGivenName("Anthony");
    account.setSurname("Wolski");
    account.setEmail("*****@*****.**");
    account.setPassword("password");
    account.setUsername("awolski");
    accountService.createAccount(account);

    Group group = new Group();
    group.setName("Test Group");
    accountService.createGroup(group);

    GroupMembership groupMembership = new GroupMembership(account, group);
    accountService.createGroupMembership(groupMembership);

    List<Account> groupAccounts = accountService.getGroupAccounts(group.getId());
    assertEquals(1, groupAccounts.size());

    List<Group> accountGroups = accountService.getAccountGroups(account.getId());
    assertEquals(1, accountGroups.size());

    List<GroupMembership> groupGroupMemberships =
        accountService.getGroupGroupMemberships(group.getId());
    assertEquals(1, groupGroupMemberships.size());

    List<GroupMembership> accountGroupMemberships =
        accountService.getAccountGroupMemberships(account.getId());
    assertEquals(1, accountGroupMemberships.size());
  }
Exemple #4
0
  @SuppressWarnings("unchecked")
  public List<Group> getAllGroups() throws Exception {
    // {"vfwebqq":"3e99140e076c4dc3c8a774f1e3a37518055f3f39f94428a8eaa07c1f7c0ebfea3a18792878f2c061"}

    String url = "http://s.web2.qq.com/api/get_group_name_list_mask2";
    String content = "{\"vfwebqq\":\"" + vfwebqq + "\"}";
    PostMethodWebRequest post = new PostMethodWebRequest(url);
    post.setParameter("r", content);

    wc.setHeaderField("Referer", "http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=2");

    WebResponse rs = wc.getResponse(post);
    log.info("sendMsg response:" + rs.getText());

    List<Group> groups = new ArrayList<Group>();

    JSONObject retJson = new JSONObject(rs.getText());
    if (retJson.getInt("retcode") == 0) {
      JSONArray infos = retJson.getJSONObject("result").getJSONArray("gnamelist");
      for (int i = 0; i < infos.length(); i++) {
        JSONObject obj = infos.getJSONObject(i);
        Group group = new Group();
        group.setGid(obj.getString("gid"));
        group.setName(obj.getString("name"));
        group.setCode(obj.getString("code"));
        groups.add(group);
      }
    }
    return groups;
  }
  private Group createGroup(Organization organization) {
    Group group = new Group();
    group.setAccessCode(UUID.randomUUID().toString());
    group.setName("Test Group");
    group.setOrganization(organization);
    groupService.save(group);

    return group;
  }
Exemple #6
0
 private static Group createGroup(Map<String, String> beanAttr) {
   if (beanAttr == null) return null;
   Group group = new Group();
   if (beanAttr.get("parentGroupId").equals("\\0")) group.setParentGroupId(null);
   else group.setParentGroupId(Integer.valueOf(beanAttr.get("parentGroupId")));
   group.setId(Integer.valueOf(beanAttr.get("id")).intValue());
   group.setName(BeansUtils.eraseEscaping(beanAttr.get("name")));
   group.setDescription(BeansUtils.eraseEscaping(beanAttr.get("description")));
   group.setVoId(Integer.valueOf(beanAttr.get("voId")));
   return group;
 }
  private Group makeGroup(Properties p) {
    Group group = new Group();
    String id = p.getProperty("groupID");
    String groupname = p.getProperty("groupname");
    String description = p.getProperty("description");

    group.setId(Integer.parseInt(id));
    group.setName(groupname);
    group.setDescription(description);
    ArrayList<User> members = queryMembers(Integer.parseInt(id));
    group.addMembers(members);
    return group;
  }
  @Test
  public void addUserToGroupTest() {
    User user = getUser(UserRole.ROLE_ORG_USER, UserRole.ROLE_GROUP_USER);

    Group newGroup = new Group();
    newGroup.setName("New Group");
    groupService.add(newGroup);

    groupService.getAll();

    userService.addUserToGroup(user, newGroup.getId(), UserRole.ROLE_GROUP_USER);
    List<Group> groups = userService.getGroups(user);
    assertTrue(groups.size() == 2);
    assertTrue(userService.isUserInGroup(user, newGroup));
    assertTrue(userService.isUserInGroup(user, newGroup, UserRole.ROLE_GROUP_USER));
  }
  /**
   * @param le
   * @param sequence
   * @return
   * @throws LdapException
   */
  private Group unloadLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
    Group entity = new ObjectFactory().createGroup();
    entity.setName(getAttribute(le, SchemaConstants.CN_AT));
    entity.setDescription(getAttribute(le, SchemaConstants.DESCRIPTION_AT));
    String typeAsString = getAttribute(le, GlobalIds.TYPE);
    if (StringUtils.isNotEmpty(typeAsString)) {
      entity.setType(Group.Type.valueOf(typeAsString.toUpperCase()));
    }
    entity.setProtocol(getAttribute(le, GROUP_PROTOCOL_ATTR_IMPL));
    entity.setMembers(getAttributes(le, SchemaConstants.MEMBER_AT));
    entity.setMemberDn(true);
    entity.setProperties(PropUtil.getProperties(getAttributes(le, GROUP_PROPERTY_ATTR_IMPL), '='));
    entity.setSequenceId(sequence);

    return entity;
  }
Exemple #10
0
 @Override
 public Object convert(Object entity) {
   Group result = new Group();
   Groups object = (Groups) entity;
   result.setDescription(object.getDescription());
   // result.setGroupId(object.getGroupId());
   result.setName(object.getName());
   // result.setTime(object.getTime());
   Place pl = new Place();
   GroupType group = new GroupType();
   Collection<Participant> coll = new ArrayList();
   result.setPlaceId(pl);
   result.setParticipantsCollection(coll);
   result.setTypeId(group);
   // pl.setId(object.getPlaceId().getId());
   // group.setId(object.getTypeId().getId());
   /* for (Iterator<Participants> it = object.getParticipantsCollection().iterator(); it.hasNext();) {
       Participant curr = new Participant();
       curr.setId(it.next().getId());
       coll.add(curr);
   }*/
   return result;
 }